L L4D2node

CTerrorPlayer::GetNearbyEnemyPlayerCount

0x009a6920 · 894 bytes · __thiscall

_ZN13CTerrorPlayer25GetNearbyEnemyPlayerCountEfbPb

Decompiled

undefined (4 params)

/* CTerrorPlayer::GetNearbyEnemyPlayerCount(float, bool, bool*) */

int __thiscall
CTerrorPlayer::GetNearbyEnemyPlayerCount
          (CTerrorPlayer *this,float param_1,bool param_2,bool *param_3)

{
  code *pcVar1;
  char cVar2;
  int *piVar3;
  int iVar4;
  int iVar5;
  int *piVar6;
  int *piVar7;
  int iVar8;
  int aiStack_138 [6];
  int local_120;
  float local_11c [5];
  float local_108;
  char local_101;
  int local_100;
  float local_f4;
  float local_f0;
  float local_ec;
  float local_e8;
  float local_e4;
  float local_e0;
  undefined **local_dc [4];
  float local_cc;
  float local_c8;
  float local_c4;
  float local_bc;
  float local_b8;
  float local_b4;
  undefined4 local_ac;
  undefined4 local_a8;
  undefined4 local_a4;
  undefined4 local_9c;
  undefined4 local_98;
  undefined4 local_94;
  undefined4 local_8c;
  undefined1 local_88;
  undefined1 local_87;
  undefined1 local_70 [12];
  undefined1 local_64 [32];
  float local_44;
  int *local_24;
  
  piVar6 = aiStack_138 + 3;
  local_101 = param_2;
  if (*(int *)(gpGlobals + 0x14) < 1) {
    local_100 = 0;
  }
  else {
    local_100 = 0;
    iVar8 = 1;
    do {
      *piVar6 = iVar8;
      piVar6[-1] = 0x9a69a5;
      piVar3 = (int *)UTIL_PlayerByIndex(*piVar6);
      if (piVar3 != (int *)0x0) {
        iVar5 = *piVar3;
        *piVar6 = (int)piVar3;
        pcVar1 = *(code **)(iVar5 + 0x16c);
        piVar6[-1] = 0x9a69b6;
        cVar2 = (*pcVar1)();
        if (cVar2 != '\0') {
          if (piVar3[0xc] == 0) {
            iVar5 = 0;
          }
          else {
            iVar5 = piVar3[0xc] - *(int *)(gpGlobals + 0x58) >> 4;
          }
          if (*(int *)(this + 0x30) == 0) {
            iVar4 = 0;
          }
          else {
            iVar4 = *(int *)(this + 0x30) - *(int *)(gpGlobals + 0x58) >> 4;
          }
          if (iVar5 != iVar4) {
            iVar5 = *piVar3;
            *piVar6 = (int)piVar3;
            pcVar1 = *(code **)(iVar5 + 300);
            piVar6[-1] = 0x9a697b;
            cVar2 = (*pcVar1)();
            if ((cVar2 != '\0') && ((*(byte *)(piVar3 + 0x748) & 8) == 0)) {
              piVar6[1] = (int)this;
              *piVar6 = (int)piVar3;
              piVar6[-1] = 0x9a6a0c;
              cVar2 = CBaseEntity::InSameTeam((CBaseEntity *)*piVar6,(CBaseEntity *)piVar6[1]);
              if (cVar2 == '\0') {
                if (((byte)this[0x14d] & 8) != 0) {
                  *piVar6 = (int)this;
                  piVar6[-1] = 0x9a6aed;
                  CBaseEntity::CalcAbsolutePosition((CBaseEntity *)*piVar6);
                }
                if ((*(byte *)((int)piVar3 + 0x14d) & 8) != 0) {
                  *piVar6 = (int)piVar3;
                  piVar6[-1] = 0x9a6adf;
                  CBaseEntity::CalcAbsolutePosition((CBaseEntity *)*piVar6);
                }
                local_108 = ((float)piVar3[0xb9] - *(float *)(this + 0x2e4)) *
                            ((float)piVar3[0xb9] - *(float *)(this + 0x2e4)) +
                            ((float)piVar3[0xba] - *(float *)(this + 0x2e8)) *
                            ((float)piVar3[0xba] - *(float *)(this + 0x2e8)) +
                            ((float)piVar3[0xb8] - *(float *)(this + 0x2e0)) *
                            ((float)piVar3[0xb8] - *(float *)(this + 0x2e0));
                if (SQRT(local_108) < param_1) {
                  piVar7 = piVar6;
                  if (local_101 != '\0') {
                    piVar6[3] = 0;
                    *piVar6 = (int)local_dc;
                    piVar6[2] = 0;
                    piVar6[1] = (int)this;
                    piVar6[-1] = 0x9a6b17;
                    CTraceFilterSimple::CTraceFilterSimple
                              ((CTraceFilterSimple *)*piVar6,(IHandleEntity *)piVar6[1],piVar6[2],
                               (_func_bool_IHandleEntity_ptr_int *)piVar6[3]);
                    local_dc[0] = &PTR_ShouldHitEntity_00c54558;
                    iVar5 = *piVar3;
                    *piVar6 = (int)&local_e8;
                    piVar6[1] = (int)piVar3;
                    pcVar1 = *(code **)(iVar5 + 0x234);
                    piVar6[-1] = 0x9a6b36;
                    (*pcVar1)();
                    iVar5 = *(int *)this;
                    piVar6[-1] = (int)&local_f4;
                    *piVar6 = (int)this;
                    pcVar1 = *(code **)(iVar5 + 0x234);
                    piVar6[-2] = 0x9a6b4e;
                    (*pcVar1)();
                    local_8c = 0;
                    local_88 = 1;
                    local_cc = local_f4;
                    local_bc = local_e8 - local_f4;
                    local_c8 = local_f0;
                    local_b8 = local_e4 - local_f0;
                    local_c4 = local_ec;
                    local_b4 = local_e0 - local_ec;
                    local_94 = 0;
                    local_98 = 0;
                    local_9c = 0;
                    local_87 = local_bc * local_bc + local_b8 * local_b8 + local_b4 * local_b4 !=
                               0.0;
                    local_a4 = 0;
                    local_a8 = 0;
                    local_ac = 0;
                    iVar5 = *enginetrace;
                    piVar6[2] = (int)local_70;
                    piVar6[1] = (int)local_dc;
                    piVar6[-2] = (int)enginetrace;
                    *piVar6 = 0x2006041;
                    piVar6[-1] = (int)&local_cc;
                    pcVar1 = *(code **)(iVar5 + 0x14);
                    piVar6[-3] = 0x9a6c4f;
                    (*pcVar1)();
                    if (*(int *)(r_visualizetraces._28_4_ + 0x30) != 0) {
                      piVar6[4] = -0x40800000;
                      piVar6[-1] = (int)local_64;
                      piVar6[3] = 1;
                      piVar6[2] = 0;
                      piVar6[1] = 0;
                      *piVar6 = 0xff;
                      piVar6[-2] = (int)local_70;
                      piVar6[-3] = 0x9a6c95;
                      DebugDrawLine((Vector *)piVar6[-2],(Vector *)piVar6[-1],*piVar6,piVar6[1],
                                    piVar6[2],SUB41(piVar6[3],0),(float)piVar6[4]);
                    }
                    piVar7 = piVar6 + -2;
                    if ((local_44 < 1.0) &&
                       (piVar7 = piVar6 + -2, piVar6 = piVar6 + -2, piVar3 != local_24))
                    goto LAB_009a6990;
                  }
                  local_100 = local_100 + 1;
                  piVar6 = piVar7;
                  if (param_3 != (bool *)0x0) {
                    iVar5 = *piVar3;
                    *piVar7 = (int)piVar3;
                    pcVar1 = *(code **)(iVar5 + 0x5f4);
                    piVar7[-1] = 0x9a6ab6;
                    iVar5 = (*pcVar1)();
                    if (iVar5 != 0) {
                      *param_3 = true;
                    }
                  }
                }
              }
            }
          }
        }
      }
LAB_009a6990:
      iVar8 = iVar8 + 1;
    } while (iVar8 <= *(int *)(gpGlobals + 0x14));
  }
  return local_100;
}

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)