L L4D2node

CDirector::NewPlayerFindAndPossessBot

0x00882a20 · 859 bytes · __thiscall

_ZN9CDirector26NewPlayerFindAndPossessBotER23DirectorNewPlayerType_t

Decompiled

undefined (2 params)

/* CDirector::NewPlayerFindAndPossessBot(DirectorNewPlayerType_t&) */

undefined4 __thiscall
CDirector::NewPlayerFindAndPossessBot(CDirector *this,DirectorNewPlayerType_t *param_1)

{
  uint uVar1;
  int iVar2;
  int iVar3;
  char cVar4;
  undefined4 uVar5;
  undefined4 uVar6;
  SurvivorBot *pSVar7;
  int iVar8;
  int *piVar9;
  undefined *puVar10;
  CTerrorPlayer *this_00;
  SurvivorBot *pSVar11;
  longdouble lVar12;
  longdouble lVar13;
  undefined4 local_40;
  undefined4 local_3c;
  undefined4 local_38;
  undefined4 local_34;
  int local_30 [8];
  
  iVar8 = 0;
  uVar1 = *(uint *)param_1;
  if (((uVar1 != 0xffffffff) &&
      (puVar10 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar10 != (undefined *)0xfffffffc)) &&
     (*(uint *)(puVar10 + 8) == uVar1 >> 0xc)) {
    iVar8 = *(int *)(puVar10 + 4);
  }
  uVar5 = (**(code **)(*engine + 0x40))(engine,*(undefined4 *)(iVar8 + 0x30));
  uVar1 = *(uint *)param_1;
  piVar9 = (int *)0x0;
  if (((uVar1 != 0xffffffff) &&
      (puVar10 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar10 != (undefined *)0xfffffffc)) &&
     (*(uint *)(puVar10 + 8) == uVar1 >> 0xc)) {
    piVar9 = *(int **)(puVar10 + 4);
  }
  uVar6 = (**(code **)(*piVar9 + 0xb8))(piVar9);
  DevMsg(1,"[TAKEOVER]: %s(%d) is looking for a bot to possess.\n",uVar6,uVar5);
  if (((this[0x28e] != (CDirector)0x0) || (cVar4 = IsTransitioned(), cVar4 != '\0')) &&
     (m_isScenarioRestart == '\0')) {
    this_00 = (CTerrorPlayer *)0x0;
    uVar1 = *(uint *)param_1;
    if (((uVar1 != 0xffffffff) &&
        (puVar10 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar10 != (undefined *)0xfffffffc)) &&
       (*(uint *)(puVar10 + 8) == uVar1 >> 0xc)) {
      this_00 = *(CTerrorPlayer **)(puVar10 + 4);
    }
    cVar4 = CTerrorPlayer::IsTransitioned(this_00);
    if (cVar4 != '\0') {
      return 0;
    }
  }
  local_30[0] = 0;
  local_30[1] = 0;
  local_30[2] = 0;
  local_30[3] = 0;
  local_30[4] = 0;
  local_40 = 2;
  local_3c = 3;
  local_38 = 2;
  local_34 = 9;
                    /* try { // try from 00882b2b to 00882c3b has its CatchHandler @ 00882d9c */
  ForEachSurvivor<PlayerCollector>((PlayerCollector *)&local_40);
  if (0 < local_30[3]) {
    iVar8 = 0;
    pSVar11 = (SurvivorBot *)0x0;
LAB_00882b40:
    do {
      while ((iVar2 = *(int *)(local_30[0] + iVar8 * 4), iVar2 == 0 ||
             (pSVar7 = (SurvivorBot *)
                       __dynamic_cast(iVar2,&CTerrorPlayer::typeinfo,&SurvivorBot::typeinfo,0),
             pSVar7 == (SurvivorBot *)0x0))) {
LAB_00882c12:
        iVar8 = iVar8 + 1;
        if (local_30[3] <= iVar8) goto LAB_00882c1e;
      }
                    /* try { // try from 00882cda to 00882d32 has its CatchHandler @ 00882d9c */
      if ((*(int *)(pSVar7 + 0x4308) != 0) &&
         (cVar4 = IsHumanSpectatorValid(this,pSVar7), cVar4 != '\0')) {
        iVar8 = iVar8 + 1;
        if (local_30[3] <= iVar8) break;
        goto LAB_00882b40;
      }
      if (pSVar11 == (SurvivorBot *)0x0) {
LAB_00882c10:
        pSVar11 = pSVar7;
        goto LAB_00882c12;
      }
      cVar4 = (**(code **)(*(int *)pSVar11 + 300))(pSVar11);
      if ((cVar4 == '\0') || (cVar4 = (**(code **)(*(int *)pSVar7 + 300))(pSVar7), cVar4 != '\0')) {
        cVar4 = (**(code **)(*(int *)pSVar11 + 0x7e8))(pSVar11);
        if ((cVar4 != '\0') ||
           (cVar4 = (**(code **)(*(int *)pSVar7 + 0x7e8))(pSVar7), cVar4 == '\0')) {
          iVar2 = *(int *)(pSVar7 + 0x100);
          lVar12 = (longdouble)(**(code **)(*(int *)pSVar7 + 0x7e4))(pSVar7);
          iVar3 = *(int *)(pSVar11 + 0x100);
          lVar13 = (longdouble)(**(code **)(*(int *)pSVar11 + 0x7e4))(pSVar11);
          if ((float)iVar2 + (float)lVar12 <= (float)lVar13 + (float)iVar3) goto LAB_00882c12;
          goto LAB_00882c10;
        }
        iVar8 = iVar8 + 1;
        if (local_30[3] <= iVar8) break;
        goto LAB_00882b40;
      }
      iVar8 = iVar8 + 1;
    } while (iVar8 < local_30[3]);
LAB_00882c1e:
    if (pSVar11 != (SurvivorBot *)0x0) {
      NewPlayerPossessBot(this,param_1,pSVar11);
      local_30[3] = 0;
      CUtlMemory<CTerrorPlayer*,int>::Purge((CUtlMemory<CTerrorPlayer*,int> *)local_30);
      local_30[4] = local_30[0];
      CUtlMemory<CTerrorPlayer*,int>::Purge((CUtlMemory<CTerrorPlayer*,int> *)local_30);
      return 1;
    }
  }
  local_30[3] = 0;
  CUtlMemory<CTerrorPlayer*,int>::Purge((CUtlMemory<CTerrorPlayer*,int> *)local_30);
  local_30[4] = local_30[0];
  CUtlMemory<CTerrorPlayer*,int>::Purge((CUtlMemory<CTerrorPlayer*,int> *)local_30);
  return 0;
}

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)