L L4D2node

SurvivorBot::ResolveStuckSituation

0x00938f30 · 1948 bytes · __thiscall

_ZN11SurvivorBot21ResolveStuckSituationEP4Path

Decompiled

undefined (2 params)

/* SurvivorBot::ResolveStuckSituation(Path*) */

void __thiscall SurvivorBot::ResolveStuckSituation(SurvivorBot *this,Path *param_1)

{
  float fVar1;
  uint uVar2;
  char cVar3;
  int iVar4;
  int iVar5;
  CBaseEntity *pCVar6;
  undefined4 uVar7;
  int *piVar8;
  int iVar9;
  undefined *puVar10;
  int iVar11;
  CBaseEntity *this_00;
  longdouble lVar12;
  double local_64;
  double local_5c;
  double local_54;
  float local_44;
  float local_40;
  undefined4 local_3c;
  float local_38;
  float local_34;
  undefined4 local_30;
  uint local_2c [2];
  float local_24;
  undefined4 local_20;
  
  if (*(int *)(SurvivorBotUnstick._28_4_ + 0x30) == 0) {
    return;
  }
  cVar3 = CTerrorPlayer::IsAbleToMove((CTerrorPlayer *)this);
  if ((cVar3 == '\0') || (*(int *)(SurvivorBotMove._28_4_ + 0x30) == 0)) {
    (**(code **)(*(int *)(this + 0x4028) + 0x10c))(this + 0x4028);
    return;
  }
  lVar12 = (longdouble)CTerrorPlayer::GetTimeSinceAttackedByEnemy((CTerrorPlayer *)this);
  if (1.0 <= (float)lVar12) {
    this[0x1abb4] = (SurvivorBot)0x1;
    cVar3 = CTerrorGameRules::IsSurvivalMode();
    if (cVar3 != '\0') {
      return;
    }
    if ((*(char *)(*(int *)(TheDirector + 0x638) + 0x140) != '\0') &&
       (cVar3 = CDirector::IsFinaleVehicleReady(TheDirector), cVar3 != '\0')) {
      return;
    }
    cVar3 = (**(code **)(*(int *)param_1 + 0x44))(param_1);
    if (cVar3 != '\0') {
      iVar11 = 0;
      iVar4 = (**(code **)(*(int *)param_1 + 0x24))(param_1);
      if (iVar4 != 0) {
        do {
          cVar3 = (**(code **)(*(int *)(this + 0x4028) + 0x118))(this + 0x4028,iVar4 + 8);
          if (cVar3 == '\0') {
            local_2c[0] = *(uint *)(iVar4 + 8);
            local_2c[1] = *(undefined4 *)(iVar4 + 0xc);
            local_24 = *(float *)(iVar4 + 0x10) + 18.0;
            cVar3 = TestPosition((Vector *)this,(CBaseEntity *)local_2c);
            if (cVar3 != '\0') {
              (**(code **)(*(int *)this + 0x1dc))(this,local_2c,0,0);
              piVar8 = (int *)(**(code **)(*(int *)this + 0x9a0))(this);
              (**(code **)(*piVar8 + 0xa4))(piVar8);
              piVar8 = (int *)(**(code **)(*(int *)this + 0x9a0))(this);
              (**(code **)(*piVar8 + 0x170))(piVar8,"Teleported farther along the path");
              if (((byte)this[0x14d] & 8) == 0) {
                local_54 = (double)*(float *)(this + 0x2e8);
              }
              else {
                CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
                local_54 = (double)*(float *)(this + 0x2e8);
                if (((byte)this[0x14d] & 8) != 0) {
                  CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
                  local_5c = (double)*(float *)(this + 0x2e4);
                  if (((byte)this[0x14d] & 8) != 0) {
                    CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
                  }
                  goto LAB_009390fa;
                }
              }
              local_5c = (double)*(float *)(this + 0x2e4);
LAB_009390fa:
              fVar1 = *(float *)(this + 0x2e0);
              uVar7 = (**(code **)(*(int *)this + 0xb8))(this);
              DevMsg("%3.2f: ERROR: SurvivorBot( %s ) stuck here ( %3.2f, %3.2f, %3.2f ) - forced to next path goal position\n"
                     ,(double)*(float *)(gpGlobals + 0xc),uVar7,(double)fVar1,local_5c,local_54);
              return;
            }
          }
          iVar11 = iVar11 + 1;
          iVar4 = (**(code **)(*(int *)param_1 + 0x58))(param_1,iVar4);
        } while ((iVar4 != 0) && (iVar11 < 3));
      }
    }
    iVar11 = GetTeamSituation(this);
    iVar9 = 0;
    iVar4 = *(int *)(iVar11 + 0xc4);
    local_2c[0] = 0xffffffff;
    local_2c[1] = 0xffffffff;
    local_24 = -NAN;
    local_20 = 0xffffffff;
    if (0 < iVar4) {
      do {
        local_2c[iVar9] = *(uint *)(iVar11 + 0x88 + iVar9 * 4);
        iVar9 = iVar9 + 1;
      } while (iVar9 != iVar4);
    }
    iVar9 = 0;
    iVar11 = iVar4 + -1;
    if (0 < iVar11) {
      do {
        iVar5 = RandomInt(iVar9,iVar11);
        uVar2 = local_2c[iVar9];
        local_2c[iVar9] = local_2c[iVar5];
        iVar9 = iVar9 + 1;
        local_2c[iVar5] = uVar2;
      } while (iVar9 != iVar11);
    }
    iVar11 = 0;
    if (0 < iVar4) {
      do {
        this_00 = (CBaseEntity *)0x0;
        uVar2 = local_2c[iVar11];
        if (((uVar2 != 0xffffffff) &&
            (puVar10 = g_pEntityList + (uVar2 & 0xfff) * 0x10, puVar10 != (undefined *)0xfffffffc))
           && (*(uint *)(puVar10 + 8) == uVar2 >> 0xc)) {
          this_00 = *(CBaseEntity **)(puVar10 + 4);
        }
        pCVar6 = (CBaseEntity *)(**(code **)(*(int *)this_00 + 0x18))(this_00);
        if (((byte)this_00[0x14d] & 8) != 0) {
          CBaseEntity::CalcAbsolutePosition(this_00);
        }
        cVar3 = TestPosition(this,(Vector *)(this_00 + 0x2e0),pCVar6);
        if (cVar3 != '\0') {
          CBasePlayer::EyeVectors
                    ((CBasePlayer *)this_00,(Vector *)&local_44,(Vector *)0x0,(Vector *)0x0);
          local_3c = 0;
          if (((byte)this_00[0x14d] & 8) != 0) {
            CBaseEntity::CalcAbsolutePosition(this_00);
          }
          local_38 = *(float *)(this_00 + 0x2e0) - local_44 * 10.0;
          local_34 = *(float *)(this_00 + 0x2e4) - local_40 * 10.0;
          local_30 = *(undefined4 *)(this_00 + 0x2e8);
          if (this_00[0x39f1] != (CBaseEntity)0x0) {
            local_38 = *(float *)(this_00 + 0x3a14);
            local_34 = *(float *)(this_00 + 0x3a18);
            local_30 = *(undefined4 *)(this_00 + 0x3a1c);
          }
          CBaseEntity::AddEffects((CBaseEntity *)this,8);
          CBaseEntity::SetAbsOrigin((CBaseEntity *)this,(Vector *)&local_38);
          piVar8 = (int *)(**(code **)(*(int *)this + 0x9a0))(this);
          (**(code **)(*piVar8 + 0xa4))(piVar8);
          piVar8 = (int *)(**(code **)(*(int *)this + 0x9a0))(this);
          (**(code **)(*piVar8 + 0x170))(piVar8,"Teleported to nearby friend\'s spot");
          if (((byte)this[0x14d] & 8) == 0) {
            local_54 = (double)*(float *)(this + 0x2e8);
          }
          else {
            CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
            local_54 = (double)*(float *)(this + 0x2e8);
            if (((byte)this[0x14d] & 8) != 0) {
              CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
              local_5c = (double)*(float *)(this + 0x2e4);
              if (((byte)this[0x14d] & 8) != 0) {
                CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
              }
              goto LAB_0093956a;
            }
          }
          local_5c = (double)*(float *)(this + 0x2e4);
LAB_0093956a:
          fVar1 = *(float *)(this + 0x2e0);
          uVar7 = (**(code **)(*(int *)this + 0xb8))(this);
          DevMsg("%3.2f: ERROR: SurvivorBot( %s ) stuck here ( %3.2f, %3.2f, %3.2f ) - forced to nearby friend position\n"
                 ,(double)*(float *)(gpGlobals + 0xc),uVar7,(double)fVar1,local_5c,local_54);
          return;
        }
        iVar11 = iVar11 + 1;
      } while (iVar11 != iVar4);
    }
    if (((byte)this[0x14d] & 8) == 0) {
      local_5c = (double)*(float *)(this + 0x2e8);
    }
    else {
      CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
      local_5c = (double)*(float *)(this + 0x2e8);
      if (((byte)this[0x14d] & 8) != 0) {
        CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
        local_64 = (double)*(float *)(this + 0x2e4);
        if (((byte)this[0x14d] & 8) != 0) {
          CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
        }
        goto LAB_009393da;
      }
    }
    local_64 = (double)*(float *)(this + 0x2e4);
LAB_009393da:
    fVar1 = *(float *)(this + 0x2e0);
    uVar7 = (**(code **)(*(int *)this + 0xb8))(this);
    Warning("%3.2f: ResolveStuckSituation ERROR: Cannot resolve SurvivorBot( %s ) stuck situation at ( %3.2f, %3.2f, %3.2f )\n"
            ,(double)*(float *)(gpGlobals + 0xc),uVar7,(double)fVar1,local_64,local_5c);
    return;
  }
  if (((byte)this[0x14d] & 8) == 0) {
    local_5c = (double)*(float *)(this + 0x2e8);
  }
  else {
    CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
    local_5c = (double)*(float *)(this + 0x2e8);
    if (((byte)this[0x14d] & 8) != 0) {
      CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
      local_54 = (double)*(float *)(this + 0x2e4);
      if (((byte)this[0x14d] & 8) != 0) {
        CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
      }
      goto LAB_009391ad;
    }
  }
  local_54 = (double)*(float *)(this + 0x2e4);
LAB_009391ad:
  fVar1 = *(float *)(this + 0x2e0);
  uVar7 = (**(code **)(*(int *)this + 0xb8))(this);
  DevMsg("%3.2f: ResolveStuckSituation: SurvivorBot( %s ) at at ( %3.2f, %3.2f, %3.2f ) unable to teleport due to recent damage.\n"
         ,(double)*(float *)(gpGlobals + 0xc),uVar7,(double)fVar1,local_54,local_5c);
  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)