Buildings can now be added or removed using the latest version of UE only read the following article if you want to understand the process by which buildings are added to BotF.
I hope some of you still like to understand the how part as it is a hope of mine that by laying these how-to's out for everyone to read some of you may get inspired to tackle similar problems in BotF modding. Less than a year ago I would never have attempted adding building to BotF as i considered it 'too hard' but i applied myself to various stepping stone tasks until I gained a better understanding of the tools that help analyse and ultimately mod BotF.
Peter1981 - 8th September 2010.
PART 1:- Adding Buildings to edifice.bst:
This is the first part of how to add the data for a new structure to edifice.bst
1. Extract 'edifice.bst', 'edifdesc.bst' and 'edifbnft.bst' from the STBOF.res file (you can do this in UE!) and make a copy of each so you have a backup.
2. Open the extracted file 'edifice.bst' with a hex editor (I use Free Hex Editor Neo -- you can get that here http://www.hhdsoftware.com/Products/hom ... -free.html .)
3. Set the byte view to 176 columns (the width of one structure entry.)
4. Scroll in the text pane until you see the start of the structure entries (it's at Offset 0x02E4.)
5. In the byte pane highlight all 176 bytes of one of the structure entries (I recommend something all five empires build e.g. Wind Turbines.)
Code: Select all
UPDATE:- DO NOT COPY THIS USE AN ENTRY FROM YOUR EDIFICE.BST :-
57 69 6e 64 20 54 75 72 62 69 6e 65 73 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 57 69 6e 64 20 54 75 72 62 69 6e 65 73 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 00 ff 7f a8 fb 5a 00 67 73 70 31 00 00 00 00 70 fb 5a 00 00 03 02 00 ff ff ff ff 07 00 00 00 09 01 26 01 22 03 00 00 c8 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 32 00 32 00 32 00 32 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 59 10 00 00
7. The new structure will need a new Structure ID Offset 0x0050 to 0x0051 (2 bytes) of the 176 that you've just added this need to be set one higher than the previous. (Initially it is 317 (3D 01) so the next on is 318 (3E 01).) You'll need to remember the maximum ID as the file is not in structure ID order (see 8.).
8. Now look at the first 4 bytes of the file (Offset 0x0000 to 0x0003), these show the number of structures in the file (its 3E 01 00 00 (318) remember the structure ID starts with 00 00!) so we need to increase this as well (initially its 3E 01 00 00 so next is 3F 01 00 00) This can be used to remember the next structure ID (see 7).
9. Take a look at the next 4 bytes (Offset 0x0004 to 0x0007) this is the address of the buildings address map (file offset) that come after the structure entries, since you've add one you'll need to increase this as well by 176. (Initially it's 84 DD 00 00 and will change to 34 DE 00 00).
10. You don't need to do anything else with the Hex editor to this file, so save it and add it back into STBOF.res (you can do this in UE!)
11. Open UE and open STBOF.res (if not already open), go to EDIT -> BUILDINGS -> BUILDING STATS and scroll to the bottom of the list of structures, (you should find your new structure awaiting you there) select the new structure.
12. Edit the new structure as you like (DO NOT MOVE IT! (Unless you understand what you are doing!)).
13. When you are happy with your new structures new attributes save STBOF.res and update trek.exe.
=========================================================
PART 2:- making trek.exe work with additional structures:
1. Open 'trek.exe' in a hex editor.
2. You will need to change the following values to the new maximum structure ID value, (this is the same as the value used in PART 1 step 7.) Change the bytes to the new value. (E.g. for one extra building 3D 01 becomes 3E 01).
Code: Select all
Trek.exe Assembly Hex Code
offset Offset
0x4f8e3 4504E3 cmp ax, 13D 66 3D 3D 01
0x4fad5 4506D5 cmp dx, 13D 66 81 FA 3D 01
0x53102 453D02 cmp bx, 13D 66 81 FB 3D 01
0x85472 486072 cmp cx, 13D 66 81 F9 3D 01
0x85923 486523 cmp bx, 13D 66 81 FB 3D 01
0x85f36 486B36 cmp cx, 13D 66 81 F9 3D 01
0x86028 486C28 cmp bx, 13D 66 81 FB 3D 01
0x86391 486F91 cmp bx, 13D 66 81 FB 3D 01
0x86752 487352 cmp bx, 13D 66 81 FB 3D 01
0x8680c 48740C cmp bx, 13D 66 81 FB 3D 01
0x868e9 4874E9 cmp bx, 13D 66 81 FB 3D 01
0x869cb 4875CB cmp ecx, 13D 81 F9 3D 01 00 00
0x86abb 4876BB cmp ecx, 13D 81 F9 3D 01 00 00
Code: Select all
Trek.exe Assembly Hex Code
offset Offset
0xadda 40B9DA cmp ax, 13E 66 3D 3E 01
0xcb52 40D752 cmp bx, 13E 66 81 FB 3E 01
0x39e62 43AA62 cmp bx, 13E 66 81 FB 3E 01
0xf38c6 4F44C6 cmp dx, 13E 66 81 FA 3E 01
Thanks to DCER, Tethys and SCT for help, support and information on solving this.