Jump to content

Deployment of Soldiers within X-Com Craft


Maurice76

Recommended Posts

After some analysis of the GeoScope.exe file, I've managed to find the tables responsible for deploying the Soldiers within an X-Com craft in missions that feature them.

 

In the DOS v1.0 of TFTD, it can be found almost at the very end. Starting from address 75EF8h, there are 26 sets of 3 bytes for each of the three Troop carriers that the player has access to. The first set of 78 bytes is for the Triton, the second set is for the Hammerhead and the third set is for the Leviathan.

 

Explicitely:

Triton: address range is 75EF8h to 75F45h.

Hammerhead: address range is 75F46h to 75F93h.

Leviathan: address range is 75F94h to 75FE1h.

Each range is composed of 26 sets of 3 bytes each, one for each X-Com soldier spawn node, in sequential order. The first byte is the X-coordinate of the node, the second byte is the Y-coordinate and the third one is the Z-coordinate (relative to the craft map, not the eventual total map!). A curious note: usually they put the Y-coordinate in front of the X-coordinate wherever they use them. That's not the case here, surprisingly.

 

Organised per spawn node (instead of per craft):

Triton Hammer Leviathan

X Y Z X Y Z X Y Z

01 5 7 2 5 7 2 5 10 2

02 4 7 2 4 7 2 4 10 2

03 5 6 2 3 7 2 5 9 2

04 4 6 2 5 6 2 4 9 2

05 5 5 2 4 6 2 5 8 2

06 4 5 2 3 6 2 4 8 2

07 5 4 2 5 5 2 5 7 2

08 4 4 2 4 5 2 4 7 2

09 5 3 2 3 5 2 5 6 2

10 4 3 2 5 4 2 4 6 2

11 5 2 2 4 4 2 5 5 2

12 4 2 2 3 4 2 4 5 2

13 3 7 2 0 0 0 5 4 2

14 3 6 2 0 0 0 4 4 2

15 0 0 0 0 0 0 5 3 2

16 0 0 0 0 0 0 4 3 2

17 0 0 0 0 0 0 6 9 2

18 0 0 0 0 0 0 3 9 2

19 0 0 0 0 0 0 6 8 2

20 0 0 0 0 0 0 3 8 2

21 0 0 0 0 0 0 6 7 2

22 0 0 0 0 0 0 3 7 2

23 0 0 0 0 0 0 6 6 2

24 0 0 0 0 0 0 3 6 2

25 0 0 0 0 0 0 6 5 2

26 0 0 0 0 0 0 0 0 0

 

Note how spawn node 26 is 0 0 0 for the Leviathan - that's the bug where the soldier in slot 26 is spawned on the relative location (0, 0, 0) of the Leviathan map block instead of inside the craft (note that the Leviathan map itself only has 3 floors, with the ground floor having a Z-coordinate of 2; all overall maps with an X-Com Craft in it have 4 floors, a 4th one is added on top of it, changing the Z-coordinate of the ground floor to 3 instead of 2. This causes the Soldier in slot 26 to appear at (X, Y, 1) on the map, with X and Y being the offset values for the map block that holds the Leviathan).

 

Schematically, when we translate the above coordinates, we get the following layout for the Soldier spawn nodes for each X-Com craft:

 

Triton:

\ X 00 01 02 03 04 05 06 07 08 09

Y \ ------------------------------

00 | __ __ __ __ __ __ __ __ __ __

01 | __ __ __ __ __ __ __ __ __ __

02 | __ __ __ __ 12 11 __ __ __ __

03 | __ __ __ __ 10 09 __ __ __ __

04 | __ __ __ __ 08 07 __ __ __ __

05 | __ __ __ __ 06 05 __ __ __ __

06 | __ __ __ 14 04 03 __ __ __ __

07 | __ __ __ 13 02 01 __ __ __ __

08 | __ __ __ __ __ __ __ __ __ __

09 | __ __ __ __ __ __ __ __ __ __

 

Hammerhead:

\ X 00 01 02 03 04 05 06 07 08 09

Y \ ------------------------------

00 | __ __ __ __ __ __ __ __ __ __

01 | __ __ __ __ __ __ __ __ __ __

02 | __ __ __ __ __ __ __ __ __ __

03 | __ __ __ __ __ __ __ __ __ __

04 | __ __ __ 12 11 10 __ __ __ __

05 | __ __ __ 09 08 07 __ __ __ __

06 | __ __ __ 06 05 04 __ __ __ __

07 | __ __ __ 03 02 01 __ __ __ __

08 | __ __ __ __ __ __ __ __ __ __

09 | __ __ __ __ __ __ __ __ __ __

 

Leviathan:

\ X 00 01 02 03 04 05 06 07 08 09

Y \ ------------------------------

00 | 26*__ __ __ __ __ __ __ __ __

01 | __ __ __ __ __ __ __ __ __ __

02 | __ __ __ __ __ __ __ __ __ __

03 | __ __ __ __ 16 15 __ __ __ __

04 | __ __ __ __ 14 13 __ __ __ __

05 | __ __ __ __ 12 11 25 __ __ __

06 | __ __ __ 24 10 09 23 __ __ __

07 | __ __ __ 22 08 07 21 __ __ __

08 | __ __ __ 20 06 05 19 __ __ __

09 | __ __ __ 18 04 03 17 __ __ __

10 | __ __ __ __ 02 01 __ __ __ __

 

* = this node isn't on the ground floor, but 2 floors higher up.

 

The fix is easy enough: just alter the three bytes at address range 75FDFh - 75FE1h from 00 00 00 to 03 05 02. This places node 26 just above node 24 and to the left of node 12, where it should belong.

 

Probably when designing the craft layout, the developer assumed counting the nodes from 0 to 25, instead of from 1 to 26.

Link to comment
Share on other sites

I know X-Com Util fixes this, but I think it fixes it in memory. I don't know how the creator figured out where to patch it, but I assume he found the memory reference. In my post above, I've pinpointed the location within the .exe itself wink.png. I've already patched my own exe to spawn the 26th unit inside the craft.

 

Actually, I am considering changing the layout rather more drastically as I want to have the HWP's right next to or close to the door. In the current incarnation, you first need to unload two soldiers to make room for the HWP to exit, potentially opening those soldiers up to hostile fire. As it is, HWPs are placed inside the craft first, so the first one will occupy spawn nodes 1, 2, 3 and 4. The second one the next four, etc .... I just need to make sure to place those clusters together in the craft near the door and the other nodes around it ;)

Link to comment
Share on other sites

Aren't you also fixing it 'in memory'? Not sure what the distinction is. Though I suspect XComUtil patches the part of the executable where the craft crew positions are stored, like you are doing. XComUtil also provides a user configurable text file so you can change the crew positions, as well as the ability to define a saved set of soldier positions or a defined sort order of soldiers.

 

But there are problems running XComUtil these days so what you have done here is really helpful. A lot of the mods that XComUtil achieves are not documented or maybe just the documentation Scott relied on is no longer available in the public domain.

Link to comment
Share on other sites

Well, there is a difference. The executable is located on your harddisk and essentially just a collection of bytes taking up diskspace. In order for the program to run, it has to be loaded into computer memory, where it also reserves all the memory locations for the game's data files and then loads up the data into those memory locations. During runtime, those values will get updated and changed, depending on what the game is doing. When you save your game, all the relevant memory locations are written to files on your harddisk and when you load the game, the values contained in those files are loaded up into memory registers.

 

What I think XComUtil does, is alter the values in those memory registers, leaving the executable (or any other file) as it exists on your harddisk untouched. Rebooting your machine or simply quitting the program will also clear its memory, so you'd lose all alterations that have been made to those memory registers. I assume XComUtil keeps track of the changes you've configured within that tool and that whenever you start the game (and load everything into computer memory), XComUtil will subsequently overwrite the game's data with your personal preferences - again, all in computer memory.

 

My post above details where to find it in the actual executable file on your harddisk - and a fix there will be persistent. Whenever you start up the game from it, it will load everything into memory, including the changes you've made to that file.

 

Hopefully that clears up a bit of the confusion?

Link to comment
Share on other sites

Unlike the Extenders for the Windows version of the game, XComutil doesn't operate during run-time.

 

Some hard-mods are performed when you first run the XComutil setup program whereby the executables and data files are directly altered. Then, if you run the game with the supplied runxcom.bat file, XComutil does most of its magic on the temporary save in the MISSDAT folder every time the game switches between Geoscape.exe and Tactical.exe.

 

Troop placement is handled during the switch.

 

For the record: I am highly against using XComutil with TFTD. No problems with UFO, but having your all your ammo ripped away from you on 2-parters and sent to the base by XComutil is not nice.

 

- NKF

Link to comment
Share on other sites

Thanks for that explanation :). I've never used XComUtil, to be honest. I've been tempted to download it and see what it offered, but never got around to it. The option to just play a battle seems interesting and can be useful to train combat tactics.

 

Actually I am having a lot of fun (even if it's sometimes rather frustrating, too :P) to dig through the code and distill all these little tidbits of information as well as uncover bugs - and figure out ways how to patch them hard-coded into the .exe.

Link to comment
Share on other sites

  • 3 months later...

Maurice,

 

thank You for sharing this knowledge - I've made use of it to modify Hammerhead (from Satan's Claus "TFTD Crafts remake-reskin mod") and now it can carry 2 SWS + 8 aquanaus. I've described how to do it here.

 

After some analysis of the GeoScope.exe file, I've managed to find the tables responsible for deploying the Soldiers within an X-Com craft in missions that feature them.

 

In the DOS v1.0 of TFTD, it can be found almost at the very end. Starting from address 75EF8h, there are 26 sets of 3 bytes for each of the three Troop carriers that the player has access to. The first set of 78 bytes is for the Triton, the second set is for the Hammerhead and the third set is for the Leviathan.

 

Explicitely:

Triton: address range is 75EF8h to 75F45h.

Hammerhead: address range is 75F46h to 75F93h.

Leviathan: address range is 75F94h to 75FE1h.

 

Just for the record - in CE version of TFTD the offsets are further down in main .exe:

Triton: address range is 566 668 to 566 745,

Hammerhead: address range is 566 746 to 566 823,

Leviathan: address range is 566 824 to 566 901.

Of course those are decimal values.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...