L L4D2node

CMultiSpawner::Spawn

0x008d9460 · 2063 bytes · __thiscall

_ZN13CMultiSpawner5SpawnEv

Decompiled

undefined (1 param)

/* CMultiSpawner::Spawn() */

void __thiscall CMultiSpawner::Spawn(CMultiSpawner *this)

{
  CBaseEdict *pCVar1;
  char cVar2;
  char *pcVar3;
  int iVar4;
  CBaseEntity *this_00;
  CWeaponMeleeSpawn *this_01;
  int iVar5;
  uint uVar6;
  uint uVar7;
  char *pcVar8;
  int in_GS_OFFSET;
  byte bVar9;
  float fVar10;
  float fVar11;
  undefined1 local_1e8 [8];
  float local_1e0;
  CTraceFilterSimple local_1dc [16];
  float local_1cc;
  float local_1c8;
  float local_1c4;
  float local_1bc;
  float local_1b8;
  float local_1b4;
  undefined4 local_1ac;
  undefined4 local_1a8;
  undefined4 local_1a4;
  undefined4 local_19c;
  undefined4 local_198;
  undefined4 local_194;
  undefined4 local_18c;
  undefined1 local_188;
  undefined1 local_187;
  Vector local_174 [12];
  Vector local_168 [43];
  char local_13d;
  char local_11f [255];
  int local_20;
  
  bVar9 = 0;
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  if (((byte)this[0x149] & 0x80) != 0) goto LAB_008d9a47;
  (**(code **)(*(int *)this + 0x6c))(this);
  CPointEntity::Spawn((CPointEntity *)this);
  if (((byte)this[0x14d] & 8) == 0) {
    local_1c4 = *(float *)(this + 0x2e8);
    local_1bc = 0.0;
    local_1b4 = local_1c4 - 120.0;
    local_1b8 = 0.0;
    fVar11 = 0.0;
    local_1cc = *(float *)(this + 0x2e0);
    local_1c8 = *(float *)(this + 0x2e4);
  }
  else {
    CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
    local_1c4 = *(float *)(this + 0x2e8);
    local_1cc = *(float *)(this + 0x2e0);
    local_1c8 = *(float *)(this + 0x2e4);
    local_1b4 = local_1c4 - 120.0;
    if (((byte)this[0x14d] & 8) == 0) {
      local_1bc = 0.0;
      local_1b8 = local_1bc;
      fVar11 = local_1bc;
    }
    else {
      CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
      local_1bc = local_1cc - *(float *)(this + 0x2e0);
      local_1c4 = *(float *)(this + 0x2e8);
      local_1b8 = local_1c8 - *(float *)(this + 0x2e4);
      fVar11 = local_1b8 * local_1b8 + local_1bc * local_1bc;
      local_1cc = *(float *)(this + 0x2e0);
      local_1c8 = *(float *)(this + 0x2e4);
    }
  }
  local_1b4 = local_1b4 - local_1c4;
  local_187 = local_1b4 * local_1b4 + fVar11 != 0.0;
  local_194 = 0;
  local_198 = 0;
  local_19c = 0;
  local_188 = 1;
  local_18c = 0;
  local_1a4 = 0;
  local_1a8 = 0;
  local_1ac = 0;
  CTraceFilterSimple::CTraceFilterSimple
            (local_1dc,(IHandleEntity *)this,0,(_func_bool_IHandleEntity_ptr_int *)0x0);
  (**(code **)(*enginetrace + 0x14))(enginetrace,&local_1cc,0x46004003,local_1dc,local_174);
  if (*(int *)(r_visualizetraces._28_4_ + 0x30) != 0) {
    DebugDrawLine(local_174,local_168,0xff,0,0,true,-1.0);
  }
  if (local_13d == '\0') {
    CBaseEntity::SetAbsOrigin((CBaseEntity *)this,local_168);
  }
  pcVar3 = "";
  if (*(char **)(this + 0x454) != (char *)0x0) {
    pcVar3 = *(char **)(this + 0x454);
  }
  iVar4 = _V_strlen(pcVar3);
  if (0 < iVar4) {
    CUtlVector<char_const*,CUtlMemory<char_const*,int>>::InsertBefore
              ((CUtlVector<char_const*,CUtlMemory<char_const*,int>> *)(this + 0x440),
               *(int *)(this + 0x44c),(char **)pszItemNames);
  }
  if (*(int *)(this + 0x44c) < 1) goto LAB_008d9a47;
  iVar4 = RandomInt(0,*(int *)(this + 0x44c) + -1);
  pcVar3 = *(char **)(*(int *)(this + 0x440) + iVar4 * 4);
  if (pcVar3 == (char *)0x0) goto LAB_008d9a47;
  pcVar8 = local_11f;
  for (iVar4 = 0x3f; iVar4 != 0; iVar4 = iVar4 + -1) {
    pcVar8[0] = '\0';
    pcVar8[1] = '\0';
    pcVar8[2] = '\0';
    pcVar8[3] = '\0';
    pcVar8 = pcVar8 + ((uint)bVar9 * -2 + 1) * 4;
  }
  pcVar8[0] = '\0';
  pcVar8[1] = '\0';
  pcVar8[2] = '\0';
  iVar4 = memcmp(pcVar3,"models/",7);
  if (iVar4 == 0) {
    _V_strcpy(local_11f,"prop_physics");
  }
  else {
    _V_strcpy(local_11f,pcVar3);
  }
  this_00 = (CBaseEntity *)CreateEntityByName(local_11f,-1,true);
  if (this_00 == (CBaseEntity *)0x0) {
    Msg("Failed to spawn item by class %s\n",local_11f);
    goto LAB_008d9a47;
  }
  if (((byte)this[0x14d] & 8) != 0) {
    CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
  }
  CBaseEntity::SetAbsOrigin(this_00,(Vector *)(this + 0x2e0));
  if (((byte)this[0x14d] & 8) != 0) {
    CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
  }
  CBaseEntity::SetAbsAngles(this_00,(QAngle *)(this + 0x37c));
  if (*(char **)(this_00 + 0x7c) == "prop_physics") {
LAB_008d9b60:
    (**(code **)(*(int *)this_00 + 0x70))(this_00,pcVar3);
    if (((byte)this_00[0x14d] & 8) != 0) {
      CBaseEntity::CalcAbsolutePosition(this_00);
    }
    local_1cc = *(float *)(this_00 + 0x2e0);
    local_1c8 = *(float *)(this_00 + 0x2e4);
    local_1c4 = *(float *)(this_00 + 0x2e8) + 12.0;
    CBaseEntity::SetAbsOrigin(this_00,(Vector *)&local_1cc);
  }
  else {
    cVar2 = CBaseEntity::ClassMatchesComplex(this_00,"prop_physics");
    if (cVar2 != '\0') goto LAB_008d9b60;
    if (*(char **)(this_00 + 0x7c) == "weapon_melee_spawn") {
LAB_008d977e:
      this_01 = (CWeaponMeleeSpawn *)
                __dynamic_cast(this_00,&CBaseEntity::typeinfo,&CWeaponMeleeSpawn::typeinfo,0);
      if (this_01 != (CWeaponMeleeSpawn *)0x0) {
        *(undefined4 *)(this_01 + 0x146c) = *(undefined4 *)(this + 0x454);
        CWeaponMeleeSpawn::MakeWeaponSelection(this_01);
        local_1cc = *(float *)(this + 0x3a8);
        local_1c8 = *(float *)(this + 0x3ac);
        local_1c4 = *(float *)(this + 0x3b0) - 90.0;
        CBaseEntity::SetLocalAngles((CBaseEntity *)this_01,(QAngle *)&local_1cc);
      }
    }
    else {
      cVar2 = CBaseEntity::ClassMatchesComplex(this_00,"weapon_melee_spawn");
      if (cVar2 != '\0') goto LAB_008d977e;
    }
  }
  iVar4 = __dynamic_cast(this_00,&CBaseEntity::typeinfo,&CWeaponSpawn::typeinfo,0);
  if (iVar4 != 0) {
    uVar7 = *(uint *)(this + 0x148);
    if (((uVar7 & 2) != 0) &&
       (uVar6 = *(uint *)(iVar4 + 0x148) | 2, *(uint *)(iVar4 + 0x148) != uVar6)) {
      if (*(char *)(iVar4 + 0x6c) == '\0') {
        pCVar1 = *(CBaseEdict **)(iVar4 + 0x30);
        if (pCVar1 != (CBaseEdict *)0x0) {
          *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
          iVar5 = CBaseEdict::GetChangeAccessor(pCVar1);
          *(undefined2 *)(iVar5 + 2) = 0;
        }
      }
      else {
        *(byte *)(iVar4 + 0x70) = *(byte *)(iVar4 + 0x70) | 1;
      }
      *(uint *)(iVar4 + 0x148) = uVar6;
      uVar7 = *(uint *)(this + 0x148);
    }
    if (((uVar7 & 1) != 0) &&
       (uVar6 = *(uint *)(iVar4 + 0x148) | 1, *(uint *)(iVar4 + 0x148) != uVar6)) {
      if (*(char *)(iVar4 + 0x6c) == '\0') {
        pCVar1 = *(CBaseEdict **)(iVar4 + 0x30);
        if (pCVar1 != (CBaseEdict *)0x0) {
          *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
          iVar5 = CBaseEdict::GetChangeAccessor(pCVar1);
          *(undefined2 *)(iVar5 + 2) = 0;
        }
      }
      else {
        *(byte *)(iVar4 + 0x70) = *(byte *)(iVar4 + 0x70) | 1;
      }
      *(uint *)(iVar4 + 0x148) = uVar6;
      uVar7 = *(uint *)(this + 0x148);
    }
    if (((uVar7 & 8) != 0) &&
       (uVar7 = *(uint *)(iVar4 + 0x148) | 8, *(uint *)(iVar4 + 0x148) != uVar7)) {
      if (*(char *)(iVar4 + 0x6c) == '\0') {
        pCVar1 = *(CBaseEdict **)(iVar4 + 0x30);
        if (pCVar1 != (CBaseEdict *)0x0) {
          *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
          iVar5 = CBaseEdict::GetChangeAccessor(pCVar1);
          *(undefined2 *)(iVar5 + 2) = 0;
        }
      }
      else {
        *(byte *)(iVar4 + 0x70) = *(byte *)(iVar4 + 0x70) | 1;
      }
      *(uint *)(iVar4 + 0x148) = uVar7;
    }
    *(undefined4 *)(iVar4 + 0x144c) = 1;
    *(undefined4 *)(iVar4 + 0x1450) = *(undefined4 *)(this + 0x458);
    fVar11 = *(float *)(this + 0x45c);
    if (fVar11 != *(float *)(iVar4 + 0x145c)) {
      if (*(char *)(iVar4 + 0x6c) == '\0') {
        pCVar1 = *(CBaseEdict **)(iVar4 + 0x30);
        if (pCVar1 != (CBaseEdict *)0x0) {
          *(uint *)pCVar1 = *(uint *)pCVar1 | 0x101;
          iVar5 = CBaseEdict::GetChangeAccessor(pCVar1);
          *(undefined2 *)(iVar5 + 2) = 0;
        }
      }
      else {
        *(byte *)(iVar4 + 0x70) = *(byte *)(iVar4 + 0x70) | 1;
      }
      *(float *)(iVar4 + 0x145c) = fVar11;
    }
  }
  (**(code **)(*(int *)this_00 + 0x6c))(this_00);
  DispatchSpawn(this_00,true);
  (**(code **)(*(int *)(this_00 + 0x194) + 0xc))(this_00 + 0x194,local_1e8,local_1dc);
  CBaseEntity::SetCollisionGroup(this_00,0xb);
  if (((byte)this_00[0x14d] & 8) != 0) {
    CBaseEntity::CalcAbsolutePosition(this_00);
  }
  fVar11 = *(float *)(this_00 + 0x2e8);
  fVar10 = fVar11 - local_1e0;
  if (0.0 < fVar10) {
    if (((byte)this_00[0x14d] & 8) != 0) {
      CBaseEntity::CalcAbsolutePosition(this_00);
      fVar11 = *(float *)(this_00 + 0x2e8);
    }
    local_1cc = *(float *)(this_00 + 0x2e0);
    local_1c4 = fVar11 + fVar10;
    local_1c8 = *(float *)(this_00 + 0x2e4);
    CBaseEntity::SetAbsOrigin(this_00,(Vector *)&local_1cc);
  }
LAB_008d9a47:
  UTIL_Remove((CBaseEntity *)this);
  if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
    return;
  }
                    /* WARNING: Subroutine does not return */
  __stack_chk_fail();
}

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)