Proper enabling of monster cloak turned out to be a bit more complicated than expected, but here it is.
During tests, I observed some
mod-independent bugs with the Edo God:
- sometimes the auto-battle end message/voiceover & morale effect is wrong (f.e. "hail" with all ships destroyed or "retreat" with ships still in Edo sector)
- due to some AI behavior-bugs the monster cloak does not prevent the "Edo training" misuse via the one uncloaked ship tactic or via using "cloak" command in tactical combat
- even if the first-turn default command in tactical combat requires a target then ships won't fire at the Edo God (i.e. one can move to a dead angle behind the monster to kill it with a single ship resp. do "Edo training" without cloak ability). For the "charge & assault" commands this unchanged first-turn command bug leads to a crash:
Code: Select all
File: ai\assault.c, Line: 562, entity->ship.shipData.targetIsEntity
Enabling the Monster Cloak
Unlike for stations, the monster code is prepared for cloak, but requires the
cloak default fix for task forces, which enables the F1 map cloak for monster.
1.) Auto Battle
1.a) Monster de-cloak shields fix for auto battle
Code: Select all
Trek.exe at 0x127BC2
replace: (25 bytes)
8B B0 78 01 00 00 C7 40 38 00 00 00 00 83 FE 01 75 07 80 A0 90 03 00 00 FD
with:
80 B8 78 01 00 00 06 74 10 C6 40 38 00 50 E8 CB 03 00 00 80 60 68 FD 58 90
005287C2 80B8 78010000 06 CMP BYTE [EAX+178], 6
005287C9 74 10 JE SHORT 5287DB
005287CB C640 38 00 MOV BYTE [EAX+38], 0
005287CF 50 PUSH EAX
005287D0 E8 CB030000 CALL 528BA0
005287D5 8060 68 FD AND BYTE [EAX+68], 0FD
005287D9 58 POP EAX
005287DA 90 NOP
1.b) Disabling the monster cloak only for auto-battle (1.a is redundant for this)
This option is meant to protect the AI (auto-battling only) from losing main fleets against cloaked monsters.
Code: Select all
Trek.exe at 0x1272C6
replace: (36 bytes)
C7 42 38 00 00 00 00 83 FB 01 0F 85 D8 00 00 00 89 D0 E8 83 0C 00 00 F6 40 58 01 74 07 C7 42 38 01 00 00 00
with:
83 FB 07 75 1F C7 42 38 00 00 00 00 80 8A 38 03 00 00 FC 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
00527EC6 83FB 07 CMP EBX, 7
00527EC9 75 1F JNZ SHORT 527EEA
00527ECB C742 38 00000000 MOV DWORD [EDX+38], 0
00527ED2 808A 38030000 FC OR BYTE [EDX+338], 0FC
00527ED9 90... NOP *17
2.) Tactical Combat
2.a) Initial cloak fix for monster
Code: Select all
Trek.exe at 0x11FE0D
replace: (8 bytes)
39 C1 0F 85 20 03 00 00
with:
B8 01 00 00 00 90 90 90
00520A0D B8 01000000 MOV EAX, 1
00520A12 909090 NOP
2.b) Enforced "Hold" command with locked weapons fix
Sub_47215C enforces the "Hold" command for opponents of fully cloaked fleets resp. de-cloaks ships if all fleets are fully cloaked. Due to a bug in sub_471DD0 it mistakenly enforces the "Hold" command for Tarellian/29, Combat Drone/2B & Husnock/2C if they are cloaked themselves. Make sure that the monster switch in loc_472278 jumps to 47221A for all monster with map/initial cloak.
Code example for Combat Drone (2B) with cloak:
Code: Select all
Trek.exe at 0x7167D
replace: (14 bytes)
66 8B 8B DC 01 00 00 83 E9 24 66 83 F9 06
with:
8A 8B DC 01 00 00 83 E9 24 83 F9 07 74 8F
0047227D 8A8B DC010000 MOV CL, [EBX+1DC]
00472283 83E9 24 SUB ECX, 24
00472286 83F9 07 CMP ECX, 7
00472289 ^74 8F JE SHORT 47221A
2.c) Monster staying cloaked + de-cloak shields fix
Sub_528840 determines via the given command whether a cloaked ship will stay cloaked or de-cloak during the tactical turn (result of the call from 496E5C seems to be ignored, maybe this is a bug). By default the commands "cloak, retreat & hold" keep ships cloaked. Since some monster use the "hold" command, they just stay cloaked and do nothing without code adjusting:
Code: Select all
Trek.exe at 0x11EF48
replace: (39 bytes)
8B 40 48 E8 F0 8C 00 00 85 C0 75 1B C7 45 34 02 00 00 00 66 83 7B 28 2B 0F 84 D0 FB FF FF 80 4B 58 10 E9 C7 FB FF FF
with:
66 83 7B 28 24 7D 1C 8B 40 48 E8 E9 8C 00 00 85 C0 75 14 C7 45 34 02 00 00 00 80 4B 58 10 E9 CB FB FF FF 80 65 68 FD
0051FB48 66:837B 28 24 CMP WORD [EBX+28], 24 // if a monster...
0051FB4D 7D 1C JGE SHORT 51FB6B // de-cloak with shields fix
0051FB4F 8B40 48 MOV EAX, [EAX+48] // given command
0051FB52 E8 E98C0000 CALL 528840 // stay cloaked check via command
0051FB57 85C0 TEST EAX, EAX
0051FB59 75 14 JNZ SHORT 51FB6F // de-cloak ship
0051FB5B C745 34 02000000 MOV DWORD [EBP+34], 2 // stay cloaked
0051FB62 804B 58 10 OR BYTE [EBX+58], 10 // lock weapons
0051FB66 ^E9 CBFBFFFF JMP 51F736
0051FB6B 8065 68 FD AND BYTE [EBP+68], 0FD // unlock shields
In order to share the shields fix with ships, the jump at 51FB59 could be changed from 51FB6F to 51FB6B and below unlock ship shields statements removed, but I don't think it's necessary.
Code: Select all
00523280 80A0 90030000 FD AND BYTE [EAX+390], 0FD
00523EC1 80A0 90030000 FD AND BYTE [EAX+390], 0FD
00524CE5 80A0 90030000 FD AND BYTE [EAX+390], 0FD
00525798 80A0 90030000 FD AND BYTE [EAX+390], 0FD
3.) Monster using the "cloak" command in tactical combat
Note: there are some issues with the "cloak" command - see
Commands in tactical combat.
3.a) Cloak command for Combat Drone
Code: Select all
Trek.exe at 0x76A2B
replace: (27 bytes)
C7 87 FC 01 00 00 05 00 00 00 80 8F 0C 02 00 00 02 83 C4 18 5D 5F 5E 5A 59 5B C3
with:
B0 05 F6 47 38 01 75 02 B0 08 88 87 FC 01 00 00 80 8F 0C 02 00 00 02 EB 13 90 90
0047762B B0 05 MOV AL, 5 // strafe attack (default) or...
0047762D F647 38 01 TEST BYTE [EDI+38], 1 // if uncloaked...
00477631 75 02 JNZ SHORT 477635
00477633 B0 08 MOV AL, 8 // ...cloak
00477635 8887 FC010000 MOV [EDI+1FC], AL
0047763B 808F 0C020000 02 OR BYTE [EDI+20C], 2
00477642 EB 13 JMP SHORT 477657
00477644 9090 NOP
3.b) Special monster cloak command (unlock shields & weapons)
Whilst the default, with locking shields & weapons, is reasonable for player using the cloak command, it would be way too easy to kill the combat drone...
Code: Select all
Trek.exe at 0x1696B5
replace: (30 bytes)
E8 A6 E8 FB FF 80 48 58 10 89 D0 E8 DB E8 FB FF 8A 78 68 8B 4C 24 14 80 CF 02 51 88 78 68
with:
80 B8 78 01 00 00 07 74 0E 80 88 0C 02 00 00 10 80 88 90 03 00 00 02 8B 4C 24 14 51 90 90
0056A2B5 80B8 78010000 07 CMP BYTE [EAX+178], 7 // if a monster...
0056A2BC 74 0E JE SHORT 56A2CC // ...do not lock weapons & shields
0056A2BE 8088 0C020000 10 OR BYTE [EAX+20C], 10 // lock weapons
0056A2C5 8088 90030000 02 OR BYTE [EAX+390], 2 // lock shields (ships)
0056A2CC 8B4C24 14 MOV ECX, [ESP+14]
0056A2D0 51 PUSH ECX
0056A2D1 9090 NOP