Skip to content

Commit

Permalink
Add trigger action for forming a one-way alliance
Browse files Browse the repository at this point in the history
  • Loading branch information
Rampastring committed Dec 1, 2024
1 parent a43a285 commit 9a6440c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/spawner/spawner.asm
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,11 @@ _Init_Game_Check_Spawn_Arg_No_Intro:

_HouseClass__Make_Ally_STFU_when_Allying_In_Loading_Screen_Spawner:
cmp byte [IsDoingAlliancesSpawner], 1
jz 0x004BDE68
test al, al ; hooked by patch
jz 0x4BDE68
je 0x004BDE68
cmp byte [AlliesAllowed], 0
je 0x004BDE68
test al, al ; fix code that our jump-to-hook destroyed
jz 0x004BDE68
jmp 0x004BDDB9

_SessionClass__Free_Scenario_Descriptions_RETN_Patch:
Expand Down
23 changes: 23 additions & 0 deletions src/trigger_actions_extended.asm
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ hack 0x0061913B ; Extend trigger action jump table
jz .Remove_Attached_Objects_Action
cmp edx, 115
jz .Assign_Mission_To_All_Units_Action
cmp edx, 116
jz .Make_Ally_One_Sided_Action

cmp edx, 68h
ja 0x0061A9C5 ; default
Expand Down Expand Up @@ -419,3 +421,24 @@ hack 0x0061913B ; Extend trigger action jump table
jl .AM_Loop_MainBody
jmp 0x00619F9F ; success



; ***********************************
; *** Make Ally (One-Sided) ***
; ***********************************
.Make_Ally_One_Sided_Action:
mov ecx, [esi+40h] ; Fetch first parameter
cmp ecx, 0FFFFFFFFh
jz 0x00619F9F ; success
call 0x004C4730 ; HouseClass::As_Pointer(HousesType)
mov ecx, [esp+1C4h] ; Fetch owning house from trigger data
push eax
; We need to increment ScenarioInit to allow houses to ally even if they would be the "last enemies" to each other in multiplayer
mov edi, [ScenarioInit]
inc edi
mov [ScenarioInit], edi
call 0x004BDB50 ; HouseClass::Make_Ally(HouseClass *)
mov edi, [ScenarioInit]
dec edi
mov [ScenarioInit], edi
jmp 0x00619F9F ; success

0 comments on commit 9a6440c

Please sign in to comment.