CCSPlayer::OnTakeDamage
0x0065f240 · 2942 bytes · __thiscall
_ZN9CCSPlayer12OnTakeDamageERK15CTakeDamageInfo
Decompiled
undefined (2 params)
/* CCSPlayer::OnTakeDamage(CTakeDamageInfo const&) */
int __thiscall CCSPlayer::OnTakeDamage(CCSPlayer *this,CTakeDamageInfo *param_1)
{
CCSPlayer CVar1;
code *pcVar2;
CBaseEdict *this_00;
code *pcVar3;
bool bVar4;
char cVar5;
undefined *puVar6;
int iVar7;
int iVar8;
uint uVar9;
CWeaponCSBase *this_01;
int iVar10;
int *piVar11;
undefined4 uVar12;
int iVar13;
undefined4 *puVar14;
int *piVar16;
uint *puVar17;
CBaseEntity *this_02;
int in_GS_OFFSET;
longdouble lVar18;
longdouble lVar19;
float fVar20;
float fVar21;
undefined4 uStackY_f0;
float local_d0;
CBaseCombatCharacter *local_c8;
char local_c4;
CCSPlayer *local_c0;
undefined **local_b4;
undefined4 local_b0;
float local_ac;
float local_94;
float local_90;
float local_8c;
undefined **local_88;
undefined4 local_84;
float local_80;
undefined4 local_7c;
undefined4 local_78;
undefined4 local_74;
undefined4 local_70;
undefined4 local_6c;
undefined4 local_68;
uint local_64;
uint local_60;
undefined4 local_5c;
float local_58;
undefined4 local_54;
undefined4 local_50;
uint local_4c;
undefined4 local_48;
undefined4 local_44;
undefined4 local_40;
undefined4 local_3c;
undefined4 local_38;
char local_34 [20];
int local_20;
undefined4 *puVar15;
piVar16 = (int *)&stack0xffffff14;
puVar14 = (undefined4 *)&stack0xffffff14;
puVar15 = (undefined4 *)&stack0xffffff14;
puVar17 = (uint *)&stack0xffffff14;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
local_94 = *(float *)param_1;
local_90 = *(float *)(param_1 + 4);
local_8c = *(float *)(param_1 + 8);
local_88 = *(undefined ***)(param_1 + 0xc);
local_84 = *(undefined4 *)(param_1 + 0x10);
local_80 = *(float *)(param_1 + 0x14);
local_7c = *(undefined4 *)(param_1 + 0x18);
local_78 = *(undefined4 *)(param_1 + 0x1c);
local_74 = *(undefined4 *)(param_1 + 0x20);
local_70 = *(undefined4 *)(param_1 + 0x24);
local_6c = *(undefined4 *)(param_1 + 0x28);
local_68 = *(undefined4 *)(param_1 + 0x2c);
local_64 = *(uint *)(param_1 + 0x30);
local_60 = *(uint *)(param_1 + 0x34);
local_54 = *(undefined4 *)(param_1 + 0x40);
fVar20 = *(float *)(param_1 + 0x3c);
local_50 = *(undefined4 *)(param_1 + 0x44);
local_5c = *(undefined4 *)(param_1 + 0x38);
local_3c = *(undefined4 *)(param_1 + 0x58);
local_4c = *(uint *)(param_1 + 0x48);
local_48 = *(undefined4 *)(param_1 + 0x4c);
local_44 = *(undefined4 *)(param_1 + 0x50);
local_40 = *(undefined4 *)(param_1 + 0x54);
local_38 = *(undefined4 *)(param_1 + 0x5c);
local_58 = fVar20;
if ((((local_64 != 0xffffffff) &&
(puVar6 = g_pEntityList + (local_64 & 0xfff) * 0x10, puVar6 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar6 + 8) == local_64 >> 0xc)) &&
((this_02 = *(CBaseEntity **)(puVar6 + 4), this_02 != (CBaseEntity *)0x0 &&
(((byte)this[0x186] & 0xfd) != 8)))) {
uStackY_f0 = 0x65f375;
iVar7 = CBaseEntity::GetTeamNumber(this_02);
uStackY_f0 = 0x65f37f;
iVar8 = CBaseEntity::GetTeamNumber((CBaseEntity *)this);
if ((iVar7 == iVar8) && (this != (CCSPlayer *)this_02)) {
if (((local_60 != 0xffffffff) &&
(puVar6 = g_pEntityList + (local_60 & 0xfff) * 0x10, puVar6 != (undefined *)0xfffffffc))
&& (*(uint *)(puVar6 + 8) == local_60 >> 0xc)) {
local_c4 = '\0';
bVar4 = false;
if (this == *(CCSPlayer **)(puVar6 + 4)) goto LAB_0065f395;
}
uStackY_f0 = 0x65f991;
cVar5 = (**(code **)(*(int *)this_02 + 0x16c))();
if (cVar5 == '\0') {
if ((((local_60 != 0xffffffff) &&
(puVar6 = g_pEntityList + (local_60 & 0xfff) * 0x10, puVar6 != (undefined *)0xfffffffc)
) && (*(uint *)(puVar6 + 8) == local_60 >> 0xc)) &&
(this_02 = *(CBaseEntity **)(puVar6 + 4), this_02 != (CBaseEntity *)0x0)) {
uStackY_f0 = 0x65fa6c;
cVar5 = (**(code **)(*(int *)this_02 + 0x16c))();
if (cVar5 != '\0') goto LAB_0065f999;
}
local_c4 = '\0';
bVar4 = true;
}
else {
LAB_0065f999:
uStackY_f0 = 0x65f9a4;
local_c4 = (**(code **)(*(int *)this_02 + 0x778))();
if ((*(uint *)(this_02 + 0x2390) & 0x200) == 0) {
*(uint *)(this_02 + 0x2390) = *(uint *)(this_02 + 0x2390) | 0x200;
}
bVar4 = true;
if ((local_c4 == '\0') && (*(float *)(this_02 + 0x2398) + 0.6 < *(float *)(gpGlobals + 0xc))
) {
*(float *)(this_02 + 0x2398) = *(float *)(gpGlobals + 0xc);
uStackY_f0 = 0x65fa08;
(**(code **)(*(int *)this + 0xb8))();
uStackY_f0 = 0x65fa15;
(**(code **)(*(int *)this_02 + 0xb8))();
uStackY_f0 = 0x65fa29;
Msg();
}
}
}
else {
local_c4 = '\0';
bVar4 = false;
}
LAB_0065f395:
uStackY_f0 = 0x65f3aa;
(**(code **)(*(int *)this + 0x7dc))();
if (((local_60 == 0xffffffff) ||
(puVar6 = g_pEntityList + (local_60 & 0xfff) * 0x10, puVar6 == (undefined *)0xfffffffc)) ||
((*(uint *)(puVar6 + 8) != local_60 >> 0xc ||
(local_c8 = *(CBaseCombatCharacter **)(puVar6 + 4), local_c8 == (CBaseCombatCharacter *)0x0)
))) {
LAB_0065f3d8:
local_c8 = (CBaseCombatCharacter *)0x0;
local_d0 = 0.5;
}
else {
uStackY_f0 = 0x65faa6;
cVar5 = (**(code **)(*(int *)local_c8 + 0x16c))();
if (cVar5 == '\0') goto LAB_0065f3d8;
uStackY_f0 = 0x65fab6;
this_01 = (CWeaponCSBase *)CBaseCombatCharacter::GetActiveWeapon(local_c8);
if (this_01 == (CWeaponCSBase *)0x0) {
local_d0 = 0.5;
}
else {
uStackY_f0 = 0x65fac6;
iVar7 = CWeaponCSBase::GetCSWpnData(this_01);
local_d0 = *(float *)(iVar7 + 0x8a0) * 0.5;
}
}
local_c0 = (CCSPlayer *)fVar20;
if ((((((byte)this[0x113] & 2) != 0) && (sv_cheats != 0)) &&
(*(int *)(*(int *)(sv_cheats + 0x1c) + 0x30) != 0)) &&
(local_c0 = (CCSPlayer *)(float)(*(int *)(this + 0x100) + -1),
fVar20 <= (float)(*(int *)(this + 0x100) + -1))) {
local_c0 = (CCSPlayer *)fVar20;
}
iVar7 = *(int *)(this + 0x1f70);
iVar8 = (int)(float)local_c0;
*(int *)(this + 0x1d38) = iVar8;
if (((iVar7 == 0) || ((local_4c & 0x4020) != 0)) ||
(iVar10 = *(int *)(this + 0x1838), iVar7 < 1)) {
LAB_0065f538:
*(undefined4 *)(this + 0x2988) = 0;
if ((local_4c & 0x20) == 0) {
uStackY_f0 = 0x65f943;
(**(code **)(*(int *)this + 0x838))();
}
}
else {
if (iVar10 == 1) {
if (this[0x23e1] != (CCSPlayer)0x0) goto LAB_0065f47a;
goto LAB_0065f538;
}
if (iVar10 < 2) {
if (iVar10 != 0) goto LAB_0065f538;
}
else if (5 < iVar10) goto LAB_0065f538;
LAB_0065f47a:
fVar21 = (float)iVar7;
local_d0 = local_d0 * (float)local_c0;
fVar20 = ((float)local_c0 - local_d0) * 0.5;
*(int *)(this + 0x2988) = (int)fVar20;
if (fVar21 < fVar20) {
local_d0 = (float)local_c0 - (fVar21 + fVar21);
uStackY_f0 = 0x65fb48;
CBasePlayer::SetArmorValue((CBasePlayer *)this,0);
}
else {
uStackY_f0 = 0x65f4ea;
CBasePlayer::SetArmorValue
((CBasePlayer *)this,
(int)(fVar21 - (float)(~-(uint)(0.0 <= fVar20) & 0x3f800000 |
(uint)fVar20 & -(uint)(0.0 <= fVar20))));
}
local_58 = local_d0;
if (((double)*(int *)(this + 0x1f70) <= 0.0) && (this[0x23e1] != (CCSPlayer)0x0)) {
if (this[0x6c] == (CCSPlayer)0x0) {
this_00 = *(CBaseEdict **)(this + 0x30);
if (this_00 != (CBaseEdict *)0x0) {
*(uint *)this_00 = *(uint *)this_00 | 0x101;
uStackY_f0 = 0x65fb7c;
iVar7 = CBaseEdict::GetChangeAccessor(this_00);
*(undefined2 *)(iVar7 + 2) = 0;
}
}
else {
this[0x70] = (CCSPlayer)((byte)this[0x70] | 1);
}
this[0x23e1] = (CCSPlayer)0x0;
}
if ((local_4c & 0x20) == 0) {
uStackY_f0 = 0x65fb1b;
(**(code **)(*(int *)this + 0x838))();
}
iVar8 = (int)local_d0;
}
*(int *)(this + 0x2984) = iVar8;
uStackY_f0 = 0x65f562;
cVar5 = (**(code **)(*(int *)this + 0x7e0))();
if (cVar5 != '\0') {
local_58 = (float)*(int *)(this + 0x2984);
uVar12 = *(undefined4 *)(gpGlobals + 0xc);
*(undefined4 *)(this + 0x2938) = local_7c;
*(undefined ***)(this + 0x292c) = local_88;
*(undefined4 *)(this + 0x291c) = uVar12;
*(undefined4 *)(this + 0x2930) = local_84;
*(undefined4 *)(this + 0x293c) = local_78;
*(uint *)(this + 0x2950) = local_64;
*(float *)(this + 0x2920) = local_94;
*(undefined4 *)(this + 0x2940) = local_74;
*(float *)(this + 0x2924) = local_90;
*(undefined4 *)(this + 0x2944) = local_70;
*(uint *)(this + 0x2954) = local_60;
*(float *)(this + 0x2928) = local_8c;
*(undefined4 *)(this + 0x2948) = local_6c;
*(float *)(this + 0x2934) = local_80;
*(undefined4 *)(this + 0x294c) = local_68;
*(undefined4 *)(this + 0x2958) = local_5c;
*(float *)(this + 0x295c) = local_58;
*(undefined4 *)(this + 0x2960) = local_54;
*(uint *)(this + 0x2968) = local_4c;
*(undefined4 *)(this + 0x2964) = local_50;
*(undefined4 *)(this + 0x2978) = local_3c;
*(undefined4 *)(this + 0x296c) = local_48;
*(undefined4 *)(this + 0x2970) = local_44;
*(undefined4 *)(this + 0x2974) = local_40;
*(undefined4 *)(this + 0x297c) = local_38;
if (*(int *)(sv_showdamage._28_4_ + 0x30) - 1U < 2) {
local_ac = local_80 + 3.0;
local_b4 = local_88;
local_b0 = local_84;
uStackY_f0 = 0x65f701;
V_snprintf(local_34,0x14,"%d (%d)");
uStackY_f0 = 0x65f723;
NDebugOverlay::Text((Vector *)&local_b4,local_34,false,4.0);
}
if ((0.0 < local_58) || ((bVar4 && (local_c4 == '\0')))) {
piVar16 = (int *)&stack0xffffff14;
if (local_4c != 0x20000) {
if ((((local_64 == 0xffffffff) ||
(puVar6 = g_pEntityList + (local_64 & 0xfff) * 0x10,
puVar6 == (undefined *)0xfffffffc)) || (*(uint *)(puVar6 + 8) != local_64 >> 0xc)) ||
(local_c0 = *(CCSPlayer **)(puVar6 + 4), local_c0 == (CCSPlayer *)0x0)) {
uStackY_f0 = 0x65f77f;
cVar5 = CBasePlayer::ShouldThrottleUserMessage((CBasePlayer *)this,"Damage");
puVar17 = (uint *)&stack0xffffff14;
if (cVar5 == '\0') {
local_c0 = this;
LAB_0065f78d:
CVar1 = local_c0[0x14d];
goto joined_r0x0065f7a0;
}
}
else {
uStackY_f0 = 0x65fc8f;
cVar5 = CBasePlayer::ShouldThrottleUserMessage((CBasePlayer *)this,"Damage");
if (cVar5 == '\0') {
if (this == local_c0) goto LAB_0065f78d;
uStackY_f0 = 0x65fcbe;
(**(code **)(*(int *)local_c0 + 0x234))();
puVar14 = &uStackY_f0;
puVar15 = &uStackY_f0;
CVar1 = local_c0[0x14d];
joined_r0x0065f7a0:
puVar17 = puVar14;
if (((byte)CVar1 & 8) != 0) {
*puVar15 = local_c0;
puVar15[-1] = 0x65fcde;
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)*puVar15);
puVar17 = puVar15;
}
*puVar17 = (uint)&local_b4;
puVar17[-1] = 0x65f7ae;
CRecipientFilter::CRecipientFilter((CRecipientFilter *)*puVar17);
puVar17[1] = (uint)this;
*puVar17 = (uint)&local_b4;
local_b4 = &PTR__CSingleUserRecipientFilter_00c08ea8;
/* try { // try from 0065f7bf to 0065f7c3 has its CatchHandler @ 0065fe10 */
puVar17[-1] = 0x65f7c4;
CRecipientFilter::AddRecipient((CRecipientFilter *)*puVar17,(CBasePlayer *)puVar17[1])
;
*puVar17 = (uint)&local_b4;
/* try { // try from 0065f7c7 to 0065f86e has its CatchHandler @ 0065fdf4 */
puVar17[-1] = 0x65f7cc;
CRecipientFilter::MakeReliable((CRecipientFilter *)*puVar17);
puVar17[1] = (uint)"Damage";
*puVar17 = (uint)&local_b4;
puVar17[-1] = 0x65f7dc;
UserMessageBegin((IRecipientFilter *)*puVar17,(char *)puVar17[1]);
uVar9 = 100;
if (local_58 <= 100.0) {
uVar9 = 0;
if (0.0 <= local_58) {
uVar9 = (int)(local_58 - (float)(-(uint)(2.1474836e+09 <= local_58) & 0x4f000000))
^ (uint)(2.1474836e+09 <= local_58) * -0x80000000;
}
}
puVar17[1] = 7;
*puVar17 = uVar9;
puVar17[-1] = 0x65f83d;
MessageWriteUBitLong(*puVar17,puVar17[1]);
if (*(int *)(local_c0 + 0x30) == 0) {
iVar7 = 0;
}
else {
iVar7 = *(int *)(local_c0 + 0x30) - *(int *)(gpGlobals + 0x58) >> 4;
}
puVar17[1] = 0xb;
*puVar17 = iVar7;
puVar17[-1] = 0x65f86a;
MessageWriteUBitLong(*puVar17,puVar17[1]);
puVar17[-1] = 0x65f86f;
MessageEnd();
*puVar17 = (uint)&local_b4;
local_b4 = &PTR__CSingleUserRecipientFilter_00c08ea8;
puVar17[-1] = 0x65f881;
CRecipientFilter::~CRecipientFilter((CRecipientFilter *)*puVar17);
}
}
piVar16 = (int *)puVar17;
if ((local_4c & 0x40) != 0) {
iVar7 = *(int *)this;
puVar17[1] = (uint)&local_94;
*puVar17 = (uint)this;
pcVar2 = *(code **)(iVar7 + 0x5a0);
puVar17[-1] = 0x65f896;
(*pcVar2)();
}
}
iVar7 = *(int *)this;
iVar8 = *(int *)(this + 0x100);
*piVar16 = (int)this;
pcVar2 = *(code **)(iVar7 + 0x7e4);
piVar16[-1] = 0x65f8a7;
lVar18 = (longdouble)(*pcVar2)();
iVar7 = *(int *)this;
*piVar16 = (int)this;
pcVar2 = *(code **)(iVar7 + 0x7e8);
piVar16[-1] = 0x65f8b8;
cVar5 = (*pcVar2)();
*(float *)(this + 0x2880) = local_90 + *(float *)(this + 0x2880);
*(float *)(this + 0x2884) = local_8c + *(float *)(this + 0x2884);
*(float *)(this + 0x287c) = *(float *)(this + 0x287c) + local_94;
piVar16[1] = (int)&local_94;
*piVar16 = (int)this;
piVar16[-1] = 0x65f912;
iVar7 = CBaseCombatCharacter::OnTakeDamage
((CBaseCombatCharacter *)*piVar16,(CTakeDamageInfo *)piVar16[1]);
if ((cVar5 == '\x01') || (iVar7 == 0)) goto LAB_0065f339;
iVar10 = *(int *)(this + 0x100);
iVar13 = *(int *)this;
*piVar16 = (int)this;
pcVar2 = *(code **)(iVar13 + 0x7e4);
piVar16[-1] = 0x65fbf3;
lVar19 = (longdouble)(*pcVar2)();
iVar8 = (int)((float)iVar8 + (float)lVar18) - (int)((float)lVar19 + (float)iVar10);
if (local_c8 == (CBaseCombatCharacter *)0x0) {
if (((local_60 != 0xffffffff) &&
(puVar6 = g_pEntityList + (local_60 & 0xfff) * 0x10, puVar6 != (undefined *)0xfffffffc
)) && ((*(uint *)(puVar6 + 8) == local_60 >> 0xc &&
(piVar11 = *(int **)(puVar6 + 4), piVar11 != (int *)0x0)))) {
iVar10 = *piVar11;
*piVar16 = (int)piVar11;
pcVar2 = *(code **)(iVar10 + 0x144);
piVar16[-1] = 0x65fda8;
piVar11 = (int *)(*pcVar2)();
if (piVar11 != (int *)0x0) {
iVar10 = *piVar11;
*piVar16 = (int)piVar11;
pcVar2 = *(code **)(iVar10 + 0x148);
piVar16[-1] = 0x65fdbf;
iVar10 = (*pcVar2)();
if (iVar10 != 0) {
iVar10 = *piVar11;
*piVar16 = (int)piVar11;
pcVar2 = *(code **)(iVar10 + 0x544);
piVar16[-1] = 0x65fdd4;
uVar12 = (*pcVar2)();
*piVar16 = uVar12;
piVar16[-1] = 0x65fddc;
iVar13 = ZombieClassName();
iVar10 = *(int *)this;
piVar16[2] = iVar8;
piVar16[1] = iVar13;
*piVar16 = (int)this;
pcVar2 = *(code **)(iVar10 + 0x8b4);
piVar16[-1] = 0x65fdef;
(*pcVar2)();
goto LAB_0065fc3a;
}
}
}
iVar10 = *(int *)this;
piVar16[2] = iVar8;
piVar16[1] = (int)"world";
*piVar16 = (int)this;
pcVar2 = *(code **)(iVar10 + 0x8b4);
piVar16[-1] = 0x65fd8c;
(*pcVar2)();
}
else if (local_c4 == '\0') {
iVar10 = *(int *)this;
*piVar16 = (int)this;
pcVar2 = *(code **)(iVar10 + 0xb8);
piVar16[-1] = 0x65fcee;
iVar10 = (*pcVar2)();
piVar16[2] = iVar8;
piVar16[1] = iVar10;
*piVar16 = (int)local_c8;
piVar16[-1] = 0x65fd04;
RecordDamageGiven((CCSPlayer *)*piVar16,(char *)piVar16[1],piVar16[2]);
pcVar2 = *(code **)(*(int *)this + 0x8b4);
iVar10 = *(int *)local_c8;
*piVar16 = (int)local_c8;
pcVar3 = *(code **)(iVar10 + 0xb8);
piVar16[-1] = 0x65fd23;
iVar10 = (*pcVar3)();
piVar16[2] = iVar8;
piVar16[1] = iVar10;
*piVar16 = (int)this;
piVar16[-1] = 0x65fd36;
(*pcVar2)();
}
LAB_0065fc3a:
iVar8 = *(int *)gamestats;
*piVar16 = (int)gamestats;
piVar16[2] = (int)&local_94;
piVar16[1] = (int)this;
pcVar2 = *(code **)(iVar8 + 0x58);
piVar16[-1] = 0x65fc4f;
(*pcVar2)();
goto LAB_0065f339;
}
}
}
iVar7 = 0;
LAB_0065f339:
if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
return iVar7;
}
/* WARNING: Subroutine does not return */
*(undefined4 *)((int)piVar16 + -4) = 0x65fd96;
__stack_chk_fail();
}
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.