CTerrorGun::UpdateSpread
0x00567870 · 1013 bytes · __thiscall
_ZN10CTerrorGun12UpdateSpreadEv
Decompiled
undefined (1 param)
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* CTerrorGun::UpdateSpread() */
void __thiscall CTerrorGun::UpdateSpread(CTerrorGun *this)
{
float fVar1;
undefined4 uVar2;
char cVar3;
int iVar4;
CBasePlayer *this_00;
int iVar5;
int iVar6;
uint uVar7;
float *pfVar8;
int iVar9;
undefined *puVar10;
longdouble lVar11;
longdouble lVar12;
float fVar13;
double dVar14;
float fVar15;
float local_24;
float local_20;
iVar4 = CTerrorWeapon::GetTerrorWeaponData((CTerrorWeapon *)this);
this_00 = (CBasePlayer *)CTerrorWeapon::GetPlayerOwner((CTerrorWeapon *)this);
if (this_00 == (CBasePlayer *)0x0) {
lVar11 = (longdouble)(**(code **)(*(int *)this + 0x73c))(this);
*(float *)(this + 0x17f0) = (float)lVar11;
return;
}
uVar7 = *(uint *)(this_00 + 0x150);
if ((uVar7 & 1) == 0) {
local_24 = 0.99999994;
}
else {
if (((byte)this_00[0x14d] & 0x10) != 0) {
CBaseEntity::CalcAbsoluteVelocity((CBaseEntity *)this_00);
uVar7 = *(uint *)(this_00 + 0x150);
}
local_24 = 0.75;
fVar13 = SQRT(*(float *)(this_00 + 0x278) * *(float *)(this_00 + 0x278) +
*(float *)(this_00 + 0x274) * *(float *)(this_00 + 0x274) +
*(float *)(this_00 + 0x27c) * *(float *)(this_00 + 0x27c));
if (fVar13 <= 0.0) {
fVar13 = 0.0;
}
if (220.0 <= fVar13) {
fVar13 = 220.0;
}
if ((uVar7 & 2) != 0) {
local_24 = 0.5;
}
local_24 = local_24 * fVar13 * 0.0045454544;
}
local_20 = 0.0;
lVar11 = (longdouble)(**(code **)(*(int *)this + 0x734))(this);
fVar13 = (float)lVar11;
lVar11 = (longdouble)(**(code **)(*(int *)this + 0x738))(this);
if ((*(uint *)(this_00 + 0x150) & 1) != 0) {
if (((*(uint *)(this_00 + 0x150) & 2) == 0) ||
(cVar3 = (**(code **)(*(int *)this_00 + 0x7e8))(this_00), cVar3 != '\0')) {
lVar12 = (longdouble)(**(code **)(*(int *)this + 0x73c))(this);
fVar13 = (float)lVar12;
}
else {
lVar12 = (longdouble)(**(code **)(*(int *)this + 0x740))(this);
fVar13 = (float)lVar12;
}
}
fVar13 = ((float)lVar11 - fVar13) * local_24 + fVar13;
cVar3 = (**(code **)(*(int *)this_00 + 0x7e8))(this_00);
if ((cVar3 != '\0') && (iVar9 = (**(code **)(*(int *)this + 0x638))(this), iVar9 != 0x20)) {
fVar13 = fVar13 + *(float *)(SurvivorIncapacitatedAccuracyPenalty._28_4_ + 0x2c) * 10.0;
}
uVar7 = *(uint *)(this_00 + 0x33c4);
if ((((uVar7 != 0xffffffff) &&
(puVar10 = g_pEntityList + (uVar7 & 0xfff) * 0x10, puVar10 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar10 + 8) == uVar7 >> 0xc)) && (*(int *)(puVar10 + 4) != 0)) {
fVar13 = fVar13 + *(float *)(TongueVictimAccuracyPenalty._28_4_ + 0x2c) * 10.0;
}
cVar3 = (**(code **)(*(int *)this + 0x6b4))(this,2);
if (cVar3 != '\0') {
fVar13 = fVar13 * *(float *)(upgrade_laser_sight_spread_factor._28_4_ + 0x2c);
}
iVar5 = CBasePlayer::GetFOV(this_00);
iVar6 = CBasePlayer::GetDefaultFOV(this_00);
iVar9 = gpGlobals;
uVar2 = z_gun_debug_spread._28_4_;
fVar13 = *(float *)(this + 0x17f0) -
*(float *)(iVar4 + 0xc18) * *(float *)(gpGlobals + 0x10) *
(*(float *)(this + 0x17f0) - (float)(iVar5 / iVar6) * fVar13);
if (0.0 <= fVar13) {
local_20 = fVar13;
}
if (90.0 <= local_20) {
local_20 = 90.0;
}
*(float *)(this + 0x17f0) = local_20;
if (*(int *)(this_00 + 0x30) == 0) {
iVar4 = 0;
}
else {
iVar4 = *(int *)(this_00 + 0x30) - *(int *)(iVar9 + 0x58) >> 4;
}
if (*(int *)(uVar2 + 0x30) != iVar4) {
return;
}
if (0x1d < _DAT_00fb3d8c) {
_DAT_00fb3d8c = _DAT_00fb3d8c + -1;
}
CUtlVector<float,CUtlMemory<float,int>>::InsertBefore
((CUtlVector<float,CUtlMemory<float,int>> *)&m_spreadHistory,0,(float *)(this + 0x17f0))
;
if (_DAT_00fb3d8c < 1) {
fVar13 = *(float *)(this + 0x17f0);
dVar14 = 0.0;
fVar15 = fVar13;
}
else {
fVar13 = 0.0;
fVar15 = 0.0;
pfVar8 = m_spreadHistory;
do {
fVar1 = *pfVar8;
pfVar8 = pfVar8 + 1;
fVar15 = fVar15 + fVar1;
if (fVar13 <= fVar1) {
fVar13 = fVar1;
}
} while (pfVar8 != m_spreadHistory + _DAT_00fb3d8c);
dVar14 = (double)fVar13;
fVar13 = *(float *)(this + 0x17f0);
fVar15 = fVar15 / (float)_DAT_00fb3d8c;
}
Msg("(%.1f) spread %.1f ( avg %.1f ) ( max %.1f )\n",(double)*(float *)(gpGlobals + 0xc),
(double)fVar13,(double)fVar15,dVar14);
return;
}
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.