L L4D2node

CPropHealthCabinet::SpawnItems

0x004ef1d0 · 1685 bytes · __thiscall

_ZN18CPropHealthCabinet10SpawnItemsEv

Decompiled

undefined (1 param)

/* CPropHealthCabinet::SpawnItems() */

void __thiscall CPropHealthCabinet::SpawnItems(CPropHealthCabinet *this)

{
  undefined4 *puVar1;
  CBaseEdict *pCVar2;
  bool bVar3;
  int *piVar4;
  char cVar5;
  Checkpoint *this_00;
  float *pfVar6;
  Vector *pVVar7;
  int iVar8;
  char *pcVar9;
  CBaseEntity *this_01;
  uint uVar10;
  uint uVar11;
  undefined4 uVar12;
  int iVar13;
  char *pcVar14;
  int in_GS_OFFSET;
  char *local_a0;
  Vector local_90 [12];
  int local_84 [3];
  float local_78;
  float local_74;
  float local_70;
  float local_6c;
  float local_68;
  float local_64;
  char local_60 [64];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  if (this[0x15dc] != (CPropHealthCabinet)0x0) goto LAB_004ef1f3;
  this[0x15dc] = (CPropHealthCabinet)0x1;
  cVar5 = CTerrorGameRules::IsVersusMode();
  piVar4 = mdlcache;
  if ((cVar5 != '\0') && (TheDirector[0x4e5] != (CDirector)0x0)) goto LAB_004ef1f3;
  (**(code **)(*mdlcache + 0x68))(mdlcache);
  if (((byte)this[0x14d] & 8) != 0) {
    CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
  }
                    /* try { // try from 004ef262 to 004ef406 has its CatchHandler @ 004ef895 */
  this_00 = (Checkpoint *)TerrorNavMesh::GetCheckpoint(TheNavMesh,(Vector *)(this + 0x2e0));
  cVar5 = CDirector::IsTransitioned(TheDirector);
  if (((cVar5 == '\0') || (cVar5 = CDirector::IsTransitionScenarioRestart(), cVar5 != '\0')) ||
     (TheDirector[0x28f] != (CDirector)0x0)) {
    if (this_00 != (Checkpoint *)0x0) goto LAB_004ef286;
LAB_004ef378:
    pVVar7 = (Vector *)(**(code **)(*(int *)this + 0x288))(this);
    iVar13 = CNavMesh::GetNearestNavArea
                       ((CNavMesh *)TheNavMesh,pVVar7,false,10000.0,false,true,false);
    if ((iVar13 == 0) || ((*(byte *)(iVar13 + 300) & 0x40) == 0)) {
      bVar3 = true;
    }
    else {
LAB_004ef360:
      bVar3 = false;
    }
    cVar5 = CTerrorGameRules::IsVersusMode();
    if (cVar5 == '\0') {
LAB_004ef3d7:
      uVar12 = 0xf;
      local_a0 = "weapon_pain_pills_spawn";
      if (!bVar3) goto LAB_004ef481;
    }
    else {
                    /* try { // try from 004ef42d to 004ef5bd has its CatchHandler @ 004ef895 */
      pVVar7 = (Vector *)(**(code **)(*(int *)this + 0x288))(this);
      iVar13 = CNavMesh::GetNearestNavArea
                         ((CNavMesh *)TheNavMesh,pVVar7,false,10000.0,false,true,false);
      if ((iVar13 == 0) || ((*(byte *)(iVar13 + 0x12d) & 8) == 0)) goto LAB_004ef3d7;
LAB_004ef481:
      local_a0 = "weapon_first_aid_kit_spawn";
      uVar12 = 0xc;
    }
    cVar5 = CDirectorChallengeMode::AllowWeaponSpawn
                      (*(CDirectorChallengeMode **)(TheDirector + 0x648),uVar12);
    if (cVar5 != '\0') {
      cVar5 = CDirectorChallengeMode::ConvertWeaponSpawn
                        (*(CDirectorChallengeMode **)(TheDirector + 0x648),uVar12,local_60,0x40);
      local_78 = 0.0;
      pcVar14 = local_60;
      if (cVar5 == '\0') {
        pcVar14 = local_a0;
      }
      local_74 = 0.0;
      local_70 = 0.0;
      local_6c = 0.0;
      local_68 = 0.0;
      local_84[0] = 1;
                    /* try { // try from 004ef60c to 004ef82e has its CatchHandler @ 004ef8ad */
      CUtlVector<int,CUtlMemory<int,int>>::InsertBefore
                ((CUtlVector<int,CUtlMemory<int,int>> *)&local_78,0,local_84);
      local_84[0] = 2;
      CUtlVector<int,CUtlMemory<int,int>>::InsertBefore
                ((CUtlVector<int,CUtlMemory<int,int>> *)&local_78,(int)local_6c,local_84);
      local_84[0] = 3;
      CUtlVector<int,CUtlMemory<int,int>>::InsertBefore
                ((CUtlVector<int,CUtlMemory<int,int>> *)&local_78,(int)local_6c,local_84);
      local_84[0] = 4;
      CUtlVector<int,CUtlMemory<int,int>>::InsertBefore
                ((CUtlVector<int,CUtlMemory<int,int>> *)&local_78,(int)local_6c,local_84);
      iVar13 = 0;
      do {
        iVar8 = RandomInt(0,100);
        puVar1 = (undefined4 *)((int)local_78 + (iVar8 % 4) * 4);
        uVar12 = *puVar1;
        *puVar1 = *(undefined4 *)((int)local_78 + iVar13);
        *(undefined4 *)((int)local_78 + iVar13) = uVar12;
        iVar13 = iVar13 + 4;
      } while (iVar13 != 0x10);
      iVar13 = 1;
      if (0 < *(int *)(this + 0x15d8)) {
        iVar13 = *(int *)(this + 0x15d8);
      }
      iVar8 = 4;
      if (iVar13 < 5) {
        iVar8 = iVar13;
      }
      iVar13 = 0;
      *(int *)(this + 0x15d8) = iVar8;
      do {
        pcVar9 = (char *)UTIL_VarArgs("item%d",*(undefined4 *)((int)local_78 + iVar13 * 4));
        cVar5 = CBaseAnimating::GetAttachment
                          ((CBaseAnimating *)this,pcVar9,local_90,(QAngle *)local_84);
        if (((cVar5 != '\0') && (iVar8 = CreateEntityByName(pcVar14,-1,true), iVar8 != 0)) &&
           (this_01 = (CBaseEntity *)
                      __dynamic_cast(iVar8,&CBaseEntity::typeinfo,&CWeaponSpawn::typeinfo,0),
           this_01 != (CBaseEntity *)0x0)) {
          CBaseEntity::SetAbsOrigin(this_01,local_90);
          CBaseEntity::SetAbsAngles(this_01,(QAngle *)local_84);
          uVar10 = *(uint *)(this_01 + 0x148);
          uVar11 = uVar10 | 0x8000;
          if (uVar10 != uVar11) {
            if (this_01[0x6c] == (CBaseEntity)0x0) {
              pCVar2 = *(CBaseEdict **)(this_01 + 0x30);
              if (pCVar2 != (CBaseEdict *)0x0) {
                *(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
                iVar8 = CBaseEdict::GetChangeAccessor(pCVar2);
                *(undefined2 *)(iVar8 + 2) = 0;
              }
            }
            else {
              this_01[0x70] = (CBaseEntity)((byte)this_01[0x70] | 1);
            }
            *(uint *)(this_01 + 0x148) = uVar11;
            uVar10 = uVar11;
          }
          if ((uVar10 | 2) != uVar10) {
            if (this_01[0x6c] == (CBaseEntity)0x0) {
              pCVar2 = *(CBaseEdict **)(this_01 + 0x30);
              if (pCVar2 != (CBaseEdict *)0x0) {
                *(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
                iVar8 = CBaseEdict::GetChangeAccessor(pCVar2);
                *(undefined2 *)(iVar8 + 2) = 0;
              }
            }
            else {
              this_01[0x70] = (CBaseEntity)((byte)this_01[0x70] | 1);
            }
            *(uint *)(this_01 + 0x148) = uVar10 | 2;
          }
          *(undefined4 *)(this_01 + 0x144c) = 1;
          DispatchSpawn(this_01,true);
        }
        iVar13 = iVar13 + 1;
      } while (iVar13 < *(int *)(this + 0x15d8));
      local_6c = 0.0;
      CUtlMemory<int,int>::Purge((CUtlMemory<int,int> *)&local_78);
      local_68 = local_78;
      CUtlMemory<int,int>::Purge((CUtlMemory<int,int> *)&local_78);
      (**(code **)(*piVar4 + 0x6c))(piVar4);
      goto LAB_004ef1f3;
    }
  }
  else {
    if (this_00 == (Checkpoint *)0x0) goto LAB_004ef378;
    if (this_00[0x5f] != (Checkpoint)0x0) {
LAB_004ef286:
      CCollisionProperty::CollisionAABBToWorldAABB
                ((CCollisionProperty *)(this + 0x194),(Vector *)(this + 0x19c),
                 (Vector *)(this + 0x1a8),(Vector *)&local_78,(Vector *)&local_6c);
      local_78 = local_78 - 150.0;
      local_74 = local_74 - 150.0;
      local_70 = local_70 - 150.0;
      local_6c = local_6c + 150.0;
      local_68 = local_68 + 150.0;
      local_64 = local_64 + 150.0;
      pfVar6 = (float *)Checkpoint::GetExtent(this_00);
      if (((local_6c < *pfVar6) || (pfVar6[3] < local_78)) ||
         ((local_68 < pfVar6[1] ||
          (((pfVar6[4] < local_74 || (local_64 < pfVar6[2])) ||
           (pfVar6[5] <= local_70 && local_70 != pfVar6[5])))))) goto LAB_004ef378;
      goto LAB_004ef360;
    }
    pVVar7 = (Vector *)(**(code **)(*(int *)this + 0x288))(this);
    iVar13 = CNavMesh::GetNearestNavArea
                       ((CNavMesh *)TheNavMesh,pVVar7,false,10000.0,false,true,false);
    if ((iVar13 == 0) || ((*(byte *)(iVar13 + 0x12d) & 8) == 0)) goto LAB_004ef286;
    if (this[0x15d5] != (CPropHealthCabinet)0x1) {
      if (this[0x6c] == (CPropHealthCabinet)0x0) {
        pCVar2 = *(CBaseEdict **)(this + 0x30);
        if (pCVar2 != (CBaseEdict *)0x0) {
          *(uint *)pCVar2 = *(uint *)pCVar2 | 0x101;
          iVar13 = CBaseEdict::GetChangeAccessor(pCVar2);
          *(undefined2 *)(iVar13 + 2) = 0;
        }
      }
      else {
        this[0x70] = (CPropHealthCabinet)((byte)this[0x70] | 1);
      }
      this[0x15d5] = (CPropHealthCabinet)0x1;
    }
    iVar13 = (**(code **)(*(int *)this + 0x340))(this,0x330);
    CDynamicProp::PropSetSequence((CDynamicProp *)this,iVar13);
    CBaseEntity::SetCollisionGroup((CBaseEntity *)this,4);
  }
  (**(code **)(*piVar4 + 0x6c))(piVar4);
LAB_004ef1f3:
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail();
  }
  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)