L L4D2node

SurvivorTeamSituation::GetFriendClosestTo

0x009664a0 · 981 bytes · __thiscall

_ZNK21SurvivorTeamSituation18GetFriendClosestToEP11CBaseEntityNS_15CloseFriendTypeE

Decompiled

undefined (3 params)

/* SurvivorTeamSituation::GetFriendClosestTo(CBaseEntity*, SurvivorTeamSituation::CloseFriendType)
   const */

undefined4 __thiscall
SurvivorTeamSituation::GetFriendClosestTo
          (SurvivorTeamSituation *this,CBaseEntity *param_1,uint param_3)

{
  uint uVar1;
  char cVar2;
  Vector *pVVar3;
  CNavArea *pCVar4;
  float *pfVar5;
  float *pfVar6;
  CNavArea *pCVar7;
  CTerrorPlayer *this_00;
  undefined *puVar8;
  int *piVar9;
  int iVar10;
  longdouble lVar11;
  float fVar12;
  undefined4 local_38;
  float local_30;
  int *local_2c;
  SurvivorTeamSituation *local_20;
  
  if (param_1 == (CBaseEntity *)0x0) {
    local_38 = 0;
  }
  else {
    pVVar3 = (Vector *)(**(code **)(*(int *)param_1 + 0x288))(param_1);
    pCVar4 = (CNavArea *)CNavMesh::GetNearestNavArea(TheNavMesh,pVVar3,true,200.0,true,true,false);
    if (*(int *)(this + 0xc4) < 1) {
      local_38 = 0;
      local_30 = 999999.9;
    }
    else {
      local_20 = this + 55000;
      iVar10 = 0;
      local_38 = 0;
      local_30 = 999999.9;
LAB_00966548:
      do {
        if ((param_3 & 1) == 0) {
LAB_00966593:
          if (((param_3 & 2) != 0) &&
             (lVar11 = (longdouble)IntervalTimer::Now(),
             0.1 < (float)lVar11 - *(float *)(local_20 + 4))) {
            local_20 = local_20 + 0xc;
            iVar10 = iVar10 + 1;
            if (*(int *)(this + 0xc4) <= iVar10) break;
            goto LAB_00966548;
          }
          pfVar5 = (float *)(**(code **)(*(int *)param_1 + 0x288))(param_1);
          uVar1 = *(uint *)(this + iVar10 * 4 + 0x88);
          local_2c = (int *)0x0;
          if ((uVar1 != 0xffffffff) &&
             ((puVar8 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar8 != (undefined *)0xfffffffc &&
              (*(uint *)(puVar8 + 8) == uVar1 >> 0xc)))) {
            local_2c = *(int **)(puVar8 + 4);
          }
          pfVar6 = (float *)(**(code **)(*local_2c + 0x288))(local_2c);
          fVar12 = (pfVar6[1] - pfVar5[1]) * (pfVar6[1] - pfVar5[1]) +
                   (pfVar6[2] - pfVar5[2]) * (pfVar6[2] - pfVar5[2]) +
                   (*pfVar6 - *pfVar5) * (*pfVar6 - *pfVar5);
          if ((fVar12 < local_30) && (pCVar4 != (CNavArea *)0x0)) {
            uVar1 = *(uint *)(this + iVar10 * 4 + 0x88);
            piVar9 = (int *)0x0;
            if ((uVar1 != 0xffffffff) &&
               ((puVar8 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar8 != (undefined *)0xfffffffc
                && (*(uint *)(puVar8 + 8) == uVar1 >> 0xc)))) {
              piVar9 = *(int **)(puVar8 + 4);
            }
            pCVar7 = (CNavArea *)(**(code **)(*piVar9 + 0x52c))(piVar9);
            cVar2 = SurvivorBot::IsReachable(*(SurvivorBot **)(this + 4),pCVar7,pCVar4);
            if (cVar2 != '\0') {
              uVar1 = *(uint *)(this + iVar10 * 4 + 0x88);
              local_30 = fVar12;
              if (((uVar1 == 0xffffffff) ||
                  (puVar8 = g_pEntityList + (uVar1 & 0xfff) * 0x10,
                  puVar8 == (undefined *)0xfffffffc)) || (*(uint *)(puVar8 + 8) != uVar1 >> 0xc)) {
                local_38 = 0;
              }
              else {
                local_38 = *(undefined4 *)(puVar8 + 4);
              }
            }
          }
        }
        else {
          uVar1 = *(uint *)(this + iVar10 * 4 + 0x88);
          this_00 = (CTerrorPlayer *)0x0;
          if (((uVar1 != 0xffffffff) &&
              (puVar8 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar8 != (undefined *)0xfffffffc))
             && (*(uint *)(puVar8 + 8) == uVar1 >> 0xc)) {
            this_00 = *(CTerrorPlayer **)(puVar8 + 4);
          }
          cVar2 = CTerrorPlayer::IsAbleToMove(this_00);
          if (cVar2 != '\0') goto LAB_00966593;
        }
        local_20 = local_20 + 0xc;
        iVar10 = iVar10 + 1;
      } while (iVar10 < *(int *)(this + 0xc4));
    }
    if ((((param_3 & 1) == 0) ||
        (cVar2 = CTerrorPlayer::IsAbleToMove(*(CTerrorPlayer **)(this + 4)), cVar2 != '\0')) &&
       (((param_3 & 2) == 0 ||
        (cVar2 = CBaseCombatCharacter::IsAbleToSee(*(CBaseCombatCharacter **)(this + 4),param_1,1),
        cVar2 != '\0')))) {
      pfVar5 = (float *)(**(code **)(*(int *)param_1 + 0x288))(param_1);
      pfVar6 = (float *)(**(code **)(**(int **)(this + 4) + 0x288))(*(int **)(this + 4));
      if (((pfVar6[1] - pfVar5[1]) * (pfVar6[1] - pfVar5[1]) +
           (*pfVar6 - *pfVar5) * (*pfVar6 - *pfVar5) +
           (pfVar6[2] - pfVar5[2]) * (pfVar6[2] - pfVar5[2]) < local_30) &&
         (cVar2 = SurvivorBot::IsReachable(*(SurvivorBot **)(this + 4),param_1), cVar2 != '\0')) {
        local_38 = *(undefined4 *)(this + 4);
      }
    }
  }
  return local_38;
}

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)