Terraforming Capacity of Task Forces

Terraforming Capacity of Task Forces (Instant-Terraforming fix); support/discussion/questions

Moderator: thunderchero

Post Reply
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 723
Joined: Sun Apr 27, 2008 2:00 am

Terraforming Capacity of Task Forces

Post by Spocks-cuddly-tribble » Sat Jun 27, 2009 2:39 pm

This topic has been renamed from former:

Instant-Terraforming Bug (fix)


Due to a bug in BotF a combination of a TT and a colony ship will terraform any planet instantly. The responsible code sequence is faulty and doesn't check for ship function. :?


As a reminder the vanilla production values of colony ships and TTs:
( * 100 = terraforming capacity! )

Colony 1 : 1 -> 100
Colony 2 : 3 -> 300

TT 1 : 400 -> 40000
TT 2 : 1600 -> 160000

Max terraforming value of planets is unmodded below 1000.

So in theory a TT 2 could terraform almost the whole map in one go. 8O


Maximum value (unmodded) for a Colony is 9 => Colonies: population, farms, factories

Minimum value (unmodded) for a TT is 10 => The Ground Combat Tech Level Multiplier


Using this information we can fix the bug by inserting of a limit check for production capacities of ships. :)
(instead of the faulty code sequence)

EDIT: Code outdated ! see below

:arrow: trek.exe at 0x6864F

replace

Code: Select all

25 FF 00 00 00 E8 47 64 00 00 25 FF FF 00 00 42
with

Code: Select all

E8 4C 64 00 00 25 FF FF 00 00 42 83 F8 0A 7D 02
(with 0A being the critical limit)

Code: Select all

loc_469241:

469241   mov    eax, [ebx+6]
469244   sar    eax, 10h
469247   call   sub_44A690    -> (read Ships in Task Force)
46924C   mov    al, [eax+52h] -> (load ship IDs)
46924F   and    eax, 0FFh     -> redundant! delete/ following statements moved up
469254   call   sub_46F6A0    -> (read_CS_TT_production) -> fixed offset 5 bytes
469259   and    eax, 0FFFFh
46925E   inc    edx       -> now following: cmp eax,0A // jge short loc_469261
46925F   add    ecx, eax  -> add ship production value to terraforming Task Force
469261   mov    eax, [esi+4]
469264   add    ebx, 4
469267   cmp    edx, eax
469269   jl     short loc_469241
46926B   nop
Last edited by Spocks-cuddly-tribble on Sat Dec 11, 2010 8:19 am, edited 3 times in total.
On the verge of a nervous breakdown? Try the relaxing tribble sounds.

User avatar
jigalypuff
Past Administrator
Past Administrator
Posts: 237
Joined: Sat Apr 26, 2008 2:00 am

Post by jigalypuff » Sat Jun 27, 2009 4:12 pm

Nice find but it`s not a bug, it`s an easter egg :)

User avatar
DOT
Lieutenant-Commander
Lieutenant-Commander
Posts: 100
Joined: Tue Dec 23, 2008 3:00 am
Location: 49°N, 8°E

Post by DOT » Tue Jun 30, 2009 11:19 am

Great work, Spock 8)

What about the following code?
Is this the untracable factor of 100, for which I am looking for weeks? If so, it seem to me to be a diviation, not a multiplication!?! :?

BTW: What about setting the trooper values as a multiple of 512 (512 - 1024 - 1536 for example) and instead of checking the productivity, using a
  • xor ax,ax
to make values higher than 255 useless - that would give the possibility to "simulate" the terraforming bug when trooper productivity is e.g. 511 instead of 512.
On the other hand, your solution enables the use of different combat strenghts of TT for different majors without having the terraforming bug. :D
life long and prosper

User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 723
Joined: Sun Apr 27, 2008 2:00 am

Post by Spocks-cuddly-tribble » Tue Jun 30, 2009 2:16 pm

The multiplication by 100 is calculated that way:


[Task Force production value] * [ 4 -1 (=3) *8 (=24) +1 (=25) *4 (=100) ]

Code: Select all

469273      mov     eax, ecx
469275      shl     ecx, 2      => *4
469278      sub     ecx, eax    => -1
46927A      shl     ecx, 3      => *8
46927D      add     ecx, eax    => +1
46927F      mov     eax, ebp
469281      xor     edx, edx
469283      xor     eax, ebp
469285      mov     dx, [ebp+3Ah]
469289      mov     ax, [ebp+3Ch]
46928D      sub     edx, eax
46928F      shl     ecx, 2      => *4



Instant-Terraforming Bug (fix) - UPDATE


My above fix was just a fast workaround for vanilla(-ish mods).

The following code will make it work as intended i.e. only colony ships can use their production value for terraforming.

(So if a mod gives terraform support abilities to non-colony ships then better keeping the above code)

Code: Select all

trek.exe at 0x6864F

change:
25 FF 00 00 00 E8 47 64 00 00 25 FF FF 00 00 42 01 C1 8B 46 04 83 C3 04 39 C2
to:
50 E8 1B 65 00 00 3C 05 58 75 08 E8 41 64 00 00 98 03 C8 42 83 C3 04 3B 56 04


46924F    50            PUSH EAX
469250    E8 1B650000   CALL 46F770 (shipfunction_to_eax)
469255    3C 05         CMP AL, 5
469257    58            POP EAX
469258    75 08         JNZ SHORT 469262
46925A    E8 41640000   CALL 46F6A0 (read_CS_TT_production)
46925F    98            CWDE
469260    03C8          ADD ECX, EAX
469262    42            INC EDX
469263    83C3 04       ADD EBX, 4
469266    3B56 04       CMP EDX, [ESI+4]
On the verge of a nervous breakdown? Try the relaxing tribble sounds.

User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 723
Joined: Sun Apr 27, 2008 2:00 am

Post by Spocks-cuddly-tribble » Sat Dec 11, 2010 8:03 am

Two features some of you might find interesting: :)



:arrow: Coupling Terraforming Output to current Bio Tech Level


The following code example ignores the shiplist.sst production value and calculates instead 50 times current Bio Tech Level per colony ship.

(smaller intervalls than 50, or using a tech & production value, quickly becomes confusingly)

Code: Select all

trek.exe at 0x68643
replace: (41 bytes)
06 C1 F8 10 E8 44 14 FE FF 8A 40 52 25 FF 00 00 00 E8 47 64 00 00 25 FF FF 00 00 42 01 C1 8B 46 04 83 C3 04 39 C2 7C D6 90
with:
08 E8 47 14 FE FF 8A 40 52 E8 1F 65 00 00 3C 05 75 01 41 42 83 C3 04 3B 56 04 7C E2 8B 47 08 33 D2 E8 17 A4 FE FF 0F AF C8

NOTE: when using the AI terraforming tweak (see below) just change at 0x68675 -> 64 to 32 instead of the following two modifications!

at 0x68673 change: 89 C8 C1 E1 02 -> 6B D9 32 90 90

AND at 0x6868F change: C1 E1 02  -> 8B CB 90


469241     8B43 08         MOV EAX, [EBX+8]
469244     E8 4714FEFF     CALL 44A690 (LoadGShipList)
469249     8A40 52         MOV AL, [EAX+52]   // shiplist.sst ID
46924C     E8 1F650000     CALL 46F770 (GetShipFunction)
469251     3C 05           CMP AL, 5          // colony ship ?
469253     75 01           JNZ SHORT 469256
469255     41              INC ECX    // number of colony ships
469256     42              INC EDX
469257     83C3 04         ADD EBX, 4
46925A     3B56 04         CMP EDX, [ESI+4]
46925D     7C E2           JL SHORT 469241 // loop next ship in task force
46925F     8B47 08         MOV EAX, [EDI+8]   // race ID
469262     33D2            XOR EDX, EDX      // tech ID 0 = Bio
469264     E8 17A4FEFF     CALL 453680 (GetTechLevel)
469269     0FAFC8          IMUL ECX, EAX    // colony ships * bio tech level

469273     6BD9 32         IMUL EBX, ECX, 32h   // TF output * 50
469276     90 90           NOP

46928F     8BCB            MOV ECX, EBX
469291     90              NOP


And, due to the growing confusing diversity of my upcoming AI topic, another uncoupled pre-release:




:arrow: Modifying AI Terraforming Speed (compatible with all above modifications)


This gives the AI a speed bonus of 50% per difficulty level above 'simple'.

i.e. [Task Force Terrafoming Capacity] * [difficulty level +1] / 2

Code: Select all

trek.exe at 0x68673
replace: (57 bytes)
89 C8 C1 E1 02 29 C1 C1 E1 03 01 C1 89 E8 31 D2 31 E8 66 8B 55 3A 66 8B 45 3C 29 C2 C1 E1 02 89 D0 39 D1 76 02 89 D1 8B 04 24 89 CB 31 D2 8B 40 0A 66 8B 54 24 04 C1 F8 10
with:
6B D9 64 8A 4F 08 B5 01 D2 E5 84 2D 28 2B 5A 00 75 0C 66 A1 44 2B 5A 00 40 0F AF D8 D1 EB 0F B7 45 3A 66 2B 45 3C 3B D8 76 02 8B D8 8B 04 24 0F B7 54 24 04 0F B7 40 0C 90


469273     6BD9 64          IMUL EBX,ECX, 64h // default TF muliplier 100
469276     8A4F 08          MOV CL, [EDI+8]  // race ID ship owner
469279     B5 01            MOV CH, 1
46927B     D2E5             SHL CH, CL
46927D     842D 282B5A00    TEST [5A2B28], CH   // AI ?
469283     75 0C            JNZ SHORT 469291    // if not skip bonus
469285     66:A1 442B5A00   MOV AX, [5A2B44] // difficulty level
46928B     40               INC EAX
46928C     0FAFD8           IMUL EBX, EAX
46928F     D1EB             SHR EBX, 1
469291     0FB745 3A        MOVZX EAX, WORD [EBP+3A] // planet TF cost total
469295     66:2B45 3C       SUB AX, WORD [EBP+3C] // total - done = still to-do
469299     3BD8             CMP EBX, EAX
46929B     76 02            JBE SHORT 46929F
46929D     8BD8             MOV EBX, EAX // prevent terraforming overflow
46929F     8B0424           MOV EAX, [ESP]
4692A2     0FB75424 04      MOVZX EDX, WORD [ESP+4]
4692A7     0FB740 0C        MOVZX EAX, WORD [EAX+C]
4692AB     90               NOP
If you still want more speed, replacing these statements with nop's increases the bonus to +100% (maybe a bit over the top):

Code: Select all

46928B     40               INC EAX

46928F     D1EB             SHR EBX, 1
Given an AI speedup, the following link again becomes interesting: :wink:

=> the AI minimum terraform threshold :idea:

Unfortunately, nobody found a way to get rid of the AI colony ships common "sitting duck" behavior, if facing opponents, yet (sometimes they still move or terraform planets, but do nothing useful and don't colonise). :(
Last edited by Spocks-cuddly-tribble on Tue Feb 22, 2011 11:47 am, edited 1 time in total.
On the verge of a nervous breakdown? Try the relaxing tribble sounds.

User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 » Sat Dec 11, 2010 7:37 pm

H A L L E L U J A H ! S C T ! May whatever gods you believe in have mercy on your sole !!

am i correct in assuming

to change the 50%bonus to a 25% (rounded down) terraforming bonus per difficulty level I need to change...
Spocks-cuddly-tribble wrote:You'd need to replace the statement at 46928B with 'add al, 3' and 46928F with 'shr ebx, 2'.

= [Terrafoming Capacity] * [difficulty level +3] / 4 = +25% per level above 'simple'.

But this means you must rewrite my whole code due to code-space issues (also note all jump/call instructions have to be adjusted).

Anyhow, considering the massively flawed AI terraforming & colonisation behavior, 50% should be reasonable. :)

User avatar
WhiteCat
Cadet 2nd Year
Cadet 2nd Year
Posts: 9
Joined: Mon Jan 11, 2010 3:00 am

Re: Terraforming Capacity of Task Forces

Post by WhiteCat » Sat Jan 14, 2017 2:00 pm

Question: if I have the ECM installed, but want transports to be able to boost terraforming speed, can I just take the original values (25 FF 00 00 00 E8 47 64 00 00 25 FF FF 00 00 42 01 C1 8B 46 04 83 C3 04 39 C2) and paste them back in at 0x6864F ?

(Personally, I think that calling the original gameplay mechanic a "bug" is an insult to the good people at the Army Corp of Engineers. :))

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

Re: Terraforming Capacity of Task Forces

Post by thunderchero » Sat Jan 14, 2017 3:41 pm

WhiteCat wrote:Question: if I have the ECM installed, but want transports to be able to boost terraforming speed, can I just take the original values (25 FF 00 00 00 E8 47 64 00 00 25 FF FF 00 00 42 01 C1 8B 46 04 83 C3 04 39 C2) and paste them back in at 0x6864F ?
yes, if;
1. if no other code has been edited related to this code.
2. if your hex editor allows copy and paste.

Post Reply

Return to “Terraforming Capacity of Task Forces (Instant-Terraforming fix)”

Who is online

Users browsing this forum: No registered users