CBasePlayer::OnTakeDamage
0x007bcdc0 · 3539 bytes · __thiscall
_ZN11CBasePlayer12OnTakeDamageERK15CTakeDamageInfo
Decompiled
undefined (2 params)
/* CBasePlayer::OnTakeDamage(CTakeDamageInfo const&) */
int __thiscall CBasePlayer::OnTakeDamage(CBasePlayer *this,CTakeDamageInfo *param_1)
{
int iVar1;
bool bVar2;
bool bVar3;
char cVar4;
CBasePlayer *pCVar5;
undefined4 uVar6;
undefined4 uVar7;
int iVar8;
uint uVar9;
int iVar10;
undefined *puVar11;
uint uVar12;
CBaseEntity *pCVar13;
int iVar14;
int in_GS_OFFSET;
longdouble lVar15;
float fVar16;
float fVar17;
float fVar18;
double dVar19;
CBasePlayer *pCVar20;
double local_1ec;
double local_1e4;
float local_1d4;
undefined4 local_1c0;
undefined4 local_1bc;
undefined4 local_1b8;
undefined4 local_1b4;
undefined4 local_1b0;
undefined4 local_1ac;
undefined4 local_1a8;
undefined4 local_1a4;
undefined4 local_1a0;
undefined4 local_19c;
undefined4 local_198;
undefined4 local_194;
uint local_190;
uint local_18c;
undefined4 local_188;
float local_184;
undefined4 local_180;
undefined4 local_17c;
uint local_178;
undefined4 local_174;
undefined4 local_170;
undefined4 local_16c;
undefined4 local_168;
undefined4 local_164;
char local_160 [64];
char local_120 [256];
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
local_1c0 = *(undefined4 *)param_1;
iVar10 = *(int *)(this + 0x100);
uVar12 = *(uint *)(param_1 + 0x48);
local_1bc = *(undefined4 *)(param_1 + 4);
local_1b8 = *(undefined4 *)(param_1 + 8);
local_1b4 = *(undefined4 *)(param_1 + 0xc);
local_1b0 = *(undefined4 *)(param_1 + 0x10);
local_1ac = *(undefined4 *)(param_1 + 0x14);
local_1a8 = *(undefined4 *)(param_1 + 0x18);
local_1a4 = *(undefined4 *)(param_1 + 0x1c);
local_1a0 = *(undefined4 *)(param_1 + 0x20);
local_19c = *(undefined4 *)(param_1 + 0x24);
local_198 = *(undefined4 *)(param_1 + 0x28);
local_194 = *(undefined4 *)(param_1 + 0x2c);
local_190 = *(uint *)(param_1 + 0x30);
local_184 = *(float *)(param_1 + 0x3c);
local_180 = *(undefined4 *)(param_1 + 0x40);
local_18c = *(uint *)(param_1 + 0x34);
local_17c = *(undefined4 *)(param_1 + 0x44);
local_168 = *(undefined4 *)(param_1 + 0x58);
local_188 = *(undefined4 *)(param_1 + 0x38);
local_174 = *(undefined4 *)(param_1 + 0x4c);
local_170 = *(undefined4 *)(param_1 + 0x50);
local_16c = *(undefined4 *)(param_1 + 0x54);
local_164 = *(undefined4 *)(param_1 + 0x5c);
pCVar20 = this;
local_178 = uVar12;
pCVar5 = (CBasePlayer *)(**(code **)(*(int *)this + 0x500))(this);
if ((((pCVar5 == (CBasePlayer *)0x0) ||
(cVar4 = (**(code **)(*(int *)pCVar5 + 0x30))(pCVar5,&local_1c0), pCVar20 = pCVar5,
cVar4 != '\0')) &&
((pCVar5 = pCVar20, cVar4 = IsInCommentaryMode(), cVar4 == '\0' ||
(pCVar5 = this, cVar4 = ShouldTakeDamageInCommentaryMode(this,(CTakeDamageInfo *)&local_1c0),
cVar4 != '\0')))) && ((*(uint *)(this + 0x150) & 0x4000) == 0)) {
if (*(int *)(buddha._28_4_ + 0x30) != 0) {
pCVar5 = (CBasePlayer *)CBaseEntity::GetTeamNumber((CBaseEntity *)this);
cVar4 = IsASurvivorTeam((int)pCVar5);
if ((cVar4 != '\0') && ((float)*(int *)(this + 0x100) - local_184 <= 0.0)) {
if (*(int *)(this + 0x100) != 1) {
pCVar5 = this;
(**(code **)(*(int *)this + 0x214))(this,this + 0x100);
*(undefined4 *)(this + 0x100) = 1;
iVar8 = 0;
goto LAB_007bd322;
}
goto LAB_007bd320;
}
}
if (local_184 != 0.0) {
local_1d4 = 1.0;
if (*(int *)(old_armor._28_4_ + 0x30) != 0) {
local_1d4 = 0.5;
}
if (((local_178 & 0x40) != 0) &&
(cVar4 = (**(code **)(*(int *)g_pGameRules + 0x88))(g_pGameRules), cVar4 != '\0')) {
local_1d4 = local_1d4 + local_1d4;
}
pCVar5 = this;
cVar4 = (**(code **)(*(int *)this + 300))(this);
if (cVar4 != '\0') {
local_1e4._0_4_ = 0;
if (((local_18c != 0xffffffff) &&
(puVar11 = g_pEntityList + (local_18c & 0xfff) * 0x10,
puVar11 != (undefined *)0xfffffffc)) && (*(uint *)(puVar11 + 8) == local_18c >> 0xc)) {
local_1e4._0_4_ = *(undefined4 *)(puVar11 + 4);
}
pCVar5 = g_pGameRules;
cVar4 = (**(code **)(*(int *)g_pGameRules + 0xf0))(g_pGameRules,this,local_1e4._0_4_);
if (cVar4 != '\0') {
if ((*(int *)(player_debug_print_damage._28_4_ + 0x30) != 0) && (0.0 < local_184)) {
pCVar13 = (CBaseEntity *)0x0;
CTakeDamageInfo::DebugGetDamageTypeString(local_178,local_160,0x200);
if ((local_190 != 0xffffffff) &&
((puVar11 = g_pEntityList + (local_190 & 0xfff) * 0x10,
puVar11 != (undefined *)0xfffffffc && (*(uint *)(puVar11 + 8) == local_190 >> 0xc)))
) {
pCVar13 = *(CBaseEntity **)(puVar11 + 4);
}
uVar6 = CBaseEntity::GetDebugName(pCVar13);
dVar19 = (double)local_184;
if (((byte)this[0x14d] & 8) == 0) {
local_1e4 = (double)*(float *)(this + 0x2e8);
LAB_007bd0ba:
local_1ec = (double)*(float *)(this + 0x2e4);
}
else {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
local_1e4 = (double)*(float *)(this + 0x2e8);
if (((byte)this[0x14d] & 8) == 0) goto LAB_007bd0ba;
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
local_1ec = (double)*(float *)(this + 0x2e4);
if (((byte)this[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
}
}
fVar18 = *(float *)(this + 0x2e0);
uVar7 = CBaseEntity::GetDebugName((CBaseEntity *)this);
V_snprintf(local_120,0x100,
"%f: Player %s at [%0.2f %0.2f %0.2f] took %f damage from %s, type %s\n",
(double)*(float *)(gpGlobals + 0xc),uVar7,(double)fVar18,local_1ec,local_1e4,
dVar19,uVar6,local_160);
Msg(local_120);
}
*(int *)(this + 0x1d38) = (int)local_184;
iVar8 = *(int *)(this + 0x1f70);
fVar18 = local_184;
if ((iVar8 != 0) && ((local_178 & 0x64020) == 0)) {
fVar18 = local_184 * 0.2;
fVar16 = (local_184 - fVar18) * local_1d4;
if ((*(int *)(old_armor._28_4_ + 0x30) == 0) && (fVar16 <= 1.0)) {
fVar16 = 1.0;
}
fVar17 = (float)iVar8;
if (fVar16 <= fVar17) {
*(float *)(this + 0x1d50) = fVar16;
if (iVar8 != iVar8 - (int)fVar16) {
(**(code **)(*(int *)this + 0x78c))(this,this + 0x1f70);
*(int *)(this + 0x1f70) = iVar8 - (int)fVar16;
}
}
else {
fVar18 = local_184 - fVar17 / local_1d4;
*(float *)(this + 0x1d50) = fVar17;
(**(code **)(*(int *)this + 0x78c))(this,this + 0x1f70);
*(undefined4 *)(this + 0x1f70) = 0;
}
}
local_184 = fVar18;
pCVar5 = this;
iVar8 = CBaseCombatCharacter::OnTakeDamage
((CBaseCombatCharacter *)this,(CTakeDamageInfo *)&local_1c0);
if (iVar8 != 0) {
if ((((local_190 != 0xffffffff) &&
(puVar11 = g_pEntityList + (local_190 & 0xfff) * 0x10,
puVar11 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar11 + 8) == local_190 >> 0xc)) &&
((pCVar13 = *(CBaseEntity **)(puVar11 + 4), pCVar13 != (CBaseEntity *)0x0 &&
(*(int *)(pCVar13 + 0x30) != 0)))) {
if (((byte)pCVar13[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition(pCVar13);
}
*(undefined4 *)(this + 0x1d40) = *(undefined4 *)(pCVar13 + 0x2e0);
*(undefined4 *)(this + 0x1d44) = *(undefined4 *)(pCVar13 + 0x2e4);
*(undefined4 *)(this + 0x1d48) = *(undefined4 *)(pCVar13 + 0x2e8);
}
iVar14 = 0;
*(float *)(this + 0x1d4c) = (float)(int)local_184 + *(float *)(this + 0x1d4c);
do {
uVar9 = 0x8000 << ((byte)iVar14 & 0x1f);
if (((local_178 & uVar9) != 0) &&
(cVar4 = (**(code **)(*(int *)g_pGameRules + 0x44))(g_pGameRules,uVar9),
cVar4 != '\0')) {
this[iVar14 + 0x1d9c] = (CBasePlayer)0x0;
}
iVar14 = iVar14 + 1;
} while (iVar14 != 8);
(**(code **)(*(int *)this + 0x59c))(this,local_184,uVar12);
iVar14 = *(int *)(this + 0x100);
iVar1 = *(int *)(this + 0x1d38);
bVar3 = true;
*(undefined4 *)(this + 0x1d58) = 0xffffffff;
bVar2 = 0x19 < iVar1;
*(uint *)(this + 0x1d54) = *(uint *)(this + 0x1d54) | uVar12;
while ((((iVar14 < 0x4c && 4 < iVar1 ||
(cVar4 = (**(code **)(*(int *)g_pGameRules + 0x44))(g_pGameRules,uVar12),
cVar4 != '\0')) && (uVar12 != 0)) && (bVar3))) {
bVar3 = false;
if ((uVar12 & 0x80) != 0) {
if (bVar2) {
SetSuitUpdate(this,"!HEV_DMG4",0,0x1e);
}
uVar12 = uVar12 & 0xffffff7f;
bVar3 = true;
}
if ((uVar12 & 0x21) != 0) {
if (bVar2) {
SetSuitUpdate(this,"!HEV_DMG5",0,0x1e);
}
else {
SetSuitUpdate(this,"!HEV_DMG4",0,0x1e);
}
uVar12 = uVar12 & 0xffffffde;
bVar3 = true;
}
if ((uVar12 & 2) != 0) {
if (5 < *(int *)(this + 0x1d38)) {
SetSuitUpdate(this,"!HEV_DMG6",0,0x1e);
}
uVar12 = uVar12 & 0xfffffffd;
bVar3 = true;
}
if ((uVar12 & 4) != 0) {
if (bVar2) {
SetSuitUpdate(this,"!HEV_DMG1",0,0x1e);
}
else {
SetSuitUpdate(this,"!HEV_DMG0",0,0x1e);
}
uVar12 = uVar12 & 0xfffffffb;
bVar3 = true;
}
if ((uVar12 & 0x200) != 0) {
if (bVar2) {
SetSuitUpdate(this,"!HEV_DMG2",0,0x3c);
}
uVar12 = uVar12 & 0xfffffdff;
bVar3 = true;
}
if ((uVar12 & 0x28000) != 0) {
if ((uVar12 & 0x20000) != 0) {
*(int *)(this + 0x1d94) = (int)((float)*(int *)(this + 0x1d94) + local_184);
uVar6 = *(undefined4 *)(gpGlobals + 0xc);
this[0x1d9e] = (CBasePlayer)0x0;
*(undefined4 *)(this + 0x1d88) = uVar6;
}
uVar12 = uVar12 & 0xfffd7fff;
SetSuitUpdate(this,"!HEV_DMG3",0,0x3c);
bVar3 = true;
}
if ((uVar12 & 0x100000) != 0) {
uVar12 = uVar12 & 0xffefffff;
SetSuitUpdate(this,"!HEV_DET1",0,0x3c);
bVar3 = true;
}
if ((uVar12 & 0x10000) != 0) {
uVar12 = uVar12 & 0xfffeffff;
SetSuitUpdate(this,"!HEV_DET0",0,0x3c);
bVar3 = true;
}
if ((uVar12 & 0x40000) != 0) {
uVar12 = uVar12 & 0xfffbffff;
SetSuitUpdate(this,"!HEV_DET2",0,0x3c);
bVar3 = true;
}
if ((uVar12 & 0x100) != 0) {
uVar12 = uVar12 & 0xfffffeff;
bVar3 = true;
}
}
if ((((*(int *)(hl2_episodic._28_4_ + 0x30) == 0) || (local_18c == 0xffffffff)) ||
((puVar11 = g_pEntityList + (local_18c & 0xfff) * 0x10,
puVar11 == (undefined *)0xfffffffc ||
((*(uint *)(puVar11 + 8) != local_18c >> 0xc || (*(int *)(puVar11 + 4) == 0))))))
|| (cVar4 = (**(code **)(*(int *)this + 0x3c8))(this,*(int *)(puVar11 + 4)),
cVar4 != '\0')) {
fVar18 = -2.0;
}
else {
fVar18 = -10.0;
if (local_184 <= 10.0) {
lVar15 = (longdouble)RandomFloat(0xc0a00000,0xc0e00000);
fVar18 = (float)lVar15;
}
}
if (fVar18 != *(float *)(this + 0x1ab0)) {
(**(code **)(*(int *)(this + 0x1a40) + 4))(this + 0x1a40,this + 0x1ab0);
*(float *)(this + 0x1ab0) = fVar18;
}
fVar18 = (float)iVar10;
if (iVar14 < 0x4c && 4 < iVar1) {
if ((bVar2) && (75.0 <= fVar18)) {
SetSuitUpdate(this,"!HEV_MED1",0,0x708);
SetSuitUpdate(this,"!HEV_HEAL7",0,0x708);
}
if ((fVar18 < 75.0) && (iVar14 < 0x1e)) {
if (*(int *)(this + 0x100) < 6) {
SetSuitUpdate(this,"!HEV_HLTH3",0,600);
}
else if (*(int *)(this + 0x100) < 0x14) {
SetSuitUpdate(this,"!HEV_HLTH2",0,600);
}
iVar10 = (**(code **)(*(int *)random_valve + 8))(random_valve,0,3);
if ((iVar10 == 0) && (fVar18 < 50.0)) {
SetSuitUpdate(this,"!HEV_DMG7",0,300);
}
}
}
pCVar5 = g_pGameRules;
cVar4 = (**(code **)(*(int *)g_pGameRules + 0x44))(g_pGameRules,local_178);
if ((cVar4 != '\0') && (fVar18 < 75.0)) {
if (50.0 <= fVar18) {
pCVar5 = this;
SetSuitUpdate(this,"!HEV_HLTH1",0,600);
}
else {
pCVar5 = random_valve;
iVar10 = (**(code **)(*(int *)random_valve + 8))(random_valve,0,3);
if (iVar10 == 0) {
pCVar5 = this;
SetSuitUpdate(this,"!HEV_DMG7",0,300);
}
}
}
if ((uVar12 & 0x40) != 0) {
pCVar5 = this;
(**(code **)(*(int *)this + 0x5a0))(this,&local_1c0);
}
if (*(int *)(this + 0x100) < 100) {
*(undefined4 *)(this + 0x1d3c) = *(undefined4 *)(gpGlobals + 0xc);
}
goto LAB_007bd322;
}
}
}
}
}
LAB_007bd320:
iVar8 = 0;
LAB_007bd322:
if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
return iVar8;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail(pCVar5);
}
SourceMod gamedata
paste intoaddons/sourcemod/gamedata/<your_plugin>.txt
used as the SourceMod key — change to fit your plugin's convention
SourceMod library name (server / engine / matchmaking)
Just a Signatures{} block, ready to drop into a gamedata
file. Wire it up in your plugin however you like - SDKCall, DHooks,
raw memory ops, or anything else.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.