From 1e14a64efc14564624ff9a38cf0752f8592444a7 Mon Sep 17 00:00:00 2001 From: BenCat07 Date: Wed, 5 May 2021 17:39:25 +0200 Subject: [PATCH] Fix problems with targets going out of aimbot range with rapidfire --- include/hacks/Aimbot.hpp | 2 +- src/hacks/Aimbot.cpp | 17 ++++++++++------- src/hacks/Warp.cpp | 3 +++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/hacks/Aimbot.hpp b/include/hacks/Aimbot.hpp index d883f69b..d5acd835 100644 --- a/include/hacks/Aimbot.hpp +++ b/include/hacks/Aimbot.hpp @@ -15,7 +15,7 @@ class IClientEntity; namespace hacks::shared::aimbot { extern settings::Boolean ignore_cloak; - +extern unsigned last_target_ignore_timer; // Used to store aimbot data to prevent calculating it again struct AimbotCalculatedData_s { diff --git a/src/hacks/Aimbot.cpp b/src/hacks/Aimbot.cpp index c4c90610..3a5055b5 100644 --- a/src/hacks/Aimbot.cpp +++ b/src/hacks/Aimbot.cpp @@ -128,6 +128,9 @@ int CurrentX, CurrentY; float last_mouse_check = 0; float stop_moving_time = 0; +// Used to make rapidfire not knock your enemies out of range +unsigned last_target_ignore_timer = 0; + int GetSentry() { for (int i = 1; i <= HIGHEST_ENTITY; i++) @@ -420,7 +423,7 @@ bool MouseMoving() if (PreviousX != CurrentX || PreviousY != CurrentY) stop_moving_time = g_GlobalVars->curtime + 0.5; - + if (g_GlobalVars->curtime <= stop_moving_time) return true; else @@ -587,7 +590,7 @@ bool IsTargetStateGood(CachedEntity *entity) { if (g_pLocalPlayer->weapon_mode != weapon_melee) { - if (entity->m_flDistance() > EffectiveTargetingRange()) + if (entity->m_flDistance() > EffectiveTargetingRange() && tickcount > hacks::shared::aimbot::last_target_ignore_timer) return false; } else @@ -739,7 +742,7 @@ bool IsTargetStateGood(CachedEntity *entity) else if (!IsVectorVisible(pos, entity->hitboxes.GetHitbox(cd.hitbox)->center, false, ENTITY(sentry))) return false; } - if (fov > 0.0f && cd.fov > fov) + if (fov > 0.0f && cd.fov > fov && tickcount > hacks::shared::aimbot::last_target_ignore_timer) return false; return true; @@ -760,7 +763,7 @@ bool IsTargetStateGood(CachedEntity *entity) // Distance if (EffectiveTargetingRange()) { - if (entity->m_flDistance() > (int) EffectiveTargetingRange()) + if (entity->m_flDistance() > (int) EffectiveTargetingRange() && tickcount > hacks::shared::aimbot::last_target_ignore_timer) return false; } @@ -796,7 +799,7 @@ bool IsTargetStateGood(CachedEntity *entity) if (!IsVectorVisible(pos, GetBuildingPosition(entity), false, ENTITY(sentry))) return false; } - if (fov > 0.0f && cd.fov > fov) + if (fov > 0.0f && cd.fov > fov && tickcount > hacks::shared::aimbot::last_target_ignore_timer) return false; return true; @@ -819,7 +822,7 @@ bool IsTargetStateGood(CachedEntity *entity) // Distance if (EffectiveTargetingRange()) { - if (entity->m_flDistance() > (int) EffectiveTargetingRange()) + if (entity->m_flDistance() > (int) EffectiveTargetingRange() && tickcount > hacks::shared::aimbot::last_target_ignore_timer) return false; } @@ -828,7 +831,7 @@ bool IsTargetStateGood(CachedEntity *entity) if (!VischeckPredictedEntity(entity)) return false; - if (fov > 0.0f && cd.fov > fov) + if (fov > 0.0f && cd.fov > fov && tickcount > hacks::shared::aimbot::last_target_ignore_timer) return false; return true; } diff --git a/src/hacks/Warp.cpp b/src/hacks/Warp.cpp index 77394da4..594c652a 100644 --- a/src/hacks/Warp.cpp +++ b/src/hacks/Warp.cpp @@ -15,6 +15,7 @@ #include "WeaponData.hpp" #include "MiscTemporary.hpp" #include "Think.hpp" +#include "Aimbot.hpp" namespace hacks::tf2::warp { @@ -357,6 +358,8 @@ void Warp(float accumulated_extra_samples, bool finalTick) { choke_packet = false; packets_sent = -1; + if (i == calls - 1) + hacks::shared::aimbot::last_target_ignore_timer = tickcount + 5; } else hooked_methods::UpdatePred();