Author Topic: Unit Offsets  (Read 1861 times)

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3237
Unit Offsets
« on: April 04, 2011, 11:01:47 PM »
I was reading through the Internal Data documents (here), specifically the notes on the UnitTypeInfo data structure.  I was hoping to change unit stats several times on-the-fly for something I've had in mind for awhile.  Unfortunately, I hit a roadblock:

Quote
Unit stats can be found at the following addresses:

Address  Unit Type
-------  ---------
551370     Common ore smelter
[end of file]

This would have been very useful, if I had been interested in playing with the Common Ore Smelter.  But I don't.  So if anyone could help me calculate the rest of the offsets, or just give me a list if it's kicking around somewhere, I'd really appreciate it.
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline BlackBox

  • Administrator
  • Hero Member
  • *****
  • Posts: 3093
Unit Offsets
« Reply #1 on: April 04, 2011, 11:47:43 PM »
Well, a table of pointers to unit info objects is located at 0x4E1348. It's indexed by map_id so you could do something like:

Code: [Select]
int **unitInfoArray = (int**)0x4e1348;

int *cargoTruckUnitInfo = unitInfoArray[mapCargoTruck];
for example to store the pointer to the cargo truck unit info in cargoTruckUnitInfo. I think if you look at the HFL source code there is some stuff in UnitInfo.cpp that might be helpful (and that class may be a cleaner way of getting at the data anyway, it has a bunch of premade functions so you could do UnitInfo truck(mapCargoTruck); and then access it with some functions on the class, or you could just grab its internalPtr that gets set up... which reminds me, I would like to finish HFL someday perhaps.
« Last Edit: April 04, 2011, 11:53:34 PM by BlackBox »

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3237
Unit Offsets
« Reply #2 on: April 05, 2011, 09:07:22 AM »
Ah, HFL can do that?  Well, I kinda wanna play around with this myself, but if I keep running into trouble I'll just use HFL.  Anyways, thanks.
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials