diff --git a/CMakeLists.txt b/CMakeLists.txt index 6569c462..520c9b88 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,6 @@ set_property(CACHE Game PROPERTY STRINGS ${GameValues}) set(EnableProfiler 0 CACHE BOOL "Enable Profiler") set(EnableVisuals 1 CACHE BOOL "Enable Visuals") -set(LagbotMode 0 CACHE BOOL "Build light cathook made for lagbots") set(ExternalDrawing 0 CACHE BOOL "External Visuals") set(EnableGUI 1 CACHE BOOL "Enable GUI") set(EnableIPC 1 CACHE BOOL "Enable IPC") diff --git a/data/menu/nullifiedcat/trigger/autobackstab.xml b/data/menu/nullifiedcat/trigger/autobackstab.xml index dc24a6ca..849fee25 100755 --- a/data/menu/nullifiedcat/trigger/autobackstab.xml +++ b/data/menu/nullifiedcat/trigger/autobackstab.xml @@ -1,8 +1,14 @@ - - + + + + - \ No newline at end of file + diff --git a/external/chirc b/external/chirc index 729ade1d..4b51a8b5 160000 --- a/external/chirc +++ b/external/chirc @@ -1 +1 @@ -Subproject commit 729ade1d523711cc0600f96d712b209425f3d956 +Subproject commit 4b51a8b590a8149de24061c21b2c61a78fcb69bd diff --git a/external/libglez b/external/libglez index dd0158bc..ac817c1c 160000 --- a/external/libglez +++ b/external/libglez @@ -1 +1 @@ -Subproject commit dd0158bcb389a5687c16ae8075574db5b7dd1954 +Subproject commit ac817c1c55b61387df289773fb3761fee8f462c0 diff --git a/include/config.h.in b/include/config.h.in index 6d4e82fd..b2cfc2de 100755 --- a/include/config.h.in +++ b/include/config.h.in @@ -6,7 +6,6 @@ #define GAME_SPECIFIC @GameSpecific@ #define GAME @Game@ #define ENABLE_VISUALS @EnableVisuals@ -#define LAGBOT_MODE @LagbotMode@ #define EXTERNAL_DRAWING @ExternalDrawing@ #define ENABLE_GUI @EnableGUI@ #define ENABLE_IPC @EnableIPC@ diff --git a/include/gameinfo.hpp b/include/gameinfo.hpp index 229def9a..7997d014 100755 --- a/include/gameinfo.hpp +++ b/include/gameinfo.hpp @@ -40,8 +40,7 @@ constexpr bool IsTF() return IsTF2() || IsTF2C(); } -// This one is supposed to be `if constexpr` but I have to upgrade to gcc7 -#define IF_GAME(x) if (x) +#define IF_GAME(x) if constexpr (x) #else diff --git a/include/hack.hpp b/include/hack.hpp index 5465a0aa..e778cb11 100644 --- a/include/hack.hpp +++ b/include/hack.hpp @@ -25,6 +25,7 @@ extern std::mutex command_stack_mutex; std::stack &command_stack(); void ExecuteCommand(const std::string command); +extern bool game_shutdown; extern bool shutdown; extern bool initialized; diff --git a/include/hacks/AutoBackstab.hpp b/include/hacks/AutoBackstab.hpp index 9cd91ce5..510c755d 100644 --- a/include/hacks/AutoBackstab.hpp +++ b/include/hacks/AutoBackstab.hpp @@ -11,5 +11,4 @@ namespace hacks::tf2::autobackstab { void CreateMove(); -void Draw(); } // namespace hacks::tf2::autobackstab diff --git a/include/hacks/DominateSay.hpp b/include/hacks/DominateSay.hpp index 92e01f2d..a2495abe 100644 --- a/include/hacks/DominateSay.hpp +++ b/include/hacks/DominateSay.hpp @@ -16,5 +16,4 @@ void shutdown(); void reload(); extern const std::vector builtin_default; -extern const std::vector jp_anime; } // namespace hacks::shared::dominatesay diff --git a/include/hacks/ESP.hpp b/include/hacks/ESP.hpp index ace53597..89f3e37a 100644 --- a/include/hacks/ESP.hpp +++ b/include/hacks/ESP.hpp @@ -38,8 +38,6 @@ public: void Init(); extern std::array data; -void Draw(); - // Entity Processing void __attribute__((fastcall)) ProcessEntity(CachedEntity *ent); void __attribute__((fastcall)) ProcessEntityPT(CachedEntity *ent); @@ -56,4 +54,4 @@ void AddEntityString(CachedEntity *entity, const std::string &string, const rgba void SetEntityColor(CachedEntity *entity, const rgba_t &color); void ResetEntityStrings(); } // namespace hacks::shared::esp -#endif \ No newline at end of file +#endif diff --git a/include/hacks/LightESP.hpp b/include/hacks/LightESP.hpp deleted file mode 100644 index d835dd83..00000000 --- a/include/hacks/LightESP.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "common.hpp" -#include -namespace hacks::shared::lightesp -{ -#if ENABLE_VISUALS -void draw(); -rgba_t LightESPColor(CachedEntity *ent); -#endif -} // namespace hacks::shared::lightesp diff --git a/include/hacks/hacklist.hpp b/include/hacks/hacklist.hpp index 9a3031d8..8135de9c 100755 --- a/include/hacks/hacklist.hpp +++ b/include/hacks/hacklist.hpp @@ -12,13 +12,11 @@ #if ENABLE_VISUALS #include "ESP.hpp" -#include "LightESP.hpp" #include "SkinChanger.hpp" #include "Radar.hpp" #include "SpyAlert.hpp" #endif -#if not LAGBOT_MODE #include "Aimbot.hpp" #include "AntiAim.hpp" #include "AntiDisguise.hpp" @@ -30,16 +28,12 @@ #include "AutoDeadringer.hpp" #include "Bunnyhop.hpp" #include "SeedPrediction.hpp" -#endif #if ENABLE_VISUALS #include "Radar.hpp" #endif -#if not LAGBOT_MODE #include "Walkbot.hpp" #include "navparser.hpp" -#endif #include "AutoJoin.hpp" -#if not LAGBOT_MODE #include "AntiBackstab.hpp" #include "AutoBackstab.hpp" #include "FollowBot.hpp" @@ -49,16 +43,11 @@ #include "DominateSay.hpp" #include "UberSpam.hpp" #include "Achievement.hpp" -#endif #include "Spam.hpp" -#if not LAGBOT_MODE #include "NavBot.hpp" #include "Noisemaker.hpp" #include "FollowBot.hpp" #include "Announcer.hpp" #include "Killstreak.hpp" -#endif #include "CatBot.hpp" -#if not LAGBOT_MODE #include "Backtrack.hpp" -#endif diff --git a/include/helpers.hpp b/include/helpers.hpp index 7ecf86ad..0d0f4f1a 100644 --- a/include/helpers.hpp +++ b/include/helpers.hpp @@ -104,6 +104,8 @@ void fClampAngle(Vector &qaAng); // const char* MakeInfoString(IClientEntity* player); bool GetProjectileData(CachedEntity *weapon, float &speed, float &gravity); bool IsVectorVisible(Vector a, Vector b, bool enviroment_only = false); +Vector GetForwardVector(Vector origin, Vector viewangles, float distance); +Vector GetForwardVector(float distance); bool IsSentryBuster(CachedEntity *ent); std::unique_ptr strfmt(const char *fmt, ...); // TODO move that to weaponid.h diff --git a/include/hooks/HookTools.hpp b/include/hooks/HookTools.hpp index e43d903b..13796ec7 100644 --- a/include/hooks/HookTools.hpp +++ b/include/hooks/HookTools.hpp @@ -1,111 +1,93 @@ #pragma once -#include -#include -#include + #include "core/profiler.hpp" -#include -#include "config.h" -#include "memory" +#include "functional" +#include -class HookedFunction; -namespace HookTools +namespace EC { -std::vector &GetHookedFunctions(); -void CM(); -void DRAW(); -void PAINT(); -} // namespace HookTools -enum HookedFunctions_types +enum ec_types : int8_t { - // Use CreateMove to run functions that need to run while ingame. - HF_CreateMove = 0, - // Use Draw to draw on screen - HF_Draw, - // Use Paint to run functions everywhere (including main menu) - HF_Paint + CreateMove = 0, +#if ENABLE_VISUALS + Draw, +#endif + Paint, + LevelInit }; -class HookedFunction +enum priority : int8_t { - std::function m_func; - int m_priority; - std::string m_name; -#if ENABLE_PROFILER - ProfilerSection section = ProfilerSection("UNNAMED_FUNCTIONS"); -#endif - void init(HookedFunctions_types type, std::string name, int priority, std::function func) - { - switch (type) - { - case HF_CreateMove: - m_name = "CM_"; - break; - case HF_Draw: - m_name = "DRAW_"; - break; - case HF_Paint: - m_name = "PAINT_"; - break; - default: - m_name = "UNDEFINED_"; - break; - } - m_name.append(name); - m_priority = priority; - m_func = func; - m_type = type; -#if ENABLE_PROFILER - section.m_name = m_name; -#endif - HookTools::GetHookedFunctions().push_back(this); - } + very_early = -2, + early, + average, + late, + very_late +}; -public: - HookedFunctions_types m_type; - bool run(HookedFunctions_types type) +template struct EventCallbackData +{ + explicit EventCallbackData(std::function function, std::string name, int8_t priority) : function{ function }, priority{ priority }, section{ name } { - if (m_type == type) - { -#if ENABLE_PROFILER - ProfilerNode node(section); -#endif - m_func(); - return true; - } - return false; } - bool operator>(HookedFunction const &other) + std::function function; + int8_t priority; + mutable ProfilerSection section; + bool operator<(const EventCallbackData &other) const { - if (this->m_type < other.m_type) - return true; - return this->m_priority > other.m_priority; - } - HookedFunction(HookedFunctions_types type, std::string name, int priority, std::function func) - { - init(type, name, priority, func); - } - HookedFunction(HookedFunctions_types type, int priority, std::function func) - { - static const std::string name("UNNAMED_FUNCTIONS"); - init(type, name, priority, func); - } - HookedFunction(HookedFunctions_types type, std::string name, std::function func) - { - int priority = 5; - init(type, name, priority, func); - } - HookedFunction(HookedFunctions_types type, std::function func) - { - static const std::string name("UNNAMED_FUNCTIONS"); - int priority = 5; - init(type, name, priority, func); + return priority < other.priority; } }; -// struct CreateMove -//{ -// int priority = 0; -// CreateMove(int priority, std::function func); -// CreateMove(std::function func); -//}; +extern std::multiset> createmoves; +#if ENABLE_VISUALS +extern std::multiset> draws; +#endif +extern std::multiset> paints; +extern std::multiset> levelinits; + +template void Register(std::function function, std::string name, int8_t priority) +{ + switch (T) + { + case CreateMove: + { + EventCallbackData data(function, name, priority); + createmoves.insert(data); + break; + } +#if ENABLE_VISUALS + case Draw: + { + EventCallbackData data(function, name, priority); + draws.insert(data); + break; + } +#endif + case Paint: + { + EventCallbackData data(function, name, priority); + paints.insert(data); + break; + } + case LevelInit: + { + EventCallbackData data(function, name, priority); + levelinits.insert(data); + break; + } + default: + throw(std::invalid_argument("Unknown event")); + break; + } +} + +void RunCreateMove(); +#if ENABLE_VISUALS +void RunDraw(); +#endif +void RunPaint(); + +void RunLevelInit(); +} // namespace EC diff --git a/include/hooks/HookedMethods.hpp b/include/hooks/HookedMethods.hpp index cdf72c3f..b679ec25 100644 --- a/include/hooks/HookedMethods.hpp +++ b/include/hooks/HookedMethods.hpp @@ -13,22 +13,21 @@ union SDL_Event; struct SDL_Window; #endif -#define DECLARE_HOOKED_METHOD(name, rtype, ...) \ - namespace types \ - { \ - using name = rtype (*)(__VA_ARGS__); \ - } \ - namespace methods \ - { \ - rtype name(__VA_ARGS__); \ - } \ - namespace original \ - { \ - extern types::name name; \ - } +#define DECLARE_HOOKED_METHOD(name, rtype, ...) namespace types \ +{ \ + using name = rtype (*)(__VA_ARGS__); \ +} \ +namespace methods \ +{ \ + rtype name(__VA_ARGS__); \ +} \ +namespace original \ +{ \ + extern types::name name; \ +} -#define DEFINE_HOOKED_METHOD(name, rtype, ...) \ - types::name original::name{ nullptr }; \ +#define DEFINE_HOOKED_METHOD(name, rtype, ...) \ + types::name original::name{ nullptr }; \ rtype methods::name(__VA_ARGS__) #define HOOK_ARGS(name) hooked_methods::methods::name, offsets::name(), &hooked_methods::original::name diff --git a/include/reclasses/C_TFWeaponBaseMelee.hpp b/include/reclasses/C_TFWeaponBaseMelee.hpp index de7dc250..61eced95 100644 --- a/include/reclasses/C_TFWeaponBaseMelee.hpp +++ b/include/reclasses/C_TFWeaponBaseMelee.hpp @@ -18,14 +18,14 @@ public: inline static bool DoSwingTrace(IClientEntity *self, trace_t *trace) { typedef bool (*fn_t)(IClientEntity *, trace_t *); - return vfunc(self, offsets::PlatformOffset(522, offsets::undefined, 522), 0)(self, trace); + return vfunc(self, offsets::PlatformOffset(523, offsets::undefined, 523), 0)(self, trace); } inline static int GetSwingRange(IClientEntity *self) { - if (self->GetClientClass()->m_ClassID == CL_CLASS(CTFSword) || self->GetClientClass()->m_ClassID == CL_CLASS(CTFKatana)) - return 128; - else - return 72; + if (g_pLocalPlayer->holding_sapper) + return 48; + typedef int (*fn_t)(IClientEntity *); + return vfunc(self, offsets::PlatformOffset(521, offsets::undefined, 521), 0)(self); } }; } // namespace re diff --git a/include/timer.hpp b/include/timer.hpp index a529ce04..cb398beb 100644 --- a/include/timer.hpp +++ b/include/timer.hpp @@ -5,8 +5,8 @@ * Author: nullifiedcat */ -#pragma once - +#ifndef CH_TIMER_HPP +#define CH_TIMER_HPP #include class Timer @@ -37,3 +37,4 @@ public: public: std::chrono::time_point last{}; }; +#endif diff --git a/include/visual/EffectChams.hpp b/include/visual/EffectChams.hpp index 474cbb67..67c4a433 100644 --- a/include/visual/EffectChams.hpp +++ b/include/visual/EffectChams.hpp @@ -18,13 +18,16 @@ class EffectChams : public IScreenSpaceEffect { public: virtual void Init(); - inline virtual void Shutdown() + virtual void Shutdown() { - mat_unlit.Shutdown(); - mat_unlit_z.Shutdown(); - mat_lit.Shutdown(); - mat_lit_z.Shutdown(); - init = false; + if (init) + { + mat_unlit.Shutdown(); + mat_unlit_z.Shutdown(); + mat_lit.Shutdown(); + mat_lit_z.Shutdown(); + init = false; + } } inline virtual void SetParameters(KeyValues *params) diff --git a/include/visual/EffectGlow.hpp b/include/visual/EffectGlow.hpp index 51268ee1..15817717 100644 --- a/include/visual/EffectGlow.hpp +++ b/include/visual/EffectGlow.hpp @@ -17,15 +17,19 @@ class EffectGlow : public IScreenSpaceEffect { public: virtual void Init(); - inline virtual void Shutdown() + virtual void Shutdown() { - mat_unlit.Shutdown(); - mat_unlit_z.Shutdown(); - mat_blit.Shutdown(); - mat_unlit.Shutdown(); - mat_unlit_z.Shutdown(); - mat_blur_x.Shutdown(); - mat_blur_y.Shutdown(); + if (init) + { + mat_unlit.Shutdown(); + mat_unlit_z.Shutdown(); + mat_blit.Shutdown(); + mat_unlit.Shutdown(); + mat_unlit_z.Shutdown(); + mat_blur_x.Shutdown(); + mat_blur_y.Shutdown(); + init = false; + } } inline virtual void SetParameters(KeyValues *params) diff --git a/src/core/entry.cpp b/src/core/entry.cpp index 9a1081b8..2704fd69 100755 --- a/src/core/entry.cpp +++ b/src/core/entry.cpp @@ -5,7 +5,7 @@ * Author: nullifiedcat */ -#include +#include "common.hpp" #include #include "hack.hpp" @@ -40,7 +40,7 @@ void *MainThread(void *arg) logging::Info("Shutting down..."); hack::Shutdown(); logging::Shutdown(); - return 0; + return nullptr; } void __attribute__((constructor)) attach() @@ -51,9 +51,19 @@ void __attribute__((constructor)) attach() pthread_create(&thread_main, 0, MainThread, &mutex_quit); } -void __attribute__((destructor)) detach() +void detach() { logging::Info("Detaching"); pthread_mutex_unlock(&mutex_quit); pthread_join(thread_main, 0); } + +void __attribute__((destructor)) deconstruct() +{ + detach(); +} + +CatCommand cat_detach("detach", "Detach cathook from TF2", []() { + hack::game_shutdown = false; + detach(); +}); diff --git a/src/core/logging.cpp b/src/core/logging.cpp index a7855c77..e7852a6a 100644 --- a/src/core/logging.cpp +++ b/src/core/logging.cpp @@ -12,6 +12,7 @@ #include #include "common.hpp" +#include "hack.hpp" settings::Bool log_to_console{ "hack.log-console", "false" }; @@ -45,7 +46,7 @@ void logging::Info(const char *fmt, ...) fprintf(logging::handle, "%s", result); fflush(logging::handle); #if ENABLE_VISUALS - if (g_ICvar) + if (!hack::game_shutdown && g_ICvar) { if (*log_to_console) g_ICvar->ConsolePrintf("%s", result); diff --git a/src/hack.cpp b/src/hack.cpp index 6c9f007c..29ed5f6b 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -32,6 +32,8 @@ * Linux */ +// game_shutdown = Is full game shutdown or just detach +bool hack::game_shutdown = true; bool hack::shutdown = false; bool hack::initialized = false; @@ -289,13 +291,11 @@ free(logname);*/ // hooks::materialsystem.HookMethod(); } #endif -#if not LAGBOT_MODE // FIXME [MP] hacks::shared::killsay::init(); hacks::shared::dominatesay::init(); hacks::shared::announcer::init(); hacks::tf2::killstreak::init(); -#endif hacks::shared::catbot::init(); logging::Info("Hooked!"); velocity::Init(); @@ -309,7 +309,6 @@ free(logname);*/ { effect_chams::g_pEffectChams = new CScreenSpaceEffectRegistration("_cathook_chams", &effect_chams::g_EffectChams); g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_chams"); - effect_chams::g_EffectChams.Init(); effect_glow::g_pEffectGlow = new CScreenSpaceEffectRegistration("_cathook_glow", &effect_glow::g_EffectGlow); g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_glow"); } @@ -319,9 +318,7 @@ free(logname);*/ logging::Info("SDL hooking done"); #endif /* TEXTMODE */ -#if not LAGBOT_MODE hacks::shared::anticheat::Init(); -#endif #if ENABLE_VISUALS #ifndef FEATURE_FIDGET_SPINNER_ENABLED InitSpinner(); @@ -329,9 +326,7 @@ free(logname);*/ #endif hacks::shared::spam::init(); #endif -#if not LAGBOT_MODE hacks::shared::walkbot::Initialize(); -#endif #if ENABLE_VISUALS hacks::shared::esp::Init(); #endif @@ -374,17 +369,24 @@ void hack::Shutdown() if (hack::shutdown) return; hack::shutdown = true; + // Stop cathook stuff + settings::RVarLock.store(true); playerlist::Save(); #if ENABLE_VISUALS sdl_hooks::cleanSdlHooks(); #endif logging::Info("Unregistering convars.."); ConVar_Unregister(); -#if not LAGBOT_MODE logging::Info("Shutting down killsay..."); - hacks::shared::killsay::shutdown(); - hacks::shared::dominatesay::shutdown(); - hacks::shared::announcer::shutdown(); + if (!hack::game_shutdown) + { + hacks::shared::killsay::shutdown(); + hacks::shared::dominatesay::shutdown(); + hacks::shared::announcer::shutdown(); +#if ENABLE_VISUALS + g_pScreenSpaceEffects->DisableScreenSpaceEffect("_cathook_glow"); + g_pScreenSpaceEffects->DisableScreenSpaceEffect("_cathook_chams"); #endif + } logging::Info("Success.."); } diff --git a/src/hacks/AutoBackstab.cpp b/src/hacks/AutoBackstab.cpp index 903f2310..329f6035 100644 --- a/src/hacks/AutoBackstab.cpp +++ b/src/hacks/AutoBackstab.cpp @@ -5,82 +5,30 @@ * Author: nullifiedcat */ -#include #include "common.hpp" -#include "hacks/Backtrack.hpp" -#include "hacks/Aimbot.hpp" -#include "hacks/Trigger.hpp" -#include "hacks/AntiAntiAim.hpp" #include "PlayerTools.hpp" +#include "Trigger.hpp" +#include "Backtrack.hpp" namespace hacks::tf2::autobackstab { -namespace backtrack = hacks::shared::backtrack; -static settings::Bool enable{ "autobackstab.enable", "0" }; -static settings::Bool silent{ "autobackstab.silent", "1" }; -void testingFunc(); +static settings::Bool enabled("autobackstab.enabled", "false"); +static settings::Int mode("autobackstab.mode", "0"); -// Not required anymore, keeping for future reference -Vector rotateVector(Vector center, float radianAngle, Vector p) +static bool angleCheck(CachedEntity *target, std::optional target_pos, Vector local_angle) { - float s = sin(radianAngle); - float c = cos(radianAngle); + Vector tarAngle = CE_VECTOR(target, netvar.m_angEyeAngles); - // translate point back to origin: - p.x -= center.x; - p.y -= center.y; - - // rotate point - // float xnew = p.x * c - p.y * s; - // float ynew = p.x * s + p.y * c; - Vector vecNew{ p.x * c - p.y * s, p.x * s + p.y * c, 0 }; - - // translate point back: - p.x = vecNew.x + center.x; - p.y = vecNew.y + center.y; - return p; -} - -// Function to find the closest hitbox to the v_Eye for a given ent -int ClosestDistanceHitbox(CachedEntity *target, backtrack::BacktrackData btd = {}) -{ - int closest = -1; - float closest_dist = 0.0f, dist = 0.0f; - for (int i = pelvis; i < lowerArm_R; i++) - { - if (hacks::shared::backtrack::isBacktrackEnabled) - dist = g_pLocalPlayer->v_Eye.DistTo(btd.hitboxes.at(i).center); - else - dist = g_pLocalPlayer->v_Eye.DistTo(target->hitboxes.GetHitbox(i)->center); - if (dist < closest_dist || closest == -1) - { - closest = i; - closest_dist = dist; - } - } - return closest; -} - -bool unifiedCanBackstab(CachedEntity *tar, Vector &vecAngle, Vector targetOrigin, Vector min, Vector max) -{ - // Get melee range - float meleeRange = re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W)); - Vector tarAngle = CE_VECTOR(tar, netvar.m_angEyeAngles); - - Vector head = g_pLocalPlayer->v_Eye; - - // Check if we are in range. Note: This has to be done in order to avoid - // false positives even when "forward" is only "meleeRange" away from the - // head. - if (head.DistTo((min + max) / 2) > meleeRange) - return false; - - Vector wsc_spy_to_victim = (targetOrigin - LOCAL_E->m_vecOrigin()); - wsc_spy_to_victim.z = 0; + Vector wsc_spy_to_victim; + if (target_pos) + wsc_spy_to_victim = *target_pos - LOCAL_E->m_vecOrigin(); + else + wsc_spy_to_victim = target->m_vecOrigin() - LOCAL_E->m_vecOrigin(); + wsc_spy_to_victim.z = 0; wsc_spy_to_victim.NormalizeInPlace(); Vector eye_spy; - AngleVectors2(VectorToQAngle(vecAngle), &eye_spy); + AngleVectors2(VectorToQAngle(local_angle), &eye_spy); eye_spy.z = 0; eye_spy.NormalizeInPlace(); @@ -89,19 +37,6 @@ bool unifiedCanBackstab(CachedEntity *tar, Vector &vecAngle, Vector targetOrigin eye_victim.z = 0; eye_victim.NormalizeInPlace(); - // Get the min and max for the hitbox - Vector minz(fminf(min.x, max.x), fminf(min.y, max.y), fminf(min.z, max.z)); - Vector maxz(fmaxf(min.x, max.x), fmaxf(min.y, max.y), fmaxf(min.z, max.z)); - - Vector forward; - AngleVectors2(VectorToQAngle(vecAngle), &forward); - forward = forward * meleeRange + head; - - Vector hit; - // Check if we our line is within the targets hitbox - if (!hacks::shared::triggerbot::CheckLineBox(minz, maxz, head, forward, hit)) - return false; - if (DotProduct(wsc_spy_to_victim, eye_victim) <= 0.0f) return false; if (DotProduct(wsc_spy_to_victim, eye_spy) <= 0.5f) @@ -111,227 +46,103 @@ bool unifiedCanBackstab(CachedEntity *tar, Vector &vecAngle, Vector targetOrigin return true; } -void CreateMove() +static void doLegitBackstab() { - // testingFunc(); - if (!enable) + trace_t trace; + if (!re::C_TFWeaponBaseMelee::DoSwingTrace(RAW_ENT(LOCAL_W), &trace)) return; - if (CE_BAD(LOCAL_E) || CE_BAD(LOCAL_W) || !LOCAL_E->m_bAlivePlayer()) + if (!trace.m_pEnt) return; - if (g_pLocalPlayer->weapon()->m_iClassID() != CL_CLASS(CTFKnife)) + int index = reinterpret_cast(trace.m_pEnt)->entindex(); + auto ent = ENTITY(index); + if (index == 0 || index > g_IEngine->GetMaxClients() || !ent->m_bEnemy() || player_tools::shouldTarget(ent) != player_tools::IgnoreReason::DO_NOT_IGNORE) return; - if (!CanShoot()) - return; - CachedEntity *besttarget = nullptr; - if (!backtrack::isBacktrackEnabled) + if (angleCheck(ENTITY(index), std::nullopt, g_pLocalPlayer->v_OrigViewangles)) { - for (int i = 0; i < g_IEngine->GetMaxClients(); i++) - { - CachedEntity *target = ENTITY(i); - if (CE_BAD(target)) - continue; - if (target == LOCAL_E || target->m_iTeam() == LOCAL_E->m_iTeam() || !target->m_bAlivePlayer() || target->m_Type() != ENTITY_PLAYER) - continue; - if (player_tools::shouldTarget(target) != player_tools::IgnoreReason::DO_NOT_IGNORE) - continue; - if (target->hitboxes.GetHitbox(spine_3)->center.DistTo(g_pLocalPlayer->v_Eye) <= 200.0f) - { - if (CE_GOOD(besttarget)) - { - if (target->hitboxes.GetHitbox(spine_3)->center.DistTo(g_pLocalPlayer->v_Eye) < besttarget->hitboxes.GetHitbox(spine_3)->center.DistTo(g_pLocalPlayer->v_Eye)) - besttarget = target; - } - else - { - besttarget = target; - } - } - } - } - else - { - // Run if backtrack is enabled - if (backtrack::iBestTarget == -1) - return; - CachedEntity *target = ENTITY(backtrack::iBestTarget); - // Various valid entity checks - if (CE_BAD(target)) - return; - if (target == LOCAL_E || target->m_iTeam() == LOCAL_E->m_iTeam() || !target->m_bAlivePlayer() || target->m_Type() != ENTITY_PLAYER) - return; - if (player_tools::shouldTarget(target) != player_tools::IgnoreReason::DO_NOT_IGNORE) - return; - // Check if besttick distance is < 200.0f - if (backtrack::headPositions[target->m_IDX][backtrack::BestTick].hitboxes.at(spine_3).center.DistTo(g_pLocalPlayer->v_Eye) < 200.0f) - besttarget = target; + current_user_cmd->buttons |= IN_ATTACK; } +} - if (CE_GOOD(besttarget)) +static void doRageBackstab() +{ + float swingrange = re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W)); + Vector newangle = g_pLocalPlayer->v_OrigViewangles; + + for (newangle.y = -180.0f; newangle.y < 180.0f; newangle.y += 10.0f) { - hacks::shared::anti_anti_aim::resolveEnt(besttarget->m_IDX); - Vector angle = NET_VECTOR(RAW_ENT(LOCAL_E), 4104); - if (!backtrack::isBacktrackEnabled) + trace_t trace; + Ray_t ray; + trace::filter_default.SetSelf(RAW_ENT(g_pLocalPlayer->entity)); + ray.Init(g_pLocalPlayer->v_Eye, GetForwardVector(g_pLocalPlayer->v_Eye, newangle, swingrange)); + g_ITrace->TraceRay(ray, MASK_SHOT_HULL, &trace::filter_default, &trace); + if (trace.m_pEnt) { - IClientEntity *raw = RAW_ENT(besttarget); - Vector origin = besttarget->m_vecOrigin(); - Vector min = raw->GetCollideable()->OBBMins() + origin; - Vector max = raw->GetCollideable()->OBBMaxs() + origin; - - for (angle.y = -180.0f; angle.y < 180.0f; angle.y += 10.0f) + int index = reinterpret_cast(trace.m_pEnt)->entindex(); + auto ent = ENTITY(index); + if (index == 0 || index > g_IEngine->GetMaxClients() || !ent->m_bEnemy() || player_tools::shouldTarget(ent) != player_tools::IgnoreReason::DO_NOT_IGNORE) + continue; + if (angleCheck(ent, std::nullopt, newangle)) { - if (!unifiedCanBackstab(besttarget, angle, origin, min, max)) - continue; - current_user_cmd->viewangles = angle; current_user_cmd->buttons |= IN_ATTACK; - besttarget = nullptr; - if (silent) - g_pLocalPlayer->bUseSilentAngles = true; + current_user_cmd->viewangles = newangle; + g_pLocalPlayer->bUseSilentAngles = true; return; } } - else - { - int idx = besttarget->m_IDX; - for (int j = 0; j < 66; j++) - { - auto i = backtrack::headPositions[idx][j]; - if (!backtrack::ValidTick(i, besttarget)) - continue; - - for (angle.y = -180.0f; angle.y < 180.0f; angle.y += 20.0f) - { - if (unifiedCanBackstab(besttarget, angle, i.entorigin, i.collidable.min, i.collidable.max)) - { - current_user_cmd->tick_count = i.tickcount; - current_user_cmd->viewangles = angle; - current_user_cmd->buttons |= IN_ATTACK; - if (silent) - g_pLocalPlayer->bUseSilentAngles = true; - return; - } - } - } - } } } -const Vector GetWorldSpaceCenter(CachedEntity *ent) + +static void doBacktrackStab() { - Vector vMin, vMax; - RAW_ENT(ent)->GetRenderBounds(vMin, vMax); - Vector vWorldSpaceCenter = RAW_ENT(ent)->GetAbsOrigin(); - vWorldSpaceCenter.z += (vMin.z + vMax.z) / 2; - return vWorldSpaceCenter; -} - -static bool InBackstabAngleRange = false; -static bool LookingAtVic = false; -static bool IsBehind = false; - -void Draw() -{ - // if (CE_BAD(LOCAL_E) || CE_BAD(LOCAL_W) || !LOCAL_E->m_bAlivePlayer()) - // return; - // if (g_pLocalPlayer->weapon()->m_iClassID() != CL_CLASS(CTFKnife)) - // return; - // CachedEntity *besttarget = nullptr; - // for (int i = 0; i < g_IEngine->GetMaxClients(); i++) - // { - // CachedEntity *target = ENTITY(i); - // if (CE_BAD(target)) - // continue; - // if (target == LOCAL_E || target->m_iTeam() == - // LOCAL_E->m_iTeam() || - // !target->m_bAlivePlayer() || target->m_Type() != - // ENTITY_PLAYER) continue; - // if (target->m_vecOrigin().DistTo( - // g_pLocalPlayer->v_Eye) <= 200.0f) - // { - // if (CE_GOOD(besttarget)) - // { - // if (besttarget->m_vecOrigin().DistTo( - // g_pLocalPlayer->v_Eye) < - // besttarget->m_vecOrigin().DistTo( - // g_pLocalPlayer->v_Eye)) - // besttarget = target; - // } - // else - // { - // besttarget = target; - // } - // } - // } - - // if (CE_BAD(besttarget)) - // return; - // Vector angle = NET_VECTOR(RAW_ENT(LOCAL_E), netvar.m_angEyeAngles); - // Vector tarAngle = NET_VECTOR(RAW_ENT(besttarget), - // netvar.m_angEyeAngles); - - // //bool IsBehind = dot1 <= 0.0f; - // bool LookingAtVic = GetFov(angle, g_pLocalPlayer->v_Eye, - // GetWorldSpaceCenter(besttarget)) <= 60.0f; bool InBackstabAngleRange = - // fabsf(tarAngle.y - angle.y) <= 107.5f; - - // rgba_t col1 = IsBehind ? colors::green : colors::red; - // rgba_t col2 = LookingAtVic ? colors::green : colors::red; - // rgba_t col3 = InBackstabAngleRange ? colors::green : colors::red; - // AddCenterString(format("Behind target" /*, dot1*/), col1); - // AddCenterString(format("Looking at Target" /*, dot2*/), col2); - // AddCenterString(format("In Angle Range" /*, dot3*/), col3); -} - -void testingFunc() -{ - if (CE_BAD(LOCAL_E) || CE_BAD(LOCAL_W) || !LOCAL_E->m_bAlivePlayer()) + float swingrange = re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W)); + CachedEntity *ent; + try { + ent = ENTITY(hacks::shared::backtrack::iBestTarget); + } catch (std::out_of_range) { return; - if (g_pLocalPlayer->weapon()->m_iClassID() != CL_CLASS(CTFKnife)) + } + if (!ent->m_bEnemy() || player_tools::shouldTarget(ent) != player_tools::IgnoreReason::DO_NOT_IGNORE) return; - CachedEntity *besttarget = nullptr; - for (int i = 0; i < g_IEngine->GetMaxClients(); i++) + + auto &btd = hacks::shared::backtrack::headPositions[ent->m_IDX]; + for (auto &i : btd) { - CachedEntity *target = ENTITY(i); - if (CE_BAD(target)) + if (!hacks::shared::backtrack::ValidTick(i, ent)) continue; - if (target == LOCAL_E || target->m_iTeam() == LOCAL_E->m_iTeam() || !target->m_bAlivePlayer() || target->m_Type() != ENTITY_PLAYER) - continue; - if (target->m_vecOrigin().DistTo(g_pLocalPlayer->v_Eye) <= 200.0f) + Vector angle = GetAimAtAngles(g_pLocalPlayer->v_Eye, i.hitboxes[spine_1].center); + if (!angleCheck(ent, i.entorigin, angle)) + return; + + Vector hit; + if (hacks::shared::triggerbot::CheckLineBox(i.collidable.min, i.collidable.max, g_pLocalPlayer->v_Eye, GetForwardVector(g_pLocalPlayer->v_Eye, angle, swingrange), hit)) { - if (CE_GOOD(besttarget)) - { - if (target->m_vecOrigin().DistTo(g_pLocalPlayer->v_Eye) < besttarget->m_vecOrigin().DistTo(g_pLocalPlayer->v_Eye)) - besttarget = target; - } - else - { - besttarget = target; - } + current_user_cmd->tick_count = i.tickcount; + current_user_cmd->viewangles = angle; + current_user_cmd->buttons |= IN_ATTACK; + g_pLocalPlayer->bUseSilentAngles = true; } } - - if (CE_BAD(besttarget)) - return; - Vector angle = NET_VECTOR(RAW_ENT(LOCAL_E), 4104); - Vector tarAngle = NET_VECTOR(RAW_ENT(besttarget), netvar.m_angEyeAngles); - - logging::Info("Loc: %f; Tar: %f", angle.y, tarAngle.y); - - Vector wsc_spy_to_victim = (besttarget->m_vecOrigin() - LOCAL_E->m_vecOrigin()); - wsc_spy_to_victim.z = 0; - wsc_spy_to_victim.NormalizeInPlace(); - - Vector eye_spy; - AngleVectors2(VectorToQAngle(angle), &eye_spy); - eye_spy.z = 0; - eye_spy.NormalizeInPlace(); - - Vector eye_victim; - AngleVectors2(VectorToQAngle(tarAngle), &eye_victim); - eye_victim.z = 0; - eye_victim.NormalizeInPlace(); - - IsBehind = DotProduct(wsc_spy_to_victim, eye_victim) <= 0.0f; - LookingAtVic = DotProduct(wsc_spy_to_victim, eye_spy) <= 0.5f; - InBackstabAngleRange = DotProduct(eye_spy, eye_victim) <= -0.3f; } +void CreateMove() +{ + if (!enabled) + return; + if (CE_BAD(LOCAL_E) || g_pLocalPlayer->life_state || g_pLocalPlayer->clazz != tf_spy || CE_BAD(LOCAL_W) || GetWeaponMode() != weapon_melee || !CanShoot()) + return; + switch (*mode) + { + case 0: + doLegitBackstab(); + break; + case 1: + doRageBackstab(); + break; + case 2: + if (hacks::shared::backtrack::isBacktrackEnabled) + doBacktrackStab(); + default: + break; + } +} } // namespace hacks::tf2::autobackstab diff --git a/src/hacks/AutoJoin.cpp b/src/hacks/AutoJoin.cpp index 1f2f913e..98c05b3f 100644 --- a/src/hacks/AutoJoin.cpp +++ b/src/hacks/AutoJoin.cpp @@ -148,8 +148,8 @@ void updateSearch() } #endif } -static HookedFunction update(HookedFunctions_types::HF_CreateMove, "Autojoin", 1, []() { -#if !LAGBOT_MODE +static void update() +{ if (autoteam_timer.test_and_set(500)) { if (autojoin_team and UnassignedTeam()) @@ -162,12 +162,13 @@ static HookedFunction update(HookedFunctions_types::HF_CreateMove, "Autojoin", 1 g_IEngine->ExecuteClientCmd(format("join_class ", classnames[int(autojoin_class) - 1]).c_str()); } } -#endif -}); +} void onShutdown() { if (auto_queue) tfmm::startQueue(); } + +static InitRoutine init([]() { EC::Register(update, "cm_autojoin", EC::average); }); } // namespace hacks::shared::autojoin diff --git a/src/hacks/CMakeLists.txt b/src/hacks/CMakeLists.txt index ec152c61..3dc0b79e 100755 --- a/src/hacks/CMakeLists.txt +++ b/src/hacks/CMakeLists.txt @@ -3,7 +3,6 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/CatBot.cpp" "${CMAKE_CURRENT_LIST_DIR}/SeedPrediction.cpp" "${CMAKE_CURRENT_LIST_DIR}/Spam.cpp") -if(NOT LagbotMode) target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/Achievement.cpp" "${CMAKE_CURRENT_LIST_DIR}/Aimbot.cpp" @@ -37,7 +36,6 @@ if(NOT LagbotMode) "${CMAKE_CURRENT_LIST_DIR}/Walkbot.cpp" "${CMAKE_CURRENT_LIST_DIR}/Radar.cpp") add_subdirectory(ac) -endif() if(EnableVisuals) target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/ESP.cpp" diff --git a/src/hacks/CatBot.cpp b/src/hacks/CatBot.cpp index 196c3d05..4a8fba44 100644 --- a/src/hacks/CatBot.cpp +++ b/src/hacks/CatBot.cpp @@ -177,14 +177,21 @@ Timer level_init_timer{}; Timer micspam_on_timer{}; Timer micspam_off_timer{}; - +static bool patched_report; void reportall() { typedef uint64_t (*ReportPlayer_t)(uint64_t, int); static uintptr_t addr2 = gSignatures.GetClientSignature("55 89 E5 57 56 53 81 EC ? ? ? ? 8B 5D ? 8B 7D ? 89 D8"); - ReportPlayer_t ReportPlayer_fn = ReportPlayer_t(addr2); + static ReportPlayer_t ReportPlayer_fn = ReportPlayer_t(addr2); if (!addr2) return; + if (!patched_report) + { + static uintptr_t addr2 = gSignatures.GetClientSignature("73 ? 80 7D ? ? 74 ? F3 0F 10 0D") +0x2F; + static unsigned char patch[] = { 0x89, 0xe0 }; + Patch((void *)addr2, (void *)patch, sizeof(patch)); + patched_report = true; + } player_info_s local; g_IEngine->GetPlayerInfo(g_pLocalPlayer->entity_idx, &local); for (int i = 1; i < g_IEngine->GetMaxClients(); i++) @@ -257,8 +264,9 @@ void smart_crouch() } CatCommand print_ammo("debug_print_ammo", "debug", []() { - if (CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer()) + if (CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer() || CE_BAD(LOCAL_W)) return; + logging::Info("Current slot: %d", re::C_BaseCombatWeapon::GetSlot(RAW_ENT(LOCAL_W))); for (int i = 0; i < 10; i++) logging::Info("Ammo Table %d: %d", i, CE_INT(LOCAL_E, netvar.m_iAmmo + i * 4)); }); @@ -267,17 +275,24 @@ static Timer report_timer{}; static std::string health = "Health: 0/0"; static std::string ammo = "Ammo: 0/0"; static int max_ammo; +static CachedEntity *local_w; // TODO: add more stuffs -static HookedFunction cm(HF_CreateMove, "catbot", 5, []() { +static void cm() +{ if (!*catbotmode) return; if (CE_GOOD(LOCAL_E)) { + if (LOCAL_W != local_w) + { + local_w = LOCAL_W; + max_ammo = 0; + } float max_hp = g_pPlayerResource->GetMaxHealth(LOCAL_E); float curr_hp = CE_INT(LOCAL_E, netvar.iHealth); - int ammo0 = CE_INT(LOCAL_E, netvar.m_iAmmo + 4); - int ammo2 = CE_INT(LOCAL_E, netvar.m_iAmmo + 8); + int ammo0 = CE_INT(LOCAL_E, netvar.m_iClip2); + int ammo2 = CE_INT(LOCAL_E, netvar.m_iClip1); if (ammo0 + ammo2 > max_ammo) max_ammo = ammo0 + ammo2; health = format("Health: ", curr_hp, "/", max_hp); @@ -302,7 +317,7 @@ static HookedFunction cm(HF_CreateMove, "catbot", 5, []() { } if (*autoReport && report_timer.test_and_set(60000)) reportall(); -}); +} static Timer autojointeam{}; void update() @@ -420,13 +435,21 @@ void level_init() } #if ENABLE_VISUALS -static HookedFunction Paint(HookedFunctions_types::HF_Draw, "anti_motd_info", 3, []() { +static void draw() +{ if (!catbotmode || !anti_motd) return; if (CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer()) return; AddCenterString(health, colors::green); AddCenterString(ammo, colors::yellow); -}); +} #endif + +static InitRoutine runinit([]() { + EC::Register(cm, "cm_catbot", EC::average); +#if ENABLE_VISUALS + EC::Register(cm, "draw_catbot", EC::average); +#endif +}); } // namespace hacks::shared::catbot diff --git a/src/hacks/DominateSay.cpp b/src/hacks/DominateSay.cpp index dc652cd7..45436f7e 100644 --- a/src/hacks/DominateSay.cpp +++ b/src/hacks/DominateSay.cpp @@ -35,9 +35,6 @@ std::string ComposeDominateSay(IGameEvent *event) case 2: source = &builtin_default; break; - case 3: - source = &jp_anime; - break; default: break; } @@ -115,17 +112,4 @@ const std::vector builtin_default = { "%killer% is dominating the server with %dominum% dominations!", }; -// same goes to this one -const std::vector jp_anime = { - "Get d-dominated %name%-senpai >:3", - "g- gomenasai! %name%-san!", - "Wow! hey hey hey H~ ey !!! I found you again~~!", - "%name%-san please don't get mad at me.. ><", - // https://youtu.be/sW3RT0tF020?t=207 - "kore kara mo douzo yoroshiku ne.", - "konna watashi dakedo waratte yurushite ne.", - "zutto taisetsu ni shite ne.", - "eikyuu hoshou no watashi dakara.", -}; - } // namespace hacks::shared::dominatesay diff --git a/src/hacks/ESP.cpp b/src/hacks/ESP.cpp index 8585f4d6..5185d303 100644 --- a/src/hacks/ESP.cpp +++ b/src/hacks/ESP.cpp @@ -219,7 +219,7 @@ struct bonelist_s std::unordered_map bonelist_map{}; // Function called on draw -void Draw() +static void Draw() { if (!enable) return; @@ -234,7 +234,7 @@ void Draw() } // Function called on create move -static HookedFunction CreateMove(HookedFunctions_types::HF_CreateMove, "ESP", 18, []() { +static void cm() { // Check usersettings if enabled if (!*enable) return; @@ -288,7 +288,7 @@ static HookedFunction CreateMove(HookedFunctions_types::HF_CreateMove, "ESP", 18 } } } -}); +} static glez::texture atlas{ DATA_PATH "/textures/atlas.png" }; static glez::texture idspec{ DATA_PATH "/textures/idspec.png" }; @@ -1443,4 +1443,11 @@ void SetEntityColor(CachedEntity *entity, const rgba_t &color) return; data[entity->m_IDX].color = color; } + +static InitRoutine init([](){ + EC::Register(cm, "cm_esp", EC::average); + EC::Register(Draw, "draw_esp", EC::average); +}); + + } // namespace hacks::shared::esp diff --git a/src/hacks/FollowBot.cpp b/src/hacks/FollowBot.cpp index 1d49019c..4896580f 100644 --- a/src/hacks/FollowBot.cpp +++ b/src/hacks/FollowBot.cpp @@ -188,7 +188,7 @@ Timer waittime{}; int lastent = 0; #if ENABLE_IPC -static HookedFunction WorldTick(HookedFunctions_types::HF_CreateMove, "followbot", 20, []() { +static void cm() { if (!enable) { follow_target = 0; @@ -555,11 +555,11 @@ static HookedFunction WorldTick(HookedFunctions_types::HF_CreateMove, "followbot } else idle_time.update(); -}); +} #endif #if ENABLE_VISUALS -static HookedFunction func(HF_Draw, "followbot", 10, []() { +static void draw() { if (!enable || !draw_crumb) return; if (breadcrumbs.size() < 2) @@ -577,9 +577,19 @@ static HookedFunction func(HF_Draw, "followbot", 10, []() { return; glez::draw::rect(wts.x - 4, wts.y - 4, 8, 8, colors::white); glez::draw::rect_outline(wts.x - 4, wts.y - 4, 7, 7, colors::white, 1.0f); -}); +} #endif +static InitRoutine runinit([](){ +#if ENABLE_IPC + EC::Register(cm, "cm_followbot", EC::average); +#endif +#if ENABLE_VISUALS + EC::Register(cm, "draw_followbot", EC::average); +#endif +}); + + int getTarget() { return follow_target; diff --git a/src/hacks/KillSay.cpp b/src/hacks/KillSay.cpp index 54b34edb..70c64014 100644 --- a/src/hacks/KillSay.cpp +++ b/src/hacks/KillSay.cpp @@ -104,7 +104,7 @@ class KillSayEventListener : public IGameEventListener2 } }; -static HookedFunction ProcessKillsay(HookedFunctions_types::HF_Paint, "KillSay_send", 1, []() { +static void ProcessKillsay() { if (killsay_storage.empty()) return; for (auto &i : killsay_storage) @@ -117,6 +117,10 @@ static HookedFunction ProcessKillsay(HookedFunctions_types::HF_Paint, "KillSay_s i.second = {}; } } +} + +static InitRoutine runinit([](){ + EC::Register(ProcessKillsay, "paint_killsay", EC::average); }); static KillSayEventListener listener{}; diff --git a/src/hacks/LightESP.cpp b/src/hacks/LightESP.cpp index 597b30ae..223bdfa4 100644 --- a/src/hacks/LightESP.cpp +++ b/src/hacks/LightESP.cpp @@ -1,21 +1,28 @@ -#include "hacks/LightESP.hpp" +#include "config.h" #if ENABLE_VISUALS -#include -#endif -#include +#include "common.hpp" +#include "glez/draw.hpp" static settings::Bool enable{ "lightesp.enable", "false" }; namespace hacks::shared::lightesp { -Vector hitp[32]; -Vector minp[32]; -Vector maxp[32]; -bool drawEsp[32]; +static Vector hitp[32]; +static Vector minp[32]; +static Vector maxp[32]; +static bool drawEsp[32]; -#if ENABLE_VISUALS -static HookedFunction cm(HF_CreateMove, "lightesp", 5, []() { +rgba_t LightESPColor(CachedEntity *ent) +{ + if (!playerlist::IsDefault(ent)) + { + return playerlist::Color(ent); + } + return colors::green; +} + +static void cm() { if (!*enable) return; for (int i = 1; i < g_IEngine->GetMaxClients(); i++) @@ -40,12 +47,10 @@ static HookedFunction cm(HF_CreateMove, "lightesp", 5, []() { maxp[i] = pEntity->hitboxes.GetHitbox(0)->max; drawEsp[i] = true; } -}); -#endif +} void draw() { -#if ENABLE_VISUALS if (!enable) return; for (int i = 1; i < g_IEngine->GetMaxClients(); i++) @@ -72,16 +77,12 @@ void draw() glez::draw::rect(out.x - size / 8, out.y - size / 8, size / 4, size / 4, colors::red); } } -#endif } -#if ENABLE_VISUALS -rgba_t LightESPColor(CachedEntity *ent) -{ - if (!playerlist::IsDefault(ent)) - { - return playerlist::Color(ent); - } - return colors::green; -} -#endif + +static InitRoutine init([](){ + EC::Register(cm, "cm_lightesp", EC::average); + EC::Register(draw, "draw_lightesp", EC::average); +}); + } // namespace hacks::shared::lightesp +#endif diff --git a/src/hacks/Misc.cpp b/src/hacks/Misc.cpp index 29fa9922..4496fdec 100644 --- a/src/hacks/Misc.cpp +++ b/src/hacks/Misc.cpp @@ -131,7 +131,6 @@ InitRoutine init([]() { teammatesPushaway = g_ICvar->FindVar("tf_avoidteammates_ void CreateMove() { -#if !LAGBOT_MODE if (current_user_cmd->command_number) last_number = current_user_cmd->command_number; @@ -225,7 +224,6 @@ void CreateMove() if (*nopush_enabled == teammatesPushaway->GetBool()) teammatesPushaway->SetValue(!nopush_enabled); } -#endif } #if ENABLE_VISUALS diff --git a/src/hacks/MiscAimbot.cpp b/src/hacks/MiscAimbot.cpp index b1cc8be1..9d9e2dc3 100644 --- a/src/hacks/MiscAimbot.cpp +++ b/src/hacks/MiscAimbot.cpp @@ -146,7 +146,7 @@ void DoSlowAim(Vector &input_angle) fClampAngle(input_angle); } -static HookedFunction SandwichAim(HookedFunctions_types::HF_CreateMove, "SandwichAim", 5, []() { +static void SandwichAim() { if (!*sandwichaim_enabled) return; if (CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer() || CE_BAD(LOCAL_W)) @@ -186,11 +186,11 @@ static HookedFunction SandwichAim(HookedFunctions_types::HF_CreateMove, "Sandwic current_user_cmd->buttons |= IN_ATTACK2; g_pLocalPlayer->bUseSilentAngles = true; } -}); +} static bool charge_aimbotted = false; static settings::Bool charge_aim{ "chargeaim.enable", "false" }; static settings::Button charge_key{ "chargeaim.key", "" }; -static HookedFunction ChargeAimbot(HookedFunctions_types::HF_CreateMove, "ChargeAim", 2, []() { +static void ChargeAimbot() { charge_aimbotted = false; if (!*charge_aim) return; @@ -214,11 +214,11 @@ static HookedFunction ChargeAimbot(HookedFunctions_types::HF_CreateMove, "Charge current_user_cmd->viewangles = angles; charge_aimbotted = true; } -}); +} static settings::Bool charge_control{ "chargecontrol.enable", "false" }; static settings::Float charge_float{ "chargecontrol.strength", "3.0f" }; -static HookedFunction ChargeControl(HookedFunctions_types::HF_CreateMove, "chargecontrol", 5, []() { +static void ChargeControl() { if (!*charge_control || charge_aimbotted) return; if (CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer() || CE_BAD(LOCAL_W)) @@ -231,12 +231,12 @@ static HookedFunction ChargeControl(HookedFunctions_types::HF_CreateMove, "charg if (current_user_cmd->buttons & IN_MOVERIGHT) offset = -*charge_float; current_user_cmd->viewangles.y += offset; -}); +} static settings::Bool autosapper_enabled("autosapper.enabled", "false"); static settings::Bool autosapper_silent("autosapper.silent", "true"); -static HookedFunction SapperAimbot(HF_CreateMove, "sapperaimbot", 5, []() { +static void SapperAimbot() { if (!autosapper_enabled) return; if (CE_BAD(LOCAL_E) || CE_BAD(LOCAL_W) || !g_pLocalPlayer->holding_sapper) @@ -272,4 +272,13 @@ static HookedFunction SapperAimbot(HF_CreateMove, "sapperaimbot", 5, []() { g_pLocalPlayer->bUseSilentAngles = true; current_user_cmd->buttons |= IN_ATTACK; } -}); +} + +static void CreateMove(){ + SandwichAim(); + ChargeAimbot(); + ChargeControl(); + SapperAimbot(); +} + +static InitRoutine init([](){EC::Register(CreateMove, "cm_miscaimbot", EC::late);}); diff --git a/src/hacks/NavBot.cpp b/src/hacks/NavBot.cpp index f42ac400..e16bb895 100644 --- a/src/hacks/NavBot.cpp +++ b/src/hacks/NavBot.cpp @@ -390,10 +390,43 @@ static void autoJump() current_user_cmd->buttons |= IN_JUMP; } +enum slots +{ + primary = 1, + secondary = 2, + melee = 3 +}; +static int GetBestSlot() +{ + + switch (g_pLocalPlayer->clazz) + { + case tf_scout: + { + float nearest_dist = getNearestPlayerDistance().second; + if (nearest_dist < 1000) + return primary; + else + return secondary; + } + case tf_heavy: + return primary; + default: + { + float nearest_dist = getNearestPlayerDistance().second; + if (nearest_dist > 400) + return primary; + else + return secondary; + } + } + return primary; +} + static void updateSlot() { static Timer slot_timer{}; - if (!slot_timer.test_and_set(1000)) + if (!slot_timer.test_and_set(300)) return; if (CE_GOOD(LOCAL_E) && CE_GOOD(LOCAL_W) && !g_pLocalPlayer->life_state) { @@ -402,14 +435,16 @@ static void updateSlot() if (re::C_BaseCombatWeapon::IsBaseCombatWeapon(weapon)) { int slot = re::C_BaseCombatWeapon::GetSlot(weapon); - int newslot = 1; + int newslot = GetBestSlot(); if (slot != newslot - 1) g_IEngine->ClientCmd_Unrestricted(format("slot", newslot).c_str()); } } } -static HookedFunction cm(HookedFunctions_types::HF_CreateMove, "NavBot", 16, &CreateMove); +static InitRoutine runinit([](){ + EC::Register(CreateMove, "paint_killsay", EC::average); +}); void change(settings::VariableBase &, bool) { diff --git a/src/hacks/Walkbot.cpp b/src/hacks/Walkbot.cpp index 3f3163c7..15cb4b9e 100644 --- a/src/hacks/Walkbot.cpp +++ b/src/hacks/Walkbot.cpp @@ -1149,7 +1149,7 @@ void OnLevelInit() Timer quit_timer{}; Timer map_check{}; int erasedelay = 0; -static HookedFunction Move(HookedFunctions_types::HF_CreateMove, "Walkbot", 16, []() { +static void cm() { if (CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer() || CE_BAD(LOCAL_W)) return; if (state::state == WB_DISABLED) @@ -1219,5 +1219,10 @@ static HookedFunction Move(HookedFunctions_types::HF_CreateMove, "Walkbot", 16, } break; } +} + +static InitRoutine init([](){ + EC::Register(cm, "cm_walkbot", EC::average); }); + } // namespace hacks::shared::walkbot diff --git a/src/helpers.cpp b/src/helpers.cpp index f4ce33db..013c8780 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -1091,6 +1091,29 @@ void WhatIAmLookingAt(int *result_eindex, Vector *result_pos) *result_eindex = ((IClientEntity *) (trace.m_pEnt))->entindex(); } +Vector GetForwardVector(Vector origin, Vector viewangles, float distance) +{ + Vector forward; + float sp, sy, cp, cy; + QAngle angle = VectorToQAngle(viewangles); + trace_t trace; + + sy = sinf(DEG2RAD(angle[1])); + cy = cosf(DEG2RAD(angle[1])); + sp = sinf(DEG2RAD(angle[0])); + cp = cosf(DEG2RAD(angle[0])); + forward.x = cp * cy; + forward.y = cp * sy; + forward.z = -sp; + forward = forward * distance + origin; + return forward; +} + +Vector GetForwardVector(float distance) +{ + return GetForwardVector(g_pLocalPlayer->v_Eye, g_pLocalPlayer->v_OrigViewangles, distance); +} + bool IsSentryBuster(CachedEntity *entity) { return (entity->m_Type() == EntityType::ENTITY_PLAYER && CE_INT(entity, netvar.iClass) == tf_class::tf_demoman && g_pPlayerResource->GetMaxHealth(entity) == 2500); diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp index 1966c6d8..d5175e20 100644 --- a/src/hooks/CreateMove.cpp +++ b/src/hooks/CreateMove.cpp @@ -33,19 +33,6 @@ static settings::Bool no_shake{ "visual.no-shake", "true" }; #endif class CMoveData; -#if LAGBOT_MODE -CatCommand set_value("set", "Set value", [](const CCommand &args) { - if (args.ArgC() < 2) - return; - ConVar *var = g_ICvar->FindVar(args.Arg(1)); - if (!var) - return; - std::string value(args.Arg(2)); - ReplaceString(value, "\\n", "\n"); - var->SetValue(value.c_str()); - logging::Info("Set '%s' to '%s'", args.Arg(1), value.c_str()); -}); -#endif namespace engine_prediction { @@ -101,21 +88,11 @@ void RunEnginePrediction(IClientEntity *ent, CUserCmd *ucmd) return; } } // namespace engine_prediction -#if not LAGBOT_MODE -#define antikick_time 35 -#else -#define antikick_time 90 -#endif static int attackticks = 0; namespace hooked_methods { -static HookedFunction viewangs(HookedFunctions_types::HF_CreateMove, "set_ang", 21, []() { - if (CE_BAD(LOCAL_E)) - return; - g_pLocalPlayer->v_OrigViewangles = current_user_cmd->viewangles; -}); DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUserCmd *cmd) { #define TICK_INTERVAL (g_GlobalVars->interval_per_tick) @@ -133,13 +110,11 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUs tickcount++; current_user_cmd = cmd; -#if !LAGBOT_MODE IF_GAME(IsTF2C()) { if (CE_GOOD(LOCAL_W) && minigun_jump && LOCAL_W->m_iClassID() == CL_CLASS(CTFMinigun)) CE_INT(LOCAL_W, netvar.iWeaponState) = 0; } -#endif ret = original::CreateMove(this_, input_sample_time, cmd); PROF_SECTION(CreateMove); @@ -301,13 +276,12 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUs { PROF_SECTION(CM_WRAPPER); - HookTools::CM(); + EC::RunCreateMove(); } if (CE_GOOD(g_pLocalPlayer->entity)) { if (!g_pLocalPlayer->life_state && CE_GOOD(g_pLocalPlayer->weapon())) { -#if !LAGBOT_MODE // Walkbot can leave game. if (!g_IEngine->IsInGame()) { @@ -328,12 +302,12 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUs PROF_SECTION(CM_deadringer); hacks::shared::deadringer::CreateMove(); } - if (engine_pred) - engine_prediction::RunEnginePrediction(RAW_ENT(LOCAL_E), current_user_cmd); { PROF_SECTION(CM_bunnyhop); hacks::shared::bunnyhop::CreateMove(); } + if (engine_pred) + engine_prediction::RunEnginePrediction(RAW_ENT(LOCAL_E), current_user_cmd); { PROF_SECTION(CM_backtracc); hacks::shared::backtrack::Run(); @@ -405,9 +379,7 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUs if (debug_projectiles) projectile_logging::Update(); Prediction_CreateMove(); -#endif } -#if !LAGBOT_MODE { PROF_SECTION(CM_misc); hacks::shared::misc::CreateMove(); @@ -416,27 +388,22 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUs PROF_SECTION(CM_crits); criticals::create_move(); } -#endif { PROF_SECTION(CM_spam); hacks::shared::spam::createMove(); } -#if !LAGBOT_MODE { PROF_SECTION(CM_AC); hacks::shared::anticheat::CreateMove(); } -#endif } if (time_replaced) g_GlobalVars->curtime = curtime_old; g_Settings.bInvalid = false; -#if !LAGBOT_MODE { PROF_SECTION(CM_chat_stack); chat_stack::OnCreateMove(); } -#endif // TODO Auto Steam Friend @@ -451,7 +418,6 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUs } } #endif -#if !LAGBOT_MODE hacks::shared::backtrack::UpdateIncomingSequences(); if (CE_GOOD(g_pLocalPlayer->entity)) { @@ -523,7 +489,6 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUs g_Settings.brute.choke[i].pop_front(); } } -#endif // PROF_END("CreateMove"); if (!(cmd->buttons & IN_ATTACK)) diff --git a/src/hooks/DispatchUserMessage.cpp b/src/hooks/DispatchUserMessage.cpp index 76ecdd82..99a47eaf 100644 --- a/src/hooks/DispatchUserMessage.cpp +++ b/src/hooks/DispatchUserMessage.cpp @@ -58,7 +58,26 @@ template void SplitName(std::vector &ret, const T &name, int num if (tmp.size() > 2) ret.push_back(tmp); } - +static int anti_balance_attempts = 0; +static std::string previous_name = ""; +static Timer reset_it{}; +static Timer wait_timer{}; +void Paint() +{ + if (!wait_timer.test_and_set(1000)) + return; + INetChannel *server = (INetChannel *)g_IEngine->GetNetChannelInfo(); + if (server) + reset_it.update(); + if (reset_it.test_and_set(20000)) + { + anti_balance_attempts = 0; + previous_name = ""; + } +} +static InitRoutine Autobalance([](){ + EC::Register(Paint, "paint_autobalance", EC::average); +}); DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type, bf_read &buf) { if (!isHackActive()) @@ -91,10 +110,30 @@ DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type, bf_read & case 5: if (*anti_votekick && buf.GetNumBytesLeft() > 35) { + INetChannel *server = (INetChannel *)g_IEngine->GetNetChannelInfo(); data = std::string(buf_data); logging::Info("%s", data.c_str()); if (data.find("TeamChangeP") != data.npos && CE_GOOD(LOCAL_E)) - g_IEngine->ClientCmd_Unrestricted("cat_disconnect;wait 100;cat_mm_join"); + { + std::string server_name = server->GetName(); + if (server_name != previous_name) + { + previous_name = server_name; + anti_balance_attempts = 0; + } + if (anti_balance_attempts < 2) + g_IEngine->ClientCmd_Unrestricted("cat_disconnect read if gay;wait 100;cat_mm_join"); + else + { + std::string autobalance_msg = "tf_party_chat \"autobalanced in 3 seconds"; + if (ipc::peer && ipc::peer->connected) + autobalance_msg += format(" IPC ID ", ipc::peer->client_id, "\""); + else + autobalance_msg += "\""; + g_IEngine->ClientCmd_Unrestricted(autobalance_msg.c_str()); + } + anti_balance_attempts++; + } buf.Seek(0); } break; @@ -187,7 +226,6 @@ DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type, bf_read & if (crypt_chat && message.find("!!B") == 0 && ucccccp::validate(message)) { std::string msg = ucccccp::decrypt(message); -#if !LAGBOT_MODE CachedEntity *ent = ENTITY(data[0]); if (msg != "Attempt at ucccccping and failing" && msg != "Unsupported version" && ent != LOCAL_E) { @@ -197,7 +235,6 @@ DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type, bf_read & state = playerlist::k_EState::CAT; } } -#endif PrintChat("\x07%06X%s\x01: %s", 0xe05938, name.c_str(), msg.c_str()); } chatlog::LogMessage(data[0], message); diff --git a/src/hooks/GetFriendPersonaName.cpp b/src/hooks/GetFriendPersonaName.cpp index 3edacd8c..7982b83b 100644 --- a/src/hooks/GetFriendPersonaName.cpp +++ b/src/hooks/GetFriendPersonaName.cpp @@ -128,7 +128,7 @@ const char *GetNamestealName(CSteamID steam_id) { // Return the name that has changed from the func above - return format(stolen_name, "\015").c_str(); + return format(stolen_name, "\e").c_str(); } } } @@ -171,7 +171,8 @@ static InitRoutine init([]() { }); }); static Timer set_name{}; -static HookedFunction CM(HookedFunctions_types::HF_CreateMove, "namesteal", 2, []() { +static void cm() +{ if (!namesteal) return; if (!set_name.test_and_set(500000)) @@ -187,5 +188,10 @@ static HookedFunction CM(HookedFunctions_types::HF_CreateMove, "namesteal", 2, [ setname.SetReliable(false); ch->SendNetMsg(setname, false); } +} + +static InitRoutine runinit([]() { + EC::Register(cm, "cm_namesteal", EC::late); }); + } // namespace hooked_methods diff --git a/src/hooks/HookTools.cpp b/src/hooks/HookTools.cpp index 76a619d9..92107918 100644 --- a/src/hooks/HookTools.cpp +++ b/src/hooks/HookTools.cpp @@ -1,43 +1,45 @@ -#include "HookTools.hpp" #include "common.hpp" +#include "HookTools.hpp" -std::vector &HookTools::GetHookedFunctions() +namespace EC { - static std::vector CreateMoves{}; - return CreateMoves; +// Ordered set to always keep priorities correct +std::multiset> createmoves; +#if ENABLE_VISUALS +std::multiset> draws; +#endif +std::multiset> paints; +std::multiset> levelinits; + +template inline void run(t &set) +{ + for (auto &i : set) + { +#if ENABLE_PROFILER + ProfilerNode node(i.section); +#endif + i.function(); + } } -// ----------------------------------------------------------- - -void RunHookedFunctions(HookedFunctions_types type) +void RunCreateMove() { - auto &HookedFunctions = HookTools::GetHookedFunctions(); - for (auto &i : HookedFunctions) - i->run(type); + run(createmoves); +} +#if ENABLE_VISUALS +void RunDraw() +{ + run(draws); +} +#endif +void RunPaint() +{ + run(paints); } -void HookTools::CM() +void RunLevelInit() { - RunHookedFunctions(HF_CreateMove); + run(levelinits); } -void HookTools::DRAW() -{ - RunHookedFunctions(HF_Draw); -} - -void HookTools::PAINT() -{ - RunHookedFunctions(HF_Paint); -} - -static InitRoutine init([]() { - auto &HookedFunctions = HookTools::GetHookedFunctions(); - logging::Info("Hooked Functions amount: %i", HookedFunctions.size()); - std::sort(HookedFunctions.begin(), HookedFunctions.end(), [](HookedFunction *a, HookedFunction *b) { return *a > *b; }); - logging::Info("Sorted Hooked Functions: %i", HookedFunctions.size()); -}); - -static CatCommand print("debug_print_hookedfunctions", "Print hooked functions (CreateMove, Draw, Paint)", []() { - -}); +} // namespace EC diff --git a/src/hooks/LevelInit.cpp b/src/hooks/LevelInit.cpp index 5164ec70..d54bc537 100644 --- a/src/hooks/LevelInit.cpp +++ b/src/hooks/LevelInit.cpp @@ -22,15 +22,11 @@ namespace hooked_methods DEFINE_HOOKED_METHOD(LevelInit, void, void *this_, const char *name) { -#if !LAGBOT_MODE hacks::shared::backtrack::lastincomingsequencenumber = 0; hacks::shared::backtrack::sequences.clear(); -#endif firstcm = true; // nav::init = false; -#if !LAGBOT_MODE playerlist::Save(); -#endif #if ENABLE_VISUALS #if ENABLE_GUI gui::onLevelLoad(); @@ -55,14 +51,13 @@ DEFINE_HOOKED_METHOD(LevelInit, void, void *this_, const char *name) for (int i = 0; i < 32; i++) g_Settings.brute.brutenum[i] = 0; g_IEngine->ClientCmd_Unrestricted("exec cat_matchexec"); -#if !LAGBOT_MODE hacks::shared::aimbot::Reset(); hacks::shared::backtrack::Init(); chat_stack::Reset(); hacks::shared::anticheat::ResetEverything(); original::LevelInit(this_, name); hacks::shared::walkbot::OnLevelInit(); -#endif + EC::RunLevelInit(); #if ENABLE_IPC if (ipc::peer) { diff --git a/src/hooks/LevelShutdown.cpp b/src/hooks/LevelShutdown.cpp index 9759e204..55aa7a96 100644 --- a/src/hooks/LevelShutdown.cpp +++ b/src/hooks/LevelShutdown.cpp @@ -13,15 +13,11 @@ namespace hooked_methods DEFINE_HOOKED_METHOD(LevelShutdown, void, void *this_) { need_name_change = true; -#if !LAGBOT_MODE playerlist::Save(); -#endif g_Settings.bInvalid = true; -#if !LAGBOT_MODE hacks::shared::aimbot::Reset(); chat_stack::Reset(); hacks::shared::anticheat::ResetEverything(); -#endif #if ENABLE_IPC if (ipc::peer) { diff --git a/src/hooks/Paint.cpp b/src/hooks/Paint.cpp index 175190de..24f6873e 100644 --- a/src/hooks/Paint.cpp +++ b/src/hooks/Paint.cpp @@ -24,9 +24,7 @@ DEFINE_HOOKED_METHOD(Paint, void, IEngineVGui *this_, PaintMode_t mode) if (mode & PaintMode_t::PAINT_UIPANELS) { -#if not LAGBOT_MODE hacks::tf2::killstreak::apply_killstreaks(); -#endif hacks::shared::catbot::update(); hitrate::Update(); #if ENABLE_ONLINE @@ -91,7 +89,7 @@ DEFINE_HOOKED_METHOD(Paint, void, IEngineVGui *this_, PaintMode_t mode) render_cheat_visuals(); #endif // Call all paint functions - HookTools::PAINT(); + EC::RunPaint(); } return original::Paint(this_, mode); diff --git a/src/hooks/SendDatagram.cpp b/src/hooks/SendDatagram.cpp index dfc0c616..0c821475 100644 --- a/src/hooks/SendDatagram.cpp +++ b/src/hooks/SendDatagram.cpp @@ -12,7 +12,6 @@ DEFINE_HOOKED_METHOD(SendDatagram, int, INetChannel *ch, bf_write *buf) { if (!round(hacks::shared::backtrack::getLatency())) return original::SendDatagram(ch, buf); -#if !LAGBOT_MODE int in = 0; int state = 0; if (CE_GOOD(LOCAL_E) && ch) @@ -23,17 +22,13 @@ DEFINE_HOOKED_METHOD(SendDatagram, int, INetChannel *ch, bf_write *buf) float latencysend = round((round((hacks::shared::backtrack::getLatency() - 0.5f) / 15.1515151515f) - 0.5f) * 15.1515151515f); hacks::shared::backtrack::AddLatencyToNetchan(ch, latencysend); } -#endif int ret = original::SendDatagram(ch, buf); -#if !LAGBOT_MODE if (CE_GOOD(LOCAL_E) && ch) { ch->m_nInSequenceNr = in; ch->m_nInReliableState = state; } - -#endif return ret; } } // namespace hooked_methods diff --git a/src/hooks/visual/FrameStageNotify.cpp b/src/hooks/visual/FrameStageNotify.cpp index 9ccff69b..3048a207 100644 --- a/src/hooks/visual/FrameStageNotify.cpp +++ b/src/hooks/visual/FrameStageNotify.cpp @@ -8,9 +8,7 @@ #include #include #include "HookedMethods.hpp" -#if not LAGBOT_MODE #include "hacks/Backtrack.hpp" -#endif static settings::Float nightmode{ "visual.night-mode", "0" }; static settings::Bool no_shake{ "visual.no-shake", "true" }; diff --git a/src/hoovy.cpp b/src/hoovy.cpp index 177b0098..9c695b92 100644 --- a/src/hoovy.cpp +++ b/src/hoovy.cpp @@ -37,7 +37,7 @@ bool IsHoovyHelper(CachedEntity *entity) return false; } -static HookedFunction UpdateHoovyList(HookedFunctions_types::HF_CreateMove, "HoovyList", 19, []() { +void UpdateHoovyList() { if (CE_BAD(LOCAL_E)) return; @@ -59,7 +59,7 @@ static HookedFunction UpdateHoovyList(HookedFunctions_types::HF_CreateMove, "Hoo } } } -}); +} bool IsHoovy(CachedEntity *entity) { @@ -67,3 +67,5 @@ bool IsHoovy(CachedEntity *entity) return false; return hoovy_list[entity->m_IDX - 1]; } + +static InitRoutine init([](){EC::Register(UpdateHoovyList, "cm_hoovylist", EC::average);}); diff --git a/src/irc.cpp b/src/irc.cpp index ec28af26..40b7ba39 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -301,7 +301,7 @@ int GetMaxParty() CatCommand debug_maxparty("debug_partysize", "Debug party size", []() { logging::Info("%d", GetMaxParty()); }); static Timer resize_party{}; -static HookedFunction paint(HookedFunctions_types::HF_Paint, "IRC", 16, []() { +static void run() { if (!restarting) { auto party_client = re::CTFPartyClient::GTFPartyClient(); @@ -374,7 +374,7 @@ static HookedFunction paint(HookedFunctions_types::HF_Paint, "IRC", 16, []() { irc.setState(state); } } -}); +} template void rvarCallback(settings::VariableBase &var, T after) { @@ -394,6 +394,7 @@ template void rvarCallback(settings::VariableBase &var, T after) } static InitRoutine init([]() { + EC::Register(run, "PAINT_irc", EC::average); updateData(); enabled.installChangeCallback(rvarCallback); anon.installChangeCallback(rvarCallback); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index a0cdcae9..54bca089 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -32,26 +32,38 @@ weaponmode GetWeaponModeloc() if (slot == 2) return weaponmode::weapon_melee; if (slot > 2) - { return weaponmode::weapon_pda; - } - else if (classid == CL_CLASS(CTFLunchBox) || classid == CL_CLASS(CTFLunchBox_Drink) || classid == CL_CLASS(CTFBuffItem)) + switch (classid) { + case CL_CLASS(CTFLunchBox): + case CL_CLASS(CTFLunchBox_Drink): + case CL_CLASS(CTFBuffItem): return weaponmode::weapon_consumable; - } - else if (classid == CL_CLASS(CTFRocketLauncher_DirectHit) || classid == CL_CLASS(CTFRocketLauncher) || classid == CL_CLASS(CTFGrenadeLauncher) || classid == CL_CLASS(CTFPipebombLauncher) || classid == CL_CLASS(CTFCompoundBow) || classid == CL_CLASS(CTFBat_Wood) || classid == CL_CLASS(CTFBat_Giftwrap) || classid == CL_CLASS(CTFFlareGun) || classid == CL_CLASS(CTFFlareGun_Revenge) || classid == CL_CLASS(CTFSyringeGun) || classid == CL_CLASS(CTFCrossbow) || classid == CL_CLASS(CTFShotgunBuildingRescue) || classid == CL_CLASS(CTFDRGPomson) || classid == CL_CLASS(CTFWeaponFlameBall) || classid == CL_CLASS(CTFRaygun) || classid == CL_CLASS(CTFGrapplingHook)) - { + case CL_CLASS(CTFRocketLauncher_DirectHit): + case CL_CLASS(CTFRocketLauncher): + case CL_CLASS(CTFGrenadeLauncher): + case CL_CLASS(CTFPipebombLauncher): + case CL_CLASS(CTFCompoundBow): + case CL_CLASS(CTFBat_Wood): + case CL_CLASS(CTFBat_Giftwrap): + case CL_CLASS(CTFFlareGun): + case CL_CLASS(CTFFlareGun_Revenge): + case CL_CLASS(CTFSyringeGun): + case CL_CLASS(CTFCrossbow): + case CL_CLASS(CTFShotgunBuildingRescue): + case CL_CLASS(CTFDRGPomson): + case CL_CLASS(CTFWeaponFlameBall): + case CL_CLASS(CTFRaygun): + case CL_CLASS(CTFGrapplingHook): return weaponmode::weapon_projectile; - } - else if (classid == CL_CLASS(CTFJar) || classid == CL_CLASS(CTFJarMilk)) - { + case CL_CLASS(CTFJar): + case CL_CLASS(CTFJarMilk): return weaponmode::weapon_throwable; - } - else if (classid == CL_CLASS(CWeaponMedigun)) - { + case CL_CLASS(CWeaponMedigun): return weaponmode::weapon_medigun; + default: + return weaponmode::weapon_hitscan; } - return weaponmode::weapon_hitscan; } void LocalPlayer::Update() { @@ -79,6 +91,7 @@ void LocalPlayer::Update() life_state = CE_BYTE(entity, netvar.iLifeState); v_ViewOffset = CE_VECTOR(entity, netvar.vViewOffset); v_Origin = entity->m_vecOrigin(); + v_OrigViewangles = current_user_cmd->viewangles; v_Eye = v_Origin + v_ViewOffset; clazz = CE_INT(entity, netvar.iClass); health = CE_INT(entity, netvar.iHealth); diff --git a/src/navparser.cpp b/src/navparser.cpp index a2065d34..9aa560ae 100644 --- a/src/navparser.cpp +++ b/src/navparser.cpp @@ -563,7 +563,8 @@ void repath() static Timer last_jump{}; // Main movement function, gets path from NavTo -static HookedFunction CreateMove(HookedFunctions_types::HF_CreateMove, "NavParser", 17, []() { +static void cm() +{ if (!enabled || status != on) return; if (CE_BAD(LOCAL_E) || CE_BAD(LOCAL_W)) @@ -616,10 +617,11 @@ static HookedFunction CreateMove(HookedFunctions_types::HF_CreateMove, "NavParse } // Walk to next crumb WalkTo(crumbs.at(0)); -}); +} #if ENABLE_VISUALS -static HookedFunction drawcrumbs(HF_Draw, "navparser", 10, []() { +static void drawcrumbs() +{ if (!enabled || !draw) return; if (!enabled) @@ -643,9 +645,16 @@ static HookedFunction drawcrumbs(HF_Draw, "navparser", 10, []() { return; glez::draw::rect(wts.x - 4, wts.y - 4, 8, 8, colors::white); glez::draw::rect_outline(wts.x - 4, wts.y - 4, 7, 7, colors::white, 1.0f); -}); +} #endif +static InitRoutine runinit([]() { + EC::Register(cm, "cm_navparser", EC::late); +#if ENABLE_VISUALS + EC::Register(cm, "cm_navparser", EC::average); +#endif +}); + void ResetPather() { Map.pather->Reset(); diff --git a/src/visual/EffectChams.cpp b/src/visual/EffectChams.cpp index 614a029c..f2cf7f60 100644 --- a/src/visual/EffectChams.cpp +++ b/src/visual/EffectChams.cpp @@ -35,8 +35,11 @@ CatCommand fix_black_chams("fix_black_chams", "Fix Black Chams", []() { effect_chams::g_EffectChams.Shutdown(); effect_chams::g_EffectChams.Init(); }); + void EffectChams::Init() { + if (init) + return; logging::Info("Init EffectChams..."); { KeyValues *kv = new KeyValues("UnlitGeneric"); @@ -330,6 +333,8 @@ void EffectChams::Render(int x, int y, int w, int h) return; if (!enable) return; + if (g_Settings.bInvalid) + return; if (!init) Init(); if (!isHackActive() || (g_IEngine->IsTakingScreenshot() && clean_screenshots)) diff --git a/src/visual/EffectGlow.cpp b/src/visual/EffectGlow.cpp index 59c870b9..c1111964 100644 --- a/src/visual/EffectGlow.cpp +++ b/src/visual/EffectGlow.cpp @@ -129,6 +129,8 @@ CatCommand fix_black_glow("fix_black_glow", "Fix Black Glow", []() { void EffectGlow::Init() { + if (init) + return; logging::Info("Init Glow..."); { KeyValues *kv = new KeyValues("UnlitGeneric"); diff --git a/src/visual/SDLHooks.cpp b/src/visual/SDLHooks.cpp index 9b74b7a1..83d2cc3a 100644 --- a/src/visual/SDLHooks.cpp +++ b/src/visual/SDLHooks.cpp @@ -33,5 +33,6 @@ void applySdlHooks() void cleanSdlHooks() { *pointers::SDL_GL_SwapWindow = hooked_methods::original::SDL_GL_SwapWindow; + *pointers::SDL_PollEvent = hooked_methods::original::SDL_PollEvent; } -} // namespace sdl_hooks \ No newline at end of file +} // namespace sdl_hooks diff --git a/src/visual/drawmgr.cpp b/src/visual/drawmgr.cpp index 5345fa80..ae725dc0 100644 --- a/src/visual/drawmgr.cpp +++ b/src/visual/drawmgr.cpp @@ -60,8 +60,8 @@ std::mutex drawing_mutex; struct snowflake { - Vector2D pos; - Vector2D angle; + Vector2D pos{}; + Vector2D angle{}; }; double getRandom(double lower_bound, double upper_bound) @@ -88,7 +88,7 @@ void DrawCheatVisuals() { PROF_SECTION(DRAW_SNOWFLAKES); - if (zerokernel::Menu::instance && !zerokernel::Menu::instance->isInGame()) + if (zerokernel::Menu::instance && !zerokernel::Menu::instance->isInGame() && *draw_snowflakes) { // used to count current vector index int idx = 0; @@ -103,7 +103,7 @@ void DrawCheatVisuals() { flake.pos += flake.angle; - // Get a new value so the snowflakes look a bit more natural, don#t dip below min/go above max. + // Get a new value so the snowflakes look a bit more natural, don't dip below min/go above max. float rand_down_min = fminf(*snowflake_min_down, flake.angle.y - 0.01f); float rand_down_max = fmaxf(*snowflake_max_down, flake.angle.x + 0.01f); float rand_side_min = fminf(*snowflake_min_side, flake.angle.x - 0.01f); @@ -183,7 +183,7 @@ void DrawCheatVisuals() } { PROF_SECTION(DRAW_WRAPPER); - HookTools::DRAW(); + EC::RunDraw(); } if (CE_GOOD(g_pLocalPlayer->entity) && !g_Settings.bInvalid) { @@ -214,11 +214,6 @@ void DrawCheatVisuals() PROF_SECTION(DRAW_backtracc); hacks::shared::backtrack::Draw(); } - IF_GAME(IsTF2()) - { - PROF_SECTION(DRAW_lightesp); - hacks::shared::lightesp::draw(); - } { PROF_SECTION(DRAW_walkbot); hacks::shared::walkbot::Draw(); @@ -233,15 +228,10 @@ void DrawCheatVisuals() PROF_SECTION(PT_spyalert); hacks::tf::spyalert::Draw(); } - { - PROF_SECTION(DRAW_esp); - hacks::shared::esp::Draw(); - } IF_GAME(IsTF2()) { criticals::draw(); } - hacks::tf2::autobackstab::Draw(); #ifndef FEATURE_FIDGET_SPINNER_ENABLED DrawSpinner(); #endif