L L4D2node

SurvivorBot::EnforceProximityToHumans

0x0093f3d0 · 1320 bytes · __thiscall

_ZN11SurvivorBot24EnforceProximityToHumansEv

Decompiled

undefined (1 param)

/* SurvivorBot::EnforceProximityToHumans() */

void __thiscall SurvivorBot::EnforceProximityToHumans(SurvivorBot *this)

{
  float fVar1;
  char cVar2;
  int iVar3;
  undefined4 uVar4;
  int *piVar5;
  CBasePlayer *this_00;
  undefined *puVar6;
  CBaseEntity *this_01;
  int iVar7;
  uint uVar8;
  longdouble lVar9;
  Vector *local_44;
  float local_3c;
  float local_38;
  undefined4 local_34;
  float local_30;
  float local_2c;
  undefined4 local_28;
  int local_24;
  undefined4 local_20;
  
  iVar3 = CBaseEntity::GetTeamNumber((CBaseEntity *)this);
  if (iVar3 == 4) {
    return;
  }
  cVar2 = CTerrorPlayer::IsAbleToMove((CTerrorPlayer *)this);
  if (cVar2 == '\0') {
    (**(code **)(*(int *)(this + 0x4028) + 0x10c))(this + 0x4028);
    return;
  }
  cVar2 = CDirectorScriptedEventManager::AreAllSurvivorsInBattlefield
                    (*(CDirectorScriptedEventManager **)(TheDirector + 0x638));
  if (cVar2 != '\0') {
    return;
  }
  cVar2 = CDirector::AreAllSurvivorsInFinaleArea();
  if (cVar2 != '\0') {
    return;
  }
  cVar2 = CTerrorGameRules::IsSurvivalMode();
  if (cVar2 != '\0') {
    return;
  }
  lVar9 = (longdouble)CTerrorPlayer::GetTimeSinceAttackedByEnemy((CTerrorPlayer *)this);
  if ((float)lVar9 < 1.5) {
    return;
  }
  cVar2 = (**(code **)(*(int *)(this + 0x4028) + 0x104))(this + 0x4028);
  if (cVar2 == '\0') {
    return;
  }
  lVar9 = (longdouble)(**(code **)(*(int *)(this + 0x4028) + 0x108))(this + 0x4028);
  if ((float)lVar9 < 5.0) {
    return;
  }
  cVar2 = CTerrorGameRules::HasPlayerControlledZombies();
  if (cVar2 != '\0') {
    return;
  }
  if ((*(char *)(*(int *)(TheDirector + 0x638) + 0x140) != '\0') &&
     (cVar2 = CDirector::IsFinaleVehicleReady(TheDirector), cVar2 != '\0')) {
    return;
  }
  iVar3 = GetTeamSituation(this);
  uVar8 = *(uint *)(iVar3 + 0x30);
  if (uVar8 == 0xffffffff) {
    return;
  }
  puVar6 = g_pEntityList + (uVar8 & 0xfff) * 0x10;
  if (puVar6 == (undefined *)0xfffffffc) {
    return;
  }
  if (*(uint *)(puVar6 + 8) != uVar8 >> 0xc) {
    return;
  }
  if (*(int *)(puVar6 + 4) == 0) {
    return;
  }
  if (*(float *)(iVar3 + 0x34) < *(float *)(SurvivorBotEnforceProximityRange._28_4_ + 0x2c) ||
      *(float *)(iVar3 + 0x34) == *(float *)(SurvivorBotEnforceProximityRange._28_4_ + 0x2c)) {
    if (*(float *)(this + 0x1abb0) == -1.0) {
      return;
    }
    IntervalTimer::NetworkVar_m_timestamp::NetworkStateChanged(this + 0x1abb0);
    *(undefined4 *)(this + 0x1abb0) = 0xbf800000;
    return;
  }
  if ((*(float *)(this + 0x1abb0) <= 0.0) ||
     (fVar1 = *(float *)(SurvivorBotEnforceProximityLookatTimeout._28_4_ + 0x2c),
     lVar9 = (longdouble)IntervalTimer::Now(), (float)lVar9 - *(float *)(this + 0x1abb0) < fVar1)) {
    local_30 = 0.0;
    local_2c = 0.0;
    local_28 = 0;
    local_24 = 0;
    local_20 = 0;
                    /* try { // try from 0093f7c4 to 0093f853 has its CatchHandler @ 0093f903 */
    ForEachSurvivor<SurvivorCollector>((SurvivorCollector *)&local_30);
    iVar7 = 0;
    if (0 < local_24) {
      do {
        local_44 = (Vector *)&local_30;
        piVar5 = *(int **)((int)local_30 + iVar7 * 4);
        cVar2 = (**(code **)(*piVar5 + 0x778))(piVar5);
        if ((cVar2 == '\0') &&
           (piVar5 = *(int **)((int)local_30 + iVar7 * 4),
           cVar2 = (**(code **)(*piVar5 + 0x424))(piVar5,this), cVar2 != '\0')) {
          if (*(float *)(this + 0x1abb0) <= 0.0) {
                    /* try { // try from 0093f8b2 to 0093f8e3 has its CatchHandler @ 0093f903 */
            lVar9 = (longdouble)IntervalTimer::Now();
            if ((float)lVar9 != *(float *)(this + 0x1abb0)) {
              (**(code **)(*(int *)(this + 0x1abac) + 4))(this + 0x1abac,this + 0x1abb0);
              *(float *)(this + 0x1abb0) = (float)lVar9;
            }
          }
          CUtlVector<CTerrorPlayer*,CUtlMemory<CTerrorPlayer*,int>>::~CUtlVector
                    ((CUtlVector<CTerrorPlayer*,CUtlMemory<CTerrorPlayer*,int>> *)local_44);
          return;
        }
        iVar7 = iVar7 + 1;
      } while (iVar7 < local_24);
    }
    local_44 = (Vector *)&local_30;
    if (*(float *)(this + 0x1abb0) != -1.0) {
      IntervalTimer::NetworkVar_m_timestamp::NetworkStateChanged(this + 0x1abb0);
      *(undefined4 *)(this + 0x1abb0) = 0xbf800000;
    }
    CUtlVector<CTerrorPlayer*,CUtlMemory<CTerrorPlayer*,int>>::~CUtlVector
              ((CUtlVector<CTerrorPlayer*,CUtlMemory<CTerrorPlayer*,int>> *)local_44);
  }
  local_44 = (Vector *)&local_30;
  uVar4 = (**(code **)(*(int *)this + 0x9b8))(this);
  DevMsg("%3.2f: SurvivorBot %s was too far away and was forcibly relocated\n",
         (double)*(float *)(gpGlobals + 0xc),uVar4);
  this_00 = (CBasePlayer *)0x0;
  uVar8 = *(uint *)(iVar3 + 0x30);
  if (((uVar8 != 0xffffffff) &&
      (puVar6 = g_pEntityList + (uVar8 & 0xfff) * 0x10, puVar6 != (undefined *)0xfffffffc)) &&
     (*(uint *)(puVar6 + 8) == uVar8 >> 0xc)) {
    this_00 = *(CBasePlayer **)(puVar6 + 4);
  }
  this_01 = (CBaseEntity *)0x0;
  CBasePlayer::EyeVectors(this_00,(Vector *)&local_3c,(Vector *)0x0,(Vector *)0x0);
  local_34 = 0;
  uVar8 = *(uint *)(iVar3 + 0x30);
  if (((uVar8 != 0xffffffff) &&
      (puVar6 = g_pEntityList + (uVar8 & 0xfff) * 0x10, puVar6 != (undefined *)0xfffffffc)) &&
     (*(uint *)(puVar6 + 8) == uVar8 >> 0xc)) {
    this_01 = *(CBaseEntity **)(puVar6 + 4);
  }
  if (((byte)this_01[0x14d] & 8) != 0) {
    CBaseEntity::CalcAbsolutePosition(this_01);
    uVar8 = *(uint *)(iVar3 + 0x30);
  }
  local_30 = *(float *)(this_01 + 0x2e0) - local_3c * 10.0;
  local_2c = *(float *)(this_01 + 0x2e4) - local_38 * 10.0;
  local_28 = *(undefined4 *)(this_01 + 0x2e8);
  if ((uVar8 == 0xffffffff) ||
     (puVar6 = g_pEntityList + (uVar8 & 0xfff) * 0x10, puVar6 == (undefined *)0xfffffffc)) {
    iVar3 = 0;
    if (DAT_000039f1 == '\0') goto LAB_0093f70f;
  }
  else {
    if (*(uint *)(puVar6 + 8) == uVar8 >> 0xc) {
      iVar3 = *(int *)(puVar6 + 4);
    }
    else {
      iVar3 = 0;
    }
    if ((&DAT_000039f1)[iVar3] == '\0') goto LAB_0093f70f;
    if (*(uint *)(puVar6 + 8) == uVar8 >> 0xc) {
      iVar3 = *(int *)(puVar6 + 4);
    }
    else {
      iVar3 = 0;
    }
  }
  local_30 = *(float *)(iVar3 + 0x3a14);
  local_2c = *(float *)(iVar3 + 0x3a18);
  local_28 = *(undefined4 *)(iVar3 + 0x3a1c);
LAB_0093f70f:
  CBaseEntity::AddEffects((CBaseEntity *)this,8);
  CBaseEntity::SetAbsOrigin((CBaseEntity *)this,local_44);
  piVar5 = (int *)(**(code **)(*(int *)this + 0x9a8))(this);
  (**(code **)(*piVar5 + 0xa4))(piVar5);
  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)