L L4D2node

CBasePlayer::FindUseEntity

0x00417060 · 4777 bytes · __cdecl

_ZN11CBasePlayer13FindUseEntityEfffPbb

Decompiled

undefined (5 params)

/* WARNING: Removing unreachable block (ram,0x00417309) */
/* WARNING: Removing unreachable block (ram,0x004172bc) */
/* WARNING: Removing unreachable block (ram,0x00418352) */
/* WARNING: Removing unreachable block (ram,0x0041834b) */
/* CBasePlayer::FindUseEntity(float, float, float, bool*, bool) */

CBaseEntity *
CBasePlayer::FindUseEntity(float param_1,float param_2,float param_3,bool *param_4,bool param_5)

{
  code *pcVar1;
  char cVar2;
  int iVar3;
  float *pfVar4;
  int iVar5;
  int *piVar6;
  char *pcVar7;
  undefined4 uVar8;
  CBaseEntity *pCVar9;
  matrix3x4_t *pmVar10;
  Vector *pVVar11;
  int iVar12;
  float fVar13;
  float fVar14;
  float fVar15;
  float local_a0c;
  CBaseEntity *local_a08;
  CBaseEntity *this;
  CBaseEntity *pCVar16;
  float local_9fc;
  float local_9f8;
  float local_9f4;
  Vector local_9f0 [12];
  float local_9e4;
  float local_9e0;
  float local_9dc;
  float local_9d8;
  float local_9d4;
  float local_9d0;
  float local_9cc;
  float local_9c8;
  float local_9c4;
  Vector local_9c0 [12];
  Vector local_9b4 [12];
  float local_9a8;
  float local_9a4;
  float local_9a0;
  CTraceFilterSimple local_99c [16];
  float local_98c;
  float local_988;
  float local_984;
  float local_97c;
  float local_978;
  float local_974;
  undefined4 local_96c;
  undefined4 local_968;
  undefined4 local_964;
  undefined4 local_95c;
  undefined4 local_958;
  undefined4 local_954;
  undefined4 local_94c;
  undefined1 local_948;
  undefined1 local_947;
  float local_934;
  float local_930;
  float local_928;
  float local_924;
  float local_920;
  CBaseEntity *local_8e8;
  CBaseTrace local_8e0 [12];
  float local_8d4;
  float local_8d0;
  float local_8cc;
  float local_88c;
  float local_888;
  float local_884;
  Vector local_880 [4];
  float local_87c;
  float local_878;
  float local_874;
  undefined4 local_86c;
  undefined4 local_868;
  undefined4 local_864;
  float local_860;
  undefined4 local_85c;
  undefined4 local_858;
  undefined4 local_854;
  undefined4 local_84c;
  undefined1 local_848;
  undefined1 local_847;
  CBaseEntity *local_840;
  float local_82c;
  float local_828;
  float local_824;
  Vector local_820 [4];
  float local_81c;
  float local_818;
  float local_814;
  undefined4 local_80c;
  undefined4 local_808;
  undefined4 local_804;
  undefined4 local_7fc;
  undefined4 local_7f8;
  undefined4 local_7f4;
  undefined4 local_7ec;
  undefined1 local_7e8;
  undefined1 local_7e7;
  CBaseEntity *local_7e0;
  
  if ((float)param_4 <= 0.0) {
    param_4 = *(bool **)(ZombieUseTolerance._28_4_ + 0x2c);
  }
  EyeVectors((CBasePlayer *)param_1,(Vector *)&local_9fc,(Vector *)0x0,local_9f0);
  (**(code **)(*(int *)param_1 + 0x234))(&local_9e4,param_1);
  local_7e8 = 1;
  local_81c = local_9fc * 1024.0;
  local_818 = local_9f8 * 1024.0;
  local_814 = local_9f4 * 1024.0;
  local_7f4 = 0;
  local_7f8 = 0;
  local_7fc = 0;
  local_7ec = 0;
  local_804 = 0;
  local_808 = 0;
  local_80c = 0;
  local_7e7 = local_818 * local_818 + local_81c * local_81c + local_814 * local_814 != 0.0;
  local_82c = local_9e4;
  local_828 = local_9e0;
  local_824 = local_9dc;
  CTraceFilterSimple::CTraceFilterSimple
            ((CTraceFilterSimple *)&local_88c,(IHandleEntity *)param_1,0,
             (_func_bool_IHandleEntity_ptr_int *)0x0);
  (**(code **)(*enginetrace + 0x14))
            (enginetrace,(CEntitySphereQuery *)&local_82c,0x200608b,&local_88c,(Vector *)&local_934)
  ;
  if (*(int *)(r_visualizetraces._28_4_ + 0x30) != 0) {
    DebugDrawLine((Vector *)&local_934,(Vector *)&local_928,0xff,0,0,true,-1.0);
  }
  local_a08 = local_8e8;
  cVar2 = (**(code **)(*(int *)param_1 + 0x6e4))(param_1,local_8e8,0);
  if (cVar2 != '\0') {
    iVar5 = (int)param_1 + 0x194;
    if ((AllocTempVector()::s_vecTemp == '\0') &&
       (iVar3 = __cxa_guard_acquire(&AllocTempVector()::s_vecTemp), iVar3 != 0)) {
      __cxa_guard_release(&AllocTempVector()::s_vecTemp);
    }
    if ((AllocTempVector()::s_nIndex == '\0') &&
       (iVar3 = __cxa_guard_acquire(&AllocTempVector()::s_nIndex), iVar3 != 0)) {
      AllocTempVector()::s_nIndex = 0;
      __cxa_guard_release(&AllocTempVector()::s_nIndex);
    }
    AllocTempVector()::s_nIndex = AllocTempVector()::s_nIndex + 0x10001 & 0x7f;
    LOCK();
    UNLOCK();
    iVar3 = AllocTempVector()::s_nIndex * 0xc;
    if ((AllocTempVector()::s_vecTemp == '\0') &&
       (iVar12 = __cxa_guard_acquire(&AllocTempVector()::s_vecTemp), iVar12 != 0)) {
      __cxa_guard_release(&AllocTempVector()::s_vecTemp);
    }
    if ((AllocTempVector()::s_nIndex == '\0') &&
       (iVar12 = __cxa_guard_acquire(&AllocTempVector()::s_nIndex), iVar12 != 0)) {
      AllocTempVector()::s_nIndex = 0;
      __cxa_guard_release(&AllocTempVector()::s_nIndex);
    }
    AllocTempVector()::s_nIndex = AllocTempVector()::s_nIndex + 0x10001 & 0x7f;
    LOCK();
    UNLOCK();
    iVar12 = AllocTempVector()::s_nIndex * 0xc;
    *(float *)(AllocTempVector()::s_vecTemp + iVar12) =
         (*(float *)((int)param_1 + 0x1a8) - *(float *)((int)param_1 + 0x19c)) * 0.5 +
         *(float *)((int)param_1 + 0x19c);
    *(float *)(AllocTempVector()::s_vecTemp + iVar12 + 4) =
         (*(float *)((int)param_1 + 0x1ac) - *(float *)((int)param_1 + 0x1a0)) * 0.5 +
         *(float *)((int)param_1 + 0x1a0);
    *(float *)(AllocTempVector()::s_vecTemp + iVar12 + 8) =
         (*(float *)((int)param_1 + 0x1b0) - *(float *)((int)param_1 + 0x1a4)) * 0.5 +
         *(float *)((int)param_1 + 0x1a4);
    if ((((*(byte *)((int)param_1 + 0x1b4) & 0x40) == 0) &&
        ((*(byte *)((int)param_1 + 0x1b6) & 0xfd) != 0)) &&
       ((pfVar4 = (float *)(**(code **)(*(int *)((int)param_1 + 0x194) + 0x24))(iVar5),
        vec3_angle != *pfVar4 || ((DAT_01053d40 != pfVar4[1] || (DAT_01053d44 != pfVar4[2])))))) {
      pmVar10 = (matrix3x4_t *)(**(code **)(*(int *)((int)param_1 + 0x194) + 0x28))(iVar5);
      VectorTransform((float *)(AllocTempVector()::s_vecTemp + iVar12),pmVar10,
                      (float *)(AllocTempVector()::s_vecTemp + iVar3));
      fVar13 = *(float *)(AllocTempVector()::s_vecTemp + iVar3 + 8);
    }
    else {
      pfVar4 = (float *)(**(code **)(*(int *)((int)param_1 + 0x194) + 0x20))(iVar5);
      *(float *)(AllocTempVector()::s_vecTemp + iVar3) =
           *pfVar4 + *(float *)(AllocTempVector()::s_vecTemp + iVar12);
      *(float *)(AllocTempVector()::s_vecTemp + iVar3 + 4) =
           pfVar4[1] + *(float *)(AllocTempVector()::s_vecTemp + iVar12 + 4);
      fVar13 = pfVar4[2] + *(float *)(AllocTempVector()::s_vecTemp + iVar12 + 8);
      *(float *)(AllocTempVector()::s_vecTemp + iVar3 + 8) = fVar13;
    }
    iVar3 = (**(code **)(*(int *)((int)param_1 + 0x194) + 8))(iVar5);
    fVar14 = fVar13 + *(float *)(iVar3 + 8);
    iVar5 = (**(code **)(*(int *)((int)param_1 + 0x194) + 4))(iVar5);
    fVar13 = fVar13 + *(float *)(iVar5 + 8);
    fVar15 = fVar14;
    if (fVar13 <= fVar14) {
      fVar15 = fVar13;
      fVar13 = fVar14;
    }
    if (fVar15 <= local_920) {
      if (local_920 <= fVar13) {
        fVar13 = 0.0;
      }
      else {
        fVar13 = (local_920 - fVar13) * (local_920 - fVar13);
      }
    }
    else {
      fVar13 = (fVar15 - local_920) * (fVar15 - local_920);
    }
    if (SQRT((local_924 - local_930) * (local_924 - local_930) +
             (local_928 - local_934) * (local_928 - local_934) + fVar13) < param_2) {
      if (*(int *)(sv_debug_player_use._28_4_ + 0x30) != 0) {
        NDebugOverlay::Line((Vector *)&local_9e4,(Vector *)&local_928,0,0xff,0,true,30.0);
        NDebugOverlay::Cross3D((Vector *)&local_928,16.0,0,0xff,0,true,30.0);
      }
      iVar5 = CBaseEntity::MyNPCPointer();
      if (iVar5 != 0) {
        piVar6 = (int *)CBaseEntity::MyNPCPointer();
        cVar2 = (**(code **)(*piVar6 + 0x6e8))(piVar6,param_1);
        if (cVar2 != '\0') {
          local_a08 = (CBaseEntity *)
                      DoubleCheckUseNPC((CBasePlayer *)param_1,local_8e8,(Vector *)&local_9e4,
                                        (Vector *)&local_9fc);
        }
      }
      if (*(int *)(sv_debug_player_use._28_4_ + 0x30) == 0) {
        return local_a08;
      }
      pcVar7 = "no usable entity found";
      if (local_a08 != (CBaseEntity *)0x0) {
        pcVar7 = (char *)CBaseEntity::GetDebugName(local_a08);
      }
      Msg("Trace using: %s\n",pcVar7);
      return local_a08;
    }
  }
  iVar5 = CBaseEntity::GetGroundEntity((CBaseEntity *)param_1);
  if (iVar5 == 0) {
LAB_004175a5:
    local_a0c = 0.0;
    this = (CBaseEntity *)0x0;
  }
  else {
    pcVar1 = *(code **)(*(int *)param_1 + 0x6e4);
    uVar8 = CBaseEntity::GetGroundEntity((CBaseEntity *)param_1);
    cVar2 = (*pcVar1)(param_1,uVar8,0x100);
    if (cVar2 == '\0') goto LAB_004175a5;
    this = (CBaseEntity *)CBaseEntity::GetGroundEntity((CBaseEntity *)param_1);
    local_a0c = 0.707;
  }
  CEntitySphereQuery::CEntitySphereQuery
            ((CEntitySphereQuery *)&local_82c,(Vector *)&local_9e4,param_2,0);
  while (pCVar9 = (CBaseEntity *)
                  CEntitySphereQuery::GetCurrentEntity((CEntitySphereQuery *)&local_82c),
        pCVar9 != (CBaseEntity *)0x0) {
    fVar13 = local_a0c;
    pCVar16 = this;
    if (((CBaseEntity *)param_1 != pCVar9) &&
       (cVar2 = (**(code **)(*(int *)param_1 + 0x6e4))(param_1,pCVar9,0x200), cVar2 != '\0')) {
      CCollisionProperty::CollisionAABBToWorldAABB
                ((CCollisionProperty *)(pCVar9 + 0x194),(Vector *)(pCVar9 + 0x19c),
                 (Vector *)(pCVar9 + 0x1a8),local_9c0,local_9b4);
      local_88c = param_2 * local_9fc;
      local_888 = param_2 * local_9f8;
      local_884 = param_2 * local_9f4;
      cVar2 = IntersectRayWithBox((Vector *)&local_9e4,(Vector *)&local_88c,local_9c0,local_9b4,1.0,
                                  local_8e0,(float *)0x0);
      if (cVar2 == '\0') {
        local_9d4 = local_9f8 * 0.5 * param_2 + local_9e0;
        local_9d0 = local_9f4 * 0.5 * param_2 + local_9dc;
        local_9d8 = local_9fc * 0.5 * param_2 + local_9e4;
      }
      else {
        local_9d8 = local_8d4;
        local_9d4 = local_8d0;
        local_9d0 = local_8cc;
      }
      CCollisionProperty::CalcNearestPoint
                ((CCollisionProperty *)(pCVar9 + 0x194),(Vector *)&local_9d8,(Vector *)&local_9cc);
      if (*(int *)(sv_debug_player_use._28_4_ + 0x30) != 0) {
        NDebugOverlay::Cross3D((Vector *)&local_9d8,5.0,0,0xff,0,true,0.1);
        NDebugOverlay::Cross3D((Vector *)&local_9cc,5.0,0,0,0xff,true,0.1);
      }
      local_9a8 = local_9cc - local_9e4;
      local_9a4 = local_9c8 - local_9e0;
      local_9a0 = local_9c4 - local_9dc;
      VectorNormalize((Vector *)&local_9a8);
      fVar15 = local_9f8 * local_9a4 + local_9fc * local_9a8 + local_9f4 * local_9a0;
      if (((float)param_4 <= fVar15) && (local_a0c < fVar15)) {
        local_97c = local_9cc - local_9e4;
        local_978 = local_9c8 - local_9e0;
        local_98c = local_9e4;
        local_988 = local_9e0;
        local_974 = local_9c4 - local_9dc;
        local_984 = local_9dc;
        local_954 = 0;
        local_958 = 0;
        local_95c = 0;
        local_94c = 0;
        local_948 = 1;
        local_964 = 0;
        local_968 = 0;
        local_96c = 0;
        local_947 = local_978 * local_978 + local_97c * local_97c + local_974 * local_974 != 0.0;
        CTraceFilterSimple::CTraceFilterSimple
                  (local_99c,(IHandleEntity *)param_1,0,(_func_bool_IHandleEntity_ptr_int *)0x0);
        (**(code **)(*enginetrace + 0x14))(enginetrace,&local_98c,0x200608b,local_99c,&local_88c);
        if (*(int *)(r_visualizetraces._28_4_ + 0x30) != 0) {
          DebugDrawLine((Vector *)&local_88c,local_880,0xff,0,0,true,-1.0);
        }
        fVar13 = fVar15;
        pCVar16 = pCVar9;
        if ((local_860 != 1.0) && (pCVar9 != local_840)) {
          pfVar4 = (float *)(**(code **)(*(int *)pCVar9 + 0x288))(pCVar9);
          local_97c = *pfVar4 - local_9e4;
          local_978 = pfVar4[1] - local_9e0;
          local_974 = pfVar4[2] - local_9dc;
          local_98c = local_9e4;
          local_988 = local_9e0;
          local_984 = local_9dc;
          local_954 = 0;
          local_958 = 0;
          local_95c = 0;
          local_94c = 0;
          local_948 = 1;
          local_964 = 0;
          local_968 = 0;
          local_96c = 0;
          local_947 = local_978 * local_978 + local_974 * local_974 + local_97c * local_97c != 0.0;
          CTraceFilterSimple::CTraceFilterSimple
                    (local_99c,(IHandleEntity *)param_1,0,(_func_bool_IHandleEntity_ptr_int *)0x0);
          (**(code **)(*enginetrace + 0x14))(enginetrace,&local_98c,0x200608b,local_99c,&local_88c);
          if (*(int *)(r_visualizetraces._28_4_ + 0x30) != 0) {
            DebugDrawLine((Vector *)&local_88c,local_880,0xff,0,0,true,-1.0);
          }
          if ((local_860 != 1.0) && (pCVar9 != local_840)) {
            fVar13 = local_a0c;
            pCVar16 = this;
          }
        }
      }
    }
    local_a0c = fVar13;
    local_82c = (float)((int)local_82c + 1);
    this = pCVar16;
  }
  if (this == (CBaseEntity *)0x0) {
    local_87c = param_2 * local_9fc;
    local_878 = param_2 * local_9f8;
    local_854 = 0;
    local_874 = param_2 * local_9f4;
    local_858 = 0;
    local_85c = 0;
    local_84c = 0;
    local_848 = 1;
    local_864 = 0;
    local_868 = 0;
    local_86c = 0;
    local_847 = local_878 * local_878 + local_87c * local_87c + local_874 * local_874 != 0.0;
    local_88c = local_9e4;
    local_888 = local_9e0;
    local_884 = local_9dc;
    CTraceFilterSimple::CTraceFilterSimple
              ((CTraceFilterSimple *)local_8e0,(IHandleEntity *)param_1,0,
               (_func_bool_IHandleEntity_ptr_int *)0x0);
    (**(code **)(*enginetrace + 0x14))
              (enginetrace,&local_88c,0x2004081,(CTraceFilterSimple *)local_8e0,
               (CEntitySphereQuery *)&local_82c);
    if (*(int *)(r_visualizetraces._28_4_ + 0x30) != 0) {
      DebugDrawLine((Vector *)&local_82c,local_820,0xff,0,0,true,-1.0);
    }
    if (((local_7e0 != (CBaseEntity *)0x0) &&
        (cVar2 = (**(code **)(*(int *)param_1 + 0x6e4))(param_1,local_7e0,0), cVar2 != '\0')) &&
       (iVar5 = CBaseEntity::MyNPCPointer(), iVar5 != 0)) {
      piVar6 = (int *)CBaseEntity::MyNPCPointer();
      cVar2 = (**(code **)(*piVar6 + 0x6e8))(piVar6,param_1);
      if (cVar2 != '\0') {
        this = local_7e0;
        if (local_7e0 != (CBaseEntity *)0x0) goto LAB_00417c6e;
        goto LAB_00417c9f;
      }
    }
    this = (CBaseEntity *)0x0;
  }
  else {
LAB_00417c6e:
    iVar5 = CBaseEntity::MyNPCPointer();
    if (iVar5 != 0) {
      piVar6 = (int *)CBaseEntity::MyNPCPointer();
      cVar2 = (**(code **)(*piVar6 + 0x6e8))(piVar6,param_1);
      if (cVar2 != '\0') {
        this = (CBaseEntity *)
               DoubleCheckUseNPC((CBasePlayer *)param_1,this,(Vector *)&local_9e4,
                                 (Vector *)&local_9fc);
      }
    }
  }
LAB_00417c9f:
  if (*(int *)(sv_debug_player_use._28_4_ + 0x30) != 0) {
    if (this == (CBaseEntity *)0x0) {
      NDebugOverlay::Line((Vector *)&local_9e4,(Vector *)&local_928,0xff,0,0,true,30.0);
      NDebugOverlay::Cross3D((Vector *)&local_928,16.0,0xff,0,0,true,30.0);
      if (*(int *)(sv_debug_player_use._28_4_ + 0x30) != 0) {
        pcVar7 = "no usable entity found";
        goto LAB_00417d78;
      }
    }
    else {
      if (this == local_8e8) {
        NDebugOverlay::Line((Vector *)&local_9e4,(Vector *)&local_928,0,0xff,0,true,30.0);
        NDebugOverlay::Cross3D((Vector *)&local_928,16.0,0,0xff,0,true,30.0);
      }
      else {
        local_82c = 8.0;
        local_828 = 8.0;
        local_824 = 8.0;
        local_88c = -8.0;
        local_888 = -8.0;
        local_884 = -8.0;
        pVVar11 = (Vector *)(**(code **)(*(int *)this + 0x288))(this);
        NDebugOverlay::Box(pVVar11,(Vector *)&local_88c,(Vector *)&local_82c,0,0xff,0,1,30.0);
      }
      if (*(int *)(sv_debug_player_use._28_4_ + 0x30) != 0) {
        pcVar7 = (char *)CBaseEntity::GetDebugName(this);
LAB_00417d78:
        Msg("Radial using: %s\n",pcVar7);
        return this;
      }
    }
  }
  return this;
}

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)