Programatically working out how many weapons/turrets a ship has
-
Hey guys. Inside of FLHook we have the following definition for the ship entry.
struct IMPORT Ship : EqObj { Ship(struct Ship const &); Ship(struct ICliObj *); virtual ~Ship(void); struct Ship & operator=(struct Ship const &); static int const MAX_EXHAUST_NOZZLES; virtual enum AClassType get_class_type(void)const; std::vector <struct cachestring="">const * get_legal_hps(enum HpAttachmentType)const; virtual bool read(class INI_Reader &); virtual void redefine(struct Root const &); public: /* 36 */ uint iDunno12[19]; /* 55 */ char* szBayDoorAnim; /* 56 */ char* szHpBaySurface; /* 57 */ char* szHpBayExternal; /* 58 */ char* szHpTractorSource; /* 59 */ uint iIDSInfo1; /* 60 */ uint iIDSInfo2; /* 61 */ uint iIDSInfo3; /* 62 */ uint iShipClass; /* 63 */ uint iNumExhaustNozzles; /* 64 */ float fHoldSize; /* 65 */ float fLinearDrag; /* 66 */ float fAngularDrag[3]; /* 69 */ float fSteeringTorque[3]; /* 72 */ float fNudgeForce; /* 73 */ float fStrafeForce; /* 74 */ float fStrafePowerUsage; /* 75 */ float fMaxBankAngle; uint iDunno6[4]; // something about hptypes /* 80 */ uint iMaxNanobots; /* 81 */ uint iMaxShieldBats; uint idunno[20]; };</struct>
I see there was something identified to do with hptypes but it’s a mysterious unknown. I was wondering if anyone had any idea how I could work out the amount of guns / turrets a ship had.
-
Very cool, but I don’t have access to CShip. The thing I am hooking gives me a Archetype::Ship* object instead. Is it possible to get the CShip value from that at all?
-
The unknown is a vector consisting of HpAttachmentType and a vector of CacheString. You could process the vector directly, or use [c]get_legal_hps[/c] with each type. You’d then have to look at each CacheString and count the unique ones (or maybe you could get away with the one with maximum length).
-
Interesting. We don’t have a definition for HpAttachmentType (just a blank enum), so I’ll probably run some checks later on to log all the possible values for it.
Which unknown do you mean? iDunno12[19] or iDunno6[4] or idunno[20]
-
iDunno6. Here’s HpAttachmentType in FriendlyFire’s GitHub.
-
All the work has been done for me. Fantastic. Thank you all!