Skip to content

Commit

Permalink
Add trigger action for assigning a mission to all units of a house
Browse files Browse the repository at this point in the history
  • Loading branch information
Rampastring committed Jul 23, 2024
1 parent ae7887d commit 17d8b0f
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/trigger_actions_extended.asm
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ hack 0x0061913B ; Extend trigger action jump table
jz .Create_AutoSave_Action
cmp edx, 114
jz .Remove_Attached_Objects_Action
cmp edx, 115
jz .Assign_Mission_To_All_Units_Action

cmp edx, 68h
ja 0x0061A9C5 ; default
Expand Down Expand Up @@ -374,3 +376,45 @@ hack 0x0061913B ; Extend trigger action jump table
call TAction_Remove_Object
jmp 0x0061A9C5 ; default


; ***********************************
; *** Assign Mission To All Units ***
; ***********************************
.Assign_Mission_To_All_Units_Action:

mov edx, [esi+40h] ; first parameter
mov eax, [0x007B32F0] ; DynamicVectorClass<FootClass>::EntryCount
xor edi, edi
cmp eax, ebp
jle 0x00619F9F ; jump out, there are no units on the map
mov ebx, [esp+1C4h] ; Fetch owning house from trigger data

; Begin of loop
.AM_Loop_MainBody
mov ecx, [0x007B32E4] ; DynamicVectorClass<FootClass>::Vector
mov esi, [ecx+edi*4]
cmp [esi+28h], ebp ; Check that ObjectClass.Strength is above 0 (ebp is 0 here)
jle .AM_Loop_NextIteration
mov al, [esi+35h] ; ObjectClass.IsActive
test al, al
jz .AM_Loop_NextIteration
mov al, [esi+2Ch] ; ObjectClass.IsDown
test al, al
jz .AM_Loop_NextIteration
mov al, [esi+2Fh] ; ObjectClass.IsInLimbo
test al, al
jnz .AM_Loop_NextIteration
cmp ebx, [esi+0ECh] ; TechnoClass.House
jz .AM_Loop_NextIteration
mov eax, [esi]
push edx
mov ecx, esi
call [eax+158h] ; TechnoClass.Assign_Mission

.AM_Loop_NextIteration
mov eax, [0x007B32F0] ; DynamicVectorClass<FootClass>::EntryCount
inc edi
cmp edi, eax
jl .AM_Loop_MainBody
jmp 0x00619F9F ; success

0 comments on commit 17d8b0f

Please sign in to comment.