L L4D2node

CBaseCombatCharacter::Weapon_FindUsable

0x005f4a60 · 1331 bytes · __thiscall

_ZN20CBaseCombatCharacter17Weapon_FindUsableERK6Vector

Decompiled

undefined (2 params)

/* CBaseCombatCharacter::Weapon_FindUsable(Vector const&) */

CBaseCombatWeapon * __thiscall
CBaseCombatCharacter::Weapon_FindUsable(CBaseCombatCharacter *this,Vector *param_1)

{
  char cVar1;
  int iVar2;
  int iVar3;
  uint uVar4;
  CBaseCombatWeapon *this_00;
  int iVar5;
  float fVar6;
  float fVar7;
  float fVar8;
  float local_1bc;
  float local_1b8;
  CBaseCombatWeapon *local_1b4;
  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;
  undefined4 local_188;
  undefined4 local_184;
  float local_180;
  undefined4 local_17c;
  undefined4 local_178;
  float local_174;
  CGameTrace local_170 [44];
  float local_144;
  char local_139;
  CBaseCombatWeapon *local_11c [67];
  
  if (((byte)this[0x14d] & 8) == 0) {
    fVar6 = *(float *)param_1;
    fVar7 = *(float *)(param_1 + 4);
    fVar8 = *(float *)(param_1 + 8);
    local_1a0 = *(float *)(this + 0x2e0);
    local_19c = *(float *)(this + 0x2e4);
    local_198 = *(float *)(this + 0x2e8);
    local_1ac = local_1a0 - fVar6;
    local_1a8 = local_19c - fVar7;
    local_1a4 = local_198 - fVar8;
  }
  else {
    CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
    fVar6 = *(float *)param_1;
    fVar7 = *(float *)(param_1 + 4);
    fVar8 = *(float *)(param_1 + 8);
    local_1a0 = *(float *)(this + 0x2e0);
    local_19c = *(float *)(this + 0x2e4);
    local_198 = *(float *)(this + 0x2e8);
    local_1ac = local_1a0 - fVar6;
    local_1a8 = local_19c - fVar7;
    local_1a4 = local_198 - fVar8;
    if ((*(uint *)(this + 0x14c) & 0x800) != 0) {
      CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
      fVar6 = *(float *)param_1;
      fVar7 = *(float *)(param_1 + 4);
      fVar8 = *(float *)(param_1 + 8);
      local_1a0 = *(float *)(this + 0x2e0);
      local_19c = *(float *)(this + 0x2e4);
      local_198 = *(float *)(this + 0x2e8);
    }
  }
  local_1a0 = local_1a0 + fVar6;
  local_19c = local_19c + fVar7;
  local_198 = local_198 + fVar8;
  iVar2 = CBaseCombatWeapon::GetAvailableWeaponsInBox
                    (local_11c,0x40,(Vector *)&local_1ac,(Vector *)&local_1a0);
  if (iVar2 < 1) {
    local_1b4 = (CBaseCombatWeapon *)0x0;
  }
  else {
    iVar5 = 0;
    local_1b4 = (CBaseCombatWeapon *)0x0;
    local_1bc = 1e+06;
    do {
      while( true ) {
        this_00 = local_11c[iVar5];
        (**(code **)(*(int *)this_00 + 0x25c))(this_00,&local_194,0);
        cVar1 = (**(code **)(*(int *)this_00 + 0x4fc))(this_00);
        if ((((cVar1 != '\0') &&
             (local_190 * local_190 + local_18c * local_18c + local_194 * local_194 <= 1.0)) &&
            (cVar1 = (**(code **)(*(int *)this + 0x464))(this,this_00), cVar1 != '\0')) &&
           (cVar1 = CBaseCombatWeapon::IsLocked(this_00,(CBaseEntity *)this), cVar1 == '\0')) break;
LAB_005f4b58:
        iVar5 = iVar5 + 1;
        if (iVar5 == iVar2) goto LAB_005f4e60;
      }
      iVar3 = GetActiveWeapon(this);
      if (iVar3 != 0) {
        iVar3 = GetActiveWeapon(this);
        if (((*(char **)(iVar3 + 0x7c) == *(char **)(this_00 + 0x7c)) ||
            (*(char **)(this_00 + 0x7c) == "weapon_pistol")) ||
           (cVar1 = CBaseEntity::ClassMatchesComplex((CBaseEntity *)this_00,"weapon_pistol"),
           cVar1 != '\0')) goto LAB_005f4b58;
      }
      local_1b8 = SQRT((*(float *)(this_00 + 0x39c) - *(float *)(this + 0x39c)) *
                       (*(float *)(this_00 + 0x39c) - *(float *)(this + 0x39c)) +
                       (*(float *)(this_00 + 0x3a0) - *(float *)(this + 0x3a0)) *
                       (*(float *)(this_00 + 0x3a0) - *(float *)(this + 0x3a0)) +
                       (*(float *)(this_00 + 0x3a4) - *(float *)(this + 0x3a4)) *
                       (*(float *)(this_00 + 0x3a4) - *(float *)(this + 0x3a4)));
      if (((byte)this_00[0x148] & 2) != 0) {
        local_1b8 = local_1b8 * 0.5;
      }
      if (local_1b4 != (CBaseCombatWeapon *)0x0) {
        if ((*(char **)(this_00 + 0x7c) == "weapon_ar2") ||
           (cVar1 = CBaseEntity::ClassMatchesComplex((CBaseEntity *)this_00,"weapon_ar2"),
           cVar1 != '\0')) {
          local_1b8 = local_1b8 * 0.5;
        }
        uVar4 = (**(code **)(*(int *)this_00 + 0x5bc))(this_00);
        if (((uVar4 & 0x6000) == 0) || (local_1bc < local_1b8)) goto LAB_005f4b58;
      }
      cVar1 = Weapon_IsOnGround(this,this_00);
      if (cVar1 != '\0') {
        if (((byte)this_00[0x14d] & 8) != 0) {
          CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this_00);
        }
        local_188 = *(undefined4 *)(this_00 + 0x2e0);
        local_184 = *(undefined4 *)(this_00 + 0x2e4);
        local_180 = *(float *)(this_00 + 0x2e8);
        local_174 = local_180 + 1.0;
        local_17c = local_188;
        local_178 = local_184;
        UTIL_TraceEntity((CBaseEntity *)this,(Vector *)&local_188,(Vector *)&local_17c,0x200400b,
                         (IHandleEntity *)this_00,0,local_170);
        if ((local_139 != '\0') || (local_144 < 1.0)) goto LAB_005f4b58;
      }
      cVar1 = (**(code **)(*(int *)this + 0x264))(this,this_00,0x4041,0);
      if (cVar1 == '\0') {
        local_1b8 = local_1bc;
        this_00 = local_1b4;
      }
      iVar5 = iVar5 + 1;
      local_1bc = local_1b8;
      local_1b4 = this_00;
    } while (iVar5 != iVar2);
LAB_005f4e60:
    if (local_1b4 != (CBaseCombatWeapon *)0x0) {
      CBaseCombatWeapon::Lock(local_1b4,2.0,(CBaseEntity *)this);
    }
  }
  return local_1b4;
}

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)