diff --git a/apex_dma/Game.cpp b/apex_dma/Game.cpp index 4ba9e68..7934c81 100644 --- a/apex_dma/Game.cpp +++ b/apex_dma/Game.cpp @@ -7,17 +7,24 @@ float smooth = 12.0f; bool aim_no_recoil = true; int bone = 2; -bool Entity::Observing(uint64_t entitylist) +// https://github.com/Gerosity/zap-client/blob/master/Core/Player.hpp#L161 +bool Entity::Observing(uint64_t localptr) { - /*uint64_t index = *(uint64_t*)(buffer + OFFSET_OBSERVING_TARGET); - index &= ENT_ENTRY_MASK; - if (index > 0) - { - uint64_t centity2 = apex_mem.Read(entitylist + ((uint64_t)index << 5)); - return centity2; - } - return 0;*/ - return *(bool*)(buffer + OFFSET_OBSERVER_MODE); + uint64_t SpectatorList; + apex_mem.Read(apex_mem.get_proc_baseaddr() + OFFSET_OBSERVER_LIST, SpectatorList); + + int PlayerData; + apex_mem.Read(ptr + 0x38, PlayerData); + + int SpecIndex; + apex_mem.Read(SpectatorList + PlayerData * 8 + 0x964, SpecIndex); + + uint64_t SpectatorAddr; + apex_mem.Read(apex_mem.get_proc_baseaddr() + OFFSET_ENTITYLIST + ((SpecIndex & 0xFFFF) << 5), SpectatorAddr); + + if (SpectatorAddr == localptr) + return true; + return false; } //https://github.com/CasualX/apexbot/blob/master/src/state.cpp#L104 diff --git a/apex_dma/Game.h b/apex_dma/Game.h index 7b3c4bc..6593083 100644 --- a/apex_dma/Game.h +++ b/apex_dma/Game.h @@ -45,7 +45,7 @@ public: void SetViewAngles(QAngle& angles); Vector getBonePosition(int id); Vector getBonePositionByHitbox(int id); - bool Observing(uint64_t entitylist); + bool Observing(uint64_t local); void get_name(uint64_t g_Base, uint64_t index, char* name); }; diff --git a/apex_dma/apex_dma.cpp b/apex_dma/apex_dma.cpp index 4f772ab..65d6ef2 100644 --- a/apex_dma/apex_dma.cpp +++ b/apex_dma/apex_dma.cpp @@ -81,12 +81,9 @@ void ProcessPlayer(Entity& LPlayer, Entity& target, uint64_t entitylist, int ind if (!target.isAlive()) { - float localyaw = LPlayer.GetYaw(); - float targetyaw = target.GetYaw(); - - if(localyaw==targetyaw) + if(target.Observing(LPlayer.ptr)) { - if(LPlayer.getTeamId() == entity_team) + if (LPlayer.getTeamId() == entity_team) tmp_all_spec++; else tmp_spec++; @@ -141,7 +138,6 @@ void DoActions() std::this_thread::sleep_for(std::chrono::milliseconds(1)); bool tmp_thirdperson = false; bool tmp_chargerifle = false; - uint32_t counter = 0; while (g_Base!=0 && c_Base!=0) { @@ -254,22 +250,8 @@ void DoActions() } } - if(!spectators && !allied_spectators) - { - spectators = tmp_spec; - allied_spectators = tmp_all_spec; - } - else - { - //refresh spectators count every ~2 seconds - counter++; - if(counter==70) - { - spectators = tmp_spec; - allied_spectators = tmp_all_spec; - counter = 0; - } - } + spectators = tmp_spec; + allied_spectators = tmp_all_spec; if(!lock) aimentity = tmp_aimentity; diff --git a/apex_dma/offsets.h b/apex_dma/offsets.h index 192e473..5b5f4da 100644 --- a/apex_dma/offsets.h +++ b/apex_dma/offsets.h @@ -34,6 +34,7 @@ #define OFFSET_BREATH_ANGLES OFFSET_VIEWANGLES - 0x10 #define OFFSET_OBSERVER_MODE 0x34a4 //m_iObserverMode #define OFFSET_OBSERVING_TARGET 0x34b0 //m_hObserverTarget + #define OFFSET_OBSERVER_LIST 0x1EADD28 #define OFFSET_MATRIX 0x11a350 #define OFFSET_RENDER 0x74dd028