L L4D2node

CEnvGunfire::ShootThink

0x00673810 · 2215 bytes · __thiscall

_ZN11CEnvGunfire10ShootThinkEv

Decompiled

undefined (1 param)

/* CEnvGunfire::ShootThink() */

void __thiscall CEnvGunfire::ShootThink(CEnvGunfire *this)

{
  CEnvGunfire *pCVar1;
  uint uVar2;
  undefined *puVar3;
  longdouble lVar4;
  longdouble lVar5;
  float fVar6;
  float fVar7;
  float fVar8;
  float fVar9;
  char *pcVar10;
  float local_118;
  float local_114;
  float local_110;
  CTraceFilterSimple local_10c [16];
  float local_fc;
  float local_f8;
  float local_f4;
  float local_f0;
  float local_ec;
  float local_e8;
  float local_e4;
  float local_e0;
  float local_dc;
  float local_d8;
  float local_d4;
  float local_d0;
  float local_cc;
  float local_c8;
  float local_c4;
  float local_bc;
  float local_b8;
  float local_b4;
  undefined4 local_ac;
  undefined4 local_a8;
  undefined4 local_a4;
  undefined4 local_9c;
  undefined4 local_98;
  undefined4 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_44;
  
  uVar2 = *(uint *)(this + 0x48c);
  if ((((uVar2 == 0xffffffff) ||
       (puVar3 = g_pEntityList + (uVar2 & 0xfff) * 0x10, puVar3 == (undefined *)0xfffffffc)) ||
      (*(uint *)(puVar3 + 8) != uVar2 >> 0xc)) || (*(int *)(puVar3 + 4) == 0)) {
    StopShooting(this);
  }
  CBaseEntity::SetNextThink
            ((CBaseEntity *)this,*(float *)(this + 0x450) + *(float *)(gpGlobals + 0xc),(char *)0x0)
  ;
  UpdateTarget(this);
  if (((byte)this[0x14d] & 8) != 0) {
    CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
  }
  local_118 = *(float *)(this + 0x474) - *(float *)(this + 0x2e0);
  local_114 = *(float *)(this + 0x478) - *(float *)(this + 0x2e4);
  local_110 = *(float *)(this + 0x47c) - *(float *)(this + 0x2e8);
  VectorNormalize((Vector *)&local_118);
  local_fc = local_118;
  local_f8 = local_114;
  local_f4 = local_110;
  VectorVectors((Vector *)&local_fc,(Vector *)&local_f0,(Vector *)&local_e4);
  fVar7 = 0.0;
  if (0.0 <= *(float *)(this + 0x484)) {
    fVar7 = *(float *)(this + 0x484);
  }
  if (1.0 <= fVar7) {
    fVar7 = 1.0;
  }
  fVar7 = *(float *)(ai_shot_bias_min._28_4_ + 0x2c) +
          fVar7 * (*(float *)(ai_shot_bias_max._28_4_ + 0x2c) -
                  *(float *)(ai_shot_bias_min._28_4_ + 0x2c));
  fVar9 = ABS(fVar7) * 0.5;
  do {
    lVar4 = (longdouble)(**(code **)(*random_valve + 4))(random_valve,0xbf800000,0x3f800000);
    lVar5 = (longdouble)(**(code **)(*random_valve + 4))(random_valve,0xbf800000,0x3f800000);
    fVar6 = (float)lVar5 * (1.0 - fVar9) + (float)lVar4 * fVar9;
    lVar4 = (longdouble)(**(code **)(*random_valve + 4))(random_valve,0xbf800000,0x3f800000);
    lVar5 = (longdouble)(**(code **)(*random_valve + 4))(random_valve,0xbf800000,0x3f800000);
    fVar8 = (float)lVar5 * (1.0 - fVar9) + (float)lVar4 * fVar9;
    if (fVar7 < 0.0) {
      if (fVar6 < 0.0) {
        fVar6 = -1.0 - fVar6;
      }
      else {
        fVar6 = 1.0 - fVar6;
      }
      if (fVar8 < 0.0) {
        fVar8 = -1.0 - fVar8;
      }
      else {
        fVar8 = 1.0 - fVar8;
      }
    }
  } while (1.0 < fVar8 * fVar8 + fVar6 * fVar6);
  fVar8 = fVar8 * *(float *)(this + 0x46c);
  fVar6 = fVar6 * *(float *)(this + 0x468);
  local_118 = local_e4 * fVar8 + local_f0 * fVar6 + local_fc;
  local_114 = local_e0 * fVar8 + local_ec * fVar6 + local_f8;
  local_110 = fVar8 * local_dc + fVar6 * local_e8 + local_f4;
  local_d8 = local_118;
  local_d4 = local_114;
  local_d0 = local_110;
  if (this[0x488] == (CEnvGunfire)0x0) {
    fVar7 = *(float *)(this + 0x480);
    fVar6 = local_118 * fVar7;
    fVar9 = local_114 * fVar7;
    fVar7 = local_110 * fVar7;
    uVar2 = 0;
    if ((*(uint *)(this + 0x14c) & 0x800) != 0) {
      CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
      uVar2 = *(uint *)(this + 0x14c) & 0x800;
    }
    pcVar10 = *(char **)(this + 0x458);
    local_c8 = fVar9 + *(float *)(this + 0x2e4);
    local_c4 = fVar7 + *(float *)(this + 0x2e8);
    local_cc = fVar6 + *(float *)(this + 0x2e0);
  }
  else {
    fVar6 = local_118 * 8192.0;
    fVar9 = local_114 * 8192.0;
    fVar7 = local_110 * 8192.0;
    if (((byte)this[0x14d] & 8) == 0) {
      local_cc = *(float *)(this + 0x2e0);
      local_c8 = *(float *)(this + 0x2e4);
      local_c4 = *(float *)(this + 0x2e8);
      fVar6 = fVar6 + local_cc;
      fVar9 = fVar9 + local_c8;
      fVar7 = fVar7 + local_c4;
    }
    else {
      CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
      local_cc = *(float *)(this + 0x2e0);
      local_c8 = *(float *)(this + 0x2e4);
      fVar6 = fVar6 + local_cc;
      local_c4 = *(float *)(this + 0x2e8);
      fVar9 = fVar9 + local_c8;
      fVar7 = fVar7 + local_c4;
      if (((byte)this[0x14d] & 8) != 0) {
        CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
        local_cc = *(float *)(this + 0x2e0);
        local_c8 = *(float *)(this + 0x2e4);
        local_c4 = *(float *)(this + 0x2e8);
      }
    }
    local_bc = fVar6 - local_cc;
    local_b4 = fVar7 - local_c4;
    local_b8 = fVar9 - local_c8;
    local_94 = 0;
    local_98 = 0;
    local_9c = 0;
    local_8c = 0;
    local_87 = local_b4 * local_b4 + local_bc * local_bc + local_b8 * local_b8 != 0.0;
    local_88 = 1;
    local_a4 = 0;
    local_a8 = 0;
    local_ac = 0;
    CTraceFilterSimple::CTraceFilterSimple
              (local_10c,(IHandleEntity *)this,0,(_func_bool_IHandleEntity_ptr_int *)0x0);
    (**(code **)(*enginetrace + 0x14))(enginetrace,&local_cc,0x46004003,local_10c,local_70);
    if (*(int *)(r_visualizetraces._28_4_ + 0x30) != 0) {
      DebugDrawLine(local_70,(Vector *)&local_64,0xff,0,0,true,-1.0);
    }
    if (local_44 != 1.0) {
      (**(code **)(*(int *)this + 0x1f0))(this,local_70,2);
    }
    pcVar10 = *(char **)(this + 0x458);
    uVar2 = *(uint *)(this + 0x14c) & 0x800;
    local_c8 = local_60;
    local_c4 = local_5c;
    local_cc = local_64;
  }
  if (pcVar10 == (char *)0x0) {
    if (uVar2 != 0) {
      CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
    }
    pcVar10 = (char *)0x0;
  }
  else if (uVar2 != 0) {
    CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
  }
  UTIL_Tracer((Vector *)(this + 0x2e0),(Vector *)&local_cc,0,-1,5000.0,true,pcVar10,0);
  pcVar10 = "";
  if (*(char **)(this + 0x454) != (char *)0x0) {
    pcVar10 = *(char **)(this + 0x454);
  }
  CBaseEntity::EmitSound((CBaseEntity *)this,pcVar10,0.0,(float *)0x0);
  pCVar1 = this + 0x460;
  *(int *)pCVar1 = *(int *)pCVar1 + -1;
  if (*(int *)pCVar1 == 0) {
    StartShooting(this);
    fVar7 = *(float *)(gpGlobals + 0xc);
    lVar4 = (longdouble)
            (**(code **)(*random_valve + 4))
                      (random_valve,*(undefined4 *)(this + 0x448),*(undefined4 *)(this + 0x44c));
    CBaseEntity::SetNextThink((CBaseEntity *)this,(float)lVar4 + fVar7,(char *)0x0);
  }
  return;
}

SourceMod gamedata

paste into addons/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.



        

        

          

Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.

Return-type handling cheatsheet (DHookReturn)