Skip to content

Commit fa94330

Browse files
committed
Adjust guard mode patch to ignore AI-owned aircraft
Some Tiberian Sun singleplayer missions rely on the original behaviour with AI aircraft
1 parent 0de2229 commit fa94330

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/guard_mode_patch.asm

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,30 @@
44

55
;;; http://www.ppmforums.com/viewtopic.php?t=38895
66
; # Units in Guard mode will no longer chase after enemies that move out of firing range
7-
@CLEAR 0x004A1AA8, 0x90, 0x004A1AAA
7+
; @CLEAR 0x004A1AA8, 0x90, 0x004A1AAA
8+
9+
; Hack FootClass::Mission_Guard
10+
; Follow current target only if we are an AI-controlled aircraft.
11+
; Author: Rampastring
12+
hack 0x004A1AA0
13+
; Restore original code. Follow target if we are an engineer
14+
test al, al
15+
jnz 0x004A1AD6 ; continue with current target
16+
17+
mov ecx, esi ; this
18+
mov eax, [esi] ; vtable
19+
call [eax+2Ch] ; ObjectClass::What_Am_I()
20+
cmp eax, 2 ; RTTI_AIRCRAFT
21+
jne 0x004A1AAE ; if not aircraft: seek new target, idle if not found
22+
23+
mov ecx, [esi+0ECh] ; Owner
24+
call 0x004CB990 ; HouseClass::Is_Human_Control()
25+
test al, al
26+
jnz 0x004A1AAE ; if human-controlled: seek new target, idle if not found
27+
28+
; if we get here we know that 1) the foot object is an aircraft and 2) the aircraft is AI-controlled
29+
; check for its TarCom
30+
mov ecx, [esi+11Ch] ; TechnoClass.TarCom
31+
test ecx, ecx
32+
jnz 0x004A1AD6 ; continue with current target
33+
jmp 0x004A1AAE ; our tarcom is null, seek new target and idle if one is not found

0 commit comments

Comments
 (0)