Skip to content

Commit 9a6440c

Browse files
committed
Add trigger action for forming a one-way alliance
1 parent a43a285 commit 9a6440c

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/spawner/spawner.asm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,11 @@ _Init_Game_Check_Spawn_Arg_No_Intro:
601601

602602
_HouseClass__Make_Ally_STFU_when_Allying_In_Loading_Screen_Spawner:
603603
cmp byte [IsDoingAlliancesSpawner], 1
604-
jz 0x004BDE68
605-
test al, al ; hooked by patch
606-
jz 0x4BDE68
604+
je 0x004BDE68
605+
cmp byte [AlliesAllowed], 0
606+
je 0x004BDE68
607+
test al, al ; fix code that our jump-to-hook destroyed
608+
jz 0x004BDE68
607609
jmp 0x004BDDB9
608610

609611
_SessionClass__Free_Scenario_Descriptions_RETN_Patch:

src/trigger_actions_extended.asm

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ hack 0x0061913B ; Extend trigger action jump table
161161
jz .Remove_Attached_Objects_Action
162162
cmp edx, 115
163163
jz .Assign_Mission_To_All_Units_Action
164+
cmp edx, 116
165+
jz .Make_Ally_One_Sided_Action
164166

165167
cmp edx, 68h
166168
ja 0x0061A9C5 ; default
@@ -419,3 +421,24 @@ hack 0x0061913B ; Extend trigger action jump table
419421
jl .AM_Loop_MainBody
420422
jmp 0x00619F9F ; success
421423

424+
425+
426+
; ***********************************
427+
; *** Make Ally (One-Sided) ***
428+
; ***********************************
429+
.Make_Ally_One_Sided_Action:
430+
mov ecx, [esi+40h] ; Fetch first parameter
431+
cmp ecx, 0FFFFFFFFh
432+
jz 0x00619F9F ; success
433+
call 0x004C4730 ; HouseClass::As_Pointer(HousesType)
434+
mov ecx, [esp+1C4h] ; Fetch owning house from trigger data
435+
push eax
436+
; We need to increment ScenarioInit to allow houses to ally even if they would be the "last enemies" to each other in multiplayer
437+
mov edi, [ScenarioInit]
438+
inc edi
439+
mov [ScenarioInit], edi
440+
call 0x004BDB50 ; HouseClass::Make_Ally(HouseClass *)
441+
mov edi, [ScenarioInit]
442+
dec edi
443+
mov [ScenarioInit], edi
444+
jmp 0x00619F9F ; success

0 commit comments

Comments
 (0)