From 21a23d732d03fe6acefdbd74fe921a5b550ba87b Mon Sep 17 00:00:00 2001
From: TotallyNotElite <1yourexperiment@protonmail.com>
Date: Sat, 10 Oct 2020 17:56:44 +0200
Subject: [PATCH] Feat: Add autoheal.look-at-path, fix some bad code, create a
unified DoSlowAim
---
data/menu/nullifiedcat/trigger/autoheal.xml | 3 +-
include/MiscTemporary.hpp | 5 --
include/hacks/Aimbot.hpp | 6 --
include/hacks/MiscAimbot.hpp | 4 +-
include/hacks/NavBot.hpp | 4 +-
src/MiscTemporary.cpp | 1 -
src/hacks/Aimbot.cpp | 36 ++++-------
src/hacks/AutoHeal.cpp | 17 ++++--
src/hacks/MiscAimbot.cpp | 6 +-
src/hacks/NavBot.cpp | 4 +-
src/navparser.cpp | 66 ++-------------------
11 files changed, 39 insertions(+), 113 deletions(-)
diff --git a/data/menu/nullifiedcat/trigger/autoheal.xml b/data/menu/nullifiedcat/trigger/autoheal.xml
index 6299ea8f..851ac1b0 100755
--- a/data/menu/nullifiedcat/trigger/autoheal.xml
+++ b/data/menu/nullifiedcat/trigger/autoheal.xml
@@ -3,6 +3,7 @@
+
@@ -12,7 +13,7 @@
-
+
diff --git a/include/MiscTemporary.hpp b/include/MiscTemporary.hpp
index 4bca6a02..a27497ad 100755
--- a/include/MiscTemporary.hpp
+++ b/include/MiscTemporary.hpp
@@ -18,7 +18,6 @@ extern std::array bruteint;
extern std::array timers;
extern Timer DelayTimer;
-extern Timer LookAtPathTimer;
extern bool firstcm;
extern bool ignoredc;
@@ -49,10 +48,6 @@ extern bool freecam_is_toggled;
typedef void (*CL_SendMove_t)();
extern DetourHook cl_warp_sendmovedetour;
extern DetourHook cl_nospread_sendmovedetour;
-namespace hacks::tf2::misc_aimbot
-{
-bool ShouldHitBuilding(CachedEntity *ent);
-}
namespace hooked_methods
{
void sendAchievementKv(int value);
diff --git a/include/hacks/Aimbot.hpp b/include/hacks/Aimbot.hpp
index b9b0a961..a4042885 100644
--- a/include/hacks/Aimbot.hpp
+++ b/include/hacks/Aimbot.hpp
@@ -32,12 +32,6 @@ const Vector &PredictEntity(CachedEntity *entity);
bool VischeckPredictedEntity(CachedEntity *entity);
bool BacktrackVisCheck(CachedEntity *entity);
-// Variable used to tell when the aimbot has found a target
-extern bool foundTarget;
-
-// Used by esp to set their color
-extern int target_eid;
-
// Functions called by other functions for when certian game calls are run
void Reset();
diff --git a/include/hacks/MiscAimbot.hpp b/include/hacks/MiscAimbot.hpp
index 6ebc2931..bbefd62c 100644
--- a/include/hacks/MiscAimbot.hpp
+++ b/include/hacks/MiscAimbot.hpp
@@ -3,4 +3,6 @@
namespace hacks::tf2::misc_aimbot
{
std::pair FindBestEnt(bool teammate, bool Predict, bool zcheck, bool fov_check, float range = 1500.0f);
-}
+void DoSlowAim(Vector &input_angle, int speed = 5);
+bool ShouldHitBuilding(CachedEntity *ent);
+} // namespace hacks::tf2::misc_aimbot
diff --git a/include/hacks/NavBot.hpp b/include/hacks/NavBot.hpp
index dfdb140d..ea9d1b7b 100644
--- a/include/hacks/NavBot.hpp
+++ b/include/hacks/NavBot.hpp
@@ -1,6 +1,8 @@
#pragma once
-#include "common.hpp"
+#include
+#include
+
namespace hacks::tf2::NavBot
{
bool init(bool first_cm);
diff --git a/src/MiscTemporary.cpp b/src/MiscTemporary.cpp
index bfbf71a5..72ae3785 100755
--- a/src/MiscTemporary.cpp
+++ b/src/MiscTemporary.cpp
@@ -14,7 +14,6 @@ int spectator_target;
CLC_VoiceData *voicecrash{};
bool firstcm = false;
Timer DelayTimer{};
-Timer LookAtPathTimer{};
float prevflow = 0.0f;
int prevflowticks = 0;
int stored_buttons = 0;
diff --git a/src/hacks/Aimbot.cpp b/src/hacks/Aimbot.cpp
index 7d866e4e..861c1d43 100644
--- a/src/hacks/Aimbot.cpp
+++ b/src/hacks/Aimbot.cpp
@@ -218,10 +218,7 @@ static void doAutoZoom(bool target_found)
}
// Current Entity
-int target_eid{ 0 };
-CachedEntity *target = 0;
CachedEntity *target_last = 0;
-bool foundTarget = false;
// If slow aimbot allows autoshoot
bool slow_can_shoot = false;
@@ -233,17 +230,20 @@ AimbotCalculatedData_s calculated_data_array[2048]{};
// The main "loop" of the aimbot.
static void CreateMove()
{
- if (CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer() || CE_BAD(LOCAL_W))
- return;
-
enable = *normal_enable;
slow_aim = *normal_slow_aim;
fov = *normal_fov;
+ if (CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer() || CE_BAD(LOCAL_W))
+ enable = false;
+
spectatorUpdate();
if (!enable)
+ {
+ target_last = nullptr;
return;
+ }
doAutoZoom(false);
@@ -276,7 +276,8 @@ static void CreateMove()
}
// Refresh our best target
CachedEntity *target_entity = RetrieveBestTarget(aimkey_status);
- if (CE_BAD(target_entity) || !foundTarget)
+ target_last = target_entity;
+ if (CE_BAD(target_entity))
return;
// Auto-zoom
@@ -304,7 +305,6 @@ static void CreateMove()
// Attemt to auto-shoot
// flNextPrimaryAttack meme
- // target_eid = target_entity->m_IDX;
if (only_can_shoot && g_pLocalPlayer->weapon()->m_iClassID() != CL_CLASS(CTFMinigun) && g_pLocalPlayer->weapon()->m_iClassID() != CL_CLASS(CTFLaserPointer))
{
// Handle Compound bow
@@ -497,7 +497,7 @@ CachedEntity *RetrieveBestTarget(bool aimkey_state)
{
// If we have a previously chosen target, target lock is on, and the aimkey
// is allowed, then attemt to keep the previous target
- if (target_lock && foundTarget && aimkey_state)
+ if (target_lock && target_last && aimkey_state)
{
if (CE_GOOD(target_last))
{
@@ -510,11 +510,6 @@ CachedEntity *RetrieveBestTarget(bool aimkey_state)
}
}
- // We dont have a target currently so we must find one, reset statuses
- foundTarget = false;
- target_last = nullptr;
- target_eid = -1;
-
float target_highest_score, scr = 0.0f;
CachedEntity *ent;
CachedEntity *target_highest_ent = 0;
@@ -556,19 +551,12 @@ CachedEntity *RetrieveBestTarget(bool aimkey_state)
// Compare the top score to our current ents score
if (scr > target_highest_score)
{
- foundTarget = true;
target_highest_score = scr;
target_highest_ent = ent;
}
}
}
- // Save the ent for future use with target lock
- target_last = target_highest_ent;
-
- if (CE_GOOD(target_last))
- target_eid = target_last->m_IDX;
-
return target_highest_ent;
}
@@ -1368,7 +1356,6 @@ static float slow_change_dist_y = 0;
// angle, effectively slowing the aiming process
void DoSlowAim(Vector &input_angle)
{
- LookAtPathTimer.update();
auto viewangles = current_user_cmd->viewangles;
// Yaw
@@ -1479,10 +1466,7 @@ float EffectiveTargetingRange()
// A function used by gui elements to determine the current target
CachedEntity *CurrentTarget()
{
- if (foundTarget)
- return target; // Doesnt work for some reason
-
- return nullptr;
+ return target_last;
}
// Used for when you join and leave maps to reset aimbot vars
diff --git a/src/hacks/AutoHeal.cpp b/src/hacks/AutoHeal.cpp
index 02b87abc..f1e0a86c 100644
--- a/src/hacks/AutoHeal.cpp
+++ b/src/hacks/AutoHeal.cpp
@@ -9,6 +9,7 @@
#include "hacks/FollowBot.hpp"
#include "settings/Bool.hpp"
#include "PlayerTools.hpp"
+#include "MiscAimbot.hpp"
namespace hacks::tf::autoheal
{
@@ -16,6 +17,7 @@ std::vector called_medic{};
static settings::Boolean enable{ "autoheal.enable", "false" };
static settings::Boolean steamid_only{ "autoheal.steam-only", "false" };
static settings::Boolean silent{ "autoheal.silent", "true" };
+static settings::Boolean look_at_target{ "autoheal.look-at-target", "false" };
static settings::Boolean friendsonly{ "autoheal.friends-only", "false" };
static settings::Boolean pop_uber_auto{ "autoheal.uber.enable", "true" };
static settings::Boolean pop_uber_voice{ "autoheal.popvoice", "true" };
@@ -661,17 +663,24 @@ void CreateMove()
if (!CurrentHealingTargetIDX)
return;
- CachedEntity *target = ENTITY(CurrentHealingTargetIDX);
+ CachedEntity *target = ENTITY(CurrentHealingTargetIDX);
+ bool target_is_healing_target = HandleToIDX(CE_INT(LOCAL_W, netvar.m_hHealingTarget)) == CurrentHealingTargetIDX;
- if (HandleToIDX(CE_INT(LOCAL_W, netvar.m_hHealingTarget)) != CurrentHealingTargetIDX)
+ if (!target_is_healing_target || look_at_target)
{
auto out = target->hitboxes.GetHitbox(spine_2);
if (out)
{
if (silent)
g_pLocalPlayer->bUseSilentAngles = true;
- AimAt(g_pLocalPlayer->v_Eye, out->center, current_user_cmd);
- if ((g_GlobalVars->tickcount % 2) == 0)
+ auto angles = GetAimAtAngles(g_pLocalPlayer->v_Eye, out->center);
+
+ // If we are already healing our target, then follow the target using slowaim
+ if (target_is_healing_target)
+ hacks::tf2::misc_aimbot::DoSlowAim(angles);
+
+ current_user_cmd->viewangles = angles;
+ if (!target_is_healing_target && (g_GlobalVars->tickcount % 2) == 0)
current_user_cmd->buttons |= IN_ATTACK;
}
}
diff --git a/src/hacks/MiscAimbot.cpp b/src/hacks/MiscAimbot.cpp
index aee624e5..9a978a32 100644
--- a/src/hacks/MiscAimbot.cpp
+++ b/src/hacks/MiscAimbot.cpp
@@ -149,7 +149,7 @@ std::pair FindBestEnt(bool teammate, bool Predict, bool
}
static float slow_change_dist_y{};
static float slow_change_dist_p{};
-void DoSlowAim(Vector &input_angle)
+void DoSlowAim(Vector &input_angle, int speed)
{
auto viewangles = current_user_cmd->viewangles;
@@ -179,7 +179,7 @@ void DoSlowAim(Vector &input_angle)
// opposing sides making the distance spike, so just cheap out and reuse
// our last one.
if (!slow_opposing)
- slow_change_dist_y = fminf(std::abs(viewangles.y - input_angle.y), flChargeYawCap);
+ slow_change_dist_y = std::abs(viewangles.y - input_angle.y) / (int) speed;
// Move in the direction of the input angle
if (slow_dir)
@@ -192,7 +192,7 @@ void DoSlowAim(Vector &input_angle)
if (viewangles.x != input_angle.x)
{
// Get speed
- slow_change_dist_p = std::abs(viewangles.x - input_angle.x) / 5;
+ slow_change_dist_p = std::abs(viewangles.x - input_angle.x) / speed;
// Move in the direction of the input angle
if (viewangles.x > input_angle.x)
diff --git a/src/hacks/NavBot.cpp b/src/hacks/NavBot.cpp
index ab69917a..4fc0ee0d 100644
--- a/src/hacks/NavBot.cpp
+++ b/src/hacks/NavBot.cpp
@@ -3,11 +3,9 @@
#include "NavBot.hpp"
#include "PlayerTools.hpp"
#include "Aimbot.hpp"
-#include "FollowBot.hpp"
-#include "soundcache.hpp"
#include "Misc.hpp"
-#include "MiscTemporary.hpp"
#include "teamroundtimer.hpp"
+#include "MiscAimbot.hpp"
namespace hacks::tf2::NavBot
{
diff --git a/src/navparser.cpp b/src/navparser.cpp
index 4caa251a..4d467915 100644
--- a/src/navparser.cpp
+++ b/src/navparser.cpp
@@ -6,9 +6,9 @@
#include
#include
#include
-#include "soundcache.hpp"
-#include "MiscTemporary.hpp"
#include
+#include "MiscAimbot.hpp"
+#include "Aimbot.hpp"
namespace nav
{
@@ -48,7 +48,6 @@ enum ignore_status : uint8_t
void ResetPather();
void repath();
-void DoSlowAim(Vector &input_angle);
struct ignoredata
{
@@ -728,11 +727,11 @@ static void cm()
crumb_vec = &endPoint;
}
}
- if (look && LookAtPathTimer.check(1000))
+ if (look && !hacks::shared::aimbot::CurrentTarget())
{
Vector next{ crumb_vec->x, crumb_vec->y, g_pLocalPlayer->v_Eye.z };
next = GetAimAtAngles(g_pLocalPlayer->v_Eye, next);
- DoSlowAim(next);
+ hacks::tf2::misc_aimbot::DoSlowAim(next);
current_user_cmd->viewangles = next;
}
// Detect when jumping is necessary
@@ -852,63 +851,6 @@ static CatCommand nav_path_no_local("nav_path_no_local", "Debug nav path", []()
static CatCommand nav_reset_ignores("nav_reset_ignores", "Reset all ignores.", []() { ignoremanager::reset(); });
-void DoSlowAim(Vector &input_angle)
-{
- static float slow_change_dist_y{};
- static float slow_change_dist_p{};
-
- auto viewangles = current_user_cmd->viewangles;
-
- // Yaw
- if (viewangles.y != input_angle.y)
- {
-
- // Check if input angle and user angle are on opposing sides of yaw so
- // we can correct for that
- bool slow_opposing = false;
- if ((input_angle.y < -90 && viewangles.y > 90) || (input_angle.y > 90 && viewangles.y < -90))
- slow_opposing = true;
-
- // Direction
- bool slow_dir = false;
- if (slow_opposing)
- {
- if (input_angle.y > 90 && viewangles.y < -90)
- slow_dir = true;
- }
- else if (viewangles.y > input_angle.y)
- slow_dir = true;
-
- // Speed, check if opposing. We dont get a new distance due to the
- // opposing sides making the distance spike, so just cheap out and reuse
- // our last one.
- if (!slow_opposing)
- slow_change_dist_y = std::abs(viewangles.y - input_angle.y) / 5;
-
- // Move in the direction of the input angle
- if (slow_dir)
- input_angle.y = viewangles.y - slow_change_dist_y;
- else
- input_angle.y = viewangles.y + slow_change_dist_y;
- }
-
- // Pitch
- if (viewangles.x != input_angle.x)
- {
- // Get speed
- slow_change_dist_p = std::abs(viewangles.x - input_angle.x) / 5;
-
- // Move in the direction of the input angle
- if (viewangles.x > input_angle.x)
- input_angle.x = viewangles.x - slow_change_dist_p;
- else
- input_angle.x = viewangles.x + slow_change_dist_p;
- }
-
- // Clamp as we changed angles
- fClampAngle(input_angle);
-}
-
void clearInstructions()
{
crumbs.clear();