L L4D2node

CItemAmmoPack::OnActionComplete

0x00540160 · 669 bytes · __thiscall

_ZN13CItemAmmoPack16OnActionCompleteEP13CTerrorPlayerP11CBaseEntity

Decompiled

undefined (3 params)

/* CItemAmmoPack::OnActionComplete(CTerrorPlayer*, CBaseEntity*) */

void __thiscall
CItemAmmoPack::OnActionComplete(CItemAmmoPack *this,CTerrorPlayer *param_1,CBaseEntity *param_2)

{
  code *pcVar1;
  CBaseEdict *this_00;
  char cVar2;
  int *piVar3;
  undefined4 uVar4;
  CBaseCombatWeapon *this_01;
  char *pcVar5;
  undefined4 *puVar6;
  int iVar7;
  CAmmoDef *this_02;
  int iVar8;
  int iVar9;
  int local_50;
  CAI_Concept local_4c [8];
  undefined4 local_44;
  undefined4 local_40;
  CAI_Concept local_3c [44];
  
  if (param_2 != (CBaseEntity *)0x0) {
    cVar2 = (**(code **)(*(int *)param_2 + 0x16c))(param_2);
    if (cVar2 != '\0') goto LAB_00540187;
  }
  param_2 = (CBaseEntity *)0x0;
LAB_00540187:
  piVar3 = (int *)(**(code **)(*gameeventmanager + 0x1c))(gameeventmanager,"ammo_pack_used",0,0);
  if (piVar3 != (int *)0x0) {
    pcVar1 = *(code **)(*piVar3 + 0x30);
    uVar4 = (**(code **)(*engine + 0x40))(engine,*(undefined4 *)(param_1 + 0x30));
    (*pcVar1)(piVar3,"userid",uVar4);
    pcVar1 = *(code **)(*piVar3 + 0x30);
    uVar4 = (**(code **)(*engine + 0x40))(engine,*(undefined4 *)(param_2 + 0x30));
    (*pcVar1)(piVar3,"subject",uVar4);
    (**(code **)(*gameeventmanager + 0x20))(gameeventmanager,piVar3,0);
  }
  this_01 = (CBaseCombatWeapon *)(**(code **)(*(int *)param_2 + 0x484))(param_2,0);
  if (this_01 != (CBaseCombatWeapon *)0x0) {
    cVar2 = CBaseCombatWeapon::UsesPrimaryAmmo(this_01);
    if (cVar2 != '\0') {
      iVar7 = (**(code **)(*(int *)this_01 + 0x55c))(this_01);
      this_02 = (CAmmoDef *)GetAmmoDef();
      iVar8 = CAmmoDef::GetAmmoOfIndex(this_02,iVar7);
      if (iVar8 != 0) {
        local_50 = *(int *)(iVar8 + 0x24);
        if (*(int *)(iVar8 + 0x30) != 0) {
          local_50 = *(int *)(*(int *)(*(int *)(iVar8 + 0x30) + 0x1c) + 0x30);
        }
        iVar8 = (**(code **)(*(int *)this_01 + 0x510))(this_01);
        if (iVar8 != *(int *)(this_01 + 0x1420)) {
          if (this_01[0x6c] == (CBaseCombatWeapon)0x0) {
            this_00 = *(CBaseEdict **)(this_01 + 0x30);
            if (this_00 != (CBaseEdict *)0x0) {
              *(uint *)this_00 = *(uint *)this_00 | 0x101;
              iVar9 = CBaseEdict::GetChangeAccessor(this_00);
              *(undefined2 *)(iVar9 + 2) = 0;
            }
          }
          else {
            this_01[0x70] = (CBaseCombatWeapon)((byte)this_01[0x70] | 1);
          }
          *(int *)(this_01 + 0x1420) = iVar8;
        }
        (**(code **)(*(int *)param_2 + 0x450))(param_2,iVar8,iVar7);
        CBaseCombatCharacter::SetAmmoCount((CBaseCombatCharacter *)param_2,local_50,iVar7);
      }
    }
  }
  pcVar1 = *(code **)(*(int *)param_2 + 0x7b4);
  CAI_Concept::CAI_Concept(local_3c,"GivenAmmo");
  (*pcVar1)(param_2,local_3c,1,0,0,0,0);
  if (param_1 != (CTerrorPlayer *)param_2) {
    AI_CriteriaSet::AI_CriteriaSet((AI_CriteriaSet *)local_3c);
                    /* try { // try from 005402b4 to 00540336 has its CatchHandler @ 00540416 */
    pcVar5 = (char *)SurvivorCharacterName(*(undefined4 *)(param_1 + 0x2ba0));
    AI_CriteriaSet::AppendCriteria((AI_CriteriaSet *)local_3c,"Subject",pcVar5,1.0);
    puVar6 = (undefined4 *)(**(code **)(*(int *)param_2 + 0xc))(param_2);
    uVar4 = *puVar6;
    CAI_Concept::CAI_Concept(local_4c,"GivenAmmoDelayed");
    local_44 = 2;
    local_40 = uVar4;
    CResponseQueue::Add((CResponseQueue *)g_ResponseQueueManager._12_4_,local_4c,
                        (AI_CriteriaSet *)local_3c,*(float *)(gpGlobals + 0xc) + 1.0,
                        (CFollowupTargetSpec_t *)&local_44,(CBaseEntity *)param_1);
    AI_CriteriaSet::~AI_CriteriaSet((AI_CriteriaSet *)local_3c);
  }
  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)