From cc08b9adcf2528558ae249a4c1a537a92085ff7f Mon Sep 17 00:00:00 2001 From: ricardoofnl Date: Sun, 30 Aug 2026 12:51:22 +0700 Subject: [PATCH] [saco] Implement/match `CEventDamage__AffectsPed_Hook` --- saco/game/hooks.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/saco/game/hooks.cpp b/saco/game/hooks.cpp index 0aa7fc1..cb9dcbc 100644 --- a/saco/game/hooks.cpp +++ b/saco/game/hooks.cpp @@ -1107,9 +1107,40 @@ exitFn: //----------------------------------------------------------- +DWORD dwEventDamageThis; +DWORD dwEventDamagePed; + NUDE CEventDamage__AffectsPed_Hook() { - // TODO: CEventDamage__AffectsPed_Hook + __asm + { + mov dwEventDamageThis, ecx + mov eax, [esp+4] + mov dwEventDamagePed, eax + pushad + cmp pNetGame, 0 + jz do_affects_ped + call GamePool_FindPlayerPed + cmp dwEventDamagePed, eax + jnz do_affects_ped + mov eax, pbyteCurrentPlayer + movzx ecx, byte ptr [eax] + test ecx, ecx + jz do_affects_ped + popad + + // inside a remote player context: always report the event as affecting the ped + xor eax, eax + mov al, 1 + retn 4 + do_affects_ped: + popad + sub esp, 0xC + push esi + mov esi, ecx + mov eax, 0x4B35A6 // CEventDamage::AffectsPed + 6 + jmp eax + } } //-----------------------------------------------------------