Jump to content

» «

[C++|ASM] Alter damage received

  • This topic is locked This topic is locked
32 replies to this topic
  • FaTony

    C++ guy

  • Members
  • Joined: 12 Aug 2011


Posted 02 April 2012 - 03:49 AM Edited by FaTony, 03 April 2012 - 01:57 AM.

EDIT: Ok. After quite a few assembly related articles I managed to do this:
const DWORD GetPlayerPedFuncAddress = 0x008788D0;

typedef void *(__cdecl *GetPlayerPedFunc)(int);

GetPlayerPedFunc GetPlayerPed;

void InstallHooks(void)
GetPlayerPed = (GetPlayerPedFunc)(GetPlayerPedFuncAddress + dwLoadOffset);
//Other code

__declspec(naked) int __stdcall PedDamageHook(void *attacker, void *victim)
 // Function prolog
 // Create new stack frame
 push ebp
 mov  ebp, esp

 // Save relevant registers
 // Save ecx
 push ecx

 // Call C++ function
 // Push damage
 lea  eax, [ecx + 4h]
 push eax
 // Push attacker
 push [ebp + 10h]
 // Push victim
 push [ebp + 14h]
 // Call function
 call OnPedDamage
 // Clean stack
 add  esp, 12

 // Restore relevant registers
 // Restore ecx
 pop  ecx

 // Function epilog
 // Restore previous stack frame
 mov  esp, ebp
 pop  ebp

 // Code from '0x00ABB170', 8 ovewritten bytes
 sub  esp, 10h
 push ebp
 mov  ebp, [esp+1Ch]
 jmp  jmpaddress

void OnPedDamage(const void *victim, const void *attacker, float &damage)
void *player = GetPlayerPed(0);
if (victim == player)
 damage *= 0.1f;
else if (attacker == player)
 damage *= 10.0f;

The problem is, it looks like all peds have 2 ped classes associated with them. One is the "old school ped" that is used during gun fights and another is "Euphoria ped" with is used with physics and ragdolls. Old school peds have addresses in the range of 5xxxxxx. Euphoria peds have addresses in the range of 6xxxxxx. GetPlayerPed returns old school ped. So, for example, when I throw a molotov and get caught by it's fire, attacker will be my old school ped and victim will be my Euphoria ped. As a result, I will get 10x damage. That's no good.

Can you help me find a function that returns Euphoria peds?

  • Bucho

    Player Hater

  • Joined: 18 Apr 2015
  • Japan


Posted 20 April 2015 - 11:11 AM

I saw LMS blog^^



mov r8d,4
mov edx,3
mov ecx,3
call GTA5.exe+57C5F4
add rsp,12
mov ecx,100
call sleep
add rsp,4
jmp mycode

  • Silent

    Chief Vision™ Alterer

  • GTA Mods Staff
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [Modding] 2016
    Contribution Award [Mods]
    Best Script/Plugin 2014 [SilentPatch]
    Most Respected 2014
    Most Helpful [Mods] 2014
    Most Helpful [GTA] 2013
    Most Helpful [Mods] 2013
    Most Talented [Modding] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Best Vehicle 2013 [III Aircraft]
    Most Helpful [Mods] 2012
    Modder of the Year 2012


Posted 20 April 2015 - 11:21 AM

Nice bump. And wtf is this assembly code for?

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users