After testing tons of "02"s in trek.exe, I made a major detour into the assembler code and found out that the tech bonuses are not implemented as multiplications by 2, but rather as additions.
So actually there are no tech level bonus factors in vanilla BotF, but it's possible to create them
In order to guard against misunderstandings: The tech level bonuses are the bonuses that are added to the outputs of manned food/industry/energy buildings. By default they're given by
[tech level bonus] = [tech level] * 2%,
with "2" being the bonus factor.
By default, the game reads the tech level and adds it to itself when determining the bonus. That's why some modifications have to be done in order to change the bonus factor.
Being able to change the bonus factors means an invaluable opportunity to alter the economical dynamics of BotF.
I'll introduce the necessary changes to trek.exe first and then follow with a deeper explanation of what those changes actually do.
1. How-To
There are four in-game values that are affected by the tech level bonuses: the food output, the energy output, the industry output and the bonus display on the popup that comes up when you hold the cursor over one of these first three values.
The new bonus factor will always be written as "XX". It is a 1-byte integer value, and it is signed. You can set it to 0x02 (default) or any other value of your choice.
Make sure to replace the "XX" first if you intend to copy&paste the following code into your hex editor.
Food Bonus:
Go to position 0x418E7 and change
Code: Select all
01 FF 89 5C 24 10 8B 02 8B 72 04 89 44 24 0C 01 F7 DF 6C 24 0C 89 7C 24 14 DD 5C 24 04 DD 05 4C 89 57 00 DB 44 24 14 D8 C9 31 C0 D9 E8 DE C1 66 8B 41 08 DC 4C 24 04 89 44 24 14 DD 5C 24 04 DB 44 24 14 DE C9 DC 4C 24 04 DD 5C 24 04 8B 7C 24 08 57 8B 6C 24 08
Code: Select all
6B FF XX 90 89 5C 24 10 8B 02 8B 72 04 89 44 24 0C 01 F7 DF 6C 24 0C 89 7C 24 14 DD 5C 24 04 DD 05 4C 89 57 00 DB 44 24 14 D8 C9 31 C0 D9 E8 DE C1 66 8B 41 08 DC 4C 24 04 89 44 24 14 DD 5C 24 04 DB 44 24 14 DE C9 DC 4C 24 04 DD 5C 24 04 8B 7C 24 08 89 FD 57
Go to position 0x428C4 and change
Code: Select all
8D 04 36 89 7C 24 10 01 E8 DF 6C 24 0C 89 44
Code: Select all
6B F6 XX 89 7C 24 10 01 EE DF 6C 24 0C 89 74
Industry Bonus:
Go to position 0x4114B and change
Code: Select all
8D 04 36 01 C8 8B 4A 42 C1 F9 10 31 ED 83 E9 64 89 6C 24 0C 01 C8 DF 6C 24 08 89 44
Code: Select all
6B F6 XX 01 CE 8B 4A 42 C1 F9 10 31 ED 83 E9 64 89 6C 24 0C 01 CE DF 6C 24 08 89 74
Go to position 0xF179C and change
Code: Select all
74 72 01 C0
Code: Select all
6B C0 XX 90
2. In-Depth Analysis
In this section I'll also provide the corresponding assembler code.
Food Bonus:
At the start of the code,
Code: Select all
01 FF add edi, edi (doubles the tech level)
Code: Select all
6B FF XX imul edi, XX (multiplies the tech level by XX)
90 nop (does nothing)
Code: Select all
8B 7C 24 08 mov edi, dword[esp+08] (assigns a value to edi)
57 push edi (saves edi)
8B 6C 24 08 mov ebp, dword[esp+08] (assigns the same value to ebp)
55 push ebp (saves ebp)
Code: Select all
8B 7C 24 08 mov edi, dword[esp+08] (assigns a value to edi)
89 FD mov ebp, edi (assigns the same value to ebp)
57 push edi (saves edi)
55 push ebp (saves ebp)
Energy Bonus:
Code: Select all
8D 04 36 lea eax, dword[esi+esi] (doubles the tech level and stores the result in eax)
89 7C 24 10 mov dword[esp+10], edi (not changed)
01 E8 add eax, ebp (adds ebp [system bonus] to eax)
DF 6C 24 0C fild 64int[esp+0C] (not changed)
89 44 24 14 mov dword[esp+014], eax (reads eax and stores its
value at position [esp+014])
Code: Select all
6B F6 XX imul esi, XX (multiplies esi [tech level] by XX)
89 7C 24 10 mov dword[esp+10], edi
01 E8 add esi, ebp (adds ebp [system bonus] to esi)
DF 6C 24 0C fild 64int[esp+0C]
89 44 24 14 mov dword[esp+014], esi (reads esi and stores its
value at position [esp+014])
I've made sure that the changed registers eax and esi are overwritten before they're used again.
Industry Bonus:
It's basically the same here as for the Energy Bonus.
Again, I've made sure that the changed registers are overwritten before they're used again.
Bonus Popup:
Code: Select all
85 C0 test eax, eax (IF eax == 0 ...)
74 72 je 004F2410 (... THEN do not display the tech level bonus)
01 C0 add eax, eax (adds the tech level to itself)
Code: Select all
85 C0 test eax, eax (not used anymore)
6B C0 XX imul eax, XX (multiplies the tech level by XX)
90 nop (does nothing)