Hey guys,
This is actually easy to
to restructure a
CTakeDamageInfo object. As you can see, there's no virtual functions so you won't have to sigscan for the constructor as you doesn't have to set the dispatch table. All you have to do is to restructure the members:
Syntax: Select all
Vector m_vecDamageForce;
Vector m_vecDamagePosition;
Vector m_vecReportedPosition; // Position players are told damage is coming from
EHANDLE m_hInflictor;
EHANDLE m_hAttacker;
EHANDLE m_hWeapon;
float m_flDamage;
float m_flMaxDamage;
float m_flBaseDamage; // The damage amount before skill leve adjustments are made. Used to get uniform damage forces.
int m_bitsDamageType;
int m_iDamageCustom;
int m_iDamageStats;
int m_iAmmoType; // AmmoType of the weapon used to cause this damage, if any
float m_flRadius;
// CS:GO
int m_iDamagedOtherPlayers;
int m_iObjectsPenetrated;
uint32 m_uiBulletID;
uint8 m_uiRecoilIndex;
According to that your memory need to looks like:
Syntax: Select all
0 m_vecDamageForce.x
4 m_vecDamageForce.y
8 m_vecDamageForce.z
12 m_vecDamagePosition.x
16 m_vecDamagePosition.y
20 m_vecDamagePosition.z
24 m_vecReportedPosition.x
28 m_vecReportedPosition.y
32 m_vecReportedPosition.z
36 m_hInflictor
40 m_hAttacker
44 m_hWeapon
48 m_flDamage
52 m_flMaxDamage
56 m_flBaseDamage
60 m_bitsDamageType
64 m_iDamageCustom
68 m_iDamageStats
72 m_iAmmoType
76 m_flRadius
80 m_iDamagedOtherPlayers
84 m_iObjectsPenetrated
88 m_uiBulletID
92 m_uiRecoilIndex
Where you need to allocate a pointer of 96 bytes (even tho uint8 is 1 byte long it need to be aligned so m_uiRecoilIndex is from 92 to 96). Also, note that OnTakeDamage is actually a "callback" and should not be called directly ? you need to call
CBaseEntity::TakeDamage which will take care to call the proper callback for you (depending of the given entity by using the power of its dispatch table :) ). So, something like this should works:
Syntax: Select all
# Allocate our pointer...
damageinfo = Binutils.AllocateMemory(96)
# Set m_flDamage...
Binutils.SetLocInt(damageinfo + 48, 100)
# Call CBaseEntity::TakeDamage(<entity pointer>, damageinfo)
# [IMPORTANT] Free the memory used...
Binutils.DeallocatePointer(damageinfo)
NOTE: This is only based on the code, I didn't test anything, will do as soon as I can if nobody got that to work.
Good luck,
L'In20Cible