Ship Spawning
-
There is still an error in the reversed personality struct:
struct IMPORT DamageReactionStruct { DamageReactionStruct(); DamageReactionStruct& operator=(const DamageReactionStruct&); float evade_break_damage_trigger_percent; // 1 float evade_dodge_more_damage_trigger_percent; // 0.2 float drop_mines_damage_trigger_percent; // 1 float drop_mines_damage_trigger_time; // 1 float engine_kill_face_damage_trigger_percent; // 1 float engine_kill_face_damage_trigger_time; // 2 float roll_damage_trigger_percent; // 1 float roll_damage_trigger_time; // 1 float afterburner_damage_trigger_percent; // 1 float afterburner_damage_trigger_time; // 1.5 float brake_reverse_damage_trigger_percent; // 1 float fire_missiles_damage_trigger_percent; // 1 float fire_missiles_damage_trigger_time; // 0.5 float fire_guns_damage_trigger_percent; // 1 float fire_guns_damage_trigger_time; // 1 int iUnk1; int iUnk2; };
As you can see there are 2 more values at the end. I have checked the constructor and there are indeed 8 bytes more reserved as the original struct had. (Trust me this was not easy to find ^^)
I also noticed that my personality struct always hast the default values after submitting the personality params. I have to set it afterwars aswell as the stategraph. This way everything works perfectly. As soon as an NPC dies I destroy its equipment so that nothing stays it space but its cargo.
-
Yeah it worked. We’ve been spawning NPCs etc since some years now. I even tested some scripting sequences, but didn’t have the time to really develop that further. But it is planned.
-
Hey again.
I made a lot of progress with this stuff using Cannon’s code as a base and some help provided by Friendlyfire. It’s mostly stable but there’s a final issue I’m unable to fix.
If I destroy an npc through pub::SpaceObj::Destroy(*iShipIter, (pub::SpaceObj::DestroyType)0); then it effectively destroy it properly without generating any loot.
However when the spawned npc is killed via normal conditions (killed by a player) it literally spawns EVERYTHING the NPC had on him, including the guns, the engine (really), bots, ammo, etc…
Basically I didn’t find any way to hook to the npc death to prevent it from spawning any loot in space and I’m starting to lose hope
I know Schmackbolzen posted about it literally four or five posts above so I’m most likely looking in the wrong direction.
-
As far as I remember the problem was, that the main controller of the NPCs is missing (since you don’t create it). It seems to be responsible for all patrol commands etc. of the assigned NPCs and apparently also manages all the equipment on death. So the thing I did was to erase it manually. You have to create a list of all your NPCs and check when anything dies whether it is in the list. There are no new hooks necessary for that, you can use the existing ones. Going through the cargo of a ship should be somewhere in the hook SVN code (I hope, since I haven’t done any hooking stuff for a long time). I used a reverse engineered method, though.
-
You can reach the CEquipTraverser* at offset 0xE4 of a CShip* pointer. From there iterating on the cargo/equipment is easy.