Tech Level Bonus Factors

Tech Level Bonus Factors (+2%); support/discussion/questions

Moderator: thunderchero

User avatar
Gowron
Code Master
Code Master
Posts: 304
Joined: Sat Apr 26, 2008 2:00 am
Location: 50° N, 11° E

Tech Level Bonus Factors

Post by Gowron »

Finally :)

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
to

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
Energy Bonus:
Go to position 0x428C4 and change

Code: Select all

8D 04 36 89 7C 24 10 01 E8 DF 6C 24 0C 89 44
to

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
to

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
Bonus Popup:
Go to position 0xF179C and change

Code: Select all

74 72 01 C0
to

Code: Select all

6B C0 XX 90
In the bonus popup, the same bonus factor is used for all output types. You can still choose different bonus factors for food, energy and industry, but the value in the popup will then be incorrect for at least two of the output types. This is only a graphical problem, because the value in the popup does not actually do anything.



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)
was replaced by

Code: Select all

6B FF XX        imul edi, XX          (multiplies the tech level by XX)
90              nop                   (does nothing)
This uses up 2 additional bytes. They're regained at the end of the code where

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)
is replaced by

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)
The code in-between is just moved by 2 bytes and not changed.


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])
is replaced by

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])
Here, working with esi directly instead of transferring its value to eax freed up the necessary byte for the multiplication.

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)
was replaced by

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)
The side effect is that the tech level bonus will always be displayed for food, enery, industry and research, even if it the tech level bonus is zero. This is always the case for research. But it's a very small drawback IMHO ;)
A discovery consists in seeing something everybody has seen and at the same time thinking something nobody has thought yet.
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1870
Joined: Sun Apr 27, 2008 2:00 am

Re: Tech Level Bonus Factors

Post by Spocks-cuddly-tribble »

Verifying the new building types with respect to possible incompatibilities unveiled a bug in Gowron's food tech level modification.
Below a corrected code, essential extra codes for food, energy & industry and tech bonus options for main intel and research. :)



:arrow: Food Tech Bonus (default +2% * biotech tech level)

First restore original code when using modification by Gowron!

Code: Select all

trek.exe at 0x418E7 new code 0x11 bytes:

6B FF 02 89 5C 24 10 8B 02 03 7A 04 89 44 24 0C 90

asm code:

004424E7     6BFF 02      IMUL EDI, EDI, 2  // -> % bonus per tech level
004424EA     895C24 10    MOV [ESP+10], EBX
004424EE     8B02         MOV EAX, [EDX]
004424F0     037A 04      ADD EDI, [EDX+4]
004424F3     894424 0C    MOV [ESP+C], EAX
004424F7     90           NOP

:arrow: Essential extra codes for Food, Energy & Industry Tech level bonus factors :!:

Code: Select all

# 44182A -> INDUSTRY

>> 0x40C2A 25 FF FF 00 00 01 C0
<< 0x40C2A 0F B7 C0 90 6B C0 02

# last byte is INDUSTRY % bonus per tech level


# 442080 -> FOOD

>> 0x41480 25 FF FF 00 00 8B 4A 04 01 C0
<< 0x41480 0F B7 C0 8B 4A 04 90 6B C0 02

# last byte is FOOD % bonus per tech level


# 442F5A -> ENERGY

>> 0x4235A 25 FF FF 00 00 01 C0
<< 0x4235A 0F B7 C0 90 6B C0 02

# last byte is ENERGY % bonus per tech level


# 443B2A -> ENERGY

>> 0x42F2A 66 89 D9 8B 58 0C 01 C9
<< 0x42F2A 8A CB 8B 58 0C 6B C9 02

# last byte is ENERGY % bonus per tech level


# 443DC4 -> FOOD

>> 0x431C4 66 89 C8 8B 4A 04 01 C0
<< 0x431C4 8A C1 8B 4A 04 6B C0 02

# last byte is FOOD % bonus per tech level

:arrow: Research Tech Bonus (default +2% * lowest tech level aka all tech req.)

Note: Code includes the % research (local) fix. Do not use research fix from this link! viewtopic.php?p=32983#p32983

Code: Select all

trek.exe at 0x40A78-0x40AD2 new code 0x5B bytes:

8B 43 4C B2 06 E8 FE 89 FF FF 6B C0 02 6B D6 58 8D 8C 1A 40 02 00 00 90 90 90 90 8D 14 B5 00 00 00 00 29 F2 81 C3 C0 00 00 00 C1 E2 06 01 D3 83 79 50 01 75 0F C7 41 30 00 00 00 00 83 C4 0C 5D 5E 59 5B C3 0F B7 71 44 03 73 1C 8D 44 30 9C 89 04 24 DD 05 94 89 57 00 DB 04 24

code changes:

00441678     8B43 4C           MOV EAX, [EBX+4C]  // system owner ID
0044167B     B2 06             MOV DL, 6  // tech ID for bonus, 6= all techs
0044167D     E8 FE89FFFF       CALL 43A080  // get race tech level
00441682     6BC0 02           IMUL EAX, EAX, 2  // -> % bonus per tech level 
00441685     6BD6 58           IMUL EDX, ESI, 58
00441688     8D8C1A 40020000   LEA ECX, [EDX+EBX+240]
0044168F     90909090          NOP

004416BC     0FB771 44         MOVZX ESI,WORD [ECX+44]  // system morale
004416C0     0373 1C           ADD ESI, [EBX+1C]  // local system bonus %
004416C3     8D4430 9C         LEA EAX, [EAX+ESI-64]
004416C7     890424            MOV [ESP], EAX
004416CA     DD05 94895700     FLD QWORD [578994]
004416D0     DB0424            FILD DWORD [ESP]

:arrow: Intel Tech Bonus and/or Morale Effect (default +2% * computer tech level)

Note: Code includes the % intel total two-in-one bug fix. Do not use the intel fix from this link! viewtopic.php?p=32983#p32983

Intel output can go negative when using intel morale effect and system morale is lower than penalty percentage patch: viewtopic.php?p=10468#p10468

Code: Select all

trek.exe at 0x40976 new code 0x45 bytes:

50 8B 40 4C BA 01 00 00 00 E8 FC 8A FF FF 6B E8 02 58 6B CB 58 8D 8C 08 40 02 00 00 0F B7 51 44 8D 6C 2A 9C 69 DB C0 00 00 00 8D 9C 18 C0 00 00 00 03 6B 5C 90 90 90 83 79 54 01 0F 84 8E 00 00 00 56 8B F5 90

code changes:

00441576     50                PUSH EAX
00441577     8B40 4C           MOV EAX, [EAX+4C]  // system owner ID
0044157A     BA 01000000       MOV EDX, 1  // tech ID for bonus, 1= computer tech
0044157F     E8 FC8AFFFF       CALL 43A080  // get race tech level
00441584     6BE8 02           IMUL EBP, EAX, 2  // -> % bonus per tech level
00441587     58                POP EAX
00441588     6BCB 58           IMUL ECX, EBX, 58
0044158B     8D8C08 40020000   LEA ECX, [EAX+ECX+240]
00441592     0FB751 44         MOVZX EDX, WORD [ECX+44]   // system morale
00441596     8D6C2A 9C         LEA EBP,DWORD PTR DS:[EDX+EBP-64]
0044159A     69DB C0000000     IMUL EBX, EBX, 0C0
004415A0     8D9C18 C0000000   LEA EBX, [EAX+EBX+C0]
004415A7     036B 5C           ADD EBP, [EBX+5C]  // local system bonus %
004415AA     909090            NOP

004415B8     8BF5              MOV ESI, EBP
004415BA     90                NOP
For no morale effect change at asm-441596 -> 8D6C2A9C to 90909090

For no tech bonus change at asm-44157F -> E8FC8AFFFF to B800000000


The tech IDs for modding research & intel tech bonuses:

0 - Biotech
1 - Computer
2 - Construction
3 - Energy
4 - Propulsion
5 - Weapon
6 - Lowest Tech level (for all tech req.)



:arrow: Bonus Popups (just GUI cosmetics)

I think there are more important things to do, but here is the how-to for intel and research tech popups:

Gowron's code modifies sub_4F2220 which is shared for all 5 main building popups.

Code: Select all

BotF 1.0.2 original code:
004F239A                 test    eax, eax      // tech level
004F239C                 jz      short no_tech_bonus
004F239E                 add     eax, eax        // bonus factor
It's called 5 times from sub_4F5490 in same order as in the F2 screen i.e. food, industry, energy, intel & research.

There are 9 'push' commands for each call:

1. -> [0 or 1=show morale effect]
2. -> [output value]
3. -> [empire bonus]
4. -> [local bonus]
5. -> [tech level for bonus]
6. -> [system consumption for food and energy]
7. -> [address of area lexicon string]
8 & 9 (unimportant now)


For example to display an intel morale bonus:

Code: Select all

004F56C2                 push    0 -> 1
Also this popup code for empire-wide research bonus can be replaced with 'push 0' since not applied to the local research outputs:

Code: Select all

004F572C                 xor     eax, eax
004F572E                 mov     ax, [edx+8]
004F5732                 push    eax 
Last edited by Spocks-cuddly-tribble on Tue May 10, 2022 1:50 pm, edited 1 time in total.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7824
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Tech Level Bonus Factors

Post by thunderchero »

SWEET :D

thunderchero
User avatar
Quintaine
Lieutenant-Junior Grade
Lieutenant-Junior Grade
Posts: 68
Joined: Mon Apr 19, 2010 2:00 am
Location: Germany, Berlin

Re: Tech Level Bonus Factors

Post by Quintaine »

I have modified Trek.exe with Intel and Reseach Techbonus but it doesn`t work it. Botf writs 0% but i have 0A for 10% addet. What make it wrong.

This cods i have include in my trek.exe

for intel
50 8B 40 4C BA 01 00 00 00 E8 FC 8A FF FF 6B E8 0A (0A=10% Techbonus) 58 6B CB 58 8D 8C 08 40 02 00 00 0F B7 51 44 8D 6C 2A 9C 69 DB C0 00 00 00 8D 9C 18 C0 00 00 00 03 6B 5C 90 90 90 83 79 54 01 0F 84 8E 00 00 00 56 8B F5 90

for tech

8B 43 4C B2 06 E8 FE 89 FF FF 6B C0 0A (0A=10% Techbonus) 6B D6 58 8D 8C 1A 40 02 00 00 90 90 90 90 8D 14 B5 00 00 00 00 29 F2 81 C3 C0 00 00 00 C1 E2 06 01 D3 83 79 50 01 75 0F C7 41 30 00 00 00 00 83 C4 0C 5D 5E 59 5B C3 0F B7 71 44 03 73 1C 8D 44 30 9C 89 04 24 DD 05 94 89 57 00 DB 04 24
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1870
Joined: Sun Apr 27, 2008 2:00 am

Re: Tech Level Bonus Factors

Post by Spocks-cuddly-tribble »

Quintaine wrote:Botf writs 0% but i have 0A for 10% addet. What make it wrong.
Sloppy reading ^^ :
Gowron wrote:This is only a graphical problem, because the value in the popup does not actually do anything.

The how-to is @ "Bonus Popups (just GUI cosmetics)", but requires messing with the assembler code, which IMHO isn't worth the efforts for suchlike minor flaws.


-Update-

Some code mirrors for AI building behavior, the auto-build feature & a food/energy deficit warning?:

Code: Select all

tech level bonus factors for:

0044182F                 add     eax, eax // industry (AI output check, ignores morale)
00442088                 add     eax, eax // food
00442F5F                 add     eax, eax // energy
00443B30                 add     ecx, ecx // energy
00443DCA                 add     eax, eax // food
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
Quintaine
Lieutenant-Junior Grade
Lieutenant-Junior Grade
Posts: 68
Joined: Mon Apr 19, 2010 2:00 am
Location: Germany, Berlin

Re: Tech Level Bonus Factors

Post by Quintaine »

Hmmm ok i see it :). Thanks for help but i have see an other three problems on research. I have two systems of minor race, the first system multipliers tech bonus not empire bonus and the other one multipliers impire bonus not tech bonus and morale doesn´t multiplier on both systems! 8O

And Sorry my english is not so good -.-
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7824
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Tech Level Bonus Factors

Post by thunderchero »

Spocks-cuddly-tribble wrote: Bonus Popups (just GUI cosmetics)I think there are more important things to do,

Gowron's code modifies sub_4F2220 which is shared for all 5 main building popups.
I hated this being shared, so I took a look at code and here is what I came up with.

Note; these changes are only cosmetics (changes popup only) to effect tech bonus you must change values in post 1 & 2 by gowron and SCT

Code: Select all

gowrons old code changes
>> 0x0F179C 74 72 01 C0
<< 0x0F179C 6B C0 01 90
this makes it 1* bonus below.

this removes tech level check and code moved back 1 byte to allow room for bonus value
>> 0x0f4933 8B 41 1A 31 D2 C1 F8 10 E8 50 E7 F4 FF 8B 81 A8 00 00 00 E8 F5 C3 04 00 E8 10 C8 01 00 31 C0 31 D2 A0 2A 2B 5A 00 E8 22 4B F4 FF 6A 01 8B 57 14 52 6A 00 8B 5D 04 53 50
<< 0x0f4933 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 6A 00 8B 57 14 52 6A 00 8B 5D 04 53 6A XX
XX = food bonus

this removes tech level check and code moved back 1 byte to allow room for bonus value
>> 0x0f49c4 31 C0 BA 02 00 00 00 A0 2A 2B 5A 00 E8 AB 4A F4 FF 6A 01 8B 57 2C 52 8B 54 24 20 31 DB 66 8B 5A 06 53 8B 55 14 52 50
<< 0x0f49c4 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 6A 00 8B 57 2C 52 8B 54 24 20 31 DB 66 8B 5A 06 53 8B 55 14 52 6A XX
XX = industry bonus

this removes tech level check and code moved back 1 byte to allow room for bonus value
>> 0x0f4a3f 31 C0 BA 03 00 00 00 A0 2A 2B 5A 00 E8 30 4A F4 FF 89 C3 8B 41 1A 31 D2 C1 F8 10 E8 31 E4 F4 FF 31 D2 6A 00 66 8B 57 1E 52 6A 00 8B 55 0C 52 53
<< 0x0f4a3f 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 89 C3 8B 41 1A 31 D2 C1 F8 10 E8 32 E4 F4 FF 31 D2 6A 00 66 8B 57 1E 52 6A 00 8B 55 0C 52 6A XX
XX = energy bonus


>> 0x0f4acd 00
<< 0x0f4acd XX
XX = intel bonus

>> 0x0f4b38 00
<< 0x0f4b38 XX
XX = research bonus

remove display morale
>> 0xf4b23 01
<< 0xf4b23 00

then edit lexicon
lexicon index 1360 change +%d%% Technology Bonus -> +%d%% Per Tech Level Bonus
This way each bonus type can use a different bonus value but will display "per tech level bonus" not "total tech level bonus" as before. So this will remain the same though out the game.

thunderchero
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7824
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Tech Level Bonus Factors

Post by thunderchero »

Hi Everyone,

I was not satisfied with above code change, so I have updated it. :grin:

You should remove changes above for popup before applying this patch, and be sure to change all "XX" to proper value

This makes some major code changes to popups. This will display total tech bonus as you advance tech levels (same as vanilla), and added (% local) system bonus popup for intel.

Code: Select all

NAME: Bonus Popup XX%
AUTHOR: thunderchero
URL: https://www.armadafleetcommand.com/onscreen/botf/viewtopic.php?f=9&t=238&sid=94e2fb42afce779e46be639d207b264b
 
>> 0x000f179c 74 72
>> 0x000f179f c0

<< 0x000f179c 6b c0
<< 0x000f179f 90

>> 0x000f492a 75 07 31 c0 66 89 44 24 10 8b 41 1a 31 d2 c1 f8 10 e8 50
>> 0x000f493d e7 f4 ff 8b 81 a8 00
>> 0x000f4945 00 e8 f5 c3 04 00 e8 10 c8 01 00 31 c0 31 d2 a0 2a 2b 5a 00 e8 22 4b f4 ff 6a 00 8b 57 14 52 6a 00 8b 5d 04 53 50 31 c0 66 8b 47 1a 50 56 8b 74 24 30 56 8b 44 24 30 31 d2 50 8d 81 00 01 00 00 bb ff 7f 00 00 e8 91 cc ff ff b8 10 02 00 00 66 89 54 24 10 66 89 5c 24 12 e8 3d 5d f9 ff 8d 5c 24 10 89 c6 8b 41 1a ba
>> 0x000f49ad 0d 00
>> 0x000f49b0 00 c1 f8 10 e8 b7 fc f4 ff 85 c0 75 07 31 c0 66 89 44 24 10 31 c0 ba 02 00 00 00 a0 2a 2b 5a 00 e8 ab 4a f4 ff 6a
>> 0x000f49d7 8b 57 2c 52 8b 54 24 20 31 db 66 8b 5a 06 53 8b 55 14 52 50 6a 00 56 8b
>> 0x000f49f1 30 53 8b 74 24 30 31 d2 56 8d 81 18 01 00 00 bb ff 7f
>> 0x000f4a05 e8 16 cc ff ff b8 17 01 00 00 66 89 54 24 10 66 89 5c 24 12 e8 c2 5c f9 ff 8d 5c 24 10
>> 0x000f4a22 89 c6 8b 41 1a ba 02 00 00 00 c1 f8 10 e8 3c fc f4 ff 85 c0 75 07 31 c0 66 89 44 24 10 31 c0 ba 03 00 00 00 a0 2a 2b 5a 00 e8 30 4a f4
>> 0x000f4a50 89 c3 8b 41 1a 31 d2 c1 f8 10 e8 31 e4 f4 ff 31 d2 6a 00 66 8b 57 1e 52 6a 00 8b 55 0c 52 53 50 56 8b 5c 24 30 53 8b 74 24 30 31 d2 56 8d 81 30 01 00 00 bb ff 7f 00 00 e8 93 cb ff ff b8 24 02 00 00 66 89 54 24 10
>> 0x000f4a97 66 89 5c 24 12 e8 3f 5c f9 ff 8d 5c 24 10 89 c6 8b 41 1a ba 0a 00 00 00 c1 f8 10 e8 b9 fb f4 ff 85 c0 75 07 31 c0 66 89 44 24 10 6a 00 8b 47 40 50 6a 00 6a 00 6a
>> 0x000f4ace 6a 00 56 8b 54 24 30 52 8b 5c 24 30 53 8d 81 48 01 00 00 e8 3a cb ff ff 31 d2 bb ff 7f 00 00 b8 e4 03 00 00 66 89 54 24 10 ba 07 00 00 00 66 89 5c 24 12 e8 da 5b f9 ff 89 c6 8b 41 1a 8d 5c
>> 0x000f4b0d 24 10 c1 f8 10 e8 59 fb f4 ff 85 c0 75 07 31 c0 66 89 44 24 10 6a 01 8b 47 30 8b 54 24 1c 50 31 c0 66 8b 42 08 50 8b 55 1c 52 6a 00 6a 00 56 8b 5c 24 30 53 8b 74 24 30 56 8d 81 60 01
>> 0x000f4b4c e8 cf ca ff ff 5b 5a 5e 5f 83 c4 0c 5d 59 c3

<< 0x000f492a 31 c0 ba 00 00 00 00 a0 2a 2b 5a 00 e8 45 4b f4 ff 6b c0
# XX = food tech bonus multiplier
<< 0x000f493d XX 52 8b 57 14 52 6a
<< 0x000f4945 8b 5d 04 53 50 31 c0 66 8b 47 1a 50 56 8b 74 24 30 56 8b 44 24 30 31 d2 50 8d 81 00 01 00 00 bb ff 7f 00 00 e8 b2 cc ff ff b8 10 02 00 00 66 89 54 24 10 66 89 5c 24 12 e8 5e 5d f9 ff 8d 5c 24 10 89 c6 8b 41 1a ba 0d 00 00 00 c1 f8 10 e8 d8 fc f4 ff 85 c0 31 c0 ba 02 00 00 00 a0 2a 2b 5a 00 e8 d5 4a f4 ff 6b c0
# XX = industry tech bonus multiplier
<< 0x000f49ad XX 6a
<< 0x000f49b0 8b 57 2c 52 8b 54 24 20 31 db 66 8b 5a 06 53 8b 55 14 52 50 6a 00 56 8b 5c 24 30 53 8b 74 24 30 31 d2 56 8d 81 18
<< 0x000f49d7 00 00 bb ff 7f 00 00 e8 3d cc ff ff b8 17 01 00 00 66 89 54 24 10 66 89
<< 0x000f49f1 12 e8 e9 5c f9 ff 8d 5c 24 10 89 c6 8b 41 1a ba 02 00
<< 0x000f4a05 c1 f8 10 e8 63 fc f4 ff 85 c0 31 c0 ba 03 00 00 00 a0 2a 2b 5a 00 e8 60 4a f4 ff 6b c0
# XX = energy tech bonus multiplier
<< 0x000f4a22 XX 89 c3 8b 41 1a 31 d2 c1 f8 10 52 66 8b 57 1e 52 6a 00 8b 55 0c 52 53 50 56 8b 5c 24 30 53 8b 74 24 30 31 d2 56 8d 81 30 01 00 00 bb
<< 0x000f4a50 7f 00 00 e8 c8 cb ff ff b8 24 02 00 00 66 89 54 24 10 66 89 5c 24 12 e8 74 5c f9 ff 8d 5c 24 10 89 c6 8b 41 1a ba 0a 00 00 00 c1 f8 10 e8 ee fb f4 ff 85 c0 31 c0 ba 06 00 00 00 a0 2a 2b 5a 00 e8 eb 49 f4 ff 6b c0
# XX = intel tech bonus multiplier
<< 0x000f4a97 XX 6a 00 8b 57 40 52 8b 54 24 20 31 db 66 8b 5a 06 53 8b 55 5c 52 50 90 6a 00 56 8b 54 24 30 52 8b 5c 24 30 53 8d 81 48 01 00 00 e8 59 cb ff ff 31 d2 bb ff 7f 00
<< 0x000f4ace b8 e4 03 00 00 66 89 54 24 10 ba 07 00 00 00 66 89 5c 24 12 e8 f9 5b f9 ff 89 c6 8b 41 1a 8d 5c 24 10 c1 f8 10 e8 78 fb f4 ff 85 c0 31 c0 ba 06 00 00 00 a0 2a 2b 5a 00 e8 75 49 f4 ff 6b c0
# XX = research tech bonus multiplier
<< 0x000f4b0d XX 6a 00 8b 57 30 52 8b 54 24 20 31 db 66 8b 5a 06 53 8b 55 1c 52 50 90 6a 00 56 8b 5c 24 30 53 8b 74 24 30 56 8d 81 60 01 00 00 e8 e3 ca ff ff 5b 5a 5e 5f 83 c4 0c 5d 59 c3 00 00 00
<< 0x000f4b4c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
You must replace "XX" for each bonus multiplier before adding
XX= bonus multiplier food, industry, energy, intel, research (in that order)

changes summary

Code: Select all

004F552A 31 C0                xor     eax, eax
004F552C BA 00 00 00 00       mov     edx, 0 (type of tech required 0 = food)
004F5531 A0 2A 2B 5A 00       mov     al, ds:byte_5A2B2A (player empire)
004F5536 E8 45 4B F4 FF       call    sub_43A080 (Get race tech level)
004F553B 6B C0 XX             imul    eax, XXh (XX = food bonus multiplier)
004F553E 52                   push    edx   (morale switch)
004F553F 8B 57 14             mov     edx, [edi+14h]
004F5542 52                   push    edx
004F5543 6A 00                push    0
004F5545 8B 5D 04             mov     ebx, [ebp+4]
004F5548 53                   push    ebx
004F5549 50                   push    eax
004F554A 31 C0                xor     eax, eax
004F554C 66 8B 47 1A          mov     ax, [edi+1Ah]
004F5550 50                   push    eax
004F5551 56                   push    esi
004F5552 8B 74 24 30          mov     esi, [esp+40h+var_10]
004F5556 56                   push    esi
004F5557 8B 44 24 30          mov     eax, [esp+44h+var_14]
004F555B 31 D2                xor     edx, edx
004F555D 50                   push    eax
004F555E 8D 81 00 01 00 00    lea     eax, [ecx+100h]
004F5564 BB FF 7F 00 00       mov     ebx, 7FFFh
004F5569 E8 B2 CC FF FF       call    sub_4F2220
004F556E B8 10 02 00 00       mov     eax, 210h
004F5573 66 89 54 24 10       mov     word ptr [esp+24h+var_14], dx
004F5578 66 89 5C 24 12       mov     word ptr [esp+24h+var_14+2], bx
004F557D E8 5E 5D F9 FF       call    sub_48B2E0
004F5582 8D 5C 24 10          lea     ebx, [esp+24h+var_14]
004F5586 89 C6                mov     esi, eax
004F5588 8B 41 1A             mov     eax, [ecx+1Ah]
004F558B BA 0D 00 00 00       mov     edx, 0Dh
004F5590 C1 F8 10             sar     eax, 10h
004F5593 E8 D8 FC F4 FF       call    sub_445270
004F5598 85 C0                test    eax, eax
004F559A 31 C0                xor     eax, eax
004F559C BA 02 00 00 00       mov     edx, 2 (type of tech required 2 = construction)
004F55A1 A0 2A 2B 5A 00       mov     al, ds:byte_5A2B2A (player empire)
004F55A6 E8 D5 4A F4 FF       call    sub_43A080 (Get race tech level)
004F55AB 6B C0 XX             imul    eax, XXh  (XX = industry bonus multiplier)
004F55AE 6A 00                push    0  (morale switch)
004F55B0 8B 57 2C             mov     edx, [edi+2Ch]
004F55B3 52                   push    edx
004F55B4 8B 54 24 20          mov     edx, [esp+2Ch+var_C]
004F55B8 31 DB                xor     ebx, ebx
004F55BA 66 8B 5A 06          mov     bx, [edx+6]
004F55BE 53                   push    ebx
004F55BF 8B 55 14             mov     edx, [ebp+14h]
004F55C2 52                   push    edx
004F55C3 50                   push    eax
004F55C4 6A 00                push    0
004F55C6 56                   push    esi
004F55C7 8B 5C 24 30          mov     ebx, [esp+40h+var_10]
004F55CB 53                   push    ebx
004F55CC 8B 74 24 30          mov     esi, [esp+44h+var_14]
004F55D0 31 D2                xor     edx, edx
004F55D2 56                   push    esi
004F55D3 8D 81 18 01 00 00    lea     eax, [ecx+118h]
004F55D9 BB FF 7F 00 00       mov     ebx, 7FFFh
004F55DE E8 3D CC FF FF       call    sub_4F2220
004F55E3 B8 17 01 00 00       mov     eax, 117h
004F55E8 66 89 54 24 10       mov     word ptr [esp+24h+var_14], dx
004F55ED 66 89 5C 24 12       mov     word ptr [esp+24h+var_14+2], bx
004F55F2 E8 E9 5C F9 FF       call    sub_48B2E0
004F55F7 8D 5C 24 10          lea     ebx, [esp+24h+var_14]
004F55FB 89 C6                mov     esi, eax
004F55FD 8B 41 1A             mov     eax, [ecx+1Ah]
004F5600 BA 02 00 00 00       mov     edx, 2
004F5605 C1 F8 10             sar     eax, 10h
004F5608 E8 63 FC F4 FF       call    sub_445270
004F560D 85 C0                test    eax, eax
004F560F 31 C0                xor     eax, eax
004F5611 BA 03 00 00 00       mov     edx, 3 (type of tech required 3 = energy)
004F5616 A0 2A 2B 5A 00       mov     al, ds:byte_5A2B2A  (player empire)
004F561B E8 60 4A F4 FF       call    sub_43A080 (Get race tech level)
004F5620 6B C0 XX             imul    eax, XXh  (XX = energy bonus multiplier)
004F5623 89 C3                mov     ebx, eax
004F5625 8B 41 1A             mov     eax, [ecx+1Ah]
004F5628 31 D2                xor     edx, edx
004F562A C1 F8 10             sar     eax, 10h
004F562D 52                   push    edx
004F562E 66 8B 57 1E          mov     dx, [edi+1Eh]
004F5632 52                   push    edx
004F5633 6A 00                push    0 (morale switch)
004F5635 8B 55 0C             mov     edx, [ebp+0Ch]
004F5638 52                   push    edx
004F5639 53                   push    ebx
004F563A 50                   push    eax
004F563B 56                   push    esi
004F563C 8B 5C 24 30          mov     ebx, [esp+40h+var_10]
004F5640 53                   push    ebx
004F5641 8B 74 24 30          mov     esi, [esp+44h+var_14]
004F5645 31 D2                xor     edx, edx
004F5647 56                   push    esi
004F5648 8D 81 30 01 00 00    lea     eax, [ecx+130h]
004F564E BB FF 7F 00 00       mov     ebx, 7FFFh
004F5653 E8 C8 CB FF FF       call    sub_4F2220
004F5658 B8 24 02 00 00       mov     eax, 224h
004F565D 66 89 54 24 10       mov     word ptr [esp+24h+var_14], dx
004F5662 66 89 5C 24 12       mov     word ptr [esp+24h+var_14+2], bx
004F5667 E8 74 5C F9 FF       call    sub_48B2E0
004F566C 8D 5C 24 10          lea     ebx, [esp+24h+var_14]
004F5670 89 C6                mov     esi, eax
004F5672 8B 41 1A             mov     eax, [ecx+1Ah]
004F5675 BA 0A 00 00 00       mov     edx, 0Ah
004F567A C1 F8 10             sar     eax, 10h
004F567D E8 EE FB F4 FF       call    sub_445270
004F5682 85 C0                test    eax, eax
004F5684 31 C0                xor     eax, eax
004F5686 BA 06 00 00 00       mov     edx, 6 (type of tech required 6 = all)
004F568B A0 2A 2B 5A 00       mov     al, ds:byte_5A2B2A (player empire)
004F5690 E8 EB 49 F4 FF       call    sub_43A080 (Get race tech level)
004F5695 6B C0 XX             imul    eax, XXh (XX = intel bonus multiplier)
004F5698 6A 00                push    0 (morale switch)
004F569A 8B 57 40             mov     edx, [edi+40h]
004F569D 52                   push    edx
004F569E 8B 54 24 20          mov     edx, [esp+2Ch+var_C]
004F56A2 31 DB                xor     ebx, ebx
004F56A4 66 8B 5A 06          mov     bx, [edx+6]
004F56A8 53                   push    ebx
004F56A9 8B 55 5C             mov     edx, [ebp+5Ch]
004F56AC 52                   push    edx
004F56AD 50                   push    eax
004F56AE 90                   nop
004F56AF 6A 00                push    0
004F56B1 56                   push    esi
004F56B2 8B 54 24 30          mov     edx, [esp+40h+var_10]
004F56B6 52                   push    edx
004F56B7 8B 5C 24 30          mov     ebx, [esp+44h+var_14]
004F56BB 53                   push    ebx
004F56BC 8D 81 48 01 00 00    lea     eax, [ecx+148h]
004F56C2 E8 59 CB FF FF       call    sub_4F2220
004F56C7 31 D2                xor     edx, edx
004F56C9 BB FF 7F 00 00       mov     ebx, 7FFFh
004F56CE B8 E4 03 00 00       mov     eax, 3E4h
004F56D3 66 89 54 24 10       mov     word ptr [esp+24h+var_14], dx
004F56D8 BA 07 00 00 00       mov     edx, 7
004F56DD 66 89 5C 24 12       mov     word ptr [esp+24h+var_14+2], bx
004F56E2 E8 F9 5B F9 FF       call    sub_48B2E0
004F56E7 89 C6                mov     esi, eax
004F56E9 8B 41 1A             mov     eax, [ecx+1Ah]
004F56EC 8D 5C 24 10          lea     ebx, [esp+24h+var_14]
004F56F0 C1 F8 10             sar     eax, 10h
004F56F3 E8 78 FB F4 FF       call    sub_445270
004F56F8 85 C0                test    eax, eax
004F56FA 31 C0                xor     eax, eax
004F56FC BA 06 00 00 00       mov     edx, 6 (type of tech required 6 = all)
004F5701 A0 2A 2B 5A 00       mov     al, ds:byte_5A2B2A (player empire)
004F5706 E8 75 49 F4 FF       call    sub_43A080 (Get race tech level)
004F570B 6B C0 XX             imul    eax, XXh  (XX = research bonus multiplier)
004F570E 6A 00                push    0  (morale switch)
004F5710 8B 57 30             mov     edx, [edi+30h]
004F5713 52                   push    edx
004F5714 8B 54 24 20          mov     edx, [esp+2Ch+var_C]
004F5718 31 DB                xor     ebx, ebx
004F571A 66 8B 5A 06          mov     bx, [edx+6]
004F571E 53                   push    ebx
004F571F 8B 55 1C             mov     edx, [ebp+1Ch]
004F5722 52                   push    edx
004F5723 50                   push    eax
004F5724 90                   nop
004F5725 6A 00                push    0
004F5727 56                   push    esi
004F5728 8B 5C 24 30          mov     ebx, [esp+40h+var_10]
004F572C 53                   push    ebx
004F572D 8B 74 24 30          mov     esi, [esp+44h+var_14]
004F5731 56                   push    esi
004F5732 8D 81 60 01 00 00    lea     eax, [ecx+160h]
004F5738 E8 E3 CA FF FF       call    sub_4F2220
004F573D 5B                   pop     ebx
004F573E 5A                   pop     edx
004F573F 5E                   pop     esi
004F5740 5F                   pop     edi
004F5741 83 C4 0C             add     esp, 0Ch
004F5744 5D                   pop     ebp
004F5745 59                   pop     ecx
004F5746 C3                   retn
thunderchero
User avatar
Dafedz
Lieutenant-Commander
Lieutenant-Commander
Posts: 131
Joined: Mon May 05, 2008 2:00 am

Re: Tech Level Bonus Factors

Post by Dafedz »

Awesome Thunder. I only just found this, as I too was dissatisfied with how the old code was functioning - especially with me wanting slightly different % bonuses for each area. This is a great patch and works beautifully. :)
User avatar
EnPhreg
Lieutenant-Commander
Lieutenant-Commander
Posts: 130
Joined: Thu Jul 10, 2008 2:00 am

Re: Tech Level Bonus Factors

Post by EnPhreg »

Code: Select all

The tech IDs for modding research & intel tech bonuses:

0 - Biotech
1 - Computer
2 - Construction
3 - Energy
4 - Propulsion
5 - Weapon
6 - Lowest Tech level (for all tech req.)
are also the position for the industry tech ID in the trek.exe known by anybody and can be changed?
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7824
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Tech Level Bonus Factors

Post by thunderchero »

EnPhreg wrote:are also the position for the industry tech ID in the trek.exe known by anybody and can be changed?
not exactly sure of your question here, but if you use UE to edit structures and when editing main structures it has option for tech requirements.
tech.jpg
tech.jpg (137.12 KiB) Viewed 12869 times
User avatar
EnPhreg
Lieutenant-Commander
Lieutenant-Commander
Posts: 130
Joined: Thu Jul 10, 2008 2:00 am

Re: Tech Level Bonus Factors

Post by EnPhreg »

yes, but this seems only to determine the required tech for the next building level but not the tech requirement for the next bonus level.
need the value where i can set the tech field requirement for industry. for research and intel i can use the above mentioned code changes by SCT.
but for industry??
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7824
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Tech Level Bonus Factors

Post by thunderchero »

EnPhreg wrote:yes, but this seems only to determine the required tech for the next building level but not the tech requirement for the next bonus level.
need the value where i can set the tech field requirement for industry. for research and intel i can use the above mentioned code changes by SCT.
but for industry??
where are you editing for intel and research?
User avatar
EnPhreg
Lieutenant-Commander
Lieutenant-Commander
Posts: 130
Joined: Thu Jul 10, 2008 2:00 am

Re: Tech Level Bonus Factors

Post by EnPhreg »

trek.exe at 0x40A78-0x40AD2 new code 0x5B bytes:

8B 43 4C B2 06 E8 FE 89 FF FF 6B C0 02 6B D6 58 8D 8C 1A 40 02 00 00 90 90 90 90 8D 14 B5 00 00 00 00 29 F2 81 C3 C0 00 00 00 C1 E2 06 01 D3 83 79 50 01 75 0F C7 41 30 00 00 00 00 83 C4 0C 5D 5E 59 5B C3 0F B7 71 44 03 73 1C 8D 44 30 9C 89 04 24 DD 05 94 89 57 00 DB 04 24

code changes:

00441678 8B43 4C MOV EAX, [EBX+4C] // system owner ID
0044167B B2 06 MOV DL, 6 // tech ID for bonus, 6= all techs
0044167D E8 FE89FFFF CALL 43A080 // get race tech level
00441682 6BC0 02 IMUL EAX, EAX, 2 // -> % bonus per tech level
00441685 6BD6 58 IMUL EDX, ESI, 58
The tech IDs for modding research & intel tech bonuses:

0 - Biotech
1 - Computer
2 - Construction
3 - Energy
4 - Propulsion
5 - Weapon
6 - Lowest Tech level (for all tech req.)
but this code lines for research and intel are new and made by SCT. so i didn't find a value for an industry techID in the trek.exe.
i thought this new code lines were only for the variable bonus factor, but it seems that also the techID inst't implented by default in vanilla!?
but this is strange, cause the tech bonus factor is always given if you just research the construction tech, no matter if you put all the industry buildings in UE on 'required tech: all'. so there must be a variable in the trek.exe that determines the tech bonus level for industry to just construction tech. but i can't find this value. damn.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7824
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Tech Level Bonus Factors

Post by thunderchero »

sorry, I am not seeing any thing in trek.exe like that in sub section for industry.

btw do you use ida database by QD for viewing trek.exe assbly code?
viewtopic.php?f=76&t=2175
Post Reply

Return to “Tech Level Bonus Factors (+2%)”