Commands in Tactical Combat

Commands in tactical combat; support/discussion/questions

Moderator: thunderchero

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

Commands in Tactical Combat

Post by Spocks-cuddly-tribble »

It's possible to add/remove commands like cloak, hold & ram for tactical combat. But unfortunately I can't find any technical info on the subject.

It would save me time to find a fix for the broken command ship feature:

-> the command ship ability (see note by Callahan)
Last edited by Spocks-cuddly-tribble on Fri Jun 17, 2011 9:33 am, edited 3 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
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7849
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Post by thunderchero »

I know very little on how it works. I only have an edited "combat.mnu" that uses cloak during combat.

I have slightly edited text but nothing else.

combat.mnu


I also did a search for a different combat.mnu I had with ram removed.

here it is

combat.mnu

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

Post by Spocks-cuddly-tribble »

Thanks thunderchero, this is most useful. :wink:

I didn't expect that the changed combat.mnu works without any trek.exe or *.dll adjustments.

After some tests, Cloak & Hold seem to be very interesting tactical options.

Minor issues:

- Just when "select ship" was used, "hold" command disappears for all ships/groups.
- The "cloak" command doesn't check for cloak ability of ships/groups.
- No tactic descriptions for hold & cloak command.

I'd say project looks good so far :wink: (but I still can't see where combat.mnu gets loaded).
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: 7849
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Post by thunderchero »

I had an idea and I might have found some info for you.

fleet.mnu and combat.mnu might get loaded when *tactscn.wdf gets loaded They are both referenced in this file for each race.

I hope this helps you a little.

other issues:

- if all ships select cloak (5 or more ships) and starbase is present game will go non responsive. (no crash log)
- using cloak command on starbase will cause CTD
File: ..\..\source\sound\sndvoice.c, Line: 403, Ship group for combat talk function is invalid
thunderchero
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1884
Joined: Sun Apr 27, 2008 2:00 am

Post by Spocks-cuddly-tribble »

thunderchero wrote:fleet.mnu and combat.mnu might get loaded when *tactscn.wdf gets loaded They are both referenced in this file for each race.

I hope this helps you a little.
Regrettably, not much, since trek.exe handling of wdf-files is implemented in a very intricate way in BotF :?

But you already provided the necessary information for an easier approach. :wink:

-> Adding assault command to colony and troop transport

Using this information, I found the needed code location(s) and even better an example how to do it.

Figuring code keys for combat groups, group/single mode and commands should be quite easy (albeit still a bit time consuming due to need of testing & fixing of minor issues).

thunderchero wrote:- using cloak command on starbase will cause CTD
Yes, I noticed. This causes even two types of crashes:

File: ..\..\source\sound\converse\rdconv.c, Line: 705, Ship group for combat talk function is invalid
File: ..\..\source\sound\sndvoice.c, Line: 403, Ship group for combat talk function is invalid
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: 7849
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Post by thunderchero »

Last weekend I did some testing of editing the combat.mnu and fleet.mnu.

fleet.mnu:

Did not seem to even get loaded, editing it adding and even removing types had no effect.

combat.mnu:

I found the file can be cleaned up (remove most of the code) the only thing I found was the "number" for each type and description was all that is used.

Note; description in combat.mnu only changes text in popup command window not tactical display on left.

code type

solo commands
01 Solo Charge
02 Solo Assault
03 Solo Harry
04 Solo Circle
05 Solo Strafe
06 Solo Flyby
07 Solo Evade
08 Solo Cloak (both cloak options always listed on solo and group) (also shown on starbase)
09 Solo Ram
0A Solo Retreat
0B Solo Retreat (uses single ship retreat image) (also shown on starbase) (this shows on group and solo lists)
0C Solo Open hailing frequencies
0D Ignored

group ship commands
65 Group Charge
66 Group Assault
67 Group Harry
68 Group Circle
69 Group Strafe
6A Group Flyby
6B Group Evade
6C Group Cloak (both cloak options always listed on solo and group) (also shown on starbase)
6D Group Ram
6E Group Retreat
70 Group Open hailing frequencies
71 Group Hold
72 not tried

starbase/outpost commands
C8 Attack
C9 Open hailing frequencies

group/solo switches
84 Select Ship
85 Select Group
86 ignored

I did not try to add any starbase/outpost or more group commands, but did try to add new switch for command and solo(they were ignored).

01 00 00 00 1B 00 00 00 at first of file the "1B" control how many total sets of commands/switches. Each command is 88 bytes.

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

sub_4A6238

Post by Spocks-cuddly-tribble »

Due to this excellent support the analysis of sub_4A6238 is finished and we have now full control over the mechanics.

sub_53EF90 locks/unlocks tactical combat commands (ebx: 0=lock, 1=unlock / edx: command-ID)

Default for each valid command in combat.mnu is unlocked (for all groups! i.e. this happens if not referred in sub_4A6238 e.g. solo/group cloak 08/6C & withdraw 0B/6F)


First sub_4A623 locks commands depending on station/ship solo/group mode:

-lock for solo & group mode: C8 C9

-lock for solo mode:
1 2 3 4 5 6 & 65 66 67 68 69 6A + 6B / 6D 6E / 70 71 & 384

-lock for group mode:
1 2 3 4 5 6 & 65 66 67 68 69 6A + 7 / 9 A / C D & 385

-lock for stations:
1 2 3 4 5 6 & 65 66 67 68 69 6A + 7 / 9 A / C D + 6B / 6D 6E / 70 71 & 384 385

This is why "Group Hold"(71) disappears after solo or station mode.


After this, the available commands get unlocked for each combat group (see code below).


Relevant parts of sub_4A6238: (note changing combat group via ship function requires major code alterations at various locations)

edi (base for some command-IDs) is 0 in solo mode resp. 64h in group mode

Code: Select all

AUTO:004A6331                 lea     edx, [esp+8]
AUTO:004A6335                 mov     al, [esp+150h]
AUTO:004A633C                 call    read_shiplist_sst
AUTO:004A6341                 mov     edx, [esp+70h]
AUTO:004A6345                 cmp     dx, 7
AUTO:004A6349                 jnz     solo_mode__lock_station_commands
AUTO:004A634F
AUTO:004A634F station__lock_ship_commands:
AUTO:004A634F                 mov     edx, 1
AUTO:004A6354                 mov     eax, [ecx+38h]
AUTO:004A6357                 xor     ebx, ebx
AUTO:004A6359                 call    lock_unlock_TC_command
AUTO:004A635E                 mov     edx, 2
AUTO:004A6363                 mov     eax, [ecx+38h]
AUTO:004A6366                 xor     ebx, ebx
AUTO:004A6368                 call    lock_unlock_TC_command
AUTO:004A636D                 mov     edx, 3
AUTO:004A6372                 mov     eax, [ecx+38h]
AUTO:004A6375                 xor     ebx, ebx
AUTO:004A6377                 call    lock_unlock_TC_command
AUTO:004A637C                 mov     edx, 4
AUTO:004A6381                 mov     eax, [ecx+38h]
AUTO:004A6384                 xor     ebx, ebx
AUTO:004A6386                 call    lock_unlock_TC_command
AUTO:004A638B                 mov     edx, 7
AUTO:004A6390                 mov     eax, [ecx+38h]
AUTO:004A6393                 xor     ebx, ebx
AUTO:004A6395                 call    lock_unlock_TC_command
AUTO:004A639A                 mov     edx, 5
AUTO:004A639F                 mov     eax, [ecx+38h]
AUTO:004A63A2                 xor     ebx, ebx
AUTO:004A63A4                 call    lock_unlock_TC_command
AUTO:004A63A9                 mov     edx, 6
AUTO:004A63AE                 mov     eax, [ecx+38h]
AUTO:004A63B1                 xor     ebx, ebx
AUTO:004A63B3                 call    lock_unlock_TC_command
AUTO:004A63B8                 mov     edx, 0Ch
AUTO:004A63BD                 mov     eax, [ecx+38h]
AUTO:004A63C0                 xor     ebx, ebx
AUTO:004A63C2                 call    lock_unlock_TC_command
AUTO:004A63C7                 mov     edx, 0Dh
AUTO:004A63CC                 mov     eax, [ecx+38h]
AUTO:004A63CF                 xor     ebx, ebx
AUTO:004A63D1                 call    lock_unlock_TC_command
AUTO:004A63D6                 mov     edx, 9
AUTO:004A63DB                 mov     eax, [ecx+38h]
AUTO:004A63DE                 xor     ebx, ebx
AUTO:004A63E0                 call    lock_unlock_TC_command
AUTO:004A63E5                 mov     edx, 0Ah
AUTO:004A63EA                 mov     eax, [ecx+38h]
AUTO:004A63ED                 xor     ebx, ebx
AUTO:004A63EF                 call    lock_unlock_TC_command
AUTO:004A63F4                 mov     edx, 65h
AUTO:004A63F9                 mov     eax, [ecx+38h]
AUTO:004A63FC                 xor     ebx, ebx
AUTO:004A63FE                 call    lock_unlock_TC_command
AUTO:004A6403                 mov     edx, 66h
AUTO:004A6408                 mov     eax, [ecx+38h]
AUTO:004A640B                 xor     ebx, ebx
AUTO:004A640D                 call    lock_unlock_TC_command
AUTO:004A6412                 mov     edx, 67h
AUTO:004A6417                 mov     eax, [ecx+38h]
AUTO:004A641A                 xor     ebx, ebx
AUTO:004A641C                 call    lock_unlock_TC_command
AUTO:004A6421                 mov     edx, 68h
AUTO:004A6426                 mov     eax, [ecx+38h]
AUTO:004A6429                 xor     ebx, ebx
AUTO:004A642B                 call    lock_unlock_TC_command
AUTO:004A6430                 mov     edx, 6Bh
AUTO:004A6435                 mov     eax, [ecx+38h]
AUTO:004A6438                 xor     ebx, ebx
AUTO:004A643A                 call    lock_unlock_TC_command
AUTO:004A643F                 mov     edx, 69h
AUTO:004A6444                 mov     eax, [ecx+38h]
AUTO:004A6447                 xor     ebx, ebx
AUTO:004A6449                 call    lock_unlock_TC_command
AUTO:004A644E                 mov     edx, 6Ah
AUTO:004A6453                 mov     eax, [ecx+38h]
AUTO:004A6456                 xor     ebx, ebx
AUTO:004A6458                 call    lock_unlock_TC_command
AUTO:004A645D                 mov     edx, 70h
AUTO:004A6462                 mov     eax, [ecx+38h]
AUTO:004A6465                 xor     ebx, ebx
AUTO:004A6467                 call    lock_unlock_TC_command
AUTO:004A646C                 mov     edx, 71h
AUTO:004A6471                 mov     eax, [ecx+38h]
AUTO:004A6474                 xor     ebx, ebx
AUTO:004A6476                 call    lock_unlock_TC_command
AUTO:004A647B                 mov     edx, 6Dh
AUTO:004A6480                 mov     eax, [ecx+38h]
AUTO:004A6483                 xor     ebx, ebx
AUTO:004A6485                 call    lock_unlock_TC_command
AUTO:004A648A                 mov     edx, 6Eh
AUTO:004A648F                 mov     eax, [ecx+38h]
AUTO:004A6492                 xor     ebx, ebx
AUTO:004A6494                 call    lock_unlock_TC_command
AUTO:004A6499                 mov     ebx, 1
AUTO:004A649E                 mov     edx, 0C8h
AUTO:004A64A3                 mov     eax, [ecx+38h]
AUTO:004A64A6                 call    lock_unlock_TC_command
AUTO:004A64AB                 mov     ebx, 1
AUTO:004A64B0                 mov     edx, 0C9h
AUTO:004A64B5                 mov     eax, [ecx+38h]
AUTO:004A64B8                 call    lock_unlock_TC_command
AUTO:004A64BD                 mov     edx, 384h
AUTO:004A64C2                 mov     eax, [ecx+38h]
AUTO:004A64C5                 xor     ebx, ebx
AUTO:004A64C7                 call    lock_unlock_TC_command
AUTO:004A64CC                 mov     edx, 385h
AUTO:004A64D1                 mov     eax, [ecx+38h]
AUTO:004A64D4                 xor     ebx, ebx
AUTO:004A64D6
AUTO:004A64D6 last_command_all__lex_select_Order:
AUTO:004A64D6                 call    lock_unlock_TC_command

====================================================

AUTO:004A65EF solo_mode__lock_station_commands:
AUTO:004A65EF                 cmp     dx, 6
AUTO:004A65F3                 jz      station__lock_ship_commands
AUTO:004A65F9                 mov     edx, 0C8h
AUTO:004A65FE                 mov     eax, [ecx+38h]
AUTO:004A6601                 xor     ebx, ebx
AUTO:004A6603                 call    lock_unlock_TC_command
AUTO:004A6608                 mov     edx, 0C9h
AUTO:004A660D                 mov     eax, [ecx+38h]
AUTO:004A6610                 xor     ebx, ebx
AUTO:004A6612                 call    lock_unlock_TC_command
AUTO:004A6617                 cmp     ds:if_group_mode_0, 0
AUTO:004A661E                 jz      group_mode
AUTO:004A6624                 mov     edx, 65h
AUTO:004A6629                 mov     eax, [ecx+38h]
AUTO:004A662C                 xor     ebx, ebx
AUTO:004A662E                 call    lock_unlock_TC_command
AUTO:004A6633                 mov     edx, 66h
AUTO:004A6638                 mov     eax, [ecx+38h]
AUTO:004A663B                 xor     ebx, ebx
AUTO:004A663D                 call    lock_unlock_TC_command
AUTO:004A6642                 mov     edx, 67h
AUTO:004A6647                 mov     eax, [ecx+38h]
AUTO:004A664A                 xor     ebx, ebx
AUTO:004A664C                 call    lock_unlock_TC_command
AUTO:004A6651                 mov     edx, 68h
AUTO:004A6656                 mov     eax, [ecx+38h]
AUTO:004A6659                 xor     ebx, ebx
AUTO:004A665B                 call    lock_unlock_TC_command
AUTO:004A6660                 mov     edx, 6Bh
AUTO:004A6665                 mov     eax, [ecx+38h]
AUTO:004A6668                 xor     ebx, ebx
AUTO:004A666A                 call    lock_unlock_TC_command
AUTO:004A666F                 mov     edx, 69h
AUTO:004A6674                 mov     eax, [ecx+38h]
AUTO:004A6677                 xor     ebx, ebx
AUTO:004A6679                 call    lock_unlock_TC_command
AUTO:004A667E                 mov     edx, 6Ah
AUTO:004A6683                 mov     eax, [ecx+38h]
AUTO:004A6686                 xor     ebx, ebx
AUTO:004A6688                 call    lock_unlock_TC_command
AUTO:004A668D                 mov     edx, 70h
AUTO:004A6692                 mov     eax, [ecx+38h]
AUTO:004A6695                 xor     ebx, ebx
AUTO:004A6697                 call    lock_unlock_TC_command
AUTO:004A669C                 mov     edx, 71h
AUTO:004A66A1                 mov     eax, [ecx+38h]
AUTO:004A66A4                 xor     ebx, ebx
AUTO:004A66A6                 call    lock_unlock_TC_command
AUTO:004A66AB                 mov     edx, 6Dh
AUTO:004A66B0                 mov     eax, [ecx+38h]
AUTO:004A66B3                 xor     ebx, ebx
AUTO:004A66B5                 call    lock_unlock_TC_command
AUTO:004A66BA                 mov     edx, 6Eh
AUTO:004A66BF                 mov     eax, [ecx+38h]
AUTO:004A66C2                 xor     ebx, ebx
AUTO:004A66C4                 call    lock_unlock_TC_command
AUTO:004A66C9                 mov     edx, 384h
AUTO:004A66CE                 mov     eax, [ecx+38h]
AUTO:004A66D1                 xor     ebx, ebx
AUTO:004A66D3                 call    lock_unlock_TC_command
AUTO:004A66D8                 mov     ebx, 1
AUTO:004A66DD                 mov     edx, 385h
AUTO:004A66E2                 mov     eax, [ecx+38h]
AUTO:004A66E5                 xor     edi, edi
AUTO:004A66E7
AUTO:004A66E7 lock_ship_commands_2:
AUTO:004A66E7                 call    lock_unlock_TC_command
AUTO:004A66EC                 lea     edx, [edi+1]
AUTO:004A66EF                 mov     eax, [ecx+38h]
AUTO:004A66F2                 xor     ebx, ebx
AUTO:004A66F4                 call    lock_unlock_TC_command
AUTO:004A66F9                 lea     edx, [edi+2]
AUTO:004A66FC                 mov     eax, [ecx+38h]
AUTO:004A66FF                 xor     ebx, ebx
AUTO:004A6701                 call    lock_unlock_TC_command
AUTO:004A6706                 lea     edx, [edi+3]
AUTO:004A6709                 mov     eax, [ecx+38h]
AUTO:004A670C                 xor     ebx, ebx
AUTO:004A670E                 call    lock_unlock_TC_command
AUTO:004A6713                 lea     edx, [edi+4]
AUTO:004A6716                 mov     eax, [ecx+38h]
AUTO:004A6719                 xor     ebx, ebx
AUTO:004A671B                 call    lock_unlock_TC_command
AUTO:004A6720                 lea     edx, [edi+5]
AUTO:004A6723                 mov     eax, [ecx+38h]
AUTO:004A6726                 xor     ebx, ebx
AUTO:004A6728                 call    lock_unlock_TC_command
AUTO:004A672D                 lea     edx, [edi+6]
AUTO:004A6730                 mov     eax, [ecx+38h]
AUTO:004A6733                 xor     ebx, ebx
AUTO:004A6735                 call    lock_unlock_TC_command
AUTO:004A673A                 mov     esi, [esp+70h]
AUTO:004A673E                 cmp     si, 9           ; switch 10 cases
AUTO:004A6742                 ja      short unlock_shared_commands_ships ; default
AUTO:004A6744                 xor     eax, eax
AUTO:004A6746                 mov     ax, si
AUTO:004A6749                 jmp     combat_groups_switch[eax*4] ; switch jump
AUTO:004A6750
AUTO:004A6750 fast_group_commands_:
AUTO:004A6750                 xor     esi, esi        ; case 0x0
AUTO:004A6752                 mov     ebp, 1
AUTO:004A6757
AUTO:004A6757 index_loop_fast_group:
AUTO:004A6757                 mov     ebx, ebp
AUTO:004A6759                 mov     edx, ds:fast_group_commands[esi]
AUTO:004A675F                 mov     eax, [ecx+38h]
AUTO:004A6762                 add     edx, edi
AUTO:004A6764                 add     esi, 4
AUTO:004A6767                 call    lock_unlock_TC_command
AUTO:004A676C                 cmp     esi, 0Ch
AUTO:004A676F                 jnz     short index_loop_fast_group
AUTO:004A6771                 lea     eax, [eax+0]
AUTO:004A6774
AUTO:004A6774 unlock_shared_commands_ships:
AUTO:004A6774
AUTO:004A6774                 mov     ebx, 1          ; default
AUTO:004A6779                 lea     edx, [edi+7]
AUTO:004A677C                 mov     eax, [ecx+38h]
AUTO:004A677F                 call    lock_unlock_TC_command
AUTO:004A6784                 mov     ebx, 1
AUTO:004A6789                 lea     edx, [edi+9]
AUTO:004A678C                 mov     eax, [ecx+38h]
AUTO:004A678F                 call    lock_unlock_TC_command
AUTO:004A6794                 mov     ebx, 1
AUTO:004A6799                 lea     edx, [edi+0Ah]
AUTO:004A679C                 mov     eax, [ecx+38h]
AUTO:004A679F                 call    lock_unlock_TC_command
AUTO:004A67A4                 mov     ebx, 1
AUTO:004A67A9                 lea     edx, [edi+0Ch]
AUTO:004A67AC                 mov     eax, [ecx+38h]
AUTO:004A67AF                 jmp     last_command_all__lex_select_Order
AUTO:004A67B4 ; ---------------------------------------------------------------------------
AUTO:004A67B4
AUTO:004A67B4 group_mode:
AUTO:004A67B4                 mov     edx, 1
AUTO:004A67B9                 mov     eax, [ecx+38h]
AUTO:004A67BC                 xor     ebx, ebx
AUTO:004A67BE                 call    lock_unlock_TC_command
AUTO:004A67C3                 mov     edx, 2
AUTO:004A67C8                 mov     eax, [ecx+38h]
AUTO:004A67CB                 xor     ebx, ebx
AUTO:004A67CD                 call    lock_unlock_TC_command
AUTO:004A67D2                 mov     edx, 3
AUTO:004A67D7                 mov     eax, [ecx+38h]
AUTO:004A67DA                 xor     ebx, ebx
AUTO:004A67DC                 call    lock_unlock_TC_command
AUTO:004A67E1                 mov     edx, 4
AUTO:004A67E6                 mov     eax, [ecx+38h]
AUTO:004A67E9                 xor     ebx, ebx
AUTO:004A67EB                 call    lock_unlock_TC_command
AUTO:004A67F0                 mov     edx, 7
AUTO:004A67F5                 mov     eax, [ecx+38h]
AUTO:004A67F8                 xor     ebx, ebx
AUTO:004A67FA                 call    lock_unlock_TC_command
AUTO:004A67FF                 mov     edx, 5
AUTO:004A6804                 mov     eax, [ecx+38h]
AUTO:004A6807                 xor     ebx, ebx
AUTO:004A6809                 call    lock_unlock_TC_command
AUTO:004A680E                 mov     edx, 6
AUTO:004A6813                 mov     eax, [ecx+38h]
AUTO:004A6816                 xor     ebx, ebx
AUTO:004A6818                 call    lock_unlock_TC_command
AUTO:004A681D                 mov     edx, 0Ch
AUTO:004A6822                 mov     eax, [ecx+38h]
AUTO:004A6825                 xor     ebx, ebx
AUTO:004A6827                 call    lock_unlock_TC_command
AUTO:004A682C                 mov     edx, 0Dh
AUTO:004A6831                 mov     eax, [ecx+38h]
AUTO:004A6834                 xor     ebx, ebx
AUTO:004A6836                 call    lock_unlock_TC_command
AUTO:004A683B                 mov     edx, 9
AUTO:004A6840                 mov     eax, [ecx+38h]
AUTO:004A6843                 xor     ebx, ebx
AUTO:004A6845                 call    lock_unlock_TC_command
AUTO:004A684A                 mov     edx, 0Ah
AUTO:004A684F                 mov     eax, [ecx+38h]
AUTO:004A6852                 xor     ebx, ebx
AUTO:004A6854                 call    lock_unlock_TC_command
AUTO:004A6859                 mov     ebx, 1
AUTO:004A685E                 mov     edx, 384h
AUTO:004A6863                 mov     eax, [ecx+38h]
AUTO:004A6866                 call    lock_unlock_TC_command
AUTO:004A686B                 mov     edx, 385h
AUTO:004A6870                 mov     eax, [ecx+38h]
AUTO:004A6873                 xor     ebx, ebx
AUTO:004A6875                 mov     edi, 64h
AUTO:004A687A                 jmp     lock_ship_commands_2
AUTO:004A687F ; ---------------------------------------------------------------------------
AUTO:004A687F
AUTO:004A687F support_group_commands_:
AUTO:004A687F
AUTO:004A687F                 cmp     word ptr [esp+120h], 3 ; case 0x5
AUTO:004A6888                 jnz     unlock_shared_commands_ships ; default
AUTO:004A688E                 mov     ebx, 1
AUTO:004A6893                 lea     edx, [edi+2]
AUTO:004A6896                 mov     eax, [ecx+38h]
AUTO:004A6899                 call    lock_unlock_TC_command
AUTO:004A689E                 jmp     unlock_shared_commands_ships ; default
AUTO:004A68A3 ; ---------------------------------------------------------------------------
AUTO:004A68A3
AUTO:004A68A3 slow_group_commands_:
AUTO:004A68A3
AUTO:004A68A3                 xor     esi, esi        ; case 0x2
AUTO:004A68A5                 mov     ebp, 1
AUTO:004A68AA
AUTO:004A68AA index_loop_slow_group:
AUTO:004A68AA                 mov     ebx, ebp
AUTO:004A68AC                 mov     edx, ds:slow_group_commands[esi]
AUTO:004A68B2                 mov     eax, [ecx+38h]
AUTO:004A68B5                 add     edx, edi
AUTO:004A68B7                 add     esi, 4
AUTO:004A68BA                 call    lock_unlock_TC_command
AUTO:004A68BF                 cmp     esi, 10h
AUTO:004A68C2                 jnz     short index_loop_slow_group
AUTO:004A68C4                 jmp     unlock_shared_commands_ships ; default
AUTO:004A68C9 ; ---------------------------------------------------------------------------
AUTO:004A68C9
AUTO:004A68C9 strike_group_commands_:
AUTO:004A68C9
AUTO:004A68C9                 xor     esi, esi        ; case 0x3
AUTO:004A68CB                 mov     ebp, 1
AUTO:004A68D0
AUTO:004A68D0 index_loop_strike_group:
AUTO:004A68D0                 mov     ebx, ebp
AUTO:004A68D2                 mov     edx, ds:strike_group_commands[esi]
AUTO:004A68D8                 mov     eax, [ecx+38h]
AUTO:004A68DB                 add     edx, edi
AUTO:004A68DD                 add     esi, 4
AUTO:004A68E0                 call    lock_unlock_TC_command
AUTO:004A68E5                 cmp     esi, 0Ch
AUTO:004A68E8                 jnz     short index_loop_strike_group
AUTO:004A68EA                 jmp     unlock_shared_commands_ships ; default
Optimising sub_4A6238, via smarter code sharing & using loops, allows fixing command ship bug and proper implementation of cloak & hold (+ if desired withdraw 0B/6F).

Some notes:
  • This all affects player GUI only, not AI and not the random engine which selects the default orders for each group on turn 1 in tatical combat (e.g. strike group can use "Circle" if random default and not changed).
  • Checking ship abilities in group mode most likely just checks the first (or last?) ship in a combat group. For the colony/TT assault command switch this is no big problem, but consequently cloak has to be a solo-mode-only command. Also combat cloak could be restricted to a higher cloak level (effect of stealth/cloak level is just a product of imagination yet).
Important note about an interface bug:
Callahan wrote:I discovered that you can "lend" commands from other ships in a battle.
Just click on your ship and move the mouse over another - even enemy - ship to use it´s abilities for your ship/group.
Advice: Don´t let Starbases do fancy things. Crashes combat.
Tactical cheating
Last edited by Spocks-cuddly-tribble on Thu Jun 23, 2011 10:38 am, 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 »

Another huge breakthrough in this old gem of a game :D
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1884
Joined: Sun Apr 27, 2008 2:00 am

Commands in Tactical Combat

Post by Spocks-cuddly-tribble »

Here is fixed code of sub_4A6238 for copy & paste (tested and plays out great). :)

Features:
  • proper support of all valid commands (list below), so modders just can add/remove each desired command in combat.mnu
  • all solo mode commands with select target option require the command ability in fleet (broken feature fix)
  • cloak ability check added for cloak command (default requirement is cloak level 6), note in group mode just last selected ship gets tested, so Group cloak(6C) should not be in combat.mnu
  • beam weapon check added to unlock assault command for colony & TT
Code keys in combat.mnu & sub_4A6238:

Solo / Group (= +64h)

01 / 65 Charge
02 / 66 Assault
03 / 67 Harry
04 / 68 Circle
05 / 69 Strafe
06 / 6A Flyby
07 / 6B Evade
08 / 6C Cloak
09 / 6D Ram
0A / 6E Retreat
0B / 6F Withdraw (fast group Retreat, same switch mode as for Harry & Strafe)
0C / 70 Open hailing frequencies
0D / 71 Hold position

starbase/outpost

C8 Attack
C9 Open hailing frequencies

group/solo switches (ships)

384 Select Ship
385 Select Group
thunderchero wrote:Note; description in combat.mnu only changes text in popup command window not tactical display on left.

01 00 00 00 1B 00 00 00 at first of file the "1B" control how many total sets of commands/switches. Each command is 88 bytes.
The first 4 bytes of each entry is the command ID, if commands must be sorted by ID is untested.

Code: Select all

Trek.exe at 0xA5741 - 0xA5C89 replace 1353 bytes with:

33 ED 33 F6 BF 0E 00 00 00 8B 41 38 33 DB 83 C6 01 8D 14 2E E8 36 8C 09 00 3B F7 75 EC 85 ED 75 0E BD 64 00 00 00 33 F6 BF 72 00 00 00 EB DA 8B 44 24 70 3C 06 0F 84 1D 01 00 00 3C 07 0F 85 75 02 00 00 E9 10 01 00 00 90 90 BA 07 00 00 00 8B 41 38 31 DB E8 F6 8B 09 00 BA 05 00 00 00 8B 41 38 31 DB E8 E7 8B 09 00 BA 06 00 00 00 8B 41 38 31 DB E8 D8 8B 09 00 BA 0C 00 00 00 8B 41 38 31 DB E8 C9 8B 09 00 BA 0D 00 00 00 8B 41 38 31 DB E8 BA 8B 09 00 BA 09 00 00 00 8B 41 38 31 DB E8 AB 8B 09 00 BA 0A 00 00 00 8B 41 38 31 DB E8 9C 8B 09 00 BA 65 00 00 00 8B 41 38 31 DB E8 8D 8B 09 00 BA 66 00 00 00 8B 41 38 31 DB E8 7E 8B 09 00 BA 67 00 00 00 8B 41 38 31 DB E8 6F 8B 09 00 BA 68 00 00 00 8B 41 38 31 DB E8 60 8B 09 00 BA 6B 00 00 00 8B 41 38 31 DB E8 51 8B 09 00 BA 69 00 00 00 8B 41 38 31 DB E8 42 8B 09 00 BA 6A 00 00 00 8B 41 38 31 DB E8 33 8B 09 00 BA 70 00 00 00 8B 41 38 31 DB E8 24 8B 09 00 BA 71 00 00 00 8B 41 38 31 DB E8 15 8B 09 00 BA 6D 00 00 00 8B 41 38 31 DB E8 06 8B 09 00 BA 6E 00 00 00 8B 41 38 31 DB E8 F7 8A 09 00 BB 01 00 00 00 BA C8 00 00 00 8B 41 38 E8 E5 8A 09 00 BB 01 00 00 00 BA C9 00 00 00 8B 41 38 E8 D3 8A 09 00 BA 84 03 00 00 8B 41 38 31 DB E8 C4 8A 09 00 BA 85 03 00 00 8B 41 38 31 DB E8 B5 8A 09 00 8D 94 24 38 01 00 00 8B 41 38 8D B4 24 48 01 00 00 E8 1F 8B 09 00 E8 EA 74 09 00 8B 9C 24 40 01 00 00 8B AC 24 44 01 00 00 8B 84 24 3C 01 00 00 8B BC 24 38 01 00 00 29 C5 8B 41 1C 29 FB E8 32 77 08 00 89 C7 E8 FB 74 09 00 8B 41 1C 8D 94 24 28 01 00 00 E8 1C 77 08 00 E8 A7 74 09 00 89 F8 E8 50 76 09 00 29 D8 8B 9C 24 48 01 00 00 D1 E8 01 C3 89 F8 E8 2C 76 09 00 29 E8 8B 94 24 4C 01 00 00 D1 E8 01 D0 8B 71 38 89 C1 31 D2 89 F0 E8 81 8A 09 00 A1 B8 B1 5C 00 8B 40 38 E8 54 8B 09 00 B8 54 04 00 00 E8 5A 4D FE FF 89 C2 A1 B8 B1 5C 00 8B 88 A5 00 00 00 85 C9 74 07 89 C8 E8 96 72 07 00 85 D2 0F 84 49 03 00 00 89 D0 E8 62 71 07 00 8B 15 B8 B1 5C 00 89 82 A5 00 00 00 A1 B8 B1 5C 00 8B 40 64 E8 9A B7 06 00 A1 B8 B1 5C 00 C7 80 C8 00 00 00 01 00 00 00 5E 5F 81 C4 4C 01 00 00 5D C3 A1 B8 B1 5C 00 89 90 A5 00 00 00 E9 33 FD FF FF 66 83 FA 06 0F 84 56 FD FF FF BA C8 00 00 00 8B 41 38 31 DB E8 88 89 09 00 BA C9 00 00 00 8B 41 38 31 DB E8 79 89 09 00 83 3D EC 27 59 00 00 0F 84 35 02 00 00 E9 A0 00 00 00 8B 41 38 31 DB E8 5D 89 09 00 BA 66 00 00 00 8B 41 38 31 DB E8 4E 89 09 00 BA 67 00 00 00 8B 41 38 31 DB E8 3F 89 09 00 BA 68 00 00 00 8B 41 38 31 DB E8 30 89 09 00 BA 6B 00 00 00 8B 41 38 31 DB E8 21 89 09 00 BA 69 00 00 00 8B 41 38 31 DB E8 12 89 09 00 BA 6A 00 00 00 8B 41 38 31 DB E8 03 89 09 00 BA 70 00 00 00 8B 41 38 31 DB E8 F4 88 09 00 BA 71 00 00 00 8B 41 38 31 DB E8 E5 88 09 00 BA 6D 00 00 00 8B 41 38 31 DB E8 D6 88 09 00 BA 6E 00 00 00 8B 41 38 31 DB E8 C7 88 09 00 BA 84 03 00 00 8B 41 38 31 DB E8 B8 88 09 00 BB 01 00 00 00 BA 85 03 00 00 8B 41 38 31 FF E8 A4 88 09 00 8D 57 0A 8B 41 38 BB 01 00 00 00 80 7C 24 70 01 7F 09 83 C2 01 90 90 90 90 90 90 E8 84 88 09 00 80 BC 24 B8 00 00 00 06 7C 10 8D 57 08 8B 41 38 BB 01 00 00 00 E8 6A 88 09 00 85 FF 75 10 83 3D D8 AC 5C 00 00 74 51 90 90 90 90 90 90 90 8B 74 24 70 66 83 FE 09 77 30 31 C0 66 89 F0 FF 24 85 10 62 4A 00 31 F6 BD 01 00 00 00 89 EB 8B 96 34 29 59 00 8B 41 38 01 FA 83 C6 04 E8 24 88 09 00 83 FE 0C 75 E6 8D 40 00 BB 01 00 00 00 8D 57 09 8B 41 38 E8 0C 88 09 00 BB 01 00 00 00 8D 57 07 8B 41 38 E8 FC 87 09 00 BB 01 00 00 00 8D 57 0D 8B 41 38 E8 EC 87 09 00 BB 01 00 00 00 8D 57 0C 8B 41 38 E9 22 FD FF FF BA 01 00 00 00 8B 41 38 31 DB E8 CD 87 09 00 BA 02 00 00 00 8B 41 38 31 DB E8 BE 87 09 00 BA 03 00 00 00 8B 41 38 31 DB E8 AF 87 09 00 BA 04 00 00 00 8B 41 38 31 DB E8 A0 87 09 00 BA 07 00 00 00 8B 41 38 31 DB E8 91 87 09 00 BA 05 00 00 00 8B 41 38 31 DB E8 82 87 09 00 BA 06 00 00 00 8B 41 38 31 DB E8 73 87 09 00 BA 0C 00 00 00 8B 41 38 31 DB E8 64 87 09 00 BA 0D 00 00 00 8B 41 38 31 DB E8 55 87 09 00 BA 09 00 00 00 8B 41 38 31 DB E8 46 87 09 00 BA 0A 00 00 00 8B 41 38 31 DB E8 37 87 09 00 BB 01 00 00 00 BA 84 03 00 00 8B 41 38 E8 25 87 09 00 BA 85 03 00 00 8B 41 38 31 DB BF 64 00 00 00 E9 68 FE FF FF 66 83 BC 24 78 00 00 00 00 0F 84

code changes:

4A6341     33ED            XOR EBP, EBP 
4A6343     33F6            XOR ESI, ESI 
4A6345     BF 0E000000     MOV EDI, 0E 
4A634A     8B41 38         MOV EAX, [ECX+38] 
4A634D     33DB            XOR EBX, EBX 
4A634F     83C6 01         ADD ESI, 1 
4A6352     8D142E          LEA EDX, [ESI+EBP] 
4A6355     E8 368C0900     CALL 53EF90 
4A635A     3BF7            CMP ESI, EDI 
4A635C    ^75 EC           JNZ SHORT 4A634A 
4A635E     85ED            TEST EBP, EBP 
4A6360     75 0E           JNZ SHORT 4A6370 
4A6362     BD 64000000     MOV EBP, 64 
4A6367     33F6            XOR ESI, ESI 
4A6369     BF 72000000     MOV EDI, 72 
4A636E    ^EB DA           JMP SHORT 4A634A 
4A6370     8B4424 70       MOV EAX, [ESP+70] 
4A6374     3C 06           CMP AL, 6 
4A6376     0F84 1D010000   JE 4A6499 
4A637C     3C 07           CMP AL, 7 
4A637E     0F85 75020000   JNZ 4A65F9 
4A6384     E9 10010000     JMP 4A6499 
4A6389     90              NOP 
4A638A     90              NOP 

4A661E     0F84 35020000   JE 4A6859 
4A6624     E9 A0000000     JMP 4A66C9 

4A66EC     8D57 0A              LEA EDX, [EDI+A]

4A66F2     BB 01000000          MOV EBX, 1 
4A66F7     807C24 70 01         CMP BYTE [ESP+70], 1
4A66FC     7F 09                JG SHORT t4A6707
4A66FE     83C2 01              ADD EDX, 1
4A6701     90                   NOP
4A6702     90                   NOP
4A6703     90                   NOP
4A6704     90                   NOP
4A6705     90                   NOP
4A6706     90                   NOP
4A6707     E8 84880900         CALL 53EF90 
4A670C     80BC24 B8000000 06  CMP BYTE [ESP+B8], 6   // cloak level check
4A6714     7C 10               JL SHORT 4A6726 
4A6716     8D57 08             LEA EDX, [EDI+8] 
4A6719     8B41 38             MOV EAX, [ECX+38] 
4A671C     BB 01000000         MOV EBX, 1 
4A6721     E8 6A880900         CALL 53EF90 
4A6726     85FF                TEST EDI, EDI      // solo mode check
4A6728     75 10               JNZ SHORT 4A673A 
4A672A     833D D8AC5C00 00    CMP DWORD [5CACD8], 0   // command ability check
4A6731     74 51               JE SHORT 4A6784 
4A6733     90                  NOP 
4A6734     90                  NOP 
4A6735     90                  NOP 
4A6736     90                  NOP 
4A6737     90                  NOP 
4A6738     90                  NOP 
4A6739     90                  NOP 

4A6779     8D57 09            LEA EDX, [EDI+9] 

4A6789     8D57 07            LEA EDX, [EDI+7]

4A6799     8D57 0D            LEA EDX, [EDI+D]

4A687F     66:83BC24 78000000 00   CMP WORD [ESP+078], 0   // beam weapons check
4A6888    ^0F84 E6FEFFFF           JE 4A6774
If you want to disable the command ship solo-targeting restriction in one of your mods, just replace 75 with EB in my replacement code at the position below:

Code: Select all

trek.exe at 0xA5B28  change 75 to  EB
4A6728     75 10               JNZ SHORT 4A673A
Special thanks to thunderchero for his great support. :wink:

Badbru wrote:Are we going to see in future realeases a wider range of commands for both groups of ships and individual ships?
Yes, but only cloak, hold position & a second fast group retreat aka withdraw (just for cosmetic diversity).

English combat menu for ship_tactical_combat_the broken command ability.patch
english_combat.zip
(517 Bytes) Downloaded 172 times
German combat menu for ship_tactical_combat_the broken command ability.patch
german_combat.zip
(532 Bytes) Downloaded 180 times
Last edited by Spocks-cuddly-tribble on Fri May 06, 2016 4:53 am, 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
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7849
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Post by thunderchero »

Spocks-cuddly-tribble wrote:Special thanks to thunderchero for his great support. :wink:

(please move topic into coding section)
Glad I was of some help, and topic has been moved

And great work, I hope to find some time tonight to do some testing.

I wonder when gowron will sign in to see all your great work (I see a BOP update soon after) :wink:

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

Post by Spocks-cuddly-tribble »

Time to put the finishing touches on the new commands (just cosmetics) and start to look into the effects of commands (#4).


1. The two retreat commands (0A/6E & 0B/6F)

0B/6F is just unused pseudo code for a fast combat group only Retreat (just for cosmetic diversity - internal code switch for retreat speed does work, cf. #4). Same switch mode as for the fast/slow-group commands: Harry / Circle & Strafe / Flyby. But the programmer confused the switch mode with solo/group and left the code unfinished/broken. I'll refer to this command as "Withdraw" (resp. "Abzug" for german version).

=> Updated above code for sub_4A6238 (implemented new analysis - works even more efficient). Note the fast/escort group loses the retreat command without withdraw 0B/6F in combat.mnu!

Here is a german combat.mnu featuring all commands excepting 6C Group Cloak (see above).

Command code key: (for switches -1 / group mode gets converted to solo for each ship)

01 Charge
02 Assault
03 Harry
04 Circle
05 Strafe
06 Flyby
07 Evade
08 Cloak
09 Ram
0A Retreat
0B Withdraw (just for the cosmetic switches, later converted to 0A)
0C Open hailing frequencies
0D Hold position

After the cosmetic switches(#1-3) 0B gets converted to 0A:

Code: Select all

51FA24                 cmp     dword ptr [ebx+1FCh], 0Bh
51FA2B                 jnz     short loc_51FA37
51FA2D                 mov     dword ptr [ebx+1FCh], 0Ah
Note that the combat command is stored at ds:597864[+1FC] for each ship (very useful info, see #4).



2. Enabling custom descriptions for all commands (sub_4A2920)

Code: Select all

trek.exe at 0xA1CF0 - 0xA1D4A
replace: (91 bytes)
30 29 4A 00 9A 29 4A 00 5C 29 4A 00 88 29 4A 00 46 29 4A 00 72 29 4A 00 D0 29 4A 00 3C 29 4A 00 E2 29 4A 00 AC 29 4A 00 3C 29 4A 00 BE 29 4A 00 51 48 31 C9 83 F8 0B 77 13 FF 24 85 F0 28 4A 00 B8 C5 04 00 00 E8 A6 89 FE FF 89 C1 85 C9 0F 85 B0 00 00 00 59 C3 B8 D1 04 00 00
with:
C5 04 00 00 C3 04 00 00 C9 04 00 00 C7 04 00 00 D1 04 00 00 CF 04 00 00 CD 04 00 00 CB 04 00 00 D6 04 00 00 D8 04 00 00 D8 04 00 00 D3 04 00 00 51 48 31 C9 83 F8 0C 7D 18 8B 04 85 F0 28 4A 00 E8 AB 89 FE FF 8B C8 85 C9 0F 85 B5 00 00 00 59 C3 77 FC B8 D4 04 00 00 EB E6 90

loaded lexicon entries for description of commands 1-C:

4A28F0   . C5040000          DD 000004C5
4A28F4   . C3040000          DD 000004C3
4A28F8   . C9040000          DD 000004C9
4A28FC   . C7040000          DD 000004C7
4A2900   . D1040000          DD 000004D1
4A2904   . CF040000          DD 000004CF
4A2908   . CD040000          DD 000004CD
4A290C   . CB040000          DD 000004CB
4A2910   . D6040000          DD 000004D6
4A2914   . D8040000          DD 000004D8
4A2918   . D8040000          DD 000004D8
4A291C   . D3040000          DD 000004D3

4A2920     51                PUSH ECX
4A2921   . 48                DEC EAX // order ID -1 for switch
4A2922   . 31C9              XOR ECX,ECX
4A2924   . 83F8 0C           CMP EAX, 0C
4A2927   . 7D 18             JGE SHORT 4A2941
4A2929   . 8B0485 F0284A00   MOV EAX, DWORD [EAX*4+4A28F0]
4A2930   > E8 AB89FEFF       CALL 48B2E0 // load lexicon.dic entry
4A2935   . 8BC8              MOV ECX, EAX
4A2937   . 85C9              TEST ECX, ECX
4A2939   . 0F85 B5000000     JNZ 4A29F4 // show command description
4A293F   > 59                POP ECX // exit no description
4A2940   . C3                RETN
4A2941   >^77 FC             JA SHORT 4A293F // exit no description
4A2943   . B8 D4040000       MOV EAX, 4D4  // lexicon entry for hold command description
4A2948   .^EB E6             JMP SHORT 4A2930
4A294A     90                NOP
Note; by default the description entry 1240/4D8h is shared by A & B, also D reads just the shared entry 1236/4D4h "hold position". But code can be switched to the unused entries 1241/4D9h & 1242/4DAh to read more detailed command descriptions from an edited lexicon.dic.



3. Command switches for tactical display on left & labels on ships

sub_4A8FF4 -> tactical display & short descriptions on left

sub_44ADE4 -> given-command labels on ships

In order to prevent confusion wrt command ability I'd recommend changing the combat group label "Command" (lexicon entry 1157 / 485h) - for the ship functions 2 & 4 - to e.g. "Capital" (taken from fleets.mnu).



4. Effect of commands during the tactical turn (sub_5543F4)

Sub_5543F4 controls the ship movements and whether weapons & shields are available. It does not affect the result of the command after the turn (e.g. hail end combat option, cloak status). Most code is either shared (just with different input for fast/slow commands) or has only minor differences (hold vs. hail & evade vs. cloak -> weapon/shield status). As told above withdraw 0B/6F is a special case i.e. not present since converted to 0A/6E (fast/slow groups switch table is at 56C1D0).

ds:597864 (entry size 3C8h / object)

+38h -> 0 = uncloaked
+EC -> 0 = uncloaked
+14C = agility
+178h -> object type (1=ship, 5=station, 7=monster, 6=unkown torpedo/missile?)
+1DC = owner race ID
+1FC = given command (cf. #1)
+20C -> or 10h = lock weapons

sub_528BA0 (ship, monster, station switch for some ds:597864 data)

- lock shields (due to cloak)
+390h -> or 2 (for ships)
+338h -> or 2 (for monster)

- object cloaked
+35C = 2 (for ships)
+304h = 2 (for monster)


This knowledge opens a wide variety of possibilities:

Remove to unlock weapons during retreat (i.e. retreating ships under attack can return fire):

Code: Select all

56C6D8                 or      byte ptr [ebx+20Ch], 10h // lock weapons for retreat
Also this info enables a whole new level of editing monster behavior in tactical combat (just edited Tarellian ship to fire its nuclear missiles and Combat drone to cloak after surprise attack), but that will go into the Monster Editing Info topic.
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: 7849
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Post by thunderchero »

Great job SCT,

I tested some already and all commands work. :D

:?: 's

1. to add lexicon entry for commands, Could I get more detailed info on how to edit?

2.
Spocks-cuddly-tribble wrote:Remove to unlock weapons during retreat (i.e. retreating ships under attack can return fire):

Code: Select all

56C6D8                 or      byte ptr [ebx+20Ch], 10h // lock weapons for retreat
could this be given to only 1 of the retreat options?

example

0A Peaceful Retreat
0B Withdraw Return Fire

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

Post by Spocks-cuddly-tribble »

thunderchero wrote:I tested some already and all commands work. :D
I also ran some tests, and all new commands turned out as surprisingly stable (zero crashes so far). :)

Some important notes wrt bugs of the cloak command:
  • for already cloaked ships the "cloak" command sometimes doesn't work properly i.e. one of the following turns the ship could start uncloaked (this appears to be a rather erratic/sporadic problem)
  • the "evade" command sometimes allows firing torpedoes at cloaked targets (rarer even phaser?)
  • targeted before going to cloak mode the "ram" command still will be executed with the former position of the cloaked ship being the valid intercept location (3D action display out of sync)
Also remember, due to another bug, cloaked ships can be targeted by torpedoes when uncloaked ships in same combat group.

WARNING - An important note about an interface bug:
Callahan wrote:I discovered that you can "lend" commands from other ships in a battle.
Just click on your ship and move the mouse over another - even enemy - ship to use it´s abilities for your ship/group.
Advice: Don´t let Starbases do fancy things. Crashes combat.
Tactical cheating = Cloak command unusable for now :(


thunderchero wrote:to add lexicon entry for commands, Could I get more detailed info on how to edit?
Relevant parts of asm replacement code: (positions should be easy to find in the above hex code #2)

Code: Select all

loaded lexicon entries for description of commands...

4A2914   . D8040000          DD 000004D8  // for retreat 0A
4A2918   . D8040000          DD 000004D8 // for retreat 0B

4A2943   . B8 D4040000       MOV EAX, 4D4  // for hold 0D
F.e. change loaded lexicon.dic entry for retreat 0A to 4D9h (1241) and for hold 0D to 4DAh (1242). Then just edit both lexicon entries for your taste (default just since there are no matching descriptions in unmodded lexicon.dic, only for cloak).

So for "hold", one could note that the ship won't move but fire at enemies within weapon range. Exception: cloaked ships stay cloaked (side note; this command might counter the one uncloaked ship tactic/exploit).


thunderchero wrote:could this be given to only 1 of the retreat options?

example

0A Peaceful Retreat
0B Withdraw Return Fire
Good idea, and technically easy to do (this mode is official AFC recommendation now). :wink:

Note; 0A is Return Fire & 0B is Peaceful Retreat (this makes AI a bit more aggressive and the command graphics fit better with sub_4A8FF4).

1. Remove the old lock weapons statement

Code: Select all

trek.exe at 0x16BAD8 change 80 8B 0C 02 00 00 10 to -> 90 90 90 90 90 90 90

56C6D8                 or      byte ptr [ebx+20Ch], 10h // lock weapons for retreat -> nop
2. Lock weapons when converting 0B to 0A

Code: Select all

trek.exe at 0x11EE24
replace: (19 bytes)
83 BB FC 01 00 00 0B 75 0A C7 83 FC 01 00 00 0A 00 00 00
with:
8D 83 FC 01 00 00 83 38 0B 75 08 C6 00 0A 80 48 10 10 90

51FA24     8D83 FC010000   LEA EAX, [EBX+1FC]
51FA2A     8338 0B         CMP [EAX], 0B   // if 0B...
51FA2D     75 08           JNZ SHORT 51FA37
51FA2F     C600 0A         MOV BYTE [EAX], 0A   // ...convert to 0A...
51FA32     8048 10 10      OR BYTE [EAX+10], 10   // ...and lock weapons
51FA36     90              NOP
3. Undo cosmetic fast/slow-groups switch-fix -> retreat A & B are coexistent (old code taken from google cache)

Code: Select all

trek.exe at 0xA5741 - 0xA5C89 replace 1353 bytes with: 

33 ED 33 F6 BF 0E 00 00 00 8B 41 38 33 DB 83 C6 01 8D 14 2E E8 36 8C 09 00 3B F7 75 EC 85 ED 75 0E BD 64 00 00 00 33 F6 BF 72 00 00 00 EB DA 8B 44 24 70 3C 06 0F 84 1D 01 00 00 3C 07 0F 85 75 02 00 00 E9 10 01 00 00 90 90 BA 07 00 00 00 8B 41 38 31 DB E8 F6 8B 09 00 BA 05 00 00 00 8B 41 38 31 DB E8 E7 8B 09 00 BA 06 00 00 00 8B 41 38 31 DB E8 D8 8B 09 00 BA 0C 00 00 00 8B 41 38 31 DB E8 C9 8B 09 00 BA 0D 00 00 00 8B 41 38 31 DB E8 BA 8B 09 00 BA 09 00 00 00 8B 41 38 31 DB E8 AB 8B 09 00 BA 0A 00 00 00 8B 41 38 31 DB E8 9C 8B 09 00 BA 65 00 00 00 8B 41 38 31 DB E8 8D 8B 09 00 BA 66 00 00 00 8B 41 38 31 DB E8 7E 8B 09 00 BA 67 00 00 00 8B 41 38 31 DB E8 6F 8B 09 00 BA 68 00 00 00 8B 41 38 31 DB E8 60 8B 09 00 BA 6B 00 00 00 8B 41 38 31 DB E8 51 8B 09 00 BA 69 00 00 00 8B 41 38 31 DB E8 42 8B 09 00 BA 6A 00 00 00 8B 41 38 31 DB E8 33 8B 09 00 BA 70 00 00 00 8B 41 38 31 DB E8 24 8B 09 00 BA 71 00 00 00 8B 41 38 31 DB E8 15 8B 09 00 BA 6D 00 00 00 8B 41 38 31 DB E8 06 8B 09 00 BA 6E 00 00 00 8B 41 38 31 DB E8 F7 8A 09 00 BB 01 00 00 00 BA C8 00 00 00 8B 41 38 E8 E5 8A 09 00 BB 01 00 00 00 BA C9 00 00 00 8B 41 38 E8 D3 8A 09 00 BA 84 03 00 00 8B 41 38 31 DB E8 C4 8A 09 00 BA 85 03 00 00 8B 41 38 31 DB E8 B5 8A 09 00 8D 94 24 38 01 00 00 8B 41 38 8D B4 24 48 01 00 00 E8 1F 8B 09 00 E8 EA 74 09 00 8B 9C 24 40 01 00 00 8B AC 24 44 01 00 00 8B 84 24 3C 01 00 00 8B BC 24 38 01 00 00 29 C5 8B 41 1C 29 FB E8 32 77 08 00 89 C7 E8 FB 74 09 00 8B 41 1C 8D 94 24 28 01 00 00 E8 1C 77 08 00 E8 A7 74 09 00 89 F8 E8 50 76 09 00 29 D8 8B 9C 24 48 01 00 00 D1 E8 01 C3 89 F8 E8 2C 76 09 00 29 E8 8B 94 24 4C 01 00 00 D1 E8 01 D0 8B 71 38 89 C1 31 D2 89 F0 E8 81 8A 09 00 A1 B8 B1 5C 00 8B 40 38 E8 54 8B 09 00 B8 54 04 00 00 E8 5A 4D FE FF 89 C2 A1 B8 B1 5C 00 8B 88 A5 00 00 00 85 C9 74 07 89 C8 E8 96 72 07 00 85 D2 0F 84 49 03 00 00 89 D0 E8 62 71 07 00 8B 15 B8 B1 5C 00 89 82 A5 00 00 00 A1 B8 B1 5C 00 8B 40 64 E8 9A B7 06 00 A1 B8 B1 5C 00 C7 80 C8 00 00 00 01 00 00 00 5E 5F 81 C4 4C 01 00 00 5D C3 A1 B8 B1 5C 00 89 90 A5 00 00 00 E9 33 FD FF FF 66 83 FA 06 0F 84 56 FD FF FF BA C8 00 00 00 8B 41 38 31 DB E8 88 89 09 00 BA C9 00 00 00 8B 41 38 31 DB E8 79 89 09 00 83 3D EC 27 59 00 00 0F 84 35 02 00 00 E9 A0 00 00 00 8B 41 38 31 DB E8 5D 89 09 00 BA 66 00 00 00 8B 41 38 31 DB E8 4E 89 09 00 BA 67 00 00 00 8B 41 38 31 DB E8 3F 89 09 00 BA 68 00 00 00 8B 41 38 31 DB E8 30 89 09 00 BA 6B 00 00 00 8B 41 38 31 DB E8 21 89 09 00 BA 69 00 00 00 8B 41 38 31 DB E8 12 89 09 00 BA 6A 00 00 00 8B 41 38 31 DB E8 03 89 09 00 BA 70 00 00 00 8B 41 38 31 DB E8 F4 88 09 00 BA 71 00 00 00 8B 41 38 31 DB E8 E5 88 09 00 BA 6D 00 00 00 8B 41 38 31 DB E8 D6 88 09 00 BA 6E 00 00 00 8B 41 38 31 DB E8 C7 88 09 00 BA 84 03 00 00 8B 41 38 31 DB E8 B8 88 09 00 BB 01 00 00 00 BA 85 03 00 00 8B 41 38 31 FF E8 A4 88 09 00 8D 57 0D 8B 41 38 BB 01 00 00 00 E8 94 88 09 00 8D 57 0B 8B 41 38 BB 01 00 00 00 E8 84 88 09 00 80 BC 24 B8 00 00 00 06 7C 10 8D 57 08 8B 41 38 BB 01 00 00 00 E8 6A 88 09 00 85 FF 75 10 83 3D D8 AC 5C 00 00 74 51 90 90 90 90 90 90 90 8B 74 24 70 66 83 FE 09 77 30 31 C0 66 89 F0 FF 24 85 10 62 4A 00 31 F6 BD 01 00 00 00 89 EB 8B 96 34 29 59 00 8B 41 38 01 FA 83 C6 04 E8 24 88 09 00 83 FE 0C 75 E6 8D 40 00 BB 01 00 00 00 8D 57 09 8B 41 38 E8 0C 88 09 00 BB 01 00 00 00 8D 57 07 8B 41 38 E8 FC 87 09 00 BB 01 00 00 00 8D 57 0A 8B 41 38 E8 EC 87 09 00 BB 01 00 00 00 8D 57 0C 8B 41 38 E9 22 FD FF FF BA 01 00 00 00 8B 41 38 31 DB E8 CD 87 09 00 BA 02 00 00 00 8B 41 38 31 DB E8 BE 87 09 00 BA 03 00 00 00 8B 41 38 31 DB E8 AF 87 09 00 BA 04 00 00 00 8B 41 38 31 DB E8 A0 87 09 00 BA 07 00 00 00 8B 41 38 31 DB E8 91 87 09 00 BA 05 00 00 00 8B 41 38 31 DB E8 82 87 09 00 BA 06 00 00 00 8B 41 38 31 DB E8 73 87 09 00 BA 0C 00 00 00 8B 41 38 31 DB E8 64 87 09 00 BA 0D 00 00 00 8B 41 38 31 DB E8 55 87 09 00 BA 09 00 00 00 8B 41 38 31 DB E8 46 87 09 00 BA 0A 00 00 00 8B 41 38 31 DB E8 37 87 09 00 BB 01 00 00 00 BA 84 03 00 00 8B 41 38 E8 25 87 09 00 BA 85 03 00 00 8B 41 38 31 DB BF 64 00 00 00 E9 68 FE FF FF 66 83 BC 24 78 00 00 00 00 0F 84 

code changes: 

4A6341     33ED            XOR EBP, EBP 
4A6343     33F6            XOR ESI, ESI 
4A6345     BF 0E000000     MOV EDI, 0E 
4A634A     8B41 38         MOV EAX, [ECX+38] 
4A634D     33DB            XOR EBX, EBX 
4A634F     83C6 01         ADD ESI, 1 
4A6352     8D142E          LEA EDX, [ESI+EBP] 
4A6355     E8 368C0900     CALL 53EF90 
4A635A     3BF7            CMP ESI, EDI 
4A635C    ^75 EC           JNZ SHORT 4A634A 
4A635E     85ED            TEST EBP, EBP 
4A6360     75 0E           JNZ SHORT 4A6370 
4A6362     BD 64000000     MOV EBP, 64 
4A6367     33F6            XOR ESI, ESI 
4A6369     BF 72000000     MOV EDI, 72 
4A636E    ^EB DA           JMP SHORT 4A634A 
4A6370     8B4424 70       MOV EAX, [ESP+70] 
4A6374     3C 06           CMP AL, 6 
4A6376     0F84 1D010000   JE 4A6499 
4A637C     3C 07           CMP AL, 7 
4A637E     0F85 75020000   JNZ 4A65F9 
4A6384     E9 10010000     JMP 4A6499 
4A6389     90              NOP 
4A638A     90              NOP 

4A661E     0F84 35020000   JE 4A6859 
4A6624     E9 A0000000     JMP 4A66C9 

4A66EC     8D57 0D         LEA EDX, [EDI+D] 

4A66F2     BB 01000000         MOV EBX, 1 
4A66F7     E8 94880900         CALL 53EF90 
4A66FC     8D57 0B             LEA EDX, [EDI+B] 
4A66FF     8B41 38             MOV EAX, [ECX+38] 
4A6702     BB 01000000         MOV EBX, 1 
4A6707     E8 84880900         CALL 53EF90 
4A670C     80BC24 B8000000 06  CMP BYTE [ESP+B8], 6 
4A6714     7C 10               JL SHORT 4A6726 
4A6716     8D57 08             LEA EDX, [EDI+8] 
4A6719     8B41 38             MOV EAX, [ECX+38] 
4A671C     BB 01000000         MOV EBX, 1 
4A6721     E8 6A880900         CALL 53EF90 
4A6726     85FF                TEST EDI, EDI 
4A6728     75 10               JNZ SHORT 4A673A 
4A672A     833D D8AC5C00 00    CMP DWORD [5CACD8], 0 
4A6731     74 51               JE SHORT 4A6784 
4A6733     90                  NOP 
4A6734     90                  NOP 
4A6735     90                  NOP 
4A6736     90                  NOP 
4A6737     90                  NOP 
4A6738     90                  NOP 
4A6739     90                  NOP 

4A6779     8D57 09            LEA EDX, [EDI+9] 

4A6789     8D57 07            LEA EDX, [EDI+7] 

4A687F     66:83BC24 78000000 00   CMP WORD [ESP+078], 0 
4A6888    ^0F84 E6FEFFFF           JE 4A6774
A minor cosmetic flaw wrt return fire (0A) is that the command is still present for cloaked ships and unarmed colony & TTs (i.e. command is available but works just like peaceful retreat). For unarmed colony/TTs this is easy to solve, but these ships would also lose ram command.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
Nucky9
Ensign
Ensign
Posts: 20
Joined: Tue Sep 15, 2009 2:00 am

Re: Commands in tactical combat

Post by Nucky9 »

This is simply fantastic, great work!

I was wondering though, is it possible to make it so ships using the solo hold command can target an enemy ship, rather than using the ai to decide the target?

Thanks!
Spocks-cuddly-tribble wrote:
Nucky9 wrote:is it possible to make it so ships using the solo hold command can target an enemy ship, rather than using the ai to decide the target?
In theory yes, but unfortunately not that easy as e.g. the idea of the 2 retreat options by thunderchero. But never say never...
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1884
Joined: Sun Apr 27, 2008 2:00 am

Combat: Groups, Commands & AI

Post by Spocks-cuddly-tribble »

Ahead of the 10 years anniversary of the restored AFC-page, at 2018-04-25, some funny facts about tactical combat. :smile:


Datafield ds:5905A0 sets the combat groups, ships belong to, with the ship function (0 scout, 1 destroyer...) used as index value. Group IDs are:

0 - fast attack
1 - long range / artillery
2 - command / slow / cruiser
3 - support / non-combat
4 - monster


sub_4747E0 determines the random initial commands for each group (just for player interface).

So changing 04 (Circle) to e.g. 0D (Hold position) in trek.exe at 0x18E38C should finally fix the artillery group circle default bug, since this command should not be available for this group.


Selection of AI commands is a very intricate matter, but at the very least we can change the useless 'Strafe' command the AI's fast attack group uses when attacking a station. :wink:

Code: Select all

AUTO:0047874B                 mov     eax, edx        ; edx=5        //  set fast group Strafe vs station
Option:47874B                 mov     al, 01          ; set charge   //  trek.exe at 0x77B4B change 89 D0  -> B0 01

At the following locations the AI sets the ram command (I've seen it only one time happening in game during all the years):

Code: Select all

AUTO:004783D3                 mov     dword ptr [ecx+1FCh], 9 ; set ram // warships
AUTO:004784E4                 mov     dword ptr [ecx+1FCh], 9 ; set ram // non-combat unarmed
AUTO:00478509                 mov     dword ptr [ecx+1FCh], 9 ; set ram // non-combat armed

The AI battle calculation (run or fight) seems to hide in sub_479020, with the below codes initiating the fleet retreat:

Code: Select all

AUTO:00477B00                 mov     edx, 0Ah
AUTO:00477DED                 mov     edx, 0Ah
Last edited by Spocks-cuddly-tribble on Fri Apr 13, 2018 10:24 am, 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.
Post Reply

Return to “Commands in tactical combat”