CTerrorPlayer::EstimateFallingDamage
0x008e4300 · 2153 bytes · __thiscall
_ZN13CTerrorPlayer21EstimateFallingDamageEv
Decompiled
undefined (1 param)
/* CTerrorPlayer::EstimateFallingDamage() */
longdouble __thiscall CTerrorPlayer::EstimateFallingDamage(CTerrorPlayer *this)
{
char cVar1;
int iVar2;
uint uVar3;
int iVar4;
int iVar5;
longdouble lVar6;
float fVar7;
float fVar8;
float fVar9;
float fVar10;
float fVar11;
float fVar12;
CTerrorPlayer *pCVar13;
float local_11c;
float local_110;
float local_100;
float local_fc;
float local_f8;
float local_f4;
float local_f0;
float local_ec;
float local_e8;
float local_e4;
float local_e0;
undefined **local_dc [4];
float local_cc;
float local_c8;
float local_c4;
float local_bc;
float local_b8;
float local_b4;
float local_ac;
float local_a8;
float local_a4;
float local_9c;
float local_98;
float local_94;
undefined4 local_8c;
undefined1 local_88;
undefined1 local_87;
Vector local_70 [12];
float local_64;
float local_60;
float local_5c;
float local_58;
float local_54;
float local_50;
float local_44;
char local_3a;
char local_39;
cVar1 = (**(code **)(*(int *)this + 300))();
if (((cVar1 == '\0') || (iVar2 = CBaseEntity::GetGroundEntity((CBaseEntity *)this), iVar2 != 0))
|| (this[0x186] == (CTerrorPlayer)0x9)) {
LAB_008e431e:
lVar6 = (longdouble)0;
}
else {
lVar6 = (longdouble)9999999.0;
if (*(int *)(ZombieGrabForce._28_4_ + 0x30) == 0) {
pCVar13 = this;
(**(code **)(*(int *)this + 0x5b0))();
(**(code **)(*(int *)this + 0x5b4))(&local_f4,this,pCVar13);
uVar3 = *(uint *)(this + 0x14c);
if ((uVar3 & 0x800) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
uVar3 = *(uint *)(this + 0x14c);
}
local_110 = *(float *)(this + 0x2e4);
fVar8 = *(float *)(this + 0x2e0);
fVar9 = *(float *)(this + 0x2e8);
if ((uVar3 & 0x1000) != 0) {
CBaseEntity::CalcAbsoluteVelocity((CBaseEntity *)this);
}
local_e8 = *(float *)(this + 0x274) * 0.5;
local_11c = *(float *)(sv_gravity._28_4_ + 0x2c) * 0.1;
local_e4 = *(float *)(this + 0x278) * 0.5;
local_e0 = *(float *)(this + 0x27c) * 0.5;
if (*(float *)(this + 0x2c0) != 0.0) {
local_11c = *(float *)(this + 0x2c0) * local_11c;
}
fVar12 = (float)(*(int *)(SurvivorIncapacitatedMaxFallDamage._28_4_ + 0x30) + 0x32);
CTraceFilterSimple::CTraceFilterSimple
((CTraceFilterSimple *)local_dc,(IHandleEntity *)this,8,
(_func_bool_IHandleEntity_ptr_int *)0x0);
local_dc[0] = &PTR_ShouldHitEntity_00c54558;
iVar2 = CBaseEntity::GetTeamNumber((CBaseEntity *)this);
cVar1 = IsASurvivorTeam(iVar2);
if (fVar12 <= 0.0) {
iVar2 = 0;
fVar7 = 0.0;
}
else {
iVar2 = 0;
do {
iVar2 = iVar2 + 1;
local_8c = 0;
local_b8 = local_e4 * 0.1;
local_b4 = local_e0 * 0.1;
local_bc = local_e8 * 0.1;
local_87 = local_b4 * local_b4 + local_b8 * local_b8 + local_bc * local_bc != 0.0;
local_98 = (local_f0 - local_fc) * 0.5;
local_94 = (local_ec - local_f8) * 0.5;
local_9c = (local_f4 - local_100) * 0.5;
local_a8 = (local_f0 + local_fc) * 0.5;
local_ac = (local_f4 + local_100) * 0.5;
local_a4 = (local_ec + local_f8) * 0.5;
local_cc = fVar8 + local_ac;
local_c4 = fVar9 + local_a4;
local_88 = local_98 * local_98 + local_9c * local_9c + local_94 * local_94 < 1e-06;
local_c8 = local_110 + local_a8;
local_ac = -local_ac;
local_a8 = -local_a8;
local_a4 = -local_a4;
(**(code **)(*enginetrace + 0x14))
(enginetrace,&local_cc,(-(uint)(cVar1 == '\0') & 0x10800) + 0x2014a0b,local_dc,
local_70);
if (*(int *)(r_visualizetraces._28_4_ + 0x30) != 0) {
DebugDrawLine(local_70,(Vector *)&local_64,0xff,0xff,0,true,-1.0);
}
if ((local_3a != '\0') || (local_39 != '\0')) goto LAB_008e431e;
if ((local_44 < 1.0) && (0.7 < local_50)) {
local_e0 = (1.0 - local_44) * 0.5 * local_11c + local_e0;
}
lVar6 = (longdouble)FallingDamageForSpeed(-(local_e0 + SafeFallSpeed));
fVar7 = (float)lVar6;
if (fVar7 <= 0.0) {
fVar7 = 0.0;
}
if (*(int *)(ZombieDebugFallingDamage._28_4_ + 0x30) != 0) {
if (100.0 < fVar7) {
iVar5 = 0;
iVar4 = 0xff;
}
else {
iVar5 = (int)((1.0 - fVar7 * 0.01) * 255.0);
iVar4 = (int)(fVar7 * 0.01 * 255.0);
}
(**(code **)(*debugoverlay + 0xc))
(debugoverlay,local_70,&local_64,iVar4,iVar5,0,1,0x41f00000);
}
if (local_44 < 1.0) {
if (0.7 < local_50) {
if (*(int *)(ZombieDebugFallingDamage._28_4_ + 0x30) == 0) {
return (longdouble)fVar7;
}
DevMsg("Flat ground, %f damage, %d iterations\n",(double)fVar7,iVar2);
return (longdouble)fVar7;
}
if ((((local_e8 <= -0.01) || (0.01 <= local_e8)) || (local_e4 <= -0.01)) ||
(0.01 <= local_e4)) {
CBaseEntity::PhysicsClipVelocity
((CBaseEntity *)this,(Vector *)&local_e8,(Vector *)&local_58,
(Vector *)&local_cc,1.5);
if (local_e4 * local_c8 + local_e8 * local_cc <= 0.0) {
local_e8 = 0.0;
local_e4 = 0.0;
if (local_e0 < local_c4) goto LAB_008e4610;
}
else {
local_e8 = local_cc;
local_e4 = local_c8;
}
local_e0 = local_c4;
}
else {
fVar10 = local_58 * -local_58;
fVar11 = -local_58 * local_50;
fVar9 = local_50 * local_54;
fVar8 = local_54 * local_54;
lVar6 = (longdouble)VectorNormalize((Vector *)&local_e8);
local_e0 = (float)lVar6;
local_e8 = -fVar11 * local_e0;
local_e4 = fVar9 * local_e0;
local_e0 = -(fVar8 - fVar10) * local_e0;
}
}
else {
local_e0 = local_e0 - local_11c;
}
LAB_008e4610:
} while ((fVar7 < fVar12) &&
(fVar9 = local_5c, fVar8 = local_64, local_110 = local_60, iVar2 < 0x1e));
}
lVar6 = (longdouble)fVar7;
if (*(int *)(ZombieDebugFallingDamage._28_4_ + 0x30) != 0) {
DevMsg("Too many traces, %f damage, %d iterations\n",(double)fVar7,iVar2);
lVar6 = (longdouble)fVar7;
}
}
}
return lVar6;
}
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.