Ship Spawning
-
I have no clue. For me, only setting it afterwards works.
Has anyone an idea how to set the enemies of the spawned ship differently from the rep group? E.g. if you want to make an escort they should attack everything which is not friendly to the escorted player.
-
There seem to be some errors regarding the ownerlist stuff:
First of all it has to be
template <class t=""> class IMPORT OwnerList { public: OwnerList(); virtual ~OwnerList(); class OwnerList & operator=(class OwnerList const &); void free(); };</class>
and then the structs are:
struct CargoDesc // Just quickly reversed, no clue about the types { int vft; int iUnk1; int iUnk2; int iUnk3; int iUnk4; }; struct ShipInfo { uint iFlag; // 4 uint iSystem; uint iShipArchetype; Vector vPos; Vector vUnk1; // all 0 Vector vUnk2; // all 0 Matrix mOrientation; uint iUnk1; // 0 uint iLoadout; OwnerList <pub::spaceobj::cargodesc>cargoDesc; uint unk1; // 0 uint unk2; // 0 float fUnk1; uint unk3; // 0 uint iLook1; uint iLook2; uint unk4; // 0 uint unk5; // 0 uint iComm; float fUnk2; float fUnk3; float fUnk4; float fUnk5; float fUnk6; float fUnk7; float fUnk8; uint iUnk2; uint iRep; // increases for each NPC spawned, starts at 0 or 1 uint iPilotVoice; uint unk6; // 0 int iHealth; // -1 = max health uint unk7; // 0 uint unk8; // 0 uint iLevel; };</pub::spaceobj::cargodesc>
After that there is no need to set si.cargoDesc. It will be automaticly initialised like in content.dll.
I still have no clue how to iterate through the list or whether it has anything to do with NPCs dropping all their stuff.
-
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.