Flagship/heroship code changes

Flagship Mod; showcase and support/discussion/questions/suggestions/reviews

Moderator: thunderchero

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

Flagship/heroship code changes

Post by thunderchero »

Hi Everyone,

Studmaster is looking to use code changes used in flagship mod to add Hero ships to his mod.

here is what I have found/remember so far

hero/flag ships need to be available at tech 1

any command cruiser types need to be changed to cruiser type? (might have other options at tech starts/upgrades)

here is patch to edit when 3rd starting ship is available (t5 - t1) and changing 3rd ship from destroyer type to command cruiser type

Code: Select all

NAME: hero
DESC: 3rd ship available all levels, 3rd ship changed to "command Cruiser type (04)"
AUTHOR: 
URL: 

>> 0x000500b3 c0 31 d2
>> 0x0005012a 02
>> 0x0005015a 03
>> 0x000503ae 04
>> 0x000503b0 85
>> 0x000503b6 01

<< 0x000500b3 d2 b2 04
<< 0x0005012a ff
<< 0x0005015a ff
<< 0x000503ae 00
<< 0x000503b0 8c
<< 0x000503b6 00
here is patch To prevent AI from building command cruiser editing the "AI ship building sets 04 -> 02
changes all instances of command cruiser to Cruiser

Code: Select all

NAME: hero prevent AI from building hero ship
DESC: AI build set all values of 04 (new hero ship) -> 02 cruiser
AUTHOR: 
URL: 

>> 0x0018a100 04
>> 0x0018a130 04
>> 0x0018a158 04
>> 0x0018a250 04
>> 0x0018a268 04
>> 0x0018a280 04
>> 0x0018a2a0 04
>> 0x0018a340 04
>> 0x0018a368 04
>> 0x0018a388 04
>> 0x0018a3b8 04
>> 0x0018a3d0 04
>> 0x0018a450 04
>> 0x0018a468 04
>> 0x0018a488 04
>> 0x0018a4a0 04
>> 0x0018a588 04
>> 0x0018a5a8 04
>> 0x0018a5f0 04
>> 0x0018a6a0 04
>> 0x0018a7b0 04
>> 0x0018a7d0 04
>> 0x0018a7f0 04
>> 0x0018a828 04
>> 0x0018a8e8 04
>> 0x0018a908 04
>> 0x0018a938 04
>> 0x0018a9e8 04
>> 0x0018aa30 04
>> 0x0018ab20 04
>> 0x0018ab48 04
>> 0x0018ab60 04
>> 0x0018ac58 04
>> 0x0018ac80 04
>> 0x0018aca8 04
>> 0x0018ad58 04
>> 0x0018ad80 04
>> 0x0018ada0 04
>> 0x0018add0 04
>> 0x0018ae78 04
>> 0x0018ae90 04
>> 0x0018aeb8 04
>> 0x0018aed8 04
>> 0x0018afa8 04
>> 0x0018afc0 04
>> 0x0018b010 04
>> 0x0018b0c0 04
>> 0x0018b108 04
>> 0x0018b1b8 04
>> 0x0018b1f0 04
>> 0x0018b210 04
>> 0x0018b248 04
>> 0x0018b308 04
>> 0x0018b340 04
>> 0x0018b408 04
>> 0x0018b458 04
>> 0x0018b590 04
>> 0x0018b6f0 04
>> 0x0018b7c0 04
>> 0x0018b7f0 04
>> 0x0018b8c8 04
>> 0x0018b8f8 04
>> 0x0018b920 04
>> 0x0018ba10 04
>> 0x0018bb08 04
>> 0x0018bc10 04
>> 0x0018bc58 04
>> 0x0018bd20 04
>> 0x0018be68 04
>> 0x0018bf80 04
>> 0x0018bfd8 04
>> 0x0018c0c8 04
>> 0x0018c1c0 04
>> 0x0018c1f0 04
>> 0x0018c220 04
>> 0x0018c2c8 04
>> 0x0018c300 04
>> 0x0018c338 04
>> 0x0018c438 04
>> 0x0018c530 04
>> 0x0018c628 04
>> 0x0018c668 04
>> 0x0018c748 04
>> 0x0018c888 04
>> 0x0018c9b0 04
>> 0x0018c9e8 04
>> 0x0018cae8 04
>> 0x0018cbd0 04
>> 0x0018cbf8 04
>> 0x0018cc28 04
>> 0x0018cce8 04
>> 0x0018cd08 04
>> 0x0018cd38 04
>> 0x0018cd58 04
>> 0x0018cd68 04
>> 0x0018ce38 04
>> 0x0018cea0 04
>> 0x0018cf40 04
>> 0x0018d038 04
>> 0x0018d060 04
>> 0x0018d190 04
>> 0x0018d298 04
>> 0x0018d2e8 04
>> 0x0018d398 04
>> 0x0018d3c0 04

<< 0x0018a100 02
<< 0x0018a130 02
<< 0x0018a158 02
<< 0x0018a250 02
<< 0x0018a268 02
<< 0x0018a280 02
<< 0x0018a2a0 02
<< 0x0018a340 02
<< 0x0018a368 02
<< 0x0018a388 02
<< 0x0018a3b8 02
<< 0x0018a3d0 02
<< 0x0018a450 02
<< 0x0018a468 02
<< 0x0018a488 02
<< 0x0018a4a0 02
<< 0x0018a588 02
<< 0x0018a5a8 02
<< 0x0018a5f0 02
<< 0x0018a6a0 02
<< 0x0018a7b0 02
<< 0x0018a7d0 02
<< 0x0018a7f0 02
<< 0x0018a828 02
<< 0x0018a8e8 02
<< 0x0018a908 02
<< 0x0018a938 02
<< 0x0018a9e8 02
<< 0x0018aa30 02
<< 0x0018ab20 02
<< 0x0018ab48 02
<< 0x0018ab60 02
<< 0x0018ac58 02
<< 0x0018ac80 02
<< 0x0018aca8 02
<< 0x0018ad58 02
<< 0x0018ad80 02
<< 0x0018ada0 02
<< 0x0018add0 02
<< 0x0018ae78 02
<< 0x0018ae90 02
<< 0x0018aeb8 02
<< 0x0018aed8 02
<< 0x0018afa8 02
<< 0x0018afc0 02
<< 0x0018b010 02
<< 0x0018b0c0 02
<< 0x0018b108 02
<< 0x0018b1b8 02
<< 0x0018b1f0 02
<< 0x0018b210 02
<< 0x0018b248 02
<< 0x0018b308 02
<< 0x0018b340 02
<< 0x0018b408 02
<< 0x0018b458 02
<< 0x0018b590 02
<< 0x0018b6f0 02
<< 0x0018b7c0 02
<< 0x0018b7f0 02
<< 0x0018b8c8 02
<< 0x0018b8f8 02
<< 0x0018b920 02
<< 0x0018ba10 02
<< 0x0018bb08 02
<< 0x0018bc10 02
<< 0x0018bc58 02
<< 0x0018bd20 02
<< 0x0018be68 02
<< 0x0018bf80 02
<< 0x0018bfd8 02
<< 0x0018c0c8 02
<< 0x0018c1c0 02
<< 0x0018c1f0 02
<< 0x0018c220 02
<< 0x0018c2c8 02
<< 0x0018c300 02
<< 0x0018c338 02
<< 0x0018c438 02
<< 0x0018c530 02
<< 0x0018c628 02
<< 0x0018c668 02
<< 0x0018c748 02
<< 0x0018c888 02
<< 0x0018c9b0 02
<< 0x0018c9e8 02
<< 0x0018cae8 02
<< 0x0018cbd0 02
<< 0x0018cbf8 02
<< 0x0018cc28 02
<< 0x0018cce8 02
<< 0x0018cd08 02
<< 0x0018cd38 02
<< 0x0018cd58 02
<< 0x0018cd68 02
<< 0x0018ce38 02
<< 0x0018cea0 02
<< 0x0018cf40 02
<< 0x0018d038 02
<< 0x0018d060 02
<< 0x0018d190 02
<< 0x0018d298 02
<< 0x0018d2e8 02
<< 0x0018d398 02
<< 0x0018d3c0 02
Now what I can not remember is how I prevented human players from building flag/hero ships :shock:
I am sure it is something simple that I can't think of.

So how to remove/prevent ship from displaying on ship build list.

any thoughts?
thunderchero
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1950
Joined: Sun Apr 27, 2008 2:00 am

Re: Flagship/heroship code changes

Post by Spocks-cuddly-tribble »

I'd write an extra code for adding an extra starting ship to home system: viewtopic.php?p=10103#p10103

Sub_446240 add_ShipID_edx__systemID_eax -> write a table with the shiplist.sst ship IDs for each empire race ID AX ( & starting level ? ).
You can use unreachable tech requirements to prevent re-building, but you need VERY intricate special codes to enable auto-upgrades for your hero ships.

And there will be other issues (e.g. they can be stolen via intel). But you can still use all regular ship types for player and AI. :wink:


EDIT: This might work for upgrade, but I wouldn't do it...

Extra relocation code jump -> start or end of sub_452560.

Loop check all GShipList ships via empire for special IDs from special table.

Read average tech level of empire:

MOVZX XXX,WORD [raceID*2+5A3660] // get Tech Score
SHR XXX,3 // get average tech level = Tech Score / 8

Check special table: Empire/shipIDs/average tech level needed

If next tech upgrade in table use sub_44A360 AutoUpgradeShips
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: 7953
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Flagship/heroship code changes

Post by thunderchero »

I did find changes I made...

I edited the code changes made by UE for "buildable minor ships (major code modification)
at 0x00f31f3 change 07 -> 04 (starbase -> command cruiser) Note; vanilla code would change at 0xf31c9 07 -> 04
next make all starbase I an upgrade of outpost II
all starbase change ship type starbase -> outpost
after that some minor lexicon and tga replacement for base upgrades for text and gui
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7953
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Flagship/heroship code changes

Post by thunderchero »

Now that I know how I did changes...

with most "command" ships grouped in with cruisers would it be possible to give same combat commands and solo targeting as command cruisers type 04 to ship type 02 (cruiser) so both would have same abilities?
viewtopic.php?p=28508#p28508
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1950
Joined: Sun Apr 27, 2008 2:00 am

Re: Flagship/heroship code changes

Post by Spocks-cuddly-tribble »

thunderchero wrote: Sun Mar 31, 2024 8:35 pmwith most "command" ships grouped in with cruisers would it be possible to give same combat commands and solo targeting as command cruisers type 04 to ship type 02 (cruiser) so both would have same abilities?
They already have same combat orders, the broken command function is a fleet and player UI only feature (at least one command ship/station has to be still in the battle): viewtopic.php?p=28492#p28492

You need to optimize code for two checks (best cmp byte [ESP+68], 2 then 4)
495761   66:837C24 68 04  CMP WORD [ESP+68], 4  // command
In fact 04/command has some map features disabled (e.g. player intercept), but we have patches for that IIRC.


---

Vanilla trek.exe features a simple code example for easy Hero/Flag-Ships: variants of 'special ships': viewtopic.php?p=2614#p2614

But 'special ships' is a player UI only restriction and ignored by AI (otherwise it would be very easy).

To fix this for AI we need a similar exclusion table in sub_455340 get_ship_ID_for_type (not good for AI turn lag).

---

Best approach (still needs more research):

In sub_4553B0 update_techInfo_ships read new Hero Ship marker (from unused entry in shiplist.sst) and skip for 5B4864 list_buildable_ship_IDs.

E.g. byte [shiplist.sst+64h] = FF for Hero ships: viewtopic.php?p=38186#p38186

So we don't need messy exclusion tables, have not extra turn lag and the auto upgrades still work.

Only starting ships need new special code with ID table per empire/tech (not too hard).


Problem is the race start position in list_buildable_ship_IDs is calculated via ship_techInfo__2byte_race pointer (from techInfo? still needed for auto upgrades), so the deviation of a shorter list_buildable_ship_IDs wouldn't work?

Code: Select all

4554B0 shipTypeEdx_axRace_IDtoEax

004554B0         push    ebx
004554B1         sub     esp, 4
004554B4         mov     [esp], edx                        ; type
004554B7         mov     edx, ds:ship_techInfo__2byte_race ; 58FFFE list_of_tech_entry_indexes / race research index
004554BD         and     eax, 0FFFFh                       ; race
004554C2         mov     ax, [edx+eax*2]                   ; race index
004554C6         mov     edx, ds:list_buildable_ship_IDs
004554CC         and     eax, 0FFFFh
004554D1         mov     ebx, offset check_ship_ID_for_type
004554D6         mov     eax, [edx+eax*4]                  ; list1 IDs?
004554D9         mov     edx, esp                          ; list2 adr ship type
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: 7953
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Flagship/heroship code changes

Post by thunderchero »

Spocks-cuddly-tribble wrote: Mon Apr 01, 2024 1:58 pm Best approach (still needs more research):
Ok Flagship mod is a dinosaur... might not even be deserving of being in all in one installer :sad:
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1950
Joined: Sun Apr 27, 2008 2:00 am

Re: Flagship/heroship code changes

Post by Spocks-cuddly-tribble »

thunderchero wrote: Mon Apr 01, 2024 2:40 pmFlagship mod is a dinosaur... might not even be deserving of being in all in one installer :sad:
I wouldn't say that. As you say guys like Studmaster are still interested in this special function. And to this day it's the only available workaround. :up:

How many upgrades i.e. shiplist.sst slots use you Hero ships?

I'd use five slots per empire (tech 1/3/5/7/9), so 25 shiplist IDs. Another reason to avoid exclusion tables for all those IDs.


EDIT:

Anyway, I think I see a sneaky way to solve my above techInfo issue: :wink:
sub_455340 get_ship_ID_for_type

00455359     807C24 64 FF   CMP BYTE PTR SS:[ESP+64],0FF  // Hero ship ?
0045535E     74 1A          JE SHORT trek.0045537A
00455360     8A4424 68      MOV AL,BYTE PTR SS:[ESP+68]
00455364     3A01           CMP AL,BYTE PTR DS:[ECX]
00455366     74 0E          JE SHORT trek.00455376
00455368     90             NOP

00455376     33C0           XOR EAX,EAX
And here is code for vanilla player build ship UI (I need to see 'build minor ships' patch code for a similar update):
004F3DAD     8B59 04        MOV EBX,DWORD PTR DS:[ECX+4]
004F3DB0     8BD4           MOV EDX,ESP
004F3DB2     8AC3           MOV AL,BL
004F3DB4     E8 07BCF7FF    CALL trek.0046F9C0
004F3DB9     8A4424 68      MOV AL,BYTE PTR SS:[ESP+68]
004F3DBD     3C 06          CMP AL,6
004F3DBF     74 5E          JE SHORT trek.004F3E1F
004F3DC1     3C 07          CMP AL,7
004F3DC3     74 5A          JE SHORT trek.004F3E1F
004F3DC5     807C24 64 FF   CMP BYTE PTR SS:[ESP+64],0FF  // Hero ship ?
Starting ships:

Hero ship IDs in trek.exe at 0x50390 asm-450F90 (25 single byte values, sorted by empire 0-4 each for starting level 0-4)
I.e. cardassian 1-5, federation 1-5,.. You can use same IDs for different levels if you want.
00450D2B     90                NOP
00450D2C     90                NOP
00450D2D     90                NOP
00450D2E     90                NOP
00450D2F     90                NOP
00450D30     90                NOP

00450D5B     75 18             JNZ SHORT trek.00450D75
00450D5D     90                NOP
00450D5E     90                NOP
00450D5F     90                NOP
00450D60     90                NOP

00450F90     90                   NOP
00450F91     90                   NOP
00450F92     90                   NOP
00450F93     90                   NOP
00450F94     90                   NOP
00450F95     90                   NOP
00450F96     90                   NOP
00450F97     90                   NOP
00450F98     90                   NOP
00450F99     90                   NOP
00450F9A     90                   NOP
00450F9B     90                   NOP
00450F9C     90                   NOP
00450F9D     90                   NOP
00450F9E     90                   NOP
00450F9F     90                   NOP
00450FA0     90                   NOP
00450FA1     90                   NOP
00450FA2     90                   NOP
00450FA3     90                   NOP
00450FA4     90                   NOP
00450FA5     90                   NOP
00450FA6     90                   NOP
00450FA7     90                   NOP
00450FA8     90                   NOP
00450FA9     90                   NOP
00450FAA     90                   NOP
00450FAB     90                   NOP
00450FAC     6BC0 05              IMUL EAX,EAX,5
00450FAF     0FB69410 900F4500    MOVZX EDX,BYTE PTR DS:[EAX+EDX+450F90]
00450FB7     90                   NOP
00450FB8     90                   NOP
00450FB9     90                   NOP
00450FBA     90                   NOP
00450FBB     90                   NOP
00450FBC     90                   NOP
00450FBD     90                   NOP
00450FBE     90                   NOP
00450FBF     90                   NOP
00450FC0     90                   NOP
00450FC1     90                   NOP
00450FC2     90                   NOP
00450FC3     90                   NOP
00450FC4     90                   NOP
00450FC5     90                   NOP
00450FC6     90                   NOP
00450FC7     90                   NOP
00450FC8     90                   NOP
00450FC9     90                   NOP
00450FCA     90                   NOP
Then just edit shiplist.sst @+64h = FF for all Hero ships and we're in business. :wink:
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: 7953
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Flagship/heroship code changes

Post by thunderchero »

Too late tonight, one question. does code above in any way prevent AI from building hero ships?

if it does I am not seeing it

starting to wonder how hard would it be to add a new ship "type" 0A = hero ship?
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1950
Joined: Sun Apr 27, 2008 2:00 am

Re: Flagship/heroship code changes

Post by Spocks-cuddly-tribble »

thunderchero wrote: Mon Apr 01, 2024 10:48 pmdoes code above in any way prevent AI from building hero ships?
Of course, AI and starting ships use the same code (sub_455340 get_ship_ID_for_type) to determine ship ID to build via function (that's why we need the extra code with ID table - they are now blocked in the shared code). :wink:

Research based on 'AI Fleet Buildup Fix': viewtopic.php?p=57382#p57382

thunderchero wrote: Mon Apr 01, 2024 10:48 pmhow hard would it be to add a new ship "type"
Way harder than expected and much more work than above patches....
Tethys wanted to add another ship type, but understood the obstacles require weeks/months of work.
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: 7953
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Flagship/heroship code changes

Post by thunderchero »

I did get code added and tested, first game test went very well.
vanilla t1 start as feds and hid on edge from AI for 215 turns
federation, Ferengi, klingons, romulans still had hero ship. cardassians hero ship was stolen by ferengi
and no other hero ships were built by AI and not on human build list.

here is patch I made

Code: Select all

NAME: Hero ships with "buildable minor ships (major code modification)" already applied 
AUTHOR: Spocks-cuddly-tribble  
DESC: OPTION; buildable minor ships option just switch lines with and without # 
DESC: OPTION; Hero ships Intel protection remove # to add 
DESC: this patch will give a Hero ship as starting ships. the hero ship is not buildable by human or AI 
DESC: hero ships must be added to shiplist with UE and given special marker at +64h 00 -> FF
DESC: WARNING!!!! this patch must be edited to match the shiplist id's of hero ships
DESC: patch file name: hero_ship_build.patch
URL: https://www.armadafleetcommand.com/onscreen/botf/viewtopic.php?p=61800#p61800
TAG: enhancement
 
# >>  = vanilla/original value

# <<  = new value

#Hero ships Intel protection remove # to add
#protect Hero ships from destruction and theft via intel attacks: option
#>> 0x00049127 31 c0 89 e2 8a 43 52 e8 8d 5c 02 00 8b 44 24 66 8b 94 24 98 01 00 00 c1 f8 10 39 d0 75
#<< 0x00049127 8b d4 8a 43 52 e8 8f 5c 02 00 8a 44 24 68 3a 84 24 98 01 00 00 75 25 80 7c 24 64 ff 74

#protect Hero ships from destruction and theft via intel attacks:
#00449D27     8BD4              MOV EDX,ESP
#00449D29     8A43 52           MOV AL,BYTE PTR DS:[EBX+52]
#00449D2C     E8 8F5C0200       CALL trek.0046F9C0
#00449D31     8A4424 68         MOV AL,BYTE PTR SS:[ESP+68]
#00449D35     3A8424 98010000   CMP AL,BYTE PTR SS:[ESP+198]
#00449D3C     75 25             JNZ SHORT trek.00449D63
#00449D3E     807C24 64 FF      CMP BYTE PTR SS:[ESP+64],0FF  // Hero ship ?
#00449D43     74 1E             JE SHORT trek.00449D63

#buildable minor ships option just switch lines with and without #
#vanilla player build ship UI 
#"buildable minor ships (major code modification)" already applied
>> 0x000f31d7 66 8b 59 04 31 c0 89 e2 88 d8 e8 da bb f7 ff 8b 54 24 68 66 83 fa 06 74 3a 66 83 fa 07
<< 0x000f31d7 8b 59 04 8b d4 8a c3 e8 dd bb f7 ff 8a 44 24 68 3c 06 74 3f 3c 07 74 3b 80 7c 24 64 ff

#vanilla player build ship UI 
#"buildable minor ships (major code modification)" not applied
#>> 0x000f31ad 66 8b 59 04 31 c0 89 e2 88 d8 e8 04 bc f7 ff 8b 54 24 68 66 83 fa 06 74 59 66 83 fa 07
#<< 0x000f31ad 8b 59 04 8b d4 8a c3 e8 07 bc f7 ff 8a 44 24 68 3c 06 74 5e 3c 07 74 5a 80 7c 24 64 ff

>> 0x00054759 8b 44
>> 0x0005475c 66 0f bf 11 c1 f8 10 39 d0 74 0f 7d 11
>> 0x00054776 31 d0

<< 0x00054759 80 7c
<< 0x0005475c 64 ff 74 1a 8a 44 24 68 3a 01 74 0e 90
<< 0x00054776 33 c0

>> 0x0005012b 0f 8e ae 02 00 00
>> 0x0005015b 0f 85 2f 02 00 00
>> 0x00050390 83 fa 04 0f 85 
>> 0x00050395 dc fd ff ff 8b 
>> 0x0005039a 80 e8 1a 5b 00 
>> 0x0005039f e8 7c a3 0c 00 
>> 0x000503a4 83 f8 01 e9 c9 
>> 0x000503a9 fd ff ff 83 fa 04
>> 0x000503b0 85 24 fe ff ff ba 01 00 00 00 e8 f1 44 00 00 0f bf d0 83 fa ff 0f 84 0e fe ff ff

<< 0x0005012b 90 90 90 90 90 90
<< 0x0005015b 75 18 90 90 90 90

#sorted by empire 0-4 each for starting level 0-4)I.e. cardassian 1-5, federation 1-5,.. 
#You can use same IDs for different levels if you want.
#cardassian 1-5
<< 0x00050390 00 00 00 00 00 
#federation 1-5
<< 0x00050395 15 15 15 15 15 
#ferengi 1-5
<< 0x0005039a 2f 2f 2f 2f 2f 
#klingon 1-5
<< 0x0005039f 44 44 44 44 44 
#romulan 1-5
<< 0x000503a4 59 59 59 59 59 

<< 0x000503a9 90 90 90 6b c0 05
<< 0x000503b0 b6 94 10 90 0f 45 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90

#sneaky way to solve my above techInfo issue
#sub_455340 get_ship_ID_for_type

#00455359     807C24 64 FF   CMP BYTE PTR SS:[ESP+64],0FF  // Hero ship ?
#0045535E     74 1A          JE SHORT trek.0045537A
#00455360     8A4424 68      MOV AL,BYTE PTR SS:[ESP+68]
#00455364     3A01           CMP AL,BYTE PTR DS:[ECX]
#00455366     74 0E          JE SHORT trek.00455376
#00455368     90             NOP

#00455376     33C0           XOR EAX,EAX

#vanilla player build ship UI 
#with "buildable minor ships (major code modification)" already applied
#004F3DD7     8B59 04        MOV EBX,DWORD PTR DS:[ECX+4]
#004F3DDA     8BD4           MOV EDX,ESP
#004F3DDC     8AC3           MOV AL,BL
#004F3DDE     E8 DDBBF7FF    CALL trek.0046F9C0
#004F3DE3     8A4424 68      MOV AL,BYTE PTR SS:[ESP+68]
#004F3DE7     3C 06          CMP AL,6
#004F3DE9     74 3F          JE SHORT trek.004F3E2A
#004F3DEB     3C 07          CMP AL,7
#004F3DED     74 3B          JE SHORT trek.004F3E2A
#004F3DEF     807C24 64 FF   CMP BYTE PTR SS:[ESP+64],0FF

#vanilla player build ship UI 
#without "buildable minor ships (major code modification)" not applied
#004F3DAD     8B59 04        MOV EBX,DWORD PTR DS:[ECX+4]
#004F3DB0     8BD4           MOV EDX,ESP
#004F3DB2     8AC3           MOV AL,BL
#004F3DB4     E8 07BCF7FF    CALL trek.0046F9C0
#004F3DB9     8A4424 68      MOV AL,BYTE PTR SS:[ESP+68]
#004F3DBD     3C 06          CMP AL,6
#004F3DBF     74 5E          JE SHORT trek.004F3E1F
#004F3DC1     3C 07          CMP AL,7
#004F3DC3     74 5A          JE SHORT trek.004F3E1F
#004F3DC5     807C24 64 FF   CMP BYTE PTR SS:[ESP+64],0FF  // Hero ship ?

#Hero ship IDs in trek.exe at 0x50390 asm-450F90 (25 single byte values, sorted by empire 0-4 each for starting level 0-4)
#I.e. cardassian 1-5, federation 1-5,.. You can use same IDs for different levels if you want.

#00450D2B     90                NOP
#00450D2C     90                NOP
#00450D2D     90                NOP
#00450D2E     90                NOP
#00450D2F     90                NOP
#00450D30     90                NOP

#00450D5B     75 18             JNZ SHORT trek.00450D75
#00450D5D     90                NOP
#00450D5E     90                NOP
#00450D5F     90                NOP
#00450D60     90                NOP

#00450F90     90                   NOP
#00450F91     90                   NOP
#00450F92     90                   NOP
#00450F93     90                   NOP
#00450F94     90                   NOP
#00450F95     90                   NOP
#00450F96     90                   NOP
#00450F97     90                   NOP
#00450F98     90                   NOP
#00450F99     90                   NOP
#00450F9A     90                   NOP
#00450F9B     90                   NOP
#00450F9C     90                   NOP
#00450F9D     90                   NOP
#00450F9E     90                   NOP
#00450F9F     90                   NOP
#00450FA0     90                   NOP
#00450FA1     90                   NOP
#00450FA2     90                   NOP
#00450FA3     90                   NOP
#00450FA4     90                   NOP
#00450FA5     90                   NOP
#00450FA6     90                   NOP
#00450FA7     90                   NOP
#00450FA8     90                   NOP
#00450FA9     90                   NOP
#00450FAA     90                   NOP
#00450FAB     90                   NOP
#00450FAC     6BC0 05              IMUL EAX,EAX,5
#00450FAF     0FB69410 900F4500    MOVZX EDX,BYTE PTR DS:[EAX+EDX+450F90]
#00450FB7     90                   NOP
#00450FB8     90                   NOP
#00450FB9     90                   NOP
#00450FBA     90                   NOP
#00450FBB     90                   NOP
#00450FBC     90                   NOP
#00450FBD     90                   NOP
#00450FBE     90                   NOP
#00450FBF     90                   NOP
#00450FC0     90                   NOP
#00450FC1     90                   NOP
#00450FC2     90                   NOP
#00450FC3     90                   NOP
#00450FC4     90                   NOP
#00450FC5     90                   NOP
#00450FC6     90                   NOP
#00450FC7     90                   NOP
#00450FC8     90                   NOP
#00450FC9     90                   NOP
#00450FCA     90                   NOP

Spocks-cuddly-tribble wrote: Mon Apr 01, 2024 11:44 pm Way harder than expected and much more work than above patches....
expected...
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1950
Joined: Sun Apr 27, 2008 2:00 am

Re: Flagship/heroship code changes

Post by Spocks-cuddly-tribble »

Glad to hear it works without issues. Sadly I can't say the same for my new building bonuses multi-patch, have to re-start from scratch. :mad:

Code might show conflicts with patches for starting-ships/systems/structures + 'build minor ships' needs an extra variant, but all should be quite easy. :wink:

thunderchero wrote: Tue Apr 02, 2024 11:59 amcardassians hero ship was stolen by ferengi
One might expect the other way round... This should protect Hero ships from destruction and theft via intel attacks:
00449D27     8BD4              MOV EDX,ESP
00449D29     8A43 52           MOV AL,BYTE PTR DS:[EBX+52]
00449D2C     E8 8F5C0200       CALL trek.0046F9C0
00449D31     8A4424 68         MOV AL,BYTE PTR SS:[ESP+68]
00449D35     3A8424 98010000   CMP AL,BYTE PTR SS:[ESP+198]
00449D3C     75 25             JNZ SHORT trek.00449D63
00449D3E     807C24 64 FF      CMP BYTE PTR SS:[ESP+64],0FF  // Hero ship ?
00449D43     74 1E             JE SHORT trek.00449D63
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: 7953
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Flagship/heroship code changes

Post by thunderchero »

Spocks-cuddly-tribble wrote: Tue Apr 02, 2024 12:44 pm Glad to hear it works without issues.
Flocke will not be, it throws exception
special.jpg
special.jpg (46.14 KiB) Viewed 128 times
at least there is no exception throw for new hero marker at 64h of shiplist
Spocks-cuddly-tribble wrote: Tue Apr 02, 2024 12:44 pm One might expect the other way round... This should protect Hero ships from destruction and theft via intel attacks:
I had the same thought, but Cardassian were pinned between romulans and Ferengi, Cardassains were down to 1 system at turn 217
But, will try to do some testing on patch asap

note; patch above was missing a line and was updated
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1950
Joined: Sun Apr 27, 2008 2:00 am

Re: Flagship/heroship code changes

Post by Spocks-cuddly-tribble »

thunderchero wrote: Tue Apr 02, 2024 1:39 pmFlocke will not be, it throws exception
Then he can advice where to free up 7 bytes for the new Hero ship switch (near the outpost/starbase checks) to avoid UE conflicts.
I optimized loading shiplist.sst entry and cmp switches for this.
thunderchero wrote: Tue Apr 02, 2024 1:39 pm I had the same thought, but Cardassian were pinned between romulans and Ferengi
Actually it's impressive for the vanilla T1 cardassians to survive 200+ turns vs the OP vanilla Ferengi, given this map possition.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
Flocke
BORG Trouble Maker
BORG Trouble Maker
Posts: 3257
Joined: Sun Apr 27, 2008 2:00 am
Location: Hamburg, Germany
Contact:

Re: Flagship/heroship code changes

Post by Flocke »

Spocks-cuddly-tribble wrote: Tue Apr 02, 2024 2:11 pm
thunderchero wrote: Tue Apr 02, 2024 1:39 pmFlocke will not be, it throws exception
Then he can advice where to free up 7 bytes for the new Hero ship switch (near the outpost/starbase checks) to avoid UE conflicts.
I optimized loading shiplist.sst entry and cmp switches for this.
I had a look and I'm not excited. Already now this patch is a mess! :lol:

UE validates the whole subroutine so it conflicts on every single code change.
You are however lucky in that this passage is shared code for all patch modes and not modified.
Therefore it can be handled independent from other changes and the patch can even be split or leave out that passage from validation.

For now however I don't see reason to implement support for this. It is not even yet clear whether the change is a good gameplay addition or will be dropped again. Furthermore, to allow additional mod options, type checks and to get rid of the messy code patch, that subroutine also is a good target to be hooked for code extension.

So just keep above code change and if it proofs to be a great change, at some later time we will see how to deal with it. :wink:
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1950
Joined: Sun Apr 27, 2008 2:00 am

Re: Flagship/heroship code changes

Post by Spocks-cuddly-tribble »

Flocke wrote: Tue Apr 02, 2024 5:52 pmthis passage is shared code for all patch modes and not modified.
That's good news, the patch was designed to work with all other given modifications (e.g. 'build minor ships'). :wink:
Flocke wrote: Tue Apr 02, 2024 5:52 pmleave out that passage from validation.
If it's easy enough, just do it to avoid UE user confusion. :up:

And yes, this is a messy code for pet-universe players' customer's order, so no need for any further UE support. But some guys like features like this and I made sure the code doesn't affect stability or performance. Any combination with custom starting ship/fleet patches reqiures more elegant re-coding.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
Post Reply

Return to “Flagship Mod”