L L4D2node

GetUseTypeForWeapon

0x00570710 · 674 bytes · __cdecl

_Z19GetUseTypeForWeaponP11CBaseEntity10CSWeaponIDiiPS1_b

Decompiled

undefined (6 params)

/* GetUseTypeForWeapon(CBaseEntity*, CSWeaponID, int, int, CSWeaponID*, bool) */

char GetUseTypeForWeapon(CTerrorPlayer *param_1,int param_2,int param_3,int param_4,
                        undefined4 *param_5,char param_6)

{
  char cVar1;
  int iVar2;
  int *piVar3;
  int iVar4;
  CBaseCombatWeapon *this;
  undefined4 *puVar5;
  int iVar6;
  undefined4 uVar7;
  undefined4 local_20;
  
  if ((param_1 == (CTerrorPlayer *)0x0) ||
     (cVar1 = (**(code **)(*(int *)param_1 + 0x16c))(param_1), cVar1 == '\0')) {
    if (param_5 != (undefined4 *)0x0) {
      *param_5 = 0;
      return '\x02';
    }
    return '\x02';
  }
  cVar1 = CTerrorPlayer::CanUseWeapon(param_1,param_2);
  if (cVar1 == '\0') {
    return '\0';
  }
  if (param_2 == 0x36) {
    this = (CBaseCombatWeapon *)(**(code **)(*(int *)param_1 + 0x484))(param_1,0);
    if (this == (CBaseCombatWeapon *)0x0) {
      return '\0';
    }
    cVar1 = CBaseCombatWeapon::UsesPrimaryAmmo(this);
    if (cVar1 == '\0') {
      return '\0';
    }
    iVar2 = (**(code **)(*(int *)this + 0x638))(this);
    if (iVar2 == 0x25) {
      return '\0';
    }
    if (iVar2 == 0x15) {
      return '\0';
    }
    iVar2 = GetWeaponInfo(iVar2);
    if (iVar2 == 0) {
      return '\0';
    }
    iVar4 = GetAmmoDef();
    if (iVar4 == 0) {
      return '\0';
    }
    puVar5 = (undefined4 *)GetAmmoDef();
    iVar4 = (**(code **)*puVar5)(puVar5,*(undefined4 *)(iVar2 + 0x850),param_1);
    iVar6 = (**(code **)(*(int *)this + 0x510))(this);
    iVar2 = CBaseCombatCharacter::GetAmmoCount
                      ((CBaseCombatCharacter *)param_1,*(int *)(iVar2 + 0x850));
    if (iVar4 + iVar6 <= (int)((*(int *)(this + 0x1420) - (uint)(byte)this[0x1790]) + iVar2)) {
      return '\0';
    }
    return '\x02';
  }
  iVar2 = GetWeaponInfo(param_2);
  if (iVar2 == 0) {
    return '\x02';
  }
  piVar3 = (int *)(**(code **)(*(int *)param_1 + 0x484))(param_1,*(undefined4 *)(iVar2 + 0x158));
  if (piVar3 == (int *)0x0) {
    local_20 = 0;
    cVar1 = '\x02';
    goto LAB_005707ee;
  }
  local_20 = (**(code **)(*piVar3 + 0x638))(piVar3);
  iVar4 = (**(code **)(*piVar3 + 0x638))(piVar3);
  if (param_2 != iVar4) {
    cVar1 = '\x02';
    if (*(int *)(iVar2 + 0x158) == 0) {
      cVar1 = '\x02';
      iVar2 = *(int *)(iVar2 + 0xbe8);
      uVar7 = (**(code **)(*piVar3 + 0x638))(piVar3);
      iVar4 = GetWeaponInfo(uVar7);
      if (iVar4 != 0) {
        cVar1 = '\x01';
        if (*(int *)(iVar4 + 0xbe8) <= iVar2) {
          cVar1 = (*(int *)(iVar4 + 0xbe8) < iVar2) + '\x02';
        }
      }
    }
    goto LAB_005707ee;
  }
  if (param_2 == 1) {
    cVar1 = (**(code **)(*piVar3 + 0x674))(piVar3);
    if (cVar1 == '\0') goto LAB_005709b9;
  }
  else if (param_2 - 0x13U < 2) {
LAB_005709b9:
    cVar1 = '\x02';
    goto LAB_005707ee;
  }
  cVar1 = '\x02';
  if (param_6 == '\0') {
    iVar2 = GetWeaponInfo(local_20);
    if ((iVar2 != 0) &&
       (iVar2 = CBaseCombatCharacter::GetAmmoCount
                          ((CBaseCombatCharacter *)param_1,*(int *)(iVar2 + 0x850)),
       iVar2 + piVar3[0x508] < param_3 + param_4)) {
      return '\x02';
    }
    cVar1 = '\0';
  }
LAB_005707ee:
  if (param_5 != (undefined4 *)0x0) {
    *param_5 = local_20;
  }
  return cVar1;
}

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)