L L4D2node

SurvivorBot::Update

0x0093f920 · 3688 bytes · __thiscall

_ZN11SurvivorBot6UpdateEv

Decompiled

undefined (1 param)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* SurvivorBot::Update() */

void __thiscall SurvivorBot::Update(SurvivorBot *this)

{
  code *pcVar1;
  uint uVar2;
  float fVar3;
  char cVar4;
  int iVar5;
  undefined4 uVar6;
  int iVar7;
  int *piVar8;
  undefined4 *puVar9;
  int iVar10;
  float *pfVar11;
  undefined *puVar12;
  uint *puVar13;
  CBaseEntity *pCVar14;
  float fVar15;
  int in_GS_OFFSET;
  longdouble lVar16;
  float fVar17;
  SurvivorBot *pSVar18;
  undefined4 local_180;
  undefined4 local_174;
  undefined4 local_170;
  undefined4 local_168;
  undefined4 local_164;
  SurvivorBot *local_160;
  float local_15c;
  float local_158;
  undefined4 local_154;
  float local_150;
  float local_14c;
  float local_148;
  float local_144;
  float local_140;
  float local_13c;
  float local_138;
  float local_134;
  float local_130;
  CFmtStrN<256> local_12c [5];
  undefined1 local_127 [263];
  int local_20;
  
  local_174 = 0;
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  local_170 = 0;
  if (_towlower == (SurvivorBot *)0x0) {
    local_160 = (SurvivorBot *)0x0;
  }
  else {
    (**(code **)(_towlower + 0x50))
              (_towlower,&local_174,0,0,0,0,
               "/data/src/game/server/terror/survivorbot/survivorbot.cpp",0x31d,&Update()::tm_fmt,
               "(%s)%s","SurvivorBot::Update","SurvivorBot::Update");
    local_160 = _towlower;
  }
  iVar5 = _DAT_0105db00;
  local_168 = local_174;
  local_164 = local_170;
                    /* try { // try from 0093fac6 to 0093fb26 has its CatchHandler @ 00940822 */
  if (((_DAT_0105d154 != 0) || (DAT_0105d158 == '\0')) &&
     (iVar7 = ThreadGetCurrentId(), iVar5 == iVar7)) {
    if (*(char **)_DAT_0105d15c != "SurvivorBot::Update") {
      _DAT_0105d15c =
           (SurvivorBot *)
           CVProfNode::GetSubNode((char *)_DAT_0105d15c,0xd07858,(char *)0x0,0xd07858);
    }
    puVar13 = (uint *)(_DAT_0105d1e8 + 4 + *(int *)(_DAT_0105d15c + 0x70) * 8);
    *puVar13 = *puVar13 | 4;
    CVProfNode::EnterScope();
    DAT_0105d158 = '\0';
  }
                    /* try { // try from 0093f9fc to 0093fa46 has its CatchHandler @ 00940816 */
  iVar5 = CBaseEntity::GetTeamNumber((CBaseEntity *)this);
  cVar4 = IsASurvivorTeam(iVar5);
  if (cVar4 == '\0') {
    pcVar1 = *(code **)(*(int *)engine + 0x94);
    uVar6 = (**(code **)(*(int *)this + 0xb8))(this);
    uVar6 = UTIL_VarArgs("kick \"%s\"\n",uVar6);
    pSVar18 = engine;
    (*pcVar1)(engine,uVar6);
  }
  else {
                    /* try { // try from 0093fb85 to 00940060 has its CatchHandler @ 00940816 */
    pSVar18 = this;
    cVar4 = (**(code **)(*(int *)this + 300))(this);
    if ((cVar4 != '\0') && (*(int *)(bot_mimic._28_4_ + 0x30) == 0)) {
      piVar8 = (int *)(**(code **)(*(int *)this + 0x484))(this,0);
      if (piVar8 == (int *)0x0) {
        this[0x4304] = (SurvivorBot)0x0;
      }
      else {
        iVar7 = (**(code **)(*piVar8 + 0x55c))(piVar8);
        puVar9 = (undefined4 *)GetAmmoDef();
        iVar10 = (**(code **)*puVar9)(puVar9,iVar7,this);
        iVar5 = piVar8[0x508];
        iVar7 = CBaseCombatCharacter::GetAmmoCount((CBaseCombatCharacter *)this,iVar7);
        this[0x4304] = (SurvivorBot)(iVar5 + iVar7 < iVar10 / 3);
      }
      EnforceProximityToHumans(this);
      pSVar18 = this + 0x8b6c;
      (*(code *)**(undefined4 **)(this + 0x8b6c))(pSVar18);
      iVar5 = 1;
      if (0 < *(int *)(gpGlobals + 0x14)) {
        do {
          piVar8 = (int *)UTIL_PlayerByIndex(iVar5);
          if (((piVar8 != (int *)0x0) && (piVar8[0xc] != 0)) &&
             ((piVar8[0xc] - *(int *)(gpGlobals + 0x58) >> 4 != 0 &&
              ((cVar4 = (**(code **)(*piVar8 + 0x16c))(piVar8), cVar4 != '\0' &&
               (piVar8[0x7db] != 2)))))) {
            cVar4 = (**(code **)(*(int *)(this + 0x8b6c) + 4))(pSVar18,piVar8);
            local_180 = 0;
            if (cVar4 == '\0') goto LAB_0093fcea;
          }
          iVar5 = iVar5 + 1;
        } while (iVar5 <= *(int *)(gpGlobals + 0x14));
      }
      local_180 = 1;
LAB_0093fcea:
      (**(code **)(*(int *)(this + 0x8b6c) + 8))(pSVar18,local_180);
      if (this[0x1abb4] != (SurvivorBot)0x0) {
        piVar8 = (int *)(**(code **)(*(int *)this + 0x9a8))(this);
        (**(code **)(*piVar8 + 0xa4))(piVar8);
        this[0x1abb4] = (SurvivorBot)0x0;
      }
      cVar4 = (**(code **)(*(int *)this + 300))(this);
      if ((cVar4 != '\0') && (*(int *)(NextBotPlayerStop._28_4_ + 0x30) == 0)) {
                    /* try { // try from 009402a1 to 00940382 has its CatchHandler @ 00940816 */
        INextBot::Update((INextBot *)(this + 0x4028));
      }
      iVar5 = (**(code **)(*(int *)this + 0x52c))(this);
      if (iVar5 == 0) {
        if (((byte)this[0x14d] & 8) != 0) {
                    /* try { // try from 0094041c to 009404de has its CatchHandler @ 00940816 */
          CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
        }
        iVar5 = CNavMesh::GetNearestNavArea
                          (TheNavMesh,(Vector *)(this + 0x2e0),false,10000.0,false,true,false);
        if (iVar5 != 0) {
          piVar8 = (int *)(**(code **)(*(int *)this + 0x9a0))(this);
          (**(code **)(*piVar8 + 0xb4))(piVar8,iVar5 + 0x2c,0x3f800000);
        }
      }
      iVar5 = (**(code **)(*(int *)this + 0x9a8))(this);
      if (0 < *(int *)(iVar5 + 0x70)) {
        puVar13 = *(uint **)(iVar5 + 100);
        iVar7 = 0;
        do {
          if (((((char)puVar13[10] != '\0') && (uVar2 = *puVar13, uVar2 != 0xffffffff)) &&
              (puVar12 = g_pEntityList + (uVar2 & 0xfff) * 0x10, puVar12 != (undefined *)0xfffffffc)
              ) && ((*(uint *)(puVar12 + 8) == uVar2 >> 0xc &&
                    (piVar8 = *(int **)(puVar12 + 4), piVar8 != (int *)0x0)))) {
            cVar4 = (**(code **)(*piVar8 + 300))(piVar8);
            if (cVar4 != '\0') {
              uVar2 = *puVar13;
              pCVar14 = (CBaseEntity *)0x0;
              if (((uVar2 != 0xffffffff) &&
                  (puVar12 = g_pEntityList + (uVar2 & 0xfff) * 0x10,
                  puVar12 != (undefined *)0xfffffffc)) && (*(uint *)(puVar12 + 8) == uVar2 >> 0xc))
              {
                pCVar14 = *(CBaseEntity **)(puVar12 + 4);
              }
              iVar5 = CBaseEntity::GetTeamNumber(pCVar14);
              if ((iVar5 == 3) &&
                 (iVar5 = (**(code **)(*(int *)pCVar14 + 0x544))(pCVar14), iVar5 == 7)) {
                lVar16 = (longdouble)CountdownTimer::Now();
                if ((float)lVar16 + 1.0 != *(float *)(this + 0x8b64)) {
                    /* try { // try from 009407b8 to 009407ba has its CatchHandler @ 00940816 */
                  (**(code **)(*(int *)(this + 0x8b5c) + 4))(this + 0x8b5c,this + 0x8b64);
                  *(float *)(this + 0x8b64) = (float)lVar16 + 1.0;
                }
                if (*(float *)(this + 0x8b60) != 1.0) {
                  (**(code **)(*(int *)(this + 0x8b5c) + 4))(this + 0x8b5c,this + 0x8b60);
                  *(undefined4 *)(this + 0x8b60) = 0x3f800000;
                }
              }
            }
            break;
          }
          iVar7 = iVar7 + 1;
          puVar13 = puVar13 + 0xb;
        } while (iVar7 != *(int *)(iVar5 + 0x70));
      }
      if ((*(int *)(SurvivorBotFlashlight._28_4_ + 0x30) == 1) ||
         (((*(int *)(SurvivorBotFlashlight._28_4_ + 0x30) != -1 &&
           (lVar16 = (longdouble)CountdownTimer::Now(), *(float *)(this + 0x8b64) <= (float)lVar16))
          && (this[0x39e4] != (SurvivorBot)0x0)))) {
        (**(code **)(*(int *)this + 0x5f8))(this,0);
      }
      else {
        (**(code **)(*(int *)this + 0x5fc))(this,0);
      }
      if ((*(int *)(SurvivorBotShowThreatAreas._28_4_ + 0x30) != 0) &&
         (0 < *(int *)(this + 0x1aa90))) {
        iVar5 = 0;
        do {
          piVar8 = *(int **)(*(int *)(this + 0x1aa84) + iVar5 * 4);
          (**(code **)(*piVar8 + 0x54))(piVar8,0xff,0,0,0x80,0x3c279bbb,1);
          iVar5 = iVar5 + 1;
        } while (iVar5 < *(int *)(this + 0x1aa90));
      }
      if (*(int *)(SurvivorBotMove._28_4_ + 0x30) == 0) {
        (**(code **)(*(int *)this + 0x95c))(this);
        (**(code **)(*(int *)this + 0x964))(this);
        (**(code **)(*(int *)this + 0x96c))(this);
        (**(code **)(*(int *)this + 0x974))(this);
        (**(code **)(*(int *)this + 0x97c))(this);
      }
      if (*(int *)(SurvivorBotDontBash._28_4_ + 0x30) != 0) {
        (**(code **)(*(int *)this + 0x944))(this);
      }
      piVar8 = (int *)(**(code **)(*(int *)this + 0x9a0))(this);
      pfVar11 = (float *)(**(code **)(*piVar8 + 0x14c))(piVar8);
      local_15c = *pfVar11;
      local_158 = pfVar11[1];
      local_154 = 0;
      VectorNormalize((Vector *)&local_15c);
      fVar3 = local_15c;
      fVar17 = *(float *)(SurvivorBotNarrowCorridorWidth._28_4_ + 0x2c) * 0.5;
      fVar15 = -local_158;
      piVar8 = (int *)(**(code **)(*(int *)this + 0x9a0))(this);
      pfVar11 = (float *)(**(code **)(*piVar8 + 300))(piVar8);
      fVar15 = fVar15 * fVar17;
      fVar17 = fVar17 * fVar3;
      cVar4 = INextBot::IsDebugging((INextBot *)(this + 0x4028),0x10);
      if (cVar4 != '\0') {
        local_138 = *pfVar11 + fVar15;
        local_134 = pfVar11[1] + fVar17;
        local_130 = pfVar11[2];
        local_144 = *pfVar11 - fVar15;
        local_140 = pfVar11[1] - fVar17;
        local_13c = pfVar11[2];
        NDebugOverlay::HorzArrow
                  ((Vector *)&local_144,(Vector *)&local_138,2.0,0xff,0,0xff,0x80,false,0.1);
      }
                    /* try { // try from 0094006e to 00940073 has its CatchHandler @ 00940828 */
      piVar8 = (int *)(**(code **)(*(int *)this + 0x9a0))(this);
      local_150 = fVar15 + *pfVar11;
      local_14c = fVar17 + pfVar11[1];
      local_148 = pfVar11[2];
                    /* try { // try from 009400d3 to 009400d4 has its CatchHandler @ 00940826 */
      cVar4 = (**(code **)(*piVar8 + 0x158))(piVar8,pfVar11,&local_150,0,0);
      if (cVar4 == '\0') {
                    /* try { // try from 009404ed to 009404f2 has its CatchHandler @ 00940814 */
        piVar8 = (int *)(**(code **)(*(int *)this + 0x9a0))(this);
        local_138 = *pfVar11 - fVar15;
        local_134 = pfVar11[1] - fVar17;
        local_130 = pfVar11[2];
                    /* try { // try from 00940552 to 00940553 has its CatchHandler @ 00940812 */
        cVar4 = (**(code **)(*piVar8 + 0x158))(piVar8,pfVar11,&local_138,0,0);
        if (cVar4 != '\0') goto LAB_009400dd;
LAB_009403f4:
        this[0x1aaa1] = (SurvivorBot)0x1;
      }
      else {
LAB_009400dd:
                    /* try { // try from 009400e2 to 009400e7 has its CatchHandler @ 009407db */
        piVar8 = (int *)(**(code **)(*(int *)this + 0x9a0))(this);
        local_144 = fVar15 + *pfVar11;
        local_140 = fVar17 + pfVar11[1];
        local_13c = pfVar11[2];
                    /* try { // try from 0094013f to 00940140 has its CatchHandler @ 00940805 */
        cVar4 = (**(code **)(*piVar8 + 0x15c))(piVar8,pfVar11,&local_144,0);
        if (cVar4 != '\0') {
                    /* try { // try from 0094038d to 00940392 has its CatchHandler @ 00940801 */
          piVar8 = (int *)(**(code **)(*(int *)this + 0x9a0))(this);
          local_138 = *pfVar11 - fVar15;
          local_134 = pfVar11[1] - fVar17;
          local_130 = pfVar11[2];
                    /* try { // try from 009403ea to 009403eb has its CatchHandler @ 009407ff */
          cVar4 = (**(code **)(*piVar8 + 0x15c))(piVar8,pfVar11,&local_138,0);
          if (cVar4 != '\0') goto LAB_009403f4;
        }
        this[0x1aaa1] = (SurvivorBot)0x0;
      }
      pSVar18 = this;
                    /* try { // try from 00940153 to 0094020f has its CatchHandler @ 00940816 */
      AcknowledgeFriendsAttention(this);
      if (*(int *)(this + 0x1aaa4) != 0) {
        pSVar18 = this + 0x1aaac;
        lVar16 = (longdouble)CountdownTimer::Now();
        if (*(float *)(this + 0x1aab4) <= (float)lVar16) {
          uVar2 = *(uint *)(this + 0x1aab8);
          if (((uVar2 == 0xffffffff) ||
              (puVar12 = g_pEntityList + (uVar2 & 0xfff) * 0x10, puVar12 == (undefined *)0xfffffffc)
              ) || ((*(uint *)(puVar12 + 8) != uVar2 >> 0xc || (*(int *)(puVar12 + 4) == 0)))) {
LAB_009401bf:
            pcVar1 = *(code **)(*(int *)this + 0x7b4);
            CAI_Concept::CAI_Concept((CAI_Concept *)&local_138,*(char **)(this + 0x1aaa4));
            pSVar18 = this;
            (*pcVar1)(this,(CAI_Concept *)&local_138,1,0,0,0,0);
          }
          else {
                    /* try { // try from 009405a7 to 009406b5 has its CatchHandler @ 00940816 */
            piVar8 = (int *)(**(code **)(*(int *)this + 0x9a4))(this);
            uVar6 = 0;
            uVar2 = *(uint *)(this + 0x1aab8);
            if (((uVar2 != 0xffffffff) &&
                (puVar12 = g_pEntityList + (uVar2 & 0xfff) * 0x10,
                puVar12 != (undefined *)0xfffffffc)) && (*(uint *)(puVar12 + 8) == uVar2 >> 0xc)) {
              uVar6 = *(undefined4 *)(puVar12 + 4);
            }
            (**(code **)(*piVar8 + 0xc4))
                      (piVar8,uVar6,1,0x3f800000,0,"Looking at who I\'m talking to",1,0x3e800000);
            uVar2 = *(uint *)(this + 0x1aab8);
            piVar8 = (int *)0x0;
            if (((uVar2 != 0xffffffff) &&
                (puVar12 = g_pEntityList + (uVar2 & 0xfff) * 0x10,
                puVar12 != (undefined *)0xfffffffc)) && (*(uint *)(puVar12 + 8) == uVar2 >> 0xc)) {
              piVar8 = *(int **)(puVar12 + 4);
            }
            cVar4 = (**(code **)(*piVar8 + 0x16c))(piVar8);
            if (cVar4 == '\0') goto LAB_009401bf;
            uVar2 = *(uint *)(this + 0x1aab8);
            pCVar14 = (CBaseEntity *)0x0;
            if (((uVar2 != 0xffffffff) &&
                (puVar12 = g_pEntityList + (uVar2 & 0xfff) * 0x10,
                puVar12 != (undefined *)0xfffffffc)) && (*(uint *)(puVar12 + 8) == uVar2 >> 0xc)) {
              pCVar14 = *(CBaseEntity **)(puVar12 + 4);
            }
            iVar5 = CBaseEntity::GetTeamNumber(pCVar14);
            cVar4 = IsASurvivorTeam(iVar5);
            if (cVar4 == '\0') goto LAB_009401bf;
            uVar2 = *(uint *)(this + 0x1aab8);
            if ((((uVar2 == 0xffffffff) ||
                 (puVar12 = g_pEntityList + (uVar2 & 0xfff) * 0x10,
                 puVar12 == (undefined *)0xfffffffc)) || (*(uint *)(puVar12 + 8) != uVar2 >> 0xc))
               || ((piVar8 = *(int **)(puVar12 + 4), piVar8 == (int *)0x0 ||
                   (cVar4 = (**(code **)(*piVar8 + 0x16c))(piVar8), cVar4 == '\0')))) {
              piVar8 = (int *)0x0;
            }
                    /* try { // try from 009406f9 to 00940785 has its CatchHandler @ 00940803 */
            uVar6 = SurvivorCharacterName(piVar8[0xae8]);
            CFmtStrN<256>::CFmtStrN(local_12c,"subject:%s",uVar6);
            pcVar1 = *(code **)(*(int *)this + 0x7b4);
            CAI_Concept::CAI_Concept((CAI_Concept *)&local_138,*(char **)(this + 0x1aaa4));
            pSVar18 = this;
            (*pcVar1)(this,(CAI_Concept *)&local_138,1,local_127,0,0,0);
          }
          *(undefined4 *)(this + 0x1aaa4) = 0;
        }
      }
      iVar5 = _DAT_0105db00;
      if (((DAT_0105d158 == '\0') || (_DAT_0105d154 != 0)) &&
         (iVar7 = ThreadGetCurrentId(pSVar18), iVar5 == iVar7)) {
        pSVar18 = _DAT_0105d15c;
        cVar4 = CVProfNode::ExitScope();
        if (cVar4 != '\0') {
          _DAT_0105d15c = *(SurvivorBot **)(_DAT_0105d15c + 100);
        }
        DAT_0105d158 = _DAT_0105d15c == (SurvivorBot *)0x105d160;
      }
      if (local_160 != (SurvivorBot *)0x0) {
        pSVar18 = local_160;
        (**(code **)(local_160 + 0x54))(local_160,local_168,local_164,0,0,0);
      }
      goto LAB_0093fa9e;
    }
  }
  iVar5 = _DAT_0105db00;
  if (((DAT_0105d158 == '\0') || (_DAT_0105d154 != 0)) &&
     (iVar7 = ThreadGetCurrentId(), iVar5 == iVar7)) {
    pSVar18 = _DAT_0105d15c;
    cVar4 = CVProfNode::ExitScope();
    if (cVar4 != '\0') {
      _DAT_0105d15c = *(SurvivorBot **)(_DAT_0105d15c + 100);
    }
    DAT_0105d158 = _DAT_0105d15c == (SurvivorBot *)0x105d160;
  }
  if (local_160 != (SurvivorBot *)0x0) {
    pSVar18 = local_160;
    (**(code **)(local_160 + 0x54))(local_160,local_168,local_164,0,0,0);
  }
LAB_0093fa9e:
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail(pSVar18);
  }
  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)