L L4D2node

OnStartUpgradedAmmo

0x0051f960 · 402 bytes · __cdecl

_Z19OnStartUpgradedAmmoP13CTerrorWeapon19SurvivorUpgradeType

Decompiled

undefined (2 params)

/* OnStartUpgradedAmmo(CTerrorWeapon*, SurvivorUpgradeType) */

void OnStartUpgradedAmmo(CBaseCombatWeapon *param_1,undefined4 param_2)

{
  CBaseCombatWeapon CVar1;
  code *pcVar2;
  CBaseEdict *pCVar3;
  char cVar4;
  CBaseCombatWeapon CVar5;
  CBaseCombatCharacter *this;
  int iVar6;
  undefined4 uVar7;
  int iVar8;
  undefined4 *puVar9;
  int iVar10;
  int iVar11;
  int iVar12;
  
  this = (CBaseCombatCharacter *)CBaseCombatWeapon::GetOwner(param_1);
  if (this == (CBaseCombatCharacter *)0x0) {
    return;
  }
  iVar6 = (**(code **)(*(int *)param_1 + 0x638))(param_1);
  if (iVar6 == 0x25) {
    CVar5 = SUB41(*(undefined4 *)(param_1 + 0x1420),0);
    if (CVar5 == param_1[0x1790]) {
      return;
    }
    CVar1 = param_1[0x6c];
  }
  else {
    cVar4 = (**(code **)(*(int *)param_1 + 0x6b4))(param_1,param_2);
    if (cVar4 == '\0') {
      iVar8 = (**(code **)(*(int *)param_1 + 0x55c))(param_1);
      puVar9 = (undefined4 *)GetAmmoDef();
      iVar10 = (**(code **)*puVar9)(puVar9,iVar8,this);
      iVar11 = (**(code **)(*(int *)param_1 + 0x510))(param_1);
      iVar12 = CBaseCombatCharacter::GetAmmoCount(this,iVar8);
      iVar6 = iVar10 + iVar11;
      if (iVar12 + *(int *)(param_1 + 0x1420) <= iVar10 + iVar11) {
        iVar6 = iVar12 + *(int *)(param_1 + 0x1420);
      }
      CBaseCombatCharacter::SetAmmoCount(this,iVar6,iVar8);
      iVar6 = (**(code **)(*(int *)param_1 + 0x510))(param_1);
      if (iVar6 != *(int *)(param_1 + 0x1420)) {
        if (param_1[0x6c] == (CBaseCombatWeapon)0x0) {
          pCVar3 = *(CBaseEdict **)(param_1 + 0x30);
          if (pCVar3 != (CBaseEdict *)0x0) {
            *(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
            iVar8 = CBaseEdict::GetChangeAccessor(pCVar3);
            *(undefined2 *)(iVar8 + 2) = 0;
          }
        }
        else {
          param_1[0x70] = (CBaseCombatWeapon)((byte)param_1[0x70] | 1);
        }
        *(int *)(param_1 + 0x1420) = iVar6;
      }
    }
    else {
      CVar5 = param_1[0x1790];
      iVar6 = *(int *)(param_1 + 0x1420);
      pcVar2 = *(code **)(*(int *)this + 0x44c);
      uVar7 = (**(code **)(*(int *)param_1 + 0x55c))(param_1);
      (*pcVar2)(this,iVar6 - (uint)(byte)CVar5,uVar7,1);
    }
    CVar5 = (CBaseCombatWeapon)(**(code **)(*(int *)param_1 + 0x510))(param_1);
    if (CVar5 == param_1[0x1790]) {
      return;
    }
    CVar1 = param_1[0x6c];
  }
  if (CVar1 == (CBaseCombatWeapon)0x0) {
    pCVar3 = *(CBaseEdict **)(param_1 + 0x30);
    if (pCVar3 != (CBaseEdict *)0x0) {
      *(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
      iVar6 = CBaseEdict::GetChangeAccessor(pCVar3);
      *(undefined2 *)(iVar6 + 2) = 0;
    }
  }
  else {
    param_1[0x70] = (CBaseCombatWeapon)((byte)param_1[0x70] | 1);
  }
  param_1[0x1790] = CVar5;
  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)