From 9d13e787b696217b42064b67feaa99c21196310c Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Fri, 14 Jul 2017 20:47:27 +0300 Subject: [PATCH 1/4] custom spam/killsay files automatically reload. fix imgui int for some catvars --- src/gui/im/Im.cpp | 1 + src/hack.cpp | 1 + src/hacks/KillSay.cpp | 3 +++ src/hacks/Spam.cpp | 6 ++++++ src/hacks/Spam.h | 1 + src/textfile.cpp | 16 ++++++++++++++++ src/textfile.h | 1 + 7 files changed, 29 insertions(+) diff --git a/src/gui/im/Im.cpp b/src/gui/im/Im.cpp index c3ce75d6..b6131498 100644 --- a/src/gui/im/Im.cpp +++ b/src/gui/im/Im.cpp @@ -31,6 +31,7 @@ void CatVar_Integer(CatVar& var) { int value = var; ImGui::PushItemWidth(120.0f); int step = var.restricted ? (var.max - var.min) / 50 : 1; + if (step == 0) step = 1; if (ImGui::InputInt(label, &value, step, step * 20)) { var = value; } diff --git a/src/hack.cpp b/src/hack.cpp index 3746fbca..87e29fdf 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -272,6 +272,7 @@ void hack::Initialize() { hacks::shared::anticheat::Init(); hacks::tf2::healarrow::Init(); InitSpinner(); + hacks::shared::spam::Init(); logging::Info("Initialized Fidget Spinner"); } diff --git a/src/hacks/KillSay.cpp b/src/hacks/KillSay.cpp index 18c9e128..8ec75c48 100644 --- a/src/hacks/KillSay.cpp +++ b/src/hacks/KillSay.cpp @@ -82,6 +82,9 @@ void Reload() { void Init() { g_IEventManager2->AddListener(&getListener(), (const char*)"player_death", false); + filename.InstallChangeCallback([](IConVar* var, const char* pszOV, float flOV) { + file.TryLoad(std::string(filename.GetString())); + }); } void Shutdown() { diff --git a/src/hacks/Spam.cpp b/src/hacks/Spam.cpp index bc53e301..b56798d2 100644 --- a/src/hacks/Spam.cpp +++ b/src/hacks/Spam.cpp @@ -137,6 +137,12 @@ int QueryPlayer(Query query) { return index_result; } +void Init() { + filename.InstallChangeCallback([](IConVar* var, const char* pszOV, float flOV) { + file.TryLoad(std::string(filename.GetString())); + }); +} + bool SubstituteQueries(std::string& input) { size_t index = input.find("%query:"); while (index != std::string::npos) { diff --git a/src/hacks/Spam.h b/src/hacks/Spam.h index f32375ee..bab2173a 100644 --- a/src/hacks/Spam.h +++ b/src/hacks/Spam.h @@ -25,6 +25,7 @@ extern CatVar enabled; extern CatVar filename; extern CatCommand reload; +void Init(); void CreateMove(); void Reset(); void Reload(); diff --git a/src/textfile.cpp b/src/textfile.cpp index 0499c562..28c1b7d2 100644 --- a/src/textfile.cpp +++ b/src/textfile.cpp @@ -18,6 +18,21 @@ TextFile::TextFile() : lines {} {} +bool TextFile::TryLoad(std::string name) { + if (name.length() == 0) return false; + std::string filename = format("cathook/", name); + std::ifstream file(filename, std::ios::in); + if (!file) { + return false; + } + lines.clear(); + for (std::string line; std::getline(file, line);) { + if (*line.rbegin() == '\r') line.erase(line.length() - 1, 1); + lines.push_back(line); + } + return true; +} + void TextFile::Load(std::string name) { std::string filename = format("cathook/", name); std::ifstream file(filename, std::ios::in); @@ -27,6 +42,7 @@ void TextFile::Load(std::string name) { } lines.clear(); for (std::string line; std::getline(file, line);) { + if (*line.rbegin() == '\r') line.erase(line.length() - 1, 1); lines.push_back(line); } } diff --git a/src/textfile.h b/src/textfile.h index 29ee7523..e9df7356 100644 --- a/src/textfile.h +++ b/src/textfile.h @@ -17,6 +17,7 @@ class TextFile { public: TextFile(); void Load(std::string filename); + bool TryLoad(std::string filename); size_t LineCount() const; const std::string& Line(size_t id) const; public: From b42afe7feb253d876b68eb694618692c80781717 Mon Sep 17 00:00:00 2001 From: julianacat Date: Fri, 14 Jul 2017 19:22:07 -0500 Subject: [PATCH 2/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a32d4f0f..5ebd583f 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ and a lot of useful features, including Ubuntu dependencies installation: ```bash -sudo apt update && sudo apt install build-essential software-properties-common -y && sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt update && sudo apt install gcc-snapshot -y && sudo apt update && sudo apt install git libc6-dev gcc-6 g++-6 libc6-dev:i386 g++-6-multilib gdb libsdl2-dev libglew-dev libfreetype6-dev libfreetype6-dev:i386 -y && +sudo apt update && sudo apt install build-essential software-properties-common -y && sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt update && sudo apt install gcc-snapshot -y && sudo apt update && sudo apt install git libc6-dev gcc-6 g++-6 libc6-dev:i386 g++-6-multilib gdb libsdl2-dev libglew-dev libfreetype6-dev libfreetype6-dev:i386 -y ``` From 133830a1c61209edd128080b56f95da0c6c316ec Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Sat, 15 Jul 2017 14:38:13 +0300 Subject: [PATCH 3/4] AutoReflect key + experimental cat_nolerp --- src/hacks/AutoReflect.cpp | 3 ++- src/hooks/CreateMove.cpp | 37 ++++++++++++++++--------------------- tf-settings/menu.json | 3 ++- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/hacks/AutoReflect.cpp b/src/hacks/AutoReflect.cpp index 5c241dd2..1a6a88eb 100644 --- a/src/hacks/AutoReflect.cpp +++ b/src/hacks/AutoReflect.cpp @@ -17,7 +17,7 @@ CatVar enabled(CV_SWITCH, "reflect_enabled", "0", "Auto Reflect", "Master AutoRe CatVar idle_only(CV_SWITCH, "reflect_only_idle", "0", "Only when not shooting", "Don't AutoReflect if you're holding M1"); CatVar legit(CV_SWITCH, "reflect_legit", "0", "Legit Reflect", "Only Auto-airblasts projectiles that you can see, doesnt move your crosshair"); CatVar dodgeball(CV_SWITCH, "reflect_dodgeball", "0", "Dodgeball Mode", "Allows auto-reflect to work in dodgeball servers"); - +CatVar blastkey(CV_KEY, "reflect_key", "0", "Reflect Key", "Hold this key to activate auto-airblast"); CatVar stickies(CV_SWITCH, "reflect_stickybombs", "0", "Reflect stickies", "Reflect Stickybombs"); // TODO setup proj sorting // TODO CatVar big_proj(CV_SWITCH, "reflect_big_projectile", "0", "Reflect big projectiles", "Reflect Rockets"); @@ -29,6 +29,7 @@ CatVar stickies(CV_SWITCH, "reflect_stickybombs", "0", "Reflect stickies", "Refl void CreateMove() { // Check if user settings allow Auto Reflect if (!enabled) return; + if (blastkey && !blastkey.KeyDown()) return; // Check if player is using a flame thrower if (g_pLocalPlayer->weapon()->m_iClassID != CL_CLASS(CTFFlameThrower)) return; diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp index 24e88a22..94d94b1e 100644 --- a/src/hooks/CreateMove.cpp +++ b/src/hooks/CreateMove.cpp @@ -13,25 +13,6 @@ #include "hookedmethods.h" #include -// FIXME remove this temporary code already! -float AngleDiff( float destAngle, float srcAngle ) -{ - float delta; - - delta = fmodf(destAngle - srcAngle, 360.0f); - if ( destAngle > srcAngle ) - { - if ( delta >= 180 ) - delta -= 360; - } - else - { - if ( delta <= -180 ) - delta += 360; - } - return delta; -} - #include "../profiler.h" static CatVar minigun_jump(CV_SWITCH, "minigun_jump", "0", "TF2C minigun jump", "Allows jumping while shooting with minigun"); @@ -39,6 +20,8 @@ static CatVar minigun_jump(CV_SWITCH, "minigun_jump", "0", "TF2C minigun jump", CatVar jointeam(CV_SWITCH, "fb_autoteam", "1", "Joins player team automatically (NYI)"); CatVar joinclass(CV_STRING, "fb_autoclass", "spy", "Class that will be picked after joining a team (NYI)"); +CatVar nolerp(CV_SWITCH, "nolerp", "0", "NoLerp mode (experimental)"); + class CMoveData; namespace engine_prediction { @@ -180,6 +163,17 @@ bool CreateMove_hook(void* thisptr, float inputSample, CUserCmd* cmd) { time_replaced = false; curtime_old = g_GlobalVars->curtime; + static ConVar* sv_client_min_interp_ratio = g_ICvar->FindVar("sv_client_min_interp_ratio"); + static ConVar* cl_interp = g_ICvar->FindVar("cl_interp"); + static ConVar* cl_interp_ratio = g_ICvar->FindVar("cl_interp_ratio"); + + if (nolerp) { + g_pUserCmd->tick_count += 1; + if (sv_client_min_interp_ratio->GetInt() != -1) sv_client_min_interp_ratio->SetValue(-1); + if (cl_interp->GetInt() != 0) cl_interp->SetValue(0); + if (cl_interp_ratio->GetInt() != 0) cl_interp_ratio->SetValue(0); + } + if (!g_Settings.bInvalid && CE_GOOD(g_pLocalPlayer->entity)) { servertime = (float)CE_INT(g_pLocalPlayer->entity, netvar.nTickBase) * g_GlobalVars->interval_per_tick; g_GlobalVars->curtime = servertime; @@ -188,6 +182,9 @@ bool CreateMove_hook(void* thisptr, float inputSample, CUserCmd* cmd) { if (g_Settings.bInvalid) { entity_cache::Invalidate(); } + + // Disabled because this causes EXTREME aimbot inaccuracy + //if (!cmd->command_number) return ret; // PROF_BEGIN(); { PROF_SECTION(EntityCache); @@ -203,8 +200,6 @@ bool CreateMove_hook(void* thisptr, float inputSample, CUserCmd* cmd) { SAFE_CALL(g_pLocalPlayer->Update()); } g_Settings.bInvalid = false; - // Disabled because this causes EXTREME aimbot inaccuracy - //if (!cmd->command_number) return ret; #ifdef IPC_ENABLED static int team_joining_state = 0; static float last_jointeam_try = 0; diff --git a/tf-settings/menu.json b/tf-settings/menu.json index 6a8797c9..06bf6625 100644 --- a/tf-settings/menu.json +++ b/tf-settings/menu.json @@ -113,7 +113,8 @@ "reflect_legit", "reflect_only_idle", "reflect_stickybombs", - "reflect_dodgeball" + "reflect_dodgeball", + "reflect_key" ] }, { From 390f499ffe9689356263175c0f79ab4324341ef1 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Sat, 15 Jul 2017 16:38:10 +0300 Subject: [PATCH 4/4] fix crash when changing thirdperson settings in menu --- src/globals.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals.cpp b/src/globals.cpp index f9505348..4900541c 100644 --- a/src/globals.cpp +++ b/src/globals.cpp @@ -14,7 +14,7 @@ int g_AppID = 0; void ThirdpersonCallback(IConVar* var, const char* pOldValue, float flOldValue) { if (force_thirdperson.convar_parent && !force_thirdperson) { - if (g_pLocalPlayer && g_pLocalPlayer->entity) + if (g_pLocalPlayer && CE_GOOD(g_pLocalPlayer->entity)) CE_INT(g_pLocalPlayer->entity, netvar.nForceTauntCam) = 0; } }