add dynamic switching in EnemyDamageSync
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
.meta hide_from_patches_menu
|
||||
.meta name="DMC"
|
||||
.meta description="Mitigates effects\nof enemy health\ndesync"
|
||||
.meta client_flag="0x2000000000000000"
|
||||
|
||||
.versions 3OJ2 3OJ3 3OJ4 3OJ5 3OE0 3OE1 3OE2 3OP0
|
||||
|
||||
@@ -18,11 +19,18 @@ start:
|
||||
|
||||
|
||||
|
||||
.data <VERS 0x801E40C4 0x801E4648 0x801E481C 0x801E4594 0x801E4528 0x801E4528 0x801E45E8 0x801E4C24>
|
||||
.data 8
|
||||
cmpwi r0, 0
|
||||
beq +0x0C
|
||||
|
||||
|
||||
|
||||
# Don't allow 6x0A to set total_damage; we'll do it with 6xE4 instead
|
||||
.data <VERS 0x800F6064 0x800F6368 0x800F6594 0x800F6490 0x800F6308 0x800F6308 0x800F64A0 0x800F6468>
|
||||
.data 4
|
||||
.address <VERS 0x800F6064 0x800F6368 0x800F6594 0x800F6490 0x800F6308 0x800F6308 0x800F64A0 0x800F6468>
|
||||
nop
|
||||
bl set_enemy_total_damage_hook
|
||||
|
||||
|
||||
|
||||
@@ -129,8 +137,11 @@ start:
|
||||
.deltaof code_start, code_end
|
||||
.address 0x800041C0
|
||||
code_start:
|
||||
|
||||
handle_6xE4: # [std] (G_IncrementEnemyDamage_Extension_6xE4* cmd @ r3) -> void
|
||||
lwz r12, [r13 - <VERS 0x50A0 0x5098 0x5078 0x5078 0x5088 0x5088 0x5068 0x5028>]
|
||||
andi. r12, r12, 0x0080
|
||||
beqlr
|
||||
|
||||
mflr r0
|
||||
stw [r1 + 4], r0
|
||||
stwu [r1 - 0x20], r1
|
||||
@@ -224,6 +235,11 @@ on_TObjectV8047c128_add_hp_with_sync: # [std] (TObjectV8047c128* ene @ r3, int1
|
||||
on_TObjectV8047c128_subtract_hp_with_sync: # [std] (TObjectV8047c128* ene @ r3, int16_t amount @ r4) -> void
|
||||
li r5, 0
|
||||
on_add_or_subtract_hp: # [std] (TObjectV8047c128* ene @ r3, int16_t amount @ r4, bool is_add @ r5) -> void
|
||||
|
||||
lwz r12, [r13 - <VERS 0x50A0 0x5098 0x5078 0x5078 0x5088 0x5088 0x5068 0x5028>]
|
||||
andi. r12, r12, 0x0080
|
||||
beq on_add_or_subtract_hp_skip_send
|
||||
|
||||
lhz r0, [r3 + 0x1C]
|
||||
cmplwi r0, 0x1000
|
||||
blt on_add_or_subtract_hp_skip_send
|
||||
@@ -293,6 +309,15 @@ on_add_or_subtract_hp_tail_call_subtract_hp:
|
||||
|
||||
|
||||
|
||||
set_enemy_total_damage_hook:
|
||||
lwz r12, [r13 - <VERS 0x50A0 0x5098 0x5078 0x5078 0x5088 0x5088 0x5068 0x5028>]
|
||||
andi. r12, r12, 0x0080
|
||||
bnelr
|
||||
sth [r1 + 0x0E], r3
|
||||
blr
|
||||
|
||||
|
||||
|
||||
# TODO: Remove this when no longer necessary
|
||||
debug_hook1:
|
||||
mflr r0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
.meta hide_from_patches_menu
|
||||
.meta name="DMC"
|
||||
.meta description="Mitigates effects\nof enemy health\ndesync"
|
||||
.meta client_flag="0x2000000000000000"
|
||||
|
||||
.versions 4OJB 4OJD 4OJU 4OED 4OEU 4OPD 4OPU
|
||||
|
||||
@@ -16,6 +17,30 @@ write_call_to_code_multi:
|
||||
start:
|
||||
call write_static_patches
|
||||
call write_incr_hp_with_sync
|
||||
call write_6x0A_patch
|
||||
ret
|
||||
|
||||
|
||||
|
||||
write_6x0A_patch:
|
||||
push 5
|
||||
push <VERS 0x002B3B55 0x002B4625 0x002B5BB5 0x002B56C5 0x002B58A5 0x002B56E5 0x002B59B5>
|
||||
push 1
|
||||
call +4
|
||||
.deltaof on_6x0A_patch_start, on_6x0A_patch_end
|
||||
pop eax
|
||||
push dword [eax]
|
||||
call on_6x0A_patch_end
|
||||
|
||||
on_6x0A_patch_start: # (TObjectV004434c8* this @ eax, int16_t amount @ cx) -> bool @ eax
|
||||
test byte [0x006354B8], 0x80
|
||||
jnz on_6x0A_patch_skip_write
|
||||
mov [esp + 0x16], ax
|
||||
on_6x0A_patch_skip_write:
|
||||
ret
|
||||
|
||||
on_6x0A_patch_end:
|
||||
call write_call_to_code_multi
|
||||
ret
|
||||
|
||||
|
||||
@@ -65,6 +90,9 @@ on_add_or_subtract_hp_start: # (TObjectV004434c8* this @ eax, int16_t amount @
|
||||
push eax
|
||||
push ecx
|
||||
push ebx
|
||||
|
||||
test byte [0x006354B8], 0x80
|
||||
jz on_add_or_subtract_hp_skip_send
|
||||
movzx edx, word [eax + 0x1C] # ene->entity_id
|
||||
cmp edx, 0x1000
|
||||
jl on_add_or_subtract_hp_skip_send
|
||||
@@ -120,14 +148,12 @@ on_add_or_subtract_hp_end:
|
||||
write_static_patches:
|
||||
.include WriteCodeBlocksXB
|
||||
|
||||
# Don't let 6x0A handler overwrite total_damage
|
||||
.data <VERS 0x002B3B55 0x002B4625 0x002B5BB5 0x002B56C5 0x002B58A5 0x002B56E5 0x002B59B5>
|
||||
.data 5
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
.data <VERS 0x002DB7A0 0x002DC370 0x002DDC30 0x002DD700 0x002DDC00 0x002DD730 0x002DDC80>
|
||||
.data 9
|
||||
flag_check_start:
|
||||
cmp dword [0x006354B8], 0
|
||||
je +0x38
|
||||
flag_check_end:
|
||||
|
||||
.data <VERS 0x00537180 0x00537800 0x0053EB20 0x0053BFA0 0x0053B840 0x0053BFA0 0x0053C340>
|
||||
.data 8
|
||||
@@ -143,6 +169,9 @@ handle_6xE4: # [std] (G_6xE4* cmd @ [esp + 4]) -> void
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
|
||||
test byte [0x006354B8], 0x80
|
||||
jz handle_6xE4_return
|
||||
mov ebx, [esp + 0x10] # cmd
|
||||
movzx eax, word [ebx + 2]
|
||||
cmp eax, 0x1000
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
.meta hide_from_patches_menu
|
||||
.meta name="DMC"
|
||||
.meta description="Mitigates effects\nof enemy health\ndesync"
|
||||
.meta client_flag="0x2000000000000000"
|
||||
|
||||
entry_ptr:
|
||||
reloc0:
|
||||
@@ -26,6 +27,9 @@ handle_6xE4_start: # (G_6xE4* cmd @ [esp + 4]) -> void
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
|
||||
test byte [0x00AAB27C], 0x80
|
||||
jz handle_6xE4_return
|
||||
mov ebx, [esp + 0x10] # cmd
|
||||
movzx eax, word [ebx + 2]
|
||||
cmp eax, 0x1000
|
||||
@@ -135,6 +139,8 @@ handle_6xE4_end:
|
||||
call on_add_or_subtract_hp_end
|
||||
|
||||
on_add_or_subtract_hp_start: # (TObjectV00b441c0* this @ ecx, int16_t amount @ [esp + 4]) -> bool @ eax
|
||||
test byte [0x00AAB27C], 0x80
|
||||
jz on_add_or_subtract_hp_skip_send
|
||||
movzx eax, word [ecx + 0x1C] # ene->entity_id
|
||||
cmp eax, 0x1000
|
||||
jl on_add_or_subtract_hp_skip_send
|
||||
@@ -183,9 +189,24 @@ on_add_or_subtract_hp_end:
|
||||
|
||||
|
||||
|
||||
# Don't let 6x0A handler overwrite total_damage
|
||||
mov byte [0x0078781F], 0x90
|
||||
mov dword [0x00787820], 0x90909090
|
||||
push 5
|
||||
push 0x0078781F
|
||||
push 1
|
||||
call +4
|
||||
.deltaof on_6x0A_patch_start, on_6x0A_patch_end
|
||||
pop eax
|
||||
push dword [eax]
|
||||
call on_6x0A_patch_end
|
||||
|
||||
on_6x0A_patch_start: # (TObjectV00b441c0* this @ ecx, int16_t amount @ [esp + 4]) -> bool @ eax
|
||||
test byte [0x00AAB27C], 0x80
|
||||
jz on_6x0A_patch_skip_write
|
||||
mov [esp + 0x0A], cx
|
||||
on_6x0A_patch_skip_write:
|
||||
ret
|
||||
|
||||
on_6x0A_patch_end:
|
||||
call write_call_to_code_multi
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user