CBaseEntity::FireBullets
0x00410d20 · 4524 bytes · __thiscall
_ZN11CBaseEntity11FireBulletsERK17FireBulletsInfo_t
Decompiled
undefined (2 params)
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* CBaseEntity::FireBullets(FireBulletsInfo_t const&) */
void __thiscall CBaseEntity::FireBullets(CBaseEntity *this,FireBulletsInfo_t *param_1)
{
int iVar1;
float fVar2;
code *pcVar3;
byte bVar4;
char cVar5;
CAmmoDef *this_00;
uint uVar6;
uint uVar7;
CBaseCombatCharacter *this_01;
int *piVar8;
int iVar9;
CBaseEntity *pCVar10;
undefined4 uVar11;
undefined1 *puVar12;
uint uVar13;
undefined4 *puVar14;
uchar uVar15;
undefined *puVar16;
uint uVar17;
byte bVar18;
longdouble lVar19;
longdouble lVar20;
float fVar21;
float fVar22;
float fVar23;
CTakeDamageInfo *this_02;
CGameTrace *pCVar24;
Vector *pVVar25;
float local_240;
int local_23c;
uint local_22c;
char local_214;
Vector *local_210;
float local_208;
float local_204;
float local_200;
float local_1fc;
float local_1f8;
float local_1f4;
float local_1f0;
float local_1ec;
float local_1e8;
undefined **local_1e4;
CBaseEntity *local_1e0;
undefined4 local_1d4 [3];
undefined4 local_1c8;
undefined4 local_1c4;
float local_1c0;
float local_1bc;
float local_1b8;
float local_1b4;
float local_1b0;
float local_1ac;
float local_1a8;
float local_1a4;
float local_1a0;
float local_19c;
float local_198;
float local_194;
float local_190;
float local_18c;
float local_188;
float local_184;
float local_180;
float local_17c;
float local_178;
undefined4 local_174;
undefined4 local_170;
undefined4 local_16c;
undefined1 local_168;
undefined1 local_167;
undefined2 local_166;
float local_164;
undefined4 local_160;
undefined2 local_15c;
undefined1 local_15a;
char local_159;
undefined4 local_158;
undefined4 local_154;
undefined4 local_150;
undefined4 local_14c;
undefined2 local_148;
undefined2 local_146;
CBaseEntity *local_144;
uint local_140;
float local_13c;
float local_138;
float local_134;
undefined4 local_e8;
float local_dc;
float local_d8;
float local_d4;
float local_cc;
float local_c8;
float local_c4;
undefined4 local_bc;
undefined4 local_b8;
undefined4 local_b4;
undefined4 local_ac;
undefined4 local_a8;
undefined4 local_a4;
float local_a0;
undefined4 local_9c;
undefined1 local_98;
undefined1 local_97;
undefined4 local_88;
float local_7c;
float local_78;
float local_74;
float local_70;
float local_6c;
float local_68;
float local_64;
undefined4 local_60;
undefined4 local_5c;
undefined4 local_58;
undefined4 local_54;
float local_50;
undefined4 local_4c;
undefined4 local_48;
undefined4 local_44;
undefined4 local_40;
undefined4 local_3c;
undefined4 local_38;
undefined2 local_34;
undefined2 local_32;
CBaseEntity *local_30;
uint local_2c;
undefined4 local_28;
undefined1 local_24;
undefined1 local_23;
this_00 = (CAmmoDef *)GetAmmoDef();
uVar6 = CAmmoDef::DamageType(this_00,*(int *)(param_1 + 0x2c));
uVar7 = CAmmoDef::Flags(this_00,*(int *)(param_1 + 0x2c));
cVar5 = (**(code **)(*(int *)this + 0x16c))(this);
if (cVar5 != '\0') {
this_01 = (CBaseCombatCharacter *)__dynamic_cast(this,&typeinfo,&CBasePlayer::typeinfo,0);
piVar8 = (int *)CBaseCombatCharacter::GetActiveWeapon(this_01);
iVar9 = (**(code **)(*piVar8 + 0x544))(piVar8);
if (iVar9 != -1) {
uVar15 = (uchar)iVar9;
if (iVar9 == 5) {
uVar15 = (*(int *)param_1 == 0xc) + '\x05';
}
CBasePlayer::RumbleEffect((CBasePlayer *)this_01,uVar15,'\0','\x04');
}
}
local_23c = *(int *)(param_1 + 0x38);
if ((local_23c == 0) && ((uVar7 & 2) != 0)) {
local_23c = CAmmoDef::PlrDamage(this_00,*(int *)(param_1 + 0x2c));
}
pCVar10 = *(CBaseEntity **)(param_1 + 0x44);
if (*(CBaseEntity **)(param_1 + 0x44) == (CBaseEntity *)0x0) {
pCVar10 = this;
}
if ((((_DAT_00f9e2e0 != 0xffffffff) &&
(puVar16 = g_pEntityList + (_DAT_00f9e2e0 & 0xfff) * 0x10, puVar16 != (undefined *)0xfffffffc
)) && (*(uint *)(puVar16 + 8) == _DAT_00f9e2e0 >> 0xc)) && (*(int *)(puVar16 + 4) != 0)) {
ApplyMultiDamage();
}
ClearMultiDamage();
_DAT_00f9e2c8 = uVar6 | 0x1000;
CTraceFilterSimpleList::CTraceFilterSimpleList((CTraceFilterSimpleList *)&local_1e4,0);
local_1e0 = this;
local_1e4 = &PTR_ShouldHitEntity_00c09948;
/* try { // try from 00410e81 to 00411ad9 has its CatchHandler @ 00411f32 */
CTraceFilterSimpleList::AddEntityToIgnore
((CTraceFilterSimpleList *)&local_1e4,*(IHandleEntity **)(param_1 + 0x48));
cVar5 = (**(code **)(*(int *)this + 0x16c))(this);
uVar17 = (uint)(byte)m_nPredictionRandomSeed;
local_1c0 = *(float *)(param_1 + 0x10);
local_1bc = *(float *)(param_1 + 0x14);
if (cVar5 == '\0') {
uVar17 = 0;
}
local_1b8 = *(float *)(param_1 + 0x18);
VectorVectors((Vector *)&local_1c0,(Vector *)&local_1b4,(Vector *)&local_1a8);
if (*(int *)param_1 < 1) {
local_240 = 0.0;
}
else {
local_22c = 0;
local_240 = 0.0;
do {
cVar5 = (**(code **)(*(int *)this + 0x16c))(this);
if (cVar5 != '\0') {
RandomSeed(local_22c + uVar17);
}
if (((local_22c != 0) || (*(int *)param_1 < 2)) ||
(fVar23 = local_1c0, fVar22 = local_1bc, fVar21 = local_1b8, ((byte)param_1[0x3c] & 1) == 0
)) {
fVar23 = *(float *)(ai_shot_bias_max._28_4_ + 0x2c);
fVar22 = ABS(fVar23) * 0.5;
do {
lVar20 = (longdouble)(**(code **)(*random_valve + 4))(random_valve,0xbf800000,0x3f800000);
lVar19 = (longdouble)(**(code **)(*random_valve + 4))(random_valve,0xbf800000,0x3f800000);
local_210 = (Vector *)((float)lVar19 * (1.0 - fVar22) + (float)lVar20 * fVar22);
lVar20 = (longdouble)(**(code **)(*random_valve + 4))(random_valve,0xbf800000,0x3f800000);
lVar19 = (longdouble)(**(code **)(*random_valve + 4))(random_valve,0xbf800000,0x3f800000);
fVar21 = (float)lVar19 * (1.0 - fVar22) + (float)lVar20 * fVar22;
if (fVar23 < 0.0) {
if ((float)local_210 < 0.0) {
local_210 = (Vector *)(-1.0 - (float)local_210);
}
else {
local_210 = (Vector *)(1.0 - (float)local_210);
}
if (fVar21 < 0.0) {
fVar21 = -1.0 - fVar21;
}
else {
fVar21 = 1.0 - fVar21;
}
}
} while (1.0 < fVar21 * fVar21 + (float)local_210 * (float)local_210);
fVar21 = fVar21 * *(float *)(param_1 + 0x20);
fVar23 = *(float *)(param_1 + 0x1c) * (float)local_210;
local_19c = local_1a8 * fVar21 + local_1b4 * fVar23 + local_1c0;
local_198 = local_1a4 * fVar21 + local_1b0 * fVar23 + local_1bc;
local_194 = fVar21 * local_1a0 + fVar23 * local_1ac + local_1b8;
fVar23 = local_19c;
fVar22 = local_198;
fVar21 = local_194;
}
fVar2 = *(float *)(param_1 + 0x28);
local_1f8 = fVar22 * fVar2 + *(float *)(param_1 + 8);
local_1f4 = fVar21 * fVar2 + *(float *)(param_1 + 0xc);
local_1fc = fVar2 * fVar23 + *(float *)(param_1 + 4);
local_208 = fVar23;
local_204 = fVar22;
local_200 = fVar21;
cVar5 = (**(code **)(*(int *)this + 0x16c))(this);
if (((cVar5 == '\0') || (*(int *)param_1 < 2)) || ((local_22c & 1) == 0)) {
local_78 = *(float *)(param_1 + 8);
local_44 = 0;
local_74 = *(float *)(param_1 + 0xc);
local_48 = 0;
local_4c = 0;
local_3c = 0;
local_68 = local_1f8 - local_78;
local_7c = *(float *)(param_1 + 4);
local_64 = local_1f4 - local_74;
local_54 = 0;
local_58 = 0;
local_6c = local_1fc - local_7c;
local_5c = 0;
local_38._0_2_ =
CONCAT11(local_64 * local_64 + local_68 * local_68 + local_6c * local_6c != 0.0,1);
(**(code **)(*enginetrace + 0x14))(enginetrace,&local_7c,0x46004003,&local_1e4,&local_190);
if (*(int *)(r_visualizetraces._28_4_ + 0x30) != 0) {
iVar9 = 0;
goto LAB_00411128;
}
}
else {
local_dc = *(float *)(param_1 + 4);
local_98 = 0;
local_d8 = *(float *)(param_1 + 8);
local_9c = 0;
local_cc = local_1fc - local_dc;
local_d4 = *(float *)(param_1 + 0xc);
local_c8 = local_1f8 - local_d8;
local_ac = 0x40400000;
local_a8 = 0x40400000;
local_c4 = local_1f4 - local_d4;
local_a4 = 0x40400000;
local_bc = 0;
local_b8 = 0;
local_b4 = 0;
local_97 = local_c8 * local_c8 + local_cc * local_cc + local_c4 * local_c4 != 0.0;
(**(code **)(*enginetrace + 0x14))(enginetrace,&local_dc,0x46004003,&local_1e4,&local_190);
if (*(int *)(r_visualizetraces._28_4_ + 0x30) != 0) {
iVar9 = 0xff;
LAB_00411128:
local_210 = (Vector *)&local_190;
DebugDrawLine(local_210,(Vector *)&local_184,0xff,iVar9,0,true,-1.0);
}
}
local_210 = (Vector *)&local_190;
if (local_159 != '\0') {
local_164 = 0.0;
local_184 = local_190;
local_180 = local_18c;
local_17c = local_188;
}
if (*(int *)(ai_debug_shoot_positions._28_4_ + 0x30) != 0) {
NDebugOverlay::Line((Vector *)(param_1 + 4),(Vector *)&local_1fc,0xff,0xff,0xff,false,0.1);
}
CTakeDamageInfo::CTakeDamageInfo
((CTakeDamageInfo *)&local_13c,this,pCVar10,(float)*(int *)(param_1 + 0x34),uVar6,0)
;
CalculateBulletDamageForce
((CTakeDamageInfo *)&local_13c,*(int *)(param_1 + 0x2c),(Vector *)&local_208,
(Vector *)&local_184,1.0);
fVar23 = *(float *)(param_1 + 0x40);
local_e8 = *(undefined4 *)(param_1 + 0x2c);
local_13c = local_13c * fVar23;
local_138 = local_138 * fVar23;
local_134 = fVar23 * local_134;
TraceAttackToTriggers
(this,(CTakeDamageInfo *)&local_13c,local_210,(Vector *)&local_184,
(Vector *)&local_208);
if (*(int *)(param_1 + 0x2c) == -1) {
DevMsg("ERROR: Undefined ammo type!\n");
goto LAB_004115ad;
}
local_1f0 = local_184;
local_1ec = local_180;
local_1e8 = local_17c;
if (local_164 != 1.0) {
UpdateShotStatistics((CGameTrace *)this);
CSoundEnt::InsertSound
(0x10,(Vector *)&local_184,200,0.5,this,
(*(int *)(param_1 + 0x3c) << 0x1c) >> 0x1f & 6,(CBaseEntity *)0x0);
uVar13 = (**(code **)*enginetrace)(enginetrace,&local_184,0x4030,0);
if ((uVar13 & 0x30) == 0) {
local_214 = '\0';
}
else {
/* try { // try from 00411cad to 00411d0f has its CatchHandler @ 00411f32 */
local_214 = HandleShotImpactingWater
(this,param_1,(Vector *)&local_1fc,(ITraceFilter *)&local_1e4,
(Vector *)&local_1f0);
}
fVar23 = (float)*(int *)(param_1 + 0x34);
if (local_23c != 0) {
cVar5 = (**(code **)(*(int *)local_144 + 0x16c))(local_144);
if (cVar5 == '\0') {
/* try { // try from 00411e13 to 00411e8c has its CatchHandler @ 00411f32 */
iVar9 = (**(code **)(*(int *)local_144 + 0x18c))(local_144);
if (iVar9 != 0) {
puVar14 = (undefined4 *)(**(code **)(*(int *)local_144 + 0x18c))(local_144);
iVar9 = (**(code **)*puVar14)(puVar14,0);
if (iVar9 != 0) {
puVar14 = (undefined4 *)(**(code **)(*(int *)local_144 + 0x18c))(local_144);
piVar8 = (int *)(**(code **)*puVar14)(puVar14,0);
cVar5 = (**(code **)(*piVar8 + 0x16c))(piVar8);
if (cVar5 != '\0') goto LAB_00411d18;
}
}
}
else {
LAB_00411d18:
fVar23 = (float)local_23c;
}
}
if (fVar23 == 0.0) {
lVar20 = (longdouble)
(**(code **)(*g_pGameRules + 0x80))
(g_pGameRules,pCVar10,local_144,*(undefined4 *)(param_1 + 0x2c));
fVar23 = (float)lVar20;
uVar13 = uVar6;
}
else {
uVar13 = uVar6 | 0x2000;
if (fVar23 <= 16.0) {
uVar13 = uVar6 | 0x1000;
}
}
if ((local_214 == '\0') || (((byte)param_1[0x3c] & 2) == 0)) {
this_02 = (CTakeDamageInfo *)&local_dc;
/* try { // try from 00411b66 to 00411c7f has its CatchHandler @ 00411ef2 */
CTakeDamageInfo::CTakeDamageInfo(this_02,this,pCVar10,fVar23,uVar13,0);
CalculateBulletDamageForce
(this_02,*(int *)(param_1 + 0x2c),(Vector *)&local_208,(Vector *)&local_184,1.0)
;
local_88 = *(undefined4 *)(param_1 + 0x2c);
fVar23 = *(float *)(param_1 + 0x40);
local_dc = local_dc * fVar23;
pCVar24 = (CGameTrace *)&local_208;
local_d8 = local_d8 * fVar23;
local_d4 = fVar23 * local_d4;
pVVar25 = local_210;
DispatchTraceAttack((CTakeDamageInfo *)local_144,(Vector *)this_02,pCVar24);
if ((local_144 != (CBaseEntity *)0x0) &&
(iVar9 = (**(code **)(*(int *)local_144 + 0x144))(local_144,this_02,pCVar24,pVVar25),
iVar9 != 0)) {
local_240 = local_240 + local_a0;
}
if ((local_214 == '\0') || (((byte)param_1[0x3c] & 4) != 0)) {
(**(code **)(*(int *)this + 0x1f0))(this,local_210,uVar6);
}
else {
local_24 = 0;
local_70 = local_190;
local_64 = 0.0;
local_6c = local_18c;
local_68 = local_188;
local_7c = local_184;
local_60 = 0;
local_78 = local_180;
local_5c = 0;
local_58 = 0;
local_54 = 0;
local_50 = 0.0;
local_4c = 0;
local_48 = 0;
local_44 = 0x3f800000;
local_38 = 0;
local_34 = 0;
local_40 = 0;
local_3c = 0;
local_30 = (CBaseEntity *)0x0;
local_28 = 0;
local_23 = 0;
local_74 = local_17c;
local_2c = uVar6;
/* try { // try from 00411dfe to 00411e02 has its CatchHandler @ 00411ef2 */
DispatchEffect("RagdollImpact",(CEffectData *)&local_7c);
}
if ((uVar7 & 1) != 0) {
Pickup_ForcePlayerToDropThisObject(local_144);
}
}
}
if (local_144 == (CBaseEntity *)0x0) {
LAB_0041131c:
iVar9 = *(int *)(param_1 + 0x30);
bVar18 = 0;
bVar4 = 0;
if (iVar9 == 0) goto LAB_00411640;
LAB_00411329:
bVar18 = bVar4;
iVar1 = FireBullets(FireBulletsInfo_t_const&)::tracerCount + 1;
iVar9 = FireBullets(FireBulletsInfo_t_const&)::tracerCount % iVar9;
FireBullets(FireBulletsInfo_t_const&)::tracerCount = iVar1;
if (iVar9 != 0) goto LAB_00411640;
if (bVar18 != 0) goto LAB_0041164a;
local_dc = vec3_origin;
local_d8 = DAT_01053d4c;
local_d4 = DAT_01053d50;
ComputeTracerStartPosition(this,(Vector *)(param_1 + 4),(Vector *)&local_dc);
local_7c = local_190;
local_78 = local_18c;
local_74 = local_188;
local_64 = local_178;
local_60 = local_174;
local_54 = CONCAT22(local_166,CONCAT11(local_167,local_168));
local_5c = local_170;
local_58 = local_16c;
local_4c = local_160;
local_50 = local_164;
local_44 = local_158;
local_48 = CONCAT13(local_159,CONCAT12(local_15a,local_15c));
local_40 = local_154;
local_3c = local_150;
local_70 = local_1f0;
local_38 = local_14c;
local_6c = local_1ec;
local_68 = local_1e8;
local_34 = local_148;
local_32 = local_146;
local_30 = local_144;
local_2c = local_140;
pcVar3 = *(code **)(*(int *)this + 0x1e4);
uVar11 = CAmmoDef::TracerType(this_00,*(int *)(param_1 + 0x2c));
(*pcVar3)(this,(Vector *)&local_dc,&local_7c,uVar11);
}
else {
iVar9 = (**(code **)(*physprops + 0x18))(physprops,(int)(short)local_150);
if (((iVar9 == 0) || (*(short *)(iVar9 + 0x4c) != 0x59)) ||
((*(char **)(local_144 + 0x7c) != "func_breakable" &&
(cVar5 = ClassMatchesComplex(local_144,"func_breakable"), cVar5 == '\0'))))
goto LAB_0041131c;
iVar9 = *(int *)(param_1 + 0x30);
bVar18 = ((byte)(*(uint *)(local_144 + 0x148) >> 0xb) ^ 1) & 1;
bVar4 = bVar18;
if (iVar9 != 0) goto LAB_00411329;
LAB_00411640:
if (bVar18 != 0) {
LAB_0041164a:
HandleShotImpactingGlass
(this,param_1,(CGameTrace *)local_210,(Vector *)&local_208,
(ITraceFilter *)&local_1e4);
}
}
local_22c = local_22c + 1;
} while ((int)local_22c < *(int *)param_1);
}
ApplyMultiDamage();
cVar5 = (**(code **)(*(int *)this + 0x16c))(this);
if ((cVar5 != '\0') && (0.0 < local_240)) {
CTakeDamageInfo::CTakeDamageInfo((CTakeDamageInfo *)&local_7c,this,pCVar10,local_240,uVar6,0);
pcVar3 = *(code **)(*(int *)gamestats + 0x78);
iVar9 = CBaseCombatCharacter::GetActiveWeapon((CBaseCombatCharacter *)this);
puVar12 = &DAT_00d539c2;
if (*(undefined1 **)(iVar9 + 0x7c) != (undefined1 *)0x0) {
puVar12 = *(undefined1 **)(iVar9 + 0x7c);
}
(*pcVar3)(gamestats,this,param_1[0x4c],puVar12,(CTakeDamageInfo *)&local_7c);
}
LAB_004115ad:
local_1e4 = &PTR_ShouldHitEntity_00c54590;
local_1c8 = 0;
CUtlMemory<IHandleEntity*,int>::Purge((CUtlMemory<IHandleEntity*,int> *)local_1d4);
local_1c4 = local_1d4[0];
CUtlMemory<IHandleEntity*,int>::Purge((CUtlMemory<IHandleEntity*,int> *)local_1d4);
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.