Freelancer Community Network
Reminder: Internet Explorer 6 or below are NOT supported.
HomeHome
ForumForum
WikiWiki
DownloadsDownloads
ForgeForge
Multiplayer Connection Tutorial
Collapse/Expand Random Image
Collapse/Expand Login
Username:

Password:

Remember me



Lost Password?

Register now!
Collapse/Expand Chat
Collapse/Expand Who's Online
81 user(s) are online (46 user(s) are browsing Forum)

Members: 0
Guests: 81

more...
Collapse/Expand Donations
Monthly costs: -30€
Income (ads): +5€
Donations (last month): +0€

Current balance: 55€
(last updated 04/2021)

Please make a donation if you want to help keeping The-Starport online:

Thanks!
Collapse/Expand Links
Collapse/Expand Advertisement
There are currently 55 users playing Freelancer on 42 servers.
March. 29, 2023

Browsing this Thread:   1 Anonymous Users



 Bottom   Previous Topic   Next Topic  Register To Post



Programatically working out how many weapons/turrets a ship has

Joined:
2016/3/29 21:54
From England
Group:
Registered Users
Trusted Speciality Developers
Posts: 45
Offline
Hey guys. Inside of FLHook we have the following definition for the ship entry.

Code:

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];
};


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.

Posted on: 2020/3/4 19:21
Way too ambitious for his own good.
Top
Re: Programatically working out how many weapons/turrets a ship has
Just can't stay away
Joined:
2008/5/9 17:27
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 246
Offline
You could use

Code:
CEquip *equip = cship->equip_manager.Traverse(tr);


and

Code:
EquipDesc ed;
equip->GetEquipDesc(ed);


Cheers
Crazy

Posted on: 2020/3/4 21:55
Top
Re: Programatically working out how many weapons/turrets a ship has

Joined:
2016/3/29 21:54
From England
Group:
Registered Users
Trusted Speciality Developers
Posts: 45
Offline
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?

Posted on: 2020/3/4 23:03
Way too ambitious for his own good.
Top
Re: Programatically working out how many weapons/turrets a ship has
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 2021
Offline
The unknown is a vector consisting of HpAttachmentType and a vector of CacheString. You could process the vector directly, or use get_legal_hps 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).

Posted on: 2020/3/5 2:37
Top
Re: Programatically working out how many weapons/turrets a ship has

Joined:
2016/3/29 21:54
From England
Group:
Registered Users
Trusted Speciality Developers
Posts: 45
Offline
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]

Posted on: 2020/3/5 10:27
Way too ambitious for his own good.
Top
Re: Programatically working out how many weapons/turrets a ship has
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 2021
Offline
iDunno6. Here's HpAttachmentType in FriendlyFire's GitHub.

Posted on: 2020/3/5 13:22
Top
Re: Programatically working out how many weapons/turrets a ship has

Joined:
2016/3/29 21:54
From England
Group:
Registered Users
Trusted Speciality Developers
Posts: 45
Offline
All the work has been done for me. Fantastic. Thank you all!

Posted on: 2020/3/5 14:29
Way too ambitious for his own good.
Top