CTerrorGun::FireBullet
0x00566ac0 · 3247 bytes · __thiscall
_ZN10CTerrorGun10FireBulletEv
Decompiled
undefined (1 param)
/* CTerrorGun::FireBullet() */
void __thiscall CTerrorGun::FireBullet(CTerrorGun *this)
{
CTerrorGun CVar1;
char cVar2;
CBaseEdict *pCVar3;
code *pcVar4;
uint *puVar5;
bool bVar6;
int *piVar7;
char cVar8;
CTerrorGun CVar9;
CTerrorPlayer *pCVar10;
int iVar11;
int iVar12;
int *piVar13;
int iVar14;
int iVar15;
float *pfVar16;
int iVar17;
undefined4 uVar18;
int *piVar19;
int *piVar20;
char *pcVar21;
char *pcVar22;
byte bVar23;
longdouble lVar24;
longdouble lVar25;
float fVar26;
float fVar27;
int local_54;
float local_44;
float local_34;
float local_30;
float local_2c;
Vector local_28 [24];
bVar23 = 0;
piVar19 = (int *)&stack0xffffff84;
pCVar10 = (CTerrorPlayer *)CTerrorWeapon::GetPlayerOwner((CTerrorWeapon *)this);
if (pCVar10 == (CTerrorPlayer *)0x0) {
return;
}
if ((this[0x1532] != (CTerrorGun)0x0) &&
(cVar8 = (**(code **)(*(int *)this + 0x700))(), cVar8 == '\0')) {
DebugFireFailure(pCVar10,"IsHoldingFireButton() && !IsFullyAutomatic()");
return;
}
if (this[0x1531] == (CTerrorGun)0x0) {
DebugFireFailure(pCVar10,"IsFirePreventedUntilButtonRelease()");
return;
}
CTerrorWeapon::SuppressHelpingHands((CTerrorWeapon *)this,0.0);
piVar7 = mdlcache;
(**(code **)(*mdlcache + 0x68))();
if (this[0x1532] != (CTerrorGun)0x1) {
if (this[0x6c] == (CTerrorGun)0x0) {
pCVar3 = *(CBaseEdict **)(this + 0x30);
if (pCVar3 != (CBaseEdict *)0x0) {
*(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
/* try { // try from 00566b3e to 0056720f has its CatchHandler @ 005677af */
iVar11 = CBaseEdict::GetChangeAccessor(pCVar3);
*(undefined2 *)(iVar11 + 2) = 0;
}
}
else {
this[0x70] = (CTerrorGun)((byte)this[0x70] | 1);
}
this[0x1532] = (CTerrorGun)0x1;
}
iVar11 = *(int *)(pCVar10 + 0x2850);
if (pCVar10[0x6c] == (CTerrorPlayer)0x0) {
pCVar3 = *(CBaseEdict **)(pCVar10 + 0x30);
if (pCVar3 != (CBaseEdict *)0x0) {
*(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
iVar12 = CBaseEdict::GetChangeAccessor(pCVar3);
*(undefined2 *)(iVar12 + 2) = 0;
}
}
else {
pCVar10[0x70] = (CTerrorPlayer)((byte)pCVar10[0x70] | 1);
}
*(int *)(pCVar10 + 0x2850) = iVar11 + 1;
CTerrorWeapon::GetTerrorWeaponData((CTerrorWeapon *)this);
if (*(int *)(this + 0x1420) < 1) {
/* try { // try from 00567363 to 00567781 has its CatchHandler @ 005677af */
piVar13 = (int *)(**(code **)(*gameeventmanager + 0x1c))();
}
else {
piVar13 = (int *)(**(code **)(*gameeventmanager + 0x1c))();
}
if (piVar13 != (int *)0x0) {
if (*(char **)(this + 0x7c) != (char *)0x0) {
iVar11 = 7;
pcVar21 = *(char **)(this + 0x7c);
pcVar22 = "weapon_";
do {
if (iVar11 == 0) break;
iVar11 = iVar11 + -1;
cVar2 = *pcVar22;
cVar8 = *pcVar21;
pcVar21 = pcVar21 + (uint)bVar23 * -2 + 1;
pcVar22 = pcVar22 + (uint)bVar23 * -2 + 1;
} while (cVar8 == cVar2);
}
pcVar4 = *(code **)(*piVar13 + 0x30);
(**(code **)(*engine + 0x40))();
(*pcVar4)();
(**(code **)(*piVar13 + 0x3c))();
pcVar4 = *(code **)(*piVar13 + 0x30);
(**(code **)(*(int *)this + 0x638))();
(*pcVar4)();
(**(code **)(*piVar13 + 0x30))();
(**(code **)(*gameeventmanager + 0x20))();
}
iVar11 = *(int *)(this + 0x1420);
if (iVar11 < 1) {
if (this[0x145a] != (CTerrorGun)0x0) {
/* try { // try from 005672bc to 00567332 has its CatchHandler @ 005677af */
CWeaponCSBase::PlayEmptySound();
fVar26 = *(float *)(gpGlobals + 0xc) + 0.2;
if (fVar26 != *(float *)(this + 0x13fc)) {
if (this[0x6c] == (CTerrorGun)0x0) {
pCVar3 = *(CBaseEdict **)(this + 0x30);
if (pCVar3 != (CBaseEdict *)0x0) {
*(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
iVar11 = CBaseEdict::GetChangeAccessor(pCVar3);
*(undefined2 *)(iVar11 + 2) = 0;
}
}
else {
this[0x70] = (CTerrorGun)((byte)this[0x70] | 1);
}
*(float *)(this + 0x13fc) = fVar26;
}
}
DebugFireFailure(pCVar10,"m_iClip1 <= 0");
(**(code **)(*piVar7 + 0x6c))();
return;
}
iVar12 = iVar11;
if (*(int *)(sv_infinite_ammo._28_4_ + 0x30) < 0) {
LAB_005672a2:
bVar6 = true;
}
else {
iVar12 = (**(code **)(*(int *)this + 0x530))();
if ((iVar12 == 0) && (*(int *)(sv_infinite_primary_ammo._28_4_ + 0x30) < 0)) {
iVar12 = *(int *)(this + 0x1420);
goto LAB_005672a2;
}
iVar12 = *(int *)(this + 0x1420) + -1;
if (this[0x6c] == (CTerrorGun)0x0) {
pCVar3 = *(CBaseEdict **)(this + 0x30);
if (pCVar3 != (CBaseEdict *)0x0) {
*(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
iVar14 = CBaseEdict::GetChangeAccessor(pCVar3);
*(undefined2 *)(iVar14 + 2) = 0;
}
}
else {
this[0x70] = (CTerrorGun)((byte)this[0x70] | 1);
}
*(int *)(this + 0x1420) = iVar12;
bVar6 = false;
}
iVar14 = (**(code **)(*(int *)this + 0x510))();
iVar15 = (**(code **)(*(int *)this + 0x510))();
if (((((float)iVar12 / (float)iVar15) * 100.0 <= 40.0) &&
(40.0 < ((float)iVar11 / (float)iVar14) * 100.0)) &&
(piVar13 = (int *)(**(code **)(*gameeventmanager + 0x1c))(), piVar13 != (int *)0x0)) {
if (*(char **)(this + 0x7c) != (char *)0x0) {
iVar11 = 7;
pcVar21 = *(char **)(this + 0x7c);
pcVar22 = "weapon_";
do {
if (iVar11 == 0) break;
iVar11 = iVar11 + -1;
cVar2 = *pcVar22;
cVar8 = *pcVar21;
pcVar21 = pcVar21 + (uint)bVar23 * -2 + 1;
pcVar22 = pcVar22 + (uint)bVar23 * -2 + 1;
} while (cVar8 == cVar2);
}
pcVar4 = *(code **)(*piVar13 + 0x30);
(**(code **)(*engine + 0x40))();
(*pcVar4)();
(**(code **)(*piVar13 + 0x3c))();
pcVar4 = *(code **)(*piVar13 + 0x30);
(**(code **)(*(int *)this + 0x638))();
(*pcVar4)();
(**(code **)(*gameeventmanager + 0x20))();
}
(**(code **)(*(int *)pCVar10 + 0x518))();
pcVar4 = *(code **)(*(int *)this + 0x3f0);
(**(code **)(*(int *)this + 0x730))();
(*pcVar4)();
(**(code **)(*(int *)pCVar10 + 0x850))();
fVar26 = *(float *)(this + 0x17f0);
lVar24 = (longdouble)SharedRandomFloat("CTerrorGun::FireBullet HorizSpread",-fVar26,fVar26,0);
lVar25 = (longdouble)SharedRandomFloat("CTerrorGun::FireBullet VertSpread",-fVar26,fVar26,0);
pfVar16 = (float *)(**(code **)(*(int *)pCVar10 + 0x238))();
local_34 = *pfVar16;
local_30 = pfVar16[1];
local_2c = pfVar16[2];
cVar8 = (**(code **)(*(int *)pCVar10 + 0x710))();
if (cVar8 != '\0') {
pcVar4 = *(code **)(*(int *)pCVar10 + 0x708);
(**(code **)(*(int *)this + 0x4c4))();
(**(code **)(*(int *)this + 0x72c))();
(**(code **)(*(int *)this + 0x4c8))();
(*pcVar4)();
piVar19 = (int *)&stack0xffffff80;
VectorAngles(local_28,(QAngle *)&local_34);
}
local_34 = (float)lVar24 + local_34;
*piVar19 = (int)pCVar10;
local_30 = (float)lVar25 + local_30;
piVar19[-1] = 0x566fe6;
pfVar16 = (float *)CBasePlayer::GetPunchAngle((CBasePlayer *)*piVar19);
local_34 = local_34 + *pfVar16;
local_30 = local_30 + pfVar16[1];
local_2c = local_2c + pfVar16[2];
iVar11 = *(int *)this;
*piVar19 = (int)this;
pcVar4 = *(code **)(iVar11 + 0x674);
piVar19[-1] = 0x56701d;
cVar8 = (*pcVar4)();
if ((cVar8 == '\0') || (*(int *)(this + 0x1420) % 2 != 1)) {
iVar11 = *(int *)this;
piVar19[1] = 0;
*piVar19 = (int)this;
pcVar4 = *(code **)(iVar11 + 0x6b4);
piVar19[-1] = 0x56704f;
cVar8 = (*pcVar4)();
local_54 = (-(uint)(cVar8 == '\0') & 0xffffffee) + 0x13;
}
else {
local_54 = 3;
}
iVar11 = *(int *)this;
*piVar19 = (int)this;
pcVar4 = *(code **)(iVar11 + 0x700);
piVar19[-1] = 0x567069;
cVar8 = (*pcVar4)();
if (cVar8 == '\0') {
LAB_00567071:
fVar26 = *(float *)(gpGlobals + 0xc);
iVar11 = *(int *)this;
*piVar19 = (int)this;
pcVar4 = *(code **)(iVar11 + 0x718);
piVar19[-1] = 0x56708b;
lVar24 = (longdouble)(*pcVar4)();
fVar26 = (float)lVar24 + fVar26;
if (fVar26 != *(float *)(this + 0x13fc)) {
if (this[0x6c] == (CTerrorGun)0x0) {
puVar5 = *(uint **)(this + 0x30);
if (puVar5 != (uint *)0x0) {
*puVar5 = *puVar5 | 0x101;
*piVar19 = (int)puVar5;
piVar19[-1] = 0x56773d;
iVar11 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*piVar19);
*(undefined2 *)(iVar11 + 2) = 0;
}
}
else {
this[0x70] = (CTerrorGun)((byte)this[0x70] | 1);
}
*(float *)(this + 0x13fc) = fVar26;
}
iVar15 = CBaseEntity::m_nPredictionRandomSeed;
iVar11 = *(int *)(gpGlobals + 0xc);
iVar12 = *(int *)(this + 0x1420);
iVar14 = *(int *)this;
*piVar19 = (int)this;
pcVar4 = *(code **)(iVar14 + 0x638);
piVar19[-1] = 0x5670ea;
iVar17 = (*pcVar4)();
iVar14 = *(int *)pCVar10;
piVar19[1] = (int)pCVar10;
*piVar19 = (int)local_28;
pcVar4 = *(code **)(iVar14 + 0x478);
piVar19[-1] = 0x567101;
(*pcVar4)();
piVar13 = piVar19 + -1;
if (*(int *)(pCVar10 + 0x30) == 0) {
iVar14 = 0;
}
else {
iVar14 = *(int *)(pCVar10 + 0x30) - *(int *)(gpGlobals + 0x58) >> 4;
}
piVar19[2] = iVar17;
piVar19[1] = (int)&local_34;
*piVar19 = (int)local_28;
piVar19[5] = iVar11;
piVar19[4] = iVar15;
piVar19[-1] = iVar14;
piVar19[3] = (uint)(iVar12 % 2 != 1);
piVar19[-2] = 0x56714e;
FireTerrorBullets();
if (this[0x145d] != (CTerrorGun)0x0) {
iVar11 = *(int *)pCVar10;
piVar19[-1] = (int)pCVar10;
pcVar4 = *(code **)(iVar11 + 0x90c);
piVar19[-2] = 0x567715;
cVar8 = (*pcVar4)();
if (cVar8 == '\0') goto LAB_00567180;
}
iVar12 = *(int *)this;
iVar11 = *(int *)(gpGlobals + 0xc);
piVar19[-1] = (int)this;
*piVar19 = local_54;
piVar19[1] = iVar11;
pcVar4 = *(code **)(iVar12 + 0x4b8);
piVar19[-2] = 0x56717e;
(*pcVar4)();
piVar13 = piVar19 + -1;
}
else {
*piVar19 = (int)this;
piVar19[-1] = 0x567378;
iVar11 = CWeaponCSBase::GetCSWpnData((CWeaponCSBase *)*piVar19);
if (*(int *)(iVar11 + 0x894) == 3) {
*piVar19 = (int)this;
piVar19[-1] = 0x567782;
iVar11 = CWeaponCSBase::GetCSWpnData((CWeaponCSBase *)*piVar19);
if (*(int *)(iVar11 + 0xbe8) == 2) goto LAB_00567071;
}
iVar11 = *(int *)this;
*piVar19 = (int)this;
pcVar4 = *(code **)(iVar11 + 0x718);
piVar19[-1] = 0x567390;
lVar24 = (longdouble)(*pcVar4)();
iVar11 = gpGlobals;
local_44 = *(float *)(this + 0x13fc);
fVar26 = *(float *)(gpGlobals + 0xc);
if ((*(float *)(gpGlobals + 0x10) < fVar26 - local_44) &&
(fVar27 = fVar26 - *(float *)(gpGlobals + 0x10), local_44 != fVar27)) {
if (this[0x6c] == (CTerrorGun)0x0) {
puVar5 = *(uint **)(this + 0x30);
if (puVar5 != (uint *)0x0) {
*puVar5 = *puVar5 | 0x101;
*piVar19 = (int)puVar5;
piVar19[-1] = 0x567592;
iVar11 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*piVar19);
*(undefined2 *)(iVar11 + 2) = 0;
iVar11 = gpGlobals;
}
}
else {
this[0x70] = (CTerrorGun)((byte)this[0x70] | 1);
}
*(float *)(this + 0x13fc) = fVar27;
fVar26 = *(float *)(iVar11 + 0xc);
local_44 = fVar27;
}
piVar13 = piVar19;
if ((local_44 <= fVar26) && (iVar11 = *(int *)(this + 0x1420), -1 < iVar11)) {
iVar12 = 0;
piVar20 = piVar19;
do {
iVar15 = CBaseEntity::m_nPredictionRandomSeed;
iVar14 = *(int *)this;
*piVar20 = (int)this;
pcVar4 = *(code **)(iVar14 + 0x638);
piVar20[-1] = 0x567441;
iVar17 = (*pcVar4)();
iVar14 = *(int *)pCVar10;
piVar20[1] = (int)pCVar10;
*piVar20 = (int)local_28;
pcVar4 = *(code **)(iVar14 + 0x478);
piVar20[-1] = 0x567456;
(*pcVar4)();
if (*(int *)(pCVar10 + 0x30) == 0) {
iVar14 = 0;
}
else {
iVar14 = *(int *)(pCVar10 + 0x30) - *(int *)(gpGlobals + 0x58) >> 4;
}
*piVar20 = (int)local_28;
piVar20[-1] = iVar14;
piVar20[4] = iVar15;
piVar20[5] = (int)local_44;
piVar20[2] = iVar17;
piVar20[3] = (uint)(iVar11 % 2 != 1);
piVar20[1] = (int)&local_34;
piVar20[-2] = 0x5674a6;
FireTerrorBullets();
iVar14 = *(int *)this;
iVar11 = *(int *)(this + 0x13fc);
piVar20[-1] = (int)this;
piVar20[1] = iVar11;
*piVar20 = local_54;
pcVar4 = *(code **)(iVar14 + 0x4b8);
piVar20[-2] = 0x5674c6;
(*pcVar4)();
fVar26 = (float)lVar24 + *(float *)(this + 0x13fc);
if (*(float *)(this + 0x13fc) != fVar26) {
if (this[0x6c] == (CTerrorGun)0x0) {
puVar5 = *(uint **)(this + 0x30);
if (puVar5 != (uint *)0x0) {
*puVar5 = *puVar5 | 0x101;
piVar20[-1] = (int)puVar5;
piVar20[-2] = 0x567504;
iVar11 = CBaseEdict::GetChangeAccessor((CBaseEdict *)piVar20[-1]);
*(undefined2 *)(iVar11 + 2) = 0;
}
}
else {
this[0x70] = (CTerrorGun)((byte)this[0x70] | 1);
}
*(float *)(this + 0x13fc) = fVar26;
}
if (iVar12 != 0) {
iVar11 = *(int *)(this + 0x1420);
if (this[0x6c] == (CTerrorGun)0x0) {
puVar5 = *(uint **)(this + 0x30);
if (puVar5 != (uint *)0x0) {
*puVar5 = *puVar5 | 0x101;
piVar20[-1] = (int)puVar5;
piVar20[-2] = 0x56754a;
iVar14 = CBaseEdict::GetChangeAccessor((CBaseEdict *)piVar20[-1]);
*(undefined2 *)(iVar14 + 2) = 0;
}
}
else {
this[0x70] = (CTerrorGun)((byte)this[0x70] | 1);
}
*(int *)(this + 0x1420) = iVar11 + -1;
}
local_44 = *(float *)(this + 0x13fc);
piVar13 = piVar20 + -1;
if (*(float *)(gpGlobals + 0xc) <= local_44 && local_44 != *(float *)(gpGlobals + 0xc))
break;
iVar11 = *(int *)(this + 0x1420);
iVar12 = iVar12 + 1;
piVar13 = piVar20 + -1;
piVar20 = piVar20 + -1;
} while (iVar12 <= iVar11);
}
}
LAB_00567180:
if (!bVar6) {
iVar11 = *(int *)this;
piVar13[1] = 0;
*piVar13 = (int)this;
pcVar4 = *(code **)(iVar11 + 0x6b4);
piVar13[-1] = 0x56761b;
cVar8 = (*pcVar4)();
if (cVar8 == '\0') {
iVar11 = *(int *)this;
piVar13[1] = 1;
*piVar13 = (int)this;
pcVar4 = *(code **)(iVar11 + 0x6b4);
piVar13[-1] = 0x5676a9;
cVar8 = (*pcVar4)();
if (cVar8 == '\0') goto LAB_0056718a;
}
CVar9 = this[0x1790];
if (CVar9 != (CTerrorGun)0x0) {
CVar1 = (CTerrorGun)((char)CVar9 + -1);
if (CVar9 != CVar1) {
if (this[0x6c] == (CTerrorGun)0x0) {
puVar5 = *(uint **)(this + 0x30);
if (puVar5 != (uint *)0x0) {
*puVar5 = *puVar5 | 0x101;
*piVar13 = (int)puVar5;
piVar13[-1] = 0x567655;
iVar11 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*piVar13);
*(undefined2 *)(iVar11 + 2) = 0;
}
}
else {
this[0x70] = (CTerrorGun)((byte)this[0x70] | 1);
}
this[0x1790] = CVar1;
CVar9 = CVar1;
}
if (CVar9 != (CTerrorGun)0x0) goto LAB_0056718a;
}
iVar11 = *(int *)this;
piVar13[1] = 0;
*piVar13 = (int)this;
pcVar4 = *(code **)(iVar11 + 0x6ac);
piVar13[-1] = 0x56767e;
(*pcVar4)();
iVar11 = *(int *)this;
piVar13[1] = 1;
*piVar13 = (int)this;
pcVar4 = *(code **)(iVar11 + 0x6ac);
piVar13[-1] = 0x567691;
(*pcVar4)();
}
LAB_0056718a:
if (*(int *)(this + 0x1420) == 0) {
iVar11 = *(int *)this;
*piVar13 = (int)this;
pcVar4 = *(code **)(iVar11 + 0x55c);
piVar13[-1] = 0x5675c3;
uVar18 = (*pcVar4)();
piVar13[1] = uVar18;
*piVar13 = (int)pCVar10;
piVar13[-1] = 0x5675d2;
iVar11 = CBaseCombatCharacter::GetAmmoCount((CBaseCombatCharacter *)*piVar13,piVar13[1]);
if (iVar11 < 1) {
piVar13[3] = 0;
piVar13[2] = 0;
piVar13[1] = (int)"!HEV_AMO0";
*piVar13 = (int)pCVar10;
piVar13[-1] = 0x5675fd;
CBasePlayer::SetSuitUpdate((CBasePlayer *)*piVar13,(char *)piVar13[1],piVar13[2],piVar13[3]);
}
}
iVar11 = *(int *)this;
fVar26 = *(float *)(gpGlobals + 0xc);
*piVar13 = (int)this;
piVar13[1] = (int)(fVar26 + 1.8);
pcVar4 = *(code **)(iVar11 + 0x404);
piVar13[-1] = 0x5671c7;
(*pcVar4)();
*piVar13 = (int)this;
piVar13[1] = (int)pCVar10;
piVar13[-1] = 0x5671d6;
DoViewPunch((CTerrorGun *)*piVar13,(CTerrorPlayer *)piVar13[1]);
*piVar13 = (int)this;
piVar13[-1] = 0x5671de;
AddFireBulletSpread((CTerrorGun *)*piVar13);
if ((*(int *)(this + 0x1420) == 0) && (this[0x17e3] != (CTerrorGun)0x1)) {
if (this[0x6c] == (CTerrorGun)0x0) {
puVar5 = *(uint **)(this + 0x30);
if (puVar5 != (uint *)0x0) {
*puVar5 = *puVar5 | 0x101;
*piVar13 = (int)puVar5;
piVar13[-1] = 0x567210;
iVar11 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*piVar13);
*(undefined2 *)(iVar11 + 2) = 0;
}
}
else {
this[0x70] = (CTerrorGun)((byte)this[0x70] | 1);
}
this[0x17e3] = (CTerrorGun)0x1;
}
iVar11 = *piVar7;
*piVar13 = (int)piVar7;
pcVar4 = *(code **)(iVar11 + 0x6c);
piVar13[-1] = 0x567228;
(*pcVar4)();
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.