CGrenadeLauncher::PrimaryAttack
0x0053a9d0 · 1758 bytes · __thiscall
_ZN16CGrenadeLauncher13PrimaryAttackEv
Decompiled
undefined (1 param)
/* CGrenadeLauncher::PrimaryAttack() */
void __thiscall CGrenadeLauncher::PrimaryAttack(CGrenadeLauncher *this)
{
CGrenadeLauncher CVar1;
CBaseEdict *pCVar2;
byte *pbVar3;
code *pcVar4;
int iVar5;
int *piVar6;
char cVar7;
CGrenadeLauncher CVar8;
CTerrorPlayer *pCVar9;
int iVar10;
int iVar11;
char *pcVar12;
int *piVar13;
undefined4 uVar14;
int iVar15;
int iVar16;
byte *pbVar17;
byte *pbVar18;
bool bVar19;
bool bVar20;
byte bVar21;
longdouble lVar22;
float fVar23;
byte *local_30;
bVar21 = 0;
pCVar9 = (CTerrorPlayer *)CTerrorWeapon::GetPlayerOwner((CTerrorWeapon *)this);
if (((((pCVar9 != (CTerrorPlayer *)0x0) &&
(cVar7 = (**(code **)(*(int *)pCVar9 + 0x840))(pCVar9), cVar7 != '\0')) &&
(cVar7 = (**(code **)(*(int *)this + 0x434))(this), cVar7 != '\0')) &&
((cVar7 = CTerrorWeapon::HelpingHandPrimaryAttack((CTerrorWeapon *)this), cVar7 == '\0' &&
(this[0x1532] == (CGrenadeLauncher)0x0)))) && (this[0x1531] != (CGrenadeLauncher)0x0)) {
if (*(int *)(this + 0x1420) < 1) {
if (this[0x145a] != (CGrenadeLauncher)0x0) {
CWeaponCSBase::PlayEmptySound();
fVar23 = *(float *)(gpGlobals + 0xc) + 0.2;
if (fVar23 != *(float *)(this + 0x13fc)) {
if (this[0x6c] == (CGrenadeLauncher)0x0) {
pCVar2 = *(CBaseEdict **)(this + 0x30);
if (pCVar2 != (CBaseEdict *)0x0) {
*(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
iVar10 = CBaseEdict::GetChangeAccessor(pCVar2);
*(undefined2 *)(iVar10 + 2) = 0;
}
}
else {
this[0x70] = (CGrenadeLauncher)((byte)this[0x70] | 1);
}
*(float *)(this + 0x13fc) = fVar23;
}
}
}
else if (*(float *)(this + 0x13fc) < *(float *)(gpGlobals + 0xc) ||
*(float *)(this + 0x13fc) == *(float *)(gpGlobals + 0xc)) {
LaunchGrenade(this,pCVar9);
(**(code **)(*(int *)this + 0x3f0))(this,0xbf);
(**(code **)(*(int *)pCVar9 + 0x844))(pCVar9);
CTerrorWeapon::SuppressHelpingHands((CTerrorWeapon *)this,0.0);
piVar6 = mdlcache;
(**(code **)(*mdlcache + 0x68))(mdlcache);
if (this[0x1532] != (CGrenadeLauncher)0x1) {
if (this[0x6c] == (CGrenadeLauncher)0x0) {
pCVar2 = *(CBaseEdict **)(this + 0x30);
if (pCVar2 != (CBaseEdict *)0x0) {
*(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
/* try { // try from 0053aac8 to 0053af70 has its CatchHandler @ 0053b0cf */
iVar10 = CBaseEdict::GetChangeAccessor(pCVar2);
*(undefined2 *)(iVar10 + 2) = 0;
}
}
else {
this[0x70] = (CGrenadeLauncher)((byte)this[0x70] | 1);
}
this[0x1532] = (CGrenadeLauncher)0x1;
}
iVar10 = *(int *)(pCVar9 + 0x2850);
if (pCVar9[0x6c] == (CTerrorPlayer)0x0) {
pCVar2 = *(CBaseEdict **)(pCVar9 + 0x30);
if (pCVar2 != (CBaseEdict *)0x0) {
*(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
iVar11 = CBaseEdict::GetChangeAccessor(pCVar2);
*(undefined2 *)(iVar11 + 2) = 0;
}
}
else {
pCVar9[0x70] = (CTerrorPlayer)((byte)pCVar9[0x70] | 1);
}
*(int *)(pCVar9 + 0x2850) = iVar10 + 1;
iVar10 = CTerrorWeapon::GetTerrorWeaponData((CTerrorWeapon *)this);
pcVar12 = "weapon_fire";
if (*(int *)(this + 0x1420) < 1) {
pcVar12 = "weapon_fire_on_empty";
}
piVar13 = (int *)(**(code **)(*gameeventmanager + 0x1c))(gameeventmanager,pcVar12,0,0);
if (piVar13 != (int *)0x0) {
pbVar3 = *(byte **)(this + 0x7c);
bVar19 = false;
if (pbVar3 == (byte *)0x0) {
local_30 = &DAT_00d539c2;
}
else {
iVar11 = 7;
bVar20 = false;
pbVar17 = pbVar3;
pbVar18 = (byte *)"weapon_";
do {
if (iVar11 == 0) break;
iVar11 = iVar11 + -1;
bVar19 = *pbVar17 < *pbVar18;
bVar20 = *pbVar17 == *pbVar18;
pbVar17 = pbVar17 + (uint)bVar21 * -2 + 1;
pbVar18 = pbVar18 + (uint)bVar21 * -2 + 1;
} while (bVar20);
local_30 = pbVar3 + 7;
if ((!bVar19 && !bVar20) != bVar19) {
local_30 = pbVar3;
}
}
pcVar4 = *(code **)(*piVar13 + 0x30);
uVar14 = (**(code **)(*engine + 0x40))(engine,*(undefined4 *)(pCVar9 + 0x30));
(*pcVar4)(piVar13,"userid",uVar14);
(**(code **)(*piVar13 + 0x3c))(piVar13,"weapon",local_30);
pcVar4 = *(code **)(*piVar13 + 0x30);
uVar14 = (**(code **)(*(int *)this + 0x638))(this);
(*pcVar4)(piVar13,"weaponid",uVar14);
(**(code **)(*piVar13 + 0x30))(piVar13,"count",*(undefined4 *)(iVar10 + 0x9d8));
(**(code **)(*gameeventmanager + 0x20))(gameeventmanager,piVar13,0);
}
iVar11 = *(int *)(this + 0x1420);
iVar15 = (**(code **)(*(int *)this + 0x510))(this);
iVar5 = *(int *)(this + 0x1420);
iVar16 = (**(code **)(*(int *)this + 0x510))(this);
if (((((float)iVar5 / (float)iVar16) * 100.0 <= 40.0) &&
(40.0 < ((float)(iVar11 + 1) / (float)iVar15) * 100.0)) &&
(piVar13 = (int *)(**(code **)(*gameeventmanager + 0x1c))
(gameeventmanager,"weapon_fire_at_40",0,0),
piVar13 != (int *)0x0)) {
pbVar3 = *(byte **)(this + 0x7c);
bVar19 = false;
if (pbVar3 == (byte *)0x0) {
local_30 = &DAT_00d539c2;
}
else {
iVar11 = 7;
bVar20 = false;
pbVar17 = pbVar3;
pbVar18 = (byte *)"weapon_";
do {
if (iVar11 == 0) break;
iVar11 = iVar11 + -1;
bVar19 = *pbVar17 < *pbVar18;
bVar20 = *pbVar17 == *pbVar18;
pbVar17 = pbVar17 + (uint)bVar21 * -2 + 1;
pbVar18 = pbVar18 + (uint)bVar21 * -2 + 1;
} while (bVar20);
local_30 = pbVar3 + 7;
if ((!bVar19 && !bVar20) != bVar19) {
local_30 = pbVar3;
}
}
pcVar4 = *(code **)(*piVar13 + 0x30);
uVar14 = (**(code **)(*engine + 0x40))(engine,*(undefined4 *)(pCVar9 + 0x30));
(*pcVar4)(piVar13,"userid",uVar14);
(**(code **)(*piVar13 + 0x3c))(piVar13,"weapon",local_30);
pcVar4 = *(code **)(*piVar13 + 0x30);
uVar14 = (**(code **)(*(int *)this + 0x638))(this);
(*pcVar4)(piVar13,"weaponid",uVar14);
(**(code **)(*gameeventmanager + 0x20))(gameeventmanager,piVar13,0);
}
(**(code **)(*(int *)pCVar9 + 0x850))(pCVar9,*(undefined4 *)(iVar10 + 0x9f8));
cVar7 = (**(code **)(*(int *)this + 0x6b4))(this,0);
/* try { // try from 0053b03d to 0053b085 has its CatchHandler @ 0053b0cf */
if ((cVar7 != '\0') || (cVar7 = (**(code **)(*(int *)this + 0x6b4))(this,1), cVar7 != '\0')) {
CVar8 = this[0x1790];
if (CVar8 != (CGrenadeLauncher)0x0) {
CVar1 = (CGrenadeLauncher)((char)CVar8 + -1);
if (CVar8 != CVar1) {
if (this[0x6c] == (CGrenadeLauncher)0x0) {
pCVar2 = *(CBaseEdict **)(this + 0x30);
if (pCVar2 != (CBaseEdict *)0x0) {
*(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
iVar10 = CBaseEdict::GetChangeAccessor(pCVar2);
*(undefined2 *)(iVar10 + 2) = 0;
}
}
else {
this[0x70] = (CGrenadeLauncher)((byte)this[0x70] | 1);
}
this[0x1790] = CVar1;
CVar8 = CVar1;
}
if (CVar8 != (CGrenadeLauncher)0x0) goto LAB_0053ae1f;
}
(**(code **)(*(int *)this + 0x6ac))(this,0);
(**(code **)(*(int *)this + 0x6ac))(this,1);
}
LAB_0053ae1f:
(**(code **)(*(int *)pCVar9 + 0x518))(pCVar9);
(**(code **)(*(int *)pCVar9 + 0x7fc))(pCVar9,0x28,0);
iVar10 = *(int *)(this + 0x1420);
if (this[0x6c] == (CGrenadeLauncher)0x0) {
pCVar2 = *(CBaseEdict **)(this + 0x30);
if (pCVar2 != (CBaseEdict *)0x0) {
*(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
iVar11 = CBaseEdict::GetChangeAccessor(pCVar2);
*(undefined2 *)(iVar11 + 2) = 0;
}
}
else {
this[0x70] = (CGrenadeLauncher)((byte)this[0x70] | 1);
}
*(int *)(this + 0x1420) = iVar10 + -1;
CTerrorGun::DoViewPunch((CTerrorGun *)this,pCVar9);
(**(code **)(*(int *)this + 0x4b8))(this,1,0);
fVar23 = *(float *)(gpGlobals + 0xc);
lVar22 = (longdouble)(**(code **)(*(int *)this + 0x718))(this);
fVar23 = (float)lVar22 + fVar23;
if (fVar23 != *(float *)(this + 0x13fc)) {
if (this[0x6c] == (CGrenadeLauncher)0x0) {
pCVar2 = *(CBaseEdict **)(this + 0x30);
if (pCVar2 != (CBaseEdict *)0x0) {
*(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
iVar10 = CBaseEdict::GetChangeAccessor(pCVar2);
*(undefined2 *)(iVar10 + 2) = 0;
}
}
else {
this[0x70] = (CGrenadeLauncher)((byte)this[0x70] | 1);
}
*(float *)(this + 0x13fc) = fVar23;
}
(**(code **)(*(int *)this + 0x404))(this,*(float *)(gpGlobals + 0xc) + 1.8);
if ((*(int *)(this + 0x1420) == 0) && (this[0x17e3] != (CGrenadeLauncher)0x1)) {
if (this[0x6c] == (CGrenadeLauncher)0x0) {
pCVar2 = *(CBaseEdict **)(this + 0x30);
if (pCVar2 != (CBaseEdict *)0x0) {
*(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
iVar10 = CBaseEdict::GetChangeAccessor(pCVar2);
*(undefined2 *)(iVar10 + 2) = 0;
}
}
else {
this[0x70] = (CGrenadeLauncher)((byte)this[0x70] | 1);
}
this[0x17e3] = (CGrenadeLauncher)0x1;
}
/* WARNING: Could not recover jumptable at 0x0053af90. Too many branches */
/* WARNING: Treating indirect jump as call */
(**(code **)(*piVar6 + 0x6c))();
return;
}
}
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.