L L4D2node

CDirectorItemManager::DynamicConvertPillsToKits

0x008a4fd0 · 1718 bytes · __thiscall

_ZN20CDirectorItemManager25DynamicConvertPillsToKitsEv

Decompiled

undefined (1 param)

/* CDirectorItemManager::DynamicConvertPillsToKits() */

void __thiscall CDirectorItemManager::DynamicConvertPillsToKits(CDirectorItemManager *this)

{
  float fVar1;
  float fVar2;
  CBaseEntity *this_00;
  CBaseEdict *pCVar3;
  byte bVar4;
  char cVar5;
  int *piVar6;
  int iVar7;
  int iVar8;
  Vector *pVVar9;
  CBaseEntity *pCVar10;
  uint *puVar11;
  float *pfVar12;
  undefined *puVar13;
  uint *puVar14;
  uint uVar15;
  int iVar16;
  double dVar17;
  double dVar18;
  int local_48;
  int local_30;
  int local_24;
  char local_20;
  byte local_1f;
  
  CollectHealingItems(this);
  local_24 = 0;
  local_20 = '\0';
  local_1f = 0;
  ForEachSurvivor<HealthAudit>((HealthAudit *)&local_24);
  bVar4 = 0;
  local_48 = local_24;
  if (local_20 != '\0') {
    bVar4 = local_1f ^ 1;
  }
  piVar6 = (int *)CDirectorTacticalServices::GetHighestFlowSurvivor
                            (*(CDirectorTacticalServices **)(TheDirector + 0x628),0);
  if (((piVar6 != (int *)0x0) && (iVar7 = (**(code **)(*piVar6 + 0x52c))(piVar6), iVar7 != 0)) &&
     (iVar16 = *(int *)(this + 0x24), iVar16 < *(int *)(this + 0x1c))) {
    local_30 = iVar16 * 8;
    do {
      while( true ) {
        puVar14 = (uint *)(local_30 + *(int *)(this + 0x10));
        if (*(float *)(iVar7 + 0x154) - 500.0 < (float)puVar14[1]) break;
        *(int *)(this + 0x24) = *(int *)(this + 0x24) + 1;
LAB_008a5074:
        local_30 = local_30 + 8;
        iVar16 = iVar16 + 1;
        if (*(int *)(this + 0x1c) <= iVar16) {
          return;
        }
      }
      if (*(float *)(iVar7 + 0x154) + 2000.0 < (float)puVar14[1]) {
        return;
      }
      uVar15 = *puVar14;
      if (((uVar15 == 0xffffffff) ||
          (puVar13 = g_pEntityList + (uVar15 & 0xfff) * 0x10, puVar13 == (undefined *)0xfffffffc))
         || ((*(uint *)(puVar13 + 8) != uVar15 >> 0xc ||
             (this_00 = *(CBaseEntity **)(puVar13 + 4), this_00 == (CBaseEntity *)0x0))))
      goto LAB_008a5074;
      iVar8 = (**(code **)(*(int *)this_00 + 0x3cc))(this_00);
      if (iVar8 == 0x18) {
        bVar4 = 0;
        goto LAB_008a5074;
      }
      iVar8 = (**(code **)(*(int *)this_00 + 0x3cc))(this_00);
      if (iVar8 != 0xc) {
        pVVar9 = (Vector *)(**(code **)(*(int *)this_00 + 0x288))(this_00);
        cVar5 = CDirectorTacticalServices::IsVisibleToTeam
                          (*(CDirectorTacticalServices **)(TheDirector + 0x628),pVVar9,2,0,1000.0,
                           (TerrorNavArea *)0x0,this_00);
        if (cVar5 != '\0') {
          *puVar14 = 0xffffffff;
          iVar8 = (**(code **)(*(int *)this_00 + 0x288))(this_00);
          fVar1 = *(float *)(iVar8 + 8);
          iVar8 = (**(code **)(*(int *)this_00 + 0x288))(this_00);
          fVar2 = *(float *)(iVar8 + 4);
          pfVar12 = (float *)(**(code **)(*(int *)this_00 + 0x288))(this_00);
          DevMsg("Pills visible to team at ( %3.2f, %3.2f, %3.2f )\n",(double)*pfVar12,(double)fVar2
                 ,(double)fVar1);
          goto LAB_008a5074;
        }
        if (local_48 < 1) {
          if (((bVar4 == 0) ||
              (iVar8 = CreateEntityByName("weapon_defibrillator_spawn",-1,true), iVar8 == 0)) ||
             (pCVar10 = (CBaseEntity *)
                        __dynamic_cast(iVar8,&CBaseEntity::typeinfo,&CWeaponSpawn::typeinfo,0),
             pCVar10 == (CBaseEntity *)0x0)) goto LAB_008a5074;
          if (((byte)this_00[0x14d] & 8) != 0) {
            CBaseEntity::CalcAbsolutePosition(this_00);
          }
          CBaseEntity::SetAbsOrigin(pCVar10,(Vector *)(this_00 + 0x2e0));
          if (((byte)this_00[0x14d] & 8) != 0) {
            CBaseEntity::CalcAbsolutePosition(this_00);
          }
          CBaseEntity::SetAbsAngles(pCVar10,(QAngle *)(this_00 + 0x37c));
          uVar15 = *(uint *)(pCVar10 + 0x148) | 0x8000;
          if (*(uint *)(pCVar10 + 0x148) != uVar15) {
            if (pCVar10[0x6c] == (CBaseEntity)0x0) {
              pCVar3 = *(CBaseEdict **)(pCVar10 + 0x30);
              if (pCVar3 != (CBaseEdict *)0x0) {
                *(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
                iVar8 = CBaseEdict::GetChangeAccessor(pCVar3);
                *(undefined2 *)(iVar8 + 2) = 0;
              }
            }
            else {
              pCVar10[0x70] = (CBaseEntity)((byte)pCVar10[0x70] | 1);
            }
            *(uint *)(pCVar10 + 0x148) = uVar15;
          }
          *(undefined4 *)(pCVar10 + 0x144c) = 1;
          DispatchSpawn(pCVar10,true);
          UTIL_Remove(this_00);
          puVar11 = (uint *)(**(code **)(*(int *)pCVar10 + 0xc))(pCVar10);
          *puVar14 = *puVar11;
          CL4DGameStats::Event_ConvertedHealthItemToDefibrillator((CL4DGameStats *)CL4D_GameStats);
          if (((byte)pCVar10[0x14d] & 8) == 0) {
            dVar18 = (double)*(float *)(pCVar10 + 0x2e8);
LAB_008a5499:
            dVar17 = (double)*(float *)(pCVar10 + 0x2e4);
          }
          else {
            CBaseEntity::CalcAbsolutePosition(pCVar10);
            dVar18 = (double)*(float *)(pCVar10 + 0x2e8);
            if (((byte)pCVar10[0x14d] & 8) == 0) goto LAB_008a5499;
            CBaseEntity::CalcAbsolutePosition(pCVar10);
            dVar17 = (double)*(float *)(pCVar10 + 0x2e4);
            if (((byte)pCVar10[0x14d] & 8) != 0) {
              CBaseEntity::CalcAbsolutePosition(pCVar10);
            }
          }
          DevMsg("Converted healing item to Defibrillator at ( %3.2f, %3.2f, %3.2f )\n",
                 (double)*(float *)(pCVar10 + 0x2e0),dVar17,dVar18);
          bVar4 = 0;
          goto LAB_008a5074;
        }
        iVar8 = CreateEntityByName("weapon_first_aid_kit_spawn",-1,true);
        if ((iVar8 == 0) ||
           (pCVar10 = (CBaseEntity *)
                      __dynamic_cast(iVar8,&CBaseEntity::typeinfo,&CWeaponSpawn::typeinfo,0),
           pCVar10 == (CBaseEntity *)0x0)) goto LAB_008a5074;
        if (((byte)this_00[0x14d] & 8) != 0) {
          CBaseEntity::CalcAbsolutePosition(this_00);
        }
        CBaseEntity::SetAbsOrigin(pCVar10,(Vector *)(this_00 + 0x2e0));
        if (((byte)this_00[0x14d] & 8) != 0) {
          CBaseEntity::CalcAbsolutePosition(this_00);
        }
        CBaseEntity::SetAbsAngles(pCVar10,(QAngle *)(this_00 + 0x37c));
        uVar15 = *(uint *)(pCVar10 + 0x148) | 0x8000;
        if (*(uint *)(pCVar10 + 0x148) != uVar15) {
          if (pCVar10[0x6c] == (CBaseEntity)0x0) {
            pCVar3 = *(CBaseEdict **)(pCVar10 + 0x30);
            if (pCVar3 != (CBaseEdict *)0x0) {
              *(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
              iVar8 = CBaseEdict::GetChangeAccessor(pCVar3);
              *(undefined2 *)(iVar8 + 2) = 0;
            }
          }
          else {
            pCVar10[0x70] = (CBaseEntity)((byte)pCVar10[0x70] | 1);
          }
          *(uint *)(pCVar10 + 0x148) = uVar15;
        }
        *(undefined4 *)(pCVar10 + 0x144c) = 1;
        DispatchSpawn(pCVar10,true);
        UTIL_Remove(this_00);
        puVar11 = (uint *)(**(code **)(*(int *)pCVar10 + 0xc))(pCVar10);
        local_48 = local_48 + -1;
        *puVar14 = *puVar11;
        CL4DGameStats::Event_ConvertedPills((CL4DGameStats *)CL4D_GameStats);
        if (((byte)pCVar10[0x14d] & 8) == 0) {
          dVar18 = (double)*(float *)(pCVar10 + 0x2e8);
LAB_008a52fa:
          dVar17 = (double)*(float *)(pCVar10 + 0x2e4);
        }
        else {
          CBaseEntity::CalcAbsolutePosition(pCVar10);
          dVar18 = (double)*(float *)(pCVar10 + 0x2e8);
          if (((byte)pCVar10[0x14d] & 8) == 0) goto LAB_008a52fa;
          CBaseEntity::CalcAbsolutePosition(pCVar10);
          dVar17 = (double)*(float *)(pCVar10 + 0x2e4);
          if (((byte)pCVar10[0x14d] & 8) != 0) {
            CBaseEntity::CalcAbsolutePosition(pCVar10);
          }
        }
        DevMsg("Converted Pain Pills to First Aid Kit at ( %3.2f, %3.2f, %3.2f )\n",
               (double)*(float *)(pCVar10 + 0x2e0),dVar17,dVar18);
        goto LAB_008a5074;
      }
      local_48 = local_48 + -1;
      iVar16 = iVar16 + 1;
      local_30 = local_30 + 8;
    } while (iVar16 < *(int *)(this + 0x1c));
  }
  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)