L L4D2node

CCSPlayer::StockPlayerAmmo

0x0065aaa0 · 519 bytes · __thiscall

_ZN9CCSPlayer15StockPlayerAmmoEP17CBaseCombatWeapon

Decompiled

undefined (2 params)

/* CCSPlayer::StockPlayerAmmo(CBaseCombatWeapon*) */

void __thiscall CCSPlayer::StockPlayerAmmo(CCSPlayer *this,CBaseCombatWeapon *param_1)

{
  CBaseEdict *pCVar1;
  CBaseCombatWeapon *this_00;
  int iVar2;
  int *piVar3;
  CAmmoDef *pCVar4;
  undefined4 *puVar5;
  int iVar6;
  undefined4 uVar7;
  undefined4 uVar8;
  undefined4 uVar9;
  
  if ((param_1 == (CBaseCombatWeapon *)0x0) ||
     (this_00 = (CBaseCombatWeapon *)
                __dynamic_cast(param_1,&CBaseCombatWeapon::typeinfo,&CWeaponCSBase::typeinfo,0),
     this_00 == (CBaseCombatWeapon *)0x0)) {
    iVar2 = (**(code **)(*(int *)this + 0x484))(this,0);
    if ((iVar2 != 0) &&
       ((piVar3 = (int *)__dynamic_cast(iVar2,&CBaseCombatWeapon::typeinfo,&CWeaponCSBase::typeinfo,
                                        0), piVar3 != (int *)0x0 &&
        (iVar2 = (**(code **)(*piVar3 + 0x55c))(piVar3), iVar2 != -1)))) {
      pCVar4 = (CAmmoDef *)GetAmmoDef();
      puVar5 = (undefined4 *)CAmmoDef::GetAmmoOfIndex(pCVar4,iVar2);
      uVar9 = 0;
      uVar8 = *puVar5;
      uVar7 = 9999;
      CBaseCombatCharacter::GiveAmmo((int)this,(char *)0x270f,SUB41(uVar8,0));
      iVar2 = (**(code **)(*piVar3 + 0x510))(piVar3,uVar7,uVar8,uVar9);
      if (iVar2 != piVar3[0x508]) {
        if ((char)piVar3[0x1b] == '\0') {
          pCVar1 = (CBaseEdict *)piVar3[0xc];
          if (pCVar1 != (CBaseEdict *)0x0) {
            *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
            iVar6 = CBaseEdict::GetChangeAccessor(pCVar1);
            *(undefined2 *)(iVar6 + 2) = 0;
          }
        }
        else {
          *(byte *)(piVar3 + 0x1c) = *(byte *)(piVar3 + 0x1c) | 1;
        }
        piVar3[0x508] = iVar2;
      }
    }
    iVar2 = (**(code **)(*(int *)this + 0x484))(this,1);
    if (iVar2 == 0) {
      return;
    }
    this_00 = (CBaseCombatWeapon *)
              __dynamic_cast(iVar2,&CBaseCombatWeapon::typeinfo,&CWeaponCSBase::typeinfo,0);
    if (this_00 == (CBaseCombatWeapon *)0x0) {
      return;
    }
  }
  else {
    iVar2 = CBaseCombatWeapon::GetWpnData(this_00);
    if ((*(byte *)(iVar2 + 0x17c) & 0x10) != 0) {
      return;
    }
  }
  iVar2 = (**(code **)(*(int *)this_00 + 0x55c))(this_00);
  if (iVar2 != -1) {
    pCVar4 = (CAmmoDef *)GetAmmoDef();
    puVar5 = (undefined4 *)CAmmoDef::GetAmmoOfIndex(pCVar4,iVar2);
    uVar9 = 0;
    uVar8 = *puVar5;
    uVar7 = 9999;
    CBaseCombatCharacter::GiveAmmo((int)this,(char *)0x270f,SUB41(uVar8,0));
    iVar2 = (**(code **)(*(int *)this_00 + 0x510))(this_00,uVar7,uVar8,uVar9);
    if (iVar2 != *(int *)(this_00 + 0x1420)) {
      if (this_00[0x6c] == (CBaseCombatWeapon)0x0) {
        pCVar1 = *(CBaseEdict **)(this_00 + 0x30);
        if (pCVar1 != (CBaseEdict *)0x0) {
          *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
          iVar6 = CBaseEdict::GetChangeAccessor(pCVar1);
          *(undefined2 *)(iVar6 + 2) = 0;
        }
      }
      else {
        this_00[0x70] = (CBaseCombatWeapon)((byte)this_00[0x70] | 1);
      }
      *(int *)(this_00 + 0x1420) = iVar2;
      return;
    }
  }
  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)