L L4D2node

WitchWander::BuildWanderPath

0x00a44880 · 1836 bytes · __thiscall

_ZN11WitchWander15BuildWanderPathEP8Infected

Decompiled

undefined (2 params)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* WitchWander::BuildWanderPath(Infected*) */

bool __thiscall WitchWander::BuildWanderPath(WitchWander *this,Infected *param_1)

{
  uint *puVar1;
  CNavArea CVar2;
  char cVar3;
  bool bVar4;
  int iVar5;
  INextBot *pIVar6;
  Path *this_00;
  Vector *pVVar7;
  int *piVar8;
  CNavArea *pCVar9;
  CNavArea *pCVar10;
  CBaseEntity *pCVar11;
  int iVar12;
  WitchWander *pWVar13;
  Infected *pIVar14;
  longdouble lVar15;
  longdouble lVar16;
  float fVar17;
  PathFollower *local_8c;
  CNavArea *local_70;
  undefined4 local_6c;
  undefined4 local_68;
  float local_60;
  float local_5c;
  float local_58;
  undefined4 local_54;
  undefined4 local_50;
  int local_4c;
  float local_48;
  float local_44;
  float local_40;
  undefined4 local_3c;
  undefined4 local_38;
  undefined4 local_34;
  undefined **local_30;
  Infected *local_2c;
  int *local_28;
  undefined4 local_24;
  
  iVar5 = FindWanderArea(this,param_1);
  if (iVar5 == 0) goto LAB_00a44d65;
  local_30 = &PTR_operator___00d26e08;
  pIVar14 = (Infected *)0x0;
  if (param_1 != (Infected *)0x0) {
    pIVar14 = param_1 + 0x1a3c;
  }
  local_2c = pIVar14;
  local_24 = (**(code **)(*(int *)pIVar14 + 0xc0))(pIVar14);
  local_28 = (int *)(**(code **)(*(int *)pIVar14 + 0xb4))(pIVar14);
  if ((local_28 == (int *)0x0) ||
     (cVar3 = (**(code **)(*local_28 + 0x16c))(local_28), cVar3 == '\0')) {
    local_28 = (int *)0x0;
  }
  fVar17 = *(float *)(iVar5 + 0x10) - *(float *)(iVar5 + 4);
  lVar15 = (longdouble)RandomFloat(fVar17 * -0.25,fVar17 * 0.25);
  fVar17 = *(float *)(iVar5 + 0x14) - *(float *)(iVar5 + 8);
  lVar16 = (longdouble)RandomFloat(fVar17 * -0.25,fVar17 * 0.25);
  local_6c = 0;
  local_60 = (float)lVar15 + *(float *)(iVar5 + 0x2c);
  local_68 = 0;
  pIVar6 = (INextBot *)(param_1 + 0x1a3c);
  local_5c = (float)lVar16 + *(float *)(iVar5 + 0x30);
  if (param_1 == (Infected *)0x0) {
    pIVar6 = (INextBot *)0x0;
  }
  local_58 = *(float *)(iVar5 + 0x34);
  this_00 = (Path *)(this + 0x40);
  if (_towlower == 0) {
    local_4c = 0;
  }
  else {
    (**(code **)(_towlower + 0x50))
              (_towlower,&local_6c,0,0,0,0,"/data/src/game/server/nextbot/path/nextbotpath.h",0x113,
               &Path::
                Compute<WanderingWitchPathCost>(INextBot*,Vector_const&,WanderingWitchPathCost&,float)
                ::tm_fmt,"(%s)%s","NextBotSpiky","Path::Compute(goal)");
    local_4c = _towlower;
  }
  iVar5 = _DAT_0105db00;
  local_54 = local_6c;
  local_50 = local_68;
                    /* try { // try from 00a44dce to 00a44e2e has its CatchHandler @ 00a44fc6 */
  if (((_DAT_0105d154 != 0) || (DAT_0105d158 == '\0')) &&
     (iVar12 = ThreadGetCurrentId(), iVar5 == iVar12)) {
    if ((char *)*_DAT_0105d15c != "Path::Compute(goal)") {
      _DAT_0105d15c =
           (int *)CVProfNode::GetSubNode((char *)_DAT_0105d15c,0xbfa1b7,(char *)0x0,0xbfa1cb);
    }
    puVar1 = (uint *)(_DAT_0105d1e8 + 4 + _DAT_0105d15c[0x1c] * 8);
    *puVar1 = *puVar1 | 4;
    CVProfNode::EnterScope();
    DAT_0105d158 = '\0';
  }
                    /* try { // try from 00a44a61 to 00a44d0b has its CatchHandler @ 00a44fdb */
  (**(code **)(*(int *)(this + 0x40) + 0x48))(this_00);
  pVVar7 = (Vector *)(**(code **)(*(int *)pIVar6 + 0xd4))(pIVar6);
  piVar8 = (int *)(**(code **)(*(int *)pIVar6 + 0xb4))(pIVar6);
  pCVar9 = (CNavArea *)(**(code **)(*piVar8 + 0x52c))(piVar8);
  if (pCVar9 == (CNavArea *)0x0) {
    (**(code **)(*(int *)(this + 0x40) + 100))(this_00,pIVar6,2);
LAB_00a44d0c:
    bVar4 = false;
  }
  else {
    pCVar10 = (CNavArea *)
              CNavMesh::GetNearestNavArea(TheNavMesh,(Vector *)&local_60,true,200.0,true,true,false)
    ;
    if (pCVar9 == pCVar10) {
      Path::BuildTrivialPath(this_00,pIVar6,(Vector *)&local_60);
      bVar4 = true;
    }
    else {
      local_48 = local_60;
      local_44 = local_5c;
      local_40 = local_58;
      if (pCVar10 == (CNavArea *)0x0) {
        CNavMesh::GetGroundHeight(TheNavMesh,(Vector *)&local_48,&local_40,(Vector *)0x0);
      }
      else {
        lVar15 = (longdouble)CNavArea::GetZ(pCVar10,local_60,local_5c);
        local_40 = (float)lVar15;
      }
      pCVar11 = (CBaseEntity *)(**(code **)(*(int *)pIVar6 + 0xb4))(pIVar6);
      if (((byte)pCVar11[0x14d] & 8) != 0) {
                    /* try { // try from 00a44e95 to 00a44fbb has its CatchHandler @ 00a44fdb */
        CBaseEntity::CalcAbsolutePosition(pCVar11);
      }
      local_3c = *(undefined4 *)(pCVar11 + 0x2e0);
      local_70 = (CNavArea *)0x0;
      local_38 = *(undefined4 *)(pCVar11 + 0x2e4);
      local_34 = *(undefined4 *)(pCVar11 + 0x2e8);
      pCVar11 = (CBaseEntity *)(**(code **)(*(int *)pIVar6 + 0xb4))(pIVar6);
      iVar5 = CBaseEntity::GetTeamNumber(pCVar11);
      bVar4 = NavAreaBuildPath<WanderingWitchPathCost>
                        (pCVar9,pCVar10,(Vector *)&local_3c,(Vector *)&local_60,
                         (WanderingWitchPathCost *)&local_30,&local_70,0.0,iVar5,false);
      if (local_70 == (CNavArea *)0x0) goto LAB_00a44d0c;
      if (pCVar9 == local_70) {
LAB_00a44f66:
        Path::BuildTrivialPath(this_00,pIVar6,(Vector *)&local_60);
      }
      else {
        iVar5 = 1;
        pCVar10 = local_70;
        do {
          pCVar10 = *(CNavArea **)(pCVar10 + 0x78);
          if (pCVar10 == (CNavArea *)0x0) break;
          iVar5 = iVar5 + 1;
        } while (pCVar9 != pCVar10);
        if (iVar5 < 0x100) {
          if (iVar5 == 1) goto LAB_00a44f66;
          *(int *)(this + 0x4444) = iVar5;
        }
        else {
          iVar5 = 0xff;
          *(undefined4 *)(this + 0x4444) = 0xff;
        }
        pCVar9 = local_70;
        iVar12 = iVar5;
        pWVar13 = this + (iVar5 + -1) * 0x44 + 0x44;
        do {
          *(CNavArea **)pWVar13 = pCVar9;
          iVar12 = iVar12 + -1;
          CVar2 = pCVar9[0x7c];
          *(undefined4 *)(pWVar13 + 0x18) = 0;
          *(uint *)(pWVar13 + 4) = (byte)CVar2 & 0xf;
          pCVar9 = *(CNavArea **)(pCVar9 + 0x78);
          if (pCVar9 == (CNavArea *)0x0) break;
          pWVar13 = pWVar13 + -0x44;
        } while (iVar12 != 0);
        iVar5 = iVar5 * 0x44;
        *(CNavArea **)(this + iVar5 + 0x44) = local_70;
        *(float *)(this_00 + iVar5 + 0xc) = local_48;
        *(float *)(this_00 + iVar5 + 0x10) = local_44;
        *(float *)(this_00 + iVar5 + 0x14) = local_40;
        iVar5 = *(int *)(this + 0x4444);
        *(undefined4 *)(this + iVar5 * 0x44 + 0x58) = 0;
        *(undefined4 *)(this + iVar5 * 0x44 + 0x48) = 9;
        *(undefined4 *)(this + iVar5 * 0x44 + 0x5c) = 0;
        *(int *)(this + 0x4444) = iVar5 + 1;
        cVar3 = Path::ComputePathDetails(this_00,pIVar6,pVVar7);
        if (cVar3 == '\0') {
          (**(code **)(*(int *)(this + 0x40) + 0x48))(this_00);
          (**(code **)(*(int *)(this + 0x40) + 100))(this_00,pIVar6,2);
          goto LAB_00a44d0c;
        }
        Path::Optimize((INextBot *)this_00);
        Path::PostProcess(this_00);
        (**(code **)(*(int *)(this + 0x40) + 100))(this_00,pIVar6,!bVar4);
      }
    }
  }
  iVar5 = _DAT_0105db00;
  if (((DAT_0105d158 == '\0') || (_DAT_0105d154 != 0)) &&
     (iVar12 = ThreadGetCurrentId(), iVar5 == iVar12)) {
    cVar3 = CVProfNode::ExitScope();
    if (cVar3 != '\0') {
      _DAT_0105d15c = (int *)_DAT_0105d15c[0x19];
    }
    DAT_0105d158 = _DAT_0105d15c == (int *)0x105d160;
  }
  if (local_4c != 0) {
    (**(code **)(local_4c + 0x54))(local_4c,local_54,local_50,0,0,0);
  }
  if (bVar4 != false) {
    *(undefined4 *)(this + 0x4840) = 0;
    return bVar4;
  }
LAB_00a44d65:
  local_8c = (PathFollower *)(this + 0x40);
  *(int *)(this + 0x4840) = *(int *)(this + 0x4840) + 1;
  PathFollower::Invalidate(local_8c);
  if (10 < *(int *)(this + 0x4840)) {
    if (*(int *)(param_1 + 0x30) == 0) {
      iVar5 = 0;
    }
    else {
      iVar5 = *(int *)(param_1 + 0x30) - *(int *)(gpGlobals + 0x58) >> 4;
    }
    Msg("Witch %d failing excessively!\n",iVar5);
  }
  return false;
}

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)