Skip to content

Commit

Permalink
Adjust guard mode patch to ignore AI-owned aircraft
Browse files Browse the repository at this point in the history
Some Tiberian Sun singleplayer missions rely on the original behaviour with AI aircraft
  • Loading branch information
Rampastring committed Aug 20, 2024
1 parent 0de2229 commit fa94330
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/guard_mode_patch.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,30 @@

;;; http://www.ppmforums.com/viewtopic.php?t=38895
; # Units in Guard mode will no longer chase after enemies that move out of firing range
@CLEAR 0x004A1AA8, 0x90, 0x004A1AAA
; @CLEAR 0x004A1AA8, 0x90, 0x004A1AAA

; Hack FootClass::Mission_Guard
; Follow current target only if we are an AI-controlled aircraft.
; Author: Rampastring
hack 0x004A1AA0
; Restore original code. Follow target if we are an engineer
test al, al
jnz 0x004A1AD6 ; continue with current target

mov ecx, esi ; this
mov eax, [esi] ; vtable
call [eax+2Ch] ; ObjectClass::What_Am_I()
cmp eax, 2 ; RTTI_AIRCRAFT
jne 0x004A1AAE ; if not aircraft: seek new target, idle if not found

mov ecx, [esi+0ECh] ; Owner
call 0x004CB990 ; HouseClass::Is_Human_Control()
test al, al
jnz 0x004A1AAE ; if human-controlled: seek new target, idle if not found

; if we get here we know that 1) the foot object is an aircraft and 2) the aircraft is AI-controlled
; check for its TarCom
mov ecx, [esi+11Ch] ; TechnoClass.TarCom
test ecx, ecx
jnz 0x004A1AD6 ; continue with current target
jmp 0x004A1AAE ; our tarcom is null, seek new target and idle if one is not found

0 comments on commit fa94330

Please sign in to comment.