Auto-Upgrading Ships (options)

Auto-Upgrading Ships (options); support/discussion/questions

Moderator: thunderchero

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

Auto-Upgrading Ships (options)

Post by Spocks-cuddly-tribble »

After the auto-upgrading issue has been covered for stations (see Outpost/Starbase for free bug-fix), it's time to get ride of the poor implementation of ship upgradings in BotF. :)

Regrettably, the using of shipyards/starbases, to upgrade ships with industry/credits, is unrealistic within the restrictions of the game. But even apart from the somewhat solved "upgrade and scrap" exploit, auto-upgrading is still an imbalance issue that has to be addressed.

This topic summarizes the means available up to the closest possible approach to simulate a refitting process (section 3.3).




1. Basics


1.1 No Ship Upgrades

=> shiptech.sst & shiplist.sst -mechanics


1.2 No Auto-Upgrades (for ships on map, under construction/build queue)

=> how to make ships obsolete


1.3 Different upgrades for the same ship (useful infos by Thunderchild)

=> Upgrades - some ideas






2. Known Bugs


2.1 There is a bug preventing auto-upgrading ships under construction (& in build queue), if not same ship(ID) present on map or finished that turn.-> (fix-3.1)

2.2 Code for (2.1) is not shared by AI, but there hides a similar AI bug somewhere else.

2.3 For one turn, the displayed cost & total credits preview is wrong (old price) for auto-upgraded ships under construction. It's just cosmetics, but in the worst case this can lead to a "credit deficit".

2.4 The update of task force map speed is delayed by a turn. -> (fix-3.3 or redeploy).

2.5 Instant repair of all hull damage when auto-upgrading damaged ships.-> (fix-3.3)






3. Bugfixes & Modding Options



3.1 Ships in build queue occasionally not auto-upgraded (fix)

Code: Select all

trek.exe at:

0x49796 change A7 01 -> B2 00

0x497B4 change 69 01 -> 94 00

0x497D1 change 0F 85 4A 01 00 00 -> 75 79 90 90 90 90

and at 0x49851

replace: (15 bytes)
31 C0 66 8B 49 28 A0 28 2B 5A 00 D3 E2 85 D0
with:
8A 8C 24 30 01 00 00 D3 E2 84 15 28 2B 5A 00


44A394     0F84 B2000000     JE 44A44C //goto ships under construction

44A3B2     0F85 94000000     JNZ 44A44C

44A3D1     75 79             JNZ SHORT 44A44C
44A3D3     90909090          NOP

44A451     8A8C24 30010000   MOV CL, [ESP+130] // race ID
44A458     D3E2              SHL EDX, CL
44A45A     8415 282B5A00     TEST [5A2B28], DL // AI check


3.2 Auto-Upgrades for AI only


For game balance, this would be the best solution i.e. players have to scrap/replace obsolete ships with newer ones (AI won't do that see link 1.2).

However, there's another problem to deal with:

Since BotF doesn't support transferring crew(-experience) -or names- between ships, this feature somewhat diminishes the concept of "crew experience". Unfortunately, the implemetation of crew-transfer is also not practicable. :(

Anyhow, here is the option:

Code: Select all

Trek.exe at 0x497D7
replace: (30 bytes)
31 C0 89 E2 8A 84 24 2C 01 00 00 E8 D9 55 02 00 8B 84 24 20 01 00 00 8B 94 24 A8 00 00 00
with:
8A 8C 24 30 01 00 00 B5 01 D2 E5 84 2D 28 2B 5A 00 8B 8C 24 20 01 00 00 75 5B EB 3C 90 90


44A3D7     8A8C24 30010000    MOV CL, [ESP+130] // race ID
44A3DE     B5 01              MOV CH, 1
44A3E0     D2E5               SHL CH, CL
44A3E2     842D 282B5A00      TEST [5A2B28], CH // AI ?
44A3E8     8B8C24 20010000    MOV ECX, [ESP+120] // GShiplist
44A3EF     75 5B              JNZ SHORT 44A44C // if not AI goto ships under construction
44A3F1     EB 3C              JMP SHORT 44A42F // auto-upgrade ships on map
44A3F3     90 90              NOP



3.3 Instant hull repair fix + one turn delay fix (#2.4)


This fix keeps the current hull points so that auto-upgraded ships regenerate to new nominal hull (will also prevent auto-upgrade abuse w.r.t hull damage -particularly for ramming- between two battles/system attacks).

Note that completition of new ships is executed before the auto-upgradings. So all ships produced for the old price will be affected by this hull feature. :)

Side note w.r.t. the "upgrade and scrap" exploit:

Keep in mind that scrapping damaged ships in BotF doesn't yield cash. So one would have to wait until the refitting proccess is completed (i.e. full new nominal hull reached) in order to scrap the upgraded ships for credits.



Simulating a Refitting Process (Option)

Given all the above discussed ties and bounds regarding the BotF code, the best possible approach to simulate a refitting process is a loss of hull points.

This does mean, even though the upgraded systems (weapons, speed, sensors, shields) become available instantly, the refitting task isn't fully completed, reflected by a reduction of current hull points. That way, a temporary withdrawal from the front line and visiting star systems /stations could be recommended to accelerate the upgrading (i.e. regenerate hull).

Note the Ship Repair - Ally & Shipyard Bug-fix :idea:

Since ships during refitting, temporarily are also more vulnerable for ramming, an interesting counter concept, that tactic-wise plays out quite well (hull loss vs. stronger weapons, shields, agility). :)

Code: Select all

Trek.exe at 0x497F8
replace: (84 bytes)
39 D0 75 21 31 D0 8A 84 24 28 01 00 00 89 E2 E8 B4 55 02 00 8B 94 24 20 01 00 00 8B 84 24 A8 00 00 00 89 42 3C 8B 94 24 20 01 00 00 8B 84 24 28 01 00 00 66 89 42 52 8B 94 24 26 01 00 00 8B 84 24 20 01 00 00 C1 FA 10 8B 8C 24 20 01 00 00 E8 C4 02 00 00
with:
8A 8C 24 30 01 00 00 B5 01 D2 E5 84 2D 28 2B 5A 00 74 09 33 D2 66 F7 35 44 2B 5A 00 8B D8 8B 84 24 20 01 00 00 8B 94 24 28 01 00 00 E8 E7 02 00 00 8B 8C 24 20 01 00 00 89 59 3C 0F B7 41 50 BA 00 00 00 00 E8 DF F3 FF FF E8 92 E1 FF FF 90 90 90 90 90 90


44A3F8     8A8C24 30010000   MOV CL, [ESP+130] // race ID
44A3FF     B5 01             MOV CH, 1
44A401     D2E5              SHL CH, CL
44A403     842D 282B5A00     TEST [5A2B28], CH // AI ?
44A409     74 09             JE SHORT 44A414 // if AI skip player hull loss
44A40B     33D2              XOR EDX, EDX
44A40D     66:F735 442B5A00  DIV WORD [5A2B44] // difficulty level
44A414     8BD8              MOV EBX, EAX // old hull points
44A416     8B8424 20010000   MOV EAX, [ESP+120] // GShipList
44A41D     8B9424 28010000   MOV EDX, [ESP+128] // shiplist.sst ID
44A424     E8 E7020000       CALL 44A710 // update GShipList
44A429     8B8C24 20010000   MOV ECX, [ESP+120] // GShiplist
44A430     8959 3C           MOV [ECX+3C], EBX // restore old hull points
44A433     0FB741 50      MOVZX EAX, WORD [ECX+50] // load fleet ID
44A437     BA 00000000    MOV EDX, 0
44A43C     E8 DFF3FFFF    CALL 449820 // load taskforce entry
44A441     E8 92E1FFFF    CALL 4485D8 // update taskforce abilities
44A446-44A44B   90           NOP
For players the new hull points are determined via dividing the old hull points by the difficulty level (rounded down). AI is unaffected by the division.

(if you only want the bugfix for 2.5, without refitting simulation, just replace 74 with EB at asm-44A409)
Last edited by Spocks-cuddly-tribble on Sun Feb 20, 2011 12:38 pm, edited 2 times 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
Tethys
Past Administrator
Past Administrator
Posts: 2392
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Post by Tethys »

This is by far the best solution to instant upgrades. Especially the lost hull points, especially :D
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
xDx
Commander
Commander
Posts: 299
Joined: Sat May 10, 2008 2:00 am
Location: East Coast, USA

Re: Auto-Upgrading Ships (Options/Fixes)

Post by xDx »

Spocks-cuddly-tribble wrote:
Update: Fixed an omission in "3.3 Instant hull repair fix", this automatically fixes also the one turn delay (#2.4).
Works flawlessly! Great job and thanks. :)
usane
Ensign
Ensign
Posts: 26
Joined: Tue Oct 19, 2010 2:00 am

Re: Auto-Upgrading Ships (Options/Fixes)

Post by usane »

Very good.
But one question for single player. What if i want to keep the instant upgrade and want the hp increase instantly too.Not to scrapping but for imminent battle need fleet strenghtening. Is it possible. I've just beginned to learn coding so i couldnt figure it out from your fix.
Spocks-cuddly-tribble wrote:
usane wrote:What if i want to keep the instant upgrade and want the hp increase instantly too.
I don't see any point in your question. In that case you don't need any of the above fixes... (just minor flaws).
Ok. Maybe i wasnt clear. I want to fix only the one turn wait or redeploy need. i want the ship upgrade in that turn when the research is complete and i want it without redeploy and with full HP , besides one ship cannot be redeployed so for that i have to wait one turn.
Spocks-cuddly-tribble wrote:(just minor flaws)
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7851
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Auto-Upgrading Ships (Options/Fixes)

Post by thunderchero »

Hi SCT,

just a question on editing values for hull loss. since a lot of UDM game are in MP and on impossible how would I edit it to just a percent of old hull value. I was thinking 60% so a 40% loss. sorry to ask but my attempts have failed.

thunderchero
User avatar
gentle
Lieutenant-Junior Grade
Lieutenant-Junior Grade
Posts: 92
Joined: Sun Aug 14, 2011 9:52 am

Re: Auto-Upgrading Ships (Options/Fixes)

Post by gentle »

it will be better in my opinion that the hull after upgrading remain 20% or what is the current value. this will give the opponent a 5-6 turns break to try and respond somehow to this (increase or decrease research, change intel attacks etc..)
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7851
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Auto-Upgrading Ships (Options/Fixes)

Post by thunderchero »

Spocks-cuddly-tribble wrote:
thunderchero wrote:just a question on editing values for hull loss. since a lot of UDM game are in MP and on impossible how would I edit it to just a percent of old hull value. I was thinking 60% so a 40% loss.
It's in the replacement code at asm-44A40B & 44A40D (9 bytes for division). A percentage would be too complicated but you could use e.g. /2 + 1/8 (rounded down each) = ~62%

Enter in OllyDbg at 0044A40B:

shr eax
mov ebx, eax
shr ebx, 2
add eax, ebx
I think I got it but had to do a little different than you posted. But in tests it gave 62% of old hull. So I will ask is this correct?

Code: Select all

0044A40B     D1E8           SHR EAX,1
0044A40D     8BD8           MOV EBX,EAX
0044A40F     C1EB 02        SHR EBX,2
0044A412     03C3           ADD EAX,EBX
thunderchero
Spocks-cuddly-tribble wrote:That code is correct. I didn't memorize the precise syntax for the 'shr/shl,1' two byte variant.
User avatar
EnPhreg
Lieutenant-Commander
Lieutenant-Commander
Posts: 130
Joined: Thu Jul 10, 2008 2:00 am

Re: Auto-Upgrading Ships (options)

Post by EnPhreg »

SCT wrote:
2.3 For one turn, the displayed cost & total credits preview is wrong (old price) for auto-upgraded ships under construction. It's just cosmetics, but in the worst case this can lead to a "credit deficit".
Some clarification: you won't go to credit deficit if you buy the ship for a lower price and next turn the price updated to real value, cause if your credits are insufficient to pay the new price, the buy command is aborted and ship will be still under normal construction. but yes, if your credits are sufficient, it could be that you buy the ship and calculate with a much cheaper value than the new (but not already shown) price.


Additional info for SCT's option: 3.2 Auto-Upgrades for AI only
-> this option also provides upgrades for ships under construction by human players (but with one turn delay for actual turns and price like stated above).
a nice implementation.
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1884
Joined: Sun Apr 27, 2008 2:00 am

Auto-Upgrade Fix for AI Ships Under Construction

Post by Spocks-cuddly-tribble »

Here is a fix for the AI auto-upgrade bug # 2.2 our friend thundercheater recently complaint about: :wink: viewtopic.php?p=56119#p56119

Code: Select all

NAME: Auto-Upgrade Fix for AI Ships Under Construction
DESC: Default code checks only systems of player empires. 
AUTHOR: Spocks-cuddly-tribble
URL: https://www.armadafleetcommand.com/onscreen/botf/viewtopic.php?p=56841#p56841

>> 0x00049860 0f 84 bb 00 00 00
>> 0x0004c437 c0
>> 0x0004c43c 8b
>> 0x0004c442 8b bc 07 a8 00 00 00 89 f8 83 c7 60
>> 0x0004c477 00 00 00 00 00 00 00 00

<< 0x00049860 90 90 90 90 90 90
<< 0x0004c437 f8
<< 0x0004c43c 03
<< 0x0004c442 80 7f 04 02 75 2b 33 c0 b0 a8 eb 29
<< 0x0004c477 8b 04 38 8d 78 60 eb cf


#0044A460     909090909090      NOP  // remove old AI switch

#0044D036     69F8 28030000     IMUL EDI,EAX,328
#0044D03C     033D C8365A00     ADD EDI,[5A36C8]
#0044D042     807F 04 02        CMP BYTE[EDI+4],2 // check player systems....
#0044D046     75 2B             JNZ SHORT 44D073 // exit if AI
#0044D048     33C0              XOR EAX,EAX
#0044D04A     B0 A8             MOV AL,0A8 // ....for player production queue slots
#0044D04C     EB 29             JMP SHORT 44D077

#0044D077     8B0438            MOV EAX,[EAX+EDI]
#0044D07A     8D78 60           LEA EDI,[EAX+60]
#0044D07D    ^EB CF             JMP 44D04E
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: 7851
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Auto-Upgrade Fix for AI Ships Under Construction

Post by thunderchero »

Spocks-cuddly-tribble wrote: Fri Jun 17, 2022 3:57 pm Here is a fix for the AI auto-upgrade bug # 2.2 our friend thundercheater recently complaint about: :wink: viewtopic.php?p=56119#p56119

Code: Select all

NAME: Auto-Upgrade Fix for AI Ships Under Construction
DESC: Default code checks only systems of player empires. 
AUTHOR: Spocks-cuddly-tribble
URL: https://www.armadafleetcommand.com/onscreen/botf/viewtopic.php?p=56841#p56841

>> 0x00049860 0f 84 bb 00 00 00
>> 0x0004c437 c0
>> 0x0004c43c 8b
>> 0x0004c442 8b bc 07 a8 00 00 00 89 f8 83 c7 60
>> 0x0004c477 00 00 00 00 00 00 00 00

<< 0x00049860 90 90 90 90 90 90
<< 0x0004c437 f8
<< 0x0004c43c 03
<< 0x0004c442 80 7f 04 02 75 2b 33 c0 b0 a8 eb 29
<< 0x0004c477 8b 04 38 8d 78 60 eb cf


#0044A460     909090909090      NOP  // remove old AI switch

#0044D036     69F8 28030000     IMUL EDI,EAX,328
#0044D03C     033D C8365A00     ADD EDI,[5A36C8]
#0044D042     807F 04 02        CMP BYTE[EDI+4],2 // check player systems....
#0044D046     75 2B             JNZ SHORT 44D073 // exit if AI
#0044D048     33C0              XOR EAX,EAX
#0044D04A     B0 A8             MOV AL,0A8 // ....for player production queue slots
#0044D04C     EB 29             JMP SHORT 44D077

#0044D077     8B0438            MOV EAX,[EAX+EDI]
#0044D07A     8D78 60           LEA EDI,[EAX+60]
#0044D07D    ^EB CF             JMP 44D04E
Note: this patch conflicts with Build queue patch.

Edit;
I think I found fix for conflict of build queue patch

Code: Select all

0044D036     69F8 28030000     IMUL EDI,EAX,328
0044D03C     033D C8365A00     ADD EDI,[5A36C8]
0044D042     80 7F 04 02       CMP BYTE[EDI+4],2 // check player systems....
0044D046     75 2B             JNZ SHORT 44D073 // exit if AI
0044D048     90                no op
0044D049     E8 B4 E1 23 00    call    sub_68B202

sub_68B202
33C0              XOR EAX,EAX
B0 A8             MOV AL,0A8 // ....for player production queue slots
8B0438            MOV EAX,[EAX+EDI]
8DB8 C0000000     LEA EDI,DWORD PTR DS:[EAX+0C0h]
C3                return (0044D04E)
Post Reply

Return to “Auto-Upgrading Ships (options)”