From 5f78c68a767c5b0652abbd9dbe4e9a3b31bf08ce Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Thu, 27 Jul 2017 19:42:18 +0300 Subject: [PATCH] close #226 --- src/hack.cpp | 17 ++++++++++------- src/hacks/Aimbot.cpp | 4 ++-- src/hacks/AutoTaunt.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/hacks/AutoTaunt.hpp | 20 ++++++++++++++++++++ src/init.cpp | 17 +++++++++++++++++ src/init.hpp | 19 +++++++++++++++++++ 6 files changed, 106 insertions(+), 9 deletions(-) create mode 100644 src/hacks/AutoTaunt.cpp create mode 100644 src/hacks/AutoTaunt.hpp create mode 100644 src/init.cpp create mode 100644 src/init.hpp diff --git a/src/hack.cpp b/src/hack.cpp index 1a4899f3..56551bdc 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -42,6 +42,7 @@ #include "ftrender.hpp" #include "hooks/hookedmethods.h" +#include "init.hpp" #include "sdk.h" #include "vfunc.h" @@ -140,18 +141,13 @@ void hack::ExecuteCommand(const std::string command) { hack::command_stack().push(command); } + ConCommand* hack::c_Cat = 0; void hack::CC_Cat(const CCommand& args) { - g_ICvar->ConsoleColorPrintf(Color(255, 255, 255, 255), "kathook"); + g_ICvar->ConsoleColorPrintf(Color(255, 255, 255, 255), "cathook"); g_ICvar->ConsoleColorPrintf(Color( 0, 0, 255, 255), " by "); g_ICvar->ConsoleColorPrintf(Color(255, 0, 0, 255), "nullifiedcat\n"); - /*int white = colors::white, blu = colors::blu, red = colors::red; - g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&white), "kathook"); - g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&blu), " by "); - g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&red), "nullifiedcat\n"); - g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&white), GetVersion().c_str()); - g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&white), "\n");*/ } void hack::Initialize() { @@ -294,6 +290,13 @@ void hack::Initialize() { backpacktf::init(); logging::Info("Initialized Backpack.TF integration"); hacks::shared::walkbot::Initialize(); + + logging::Info("Clearing initializer stack"); + while (!init_stack().empty()) { + init_stack().top()(); + init_stack().pop(); + } + logging::Info("Initializer stack done"); } void hack::Think() { diff --git a/src/hacks/Aimbot.cpp b/src/hacks/Aimbot.cpp index 694603f2..14d779dd 100644 --- a/src/hacks/Aimbot.cpp +++ b/src/hacks/Aimbot.cpp @@ -812,8 +812,8 @@ void slowAim(Vector &inputAngle, Vector userAngle) { // Initialize vars for slow aim int slowfliptype; int slowdir; - float changey; - float changex; + float changey = 0; + float changex = 0; // Determine whether to move the mouse at all for the yaw if (userAngle.y != inputAngle.y) { diff --git a/src/hacks/AutoTaunt.cpp b/src/hacks/AutoTaunt.cpp new file mode 100644 index 00000000..ac0001f3 --- /dev/null +++ b/src/hacks/AutoTaunt.cpp @@ -0,0 +1,38 @@ +/* + * AutoTaunt.cpp + * + * Created on: Jul 27, 2017 + * Author: nullifiedcat + */ + +#include "../common.h" +#include "../init.hpp" +#include "../hack.h" + +namespace hacks { namespace tf { namespace autotaunt { + +CatVar enabled(CV_SWITCH, "autotaunt", "0", "AutoTaunt", "Automatically taunt after killing an enemy, use with walkbots I guess"); +CatVar chance(CV_FLOAT, "autotaunt_chance", "8", "AutoTaunt chance", "Chance of taunting after kill. 0 to 100.", 0.0f, 100.0f); + +class AutoTauntListener : public IGameEventListener2 { +public: + virtual void FireGameEvent(IGameEvent* event) { + if (!enabled) { + return; + } + if (g_IEngine->GetPlayerForUserID(event->GetInt("attacker")) == g_IEngine->GetLocalPlayer()) { + if (RandomFloat(0, 100) <= float(chance)) { + hack::ExecuteCommand("taunt"); + } + } + } +}; + +AutoTauntListener listener; + +// TODO remove event listener when uninjecting? +InitRoutine init([]() { + g_IEventManager2->AddListener(&listener, "player_death", false); +}); + +}}} diff --git a/src/hacks/AutoTaunt.hpp b/src/hacks/AutoTaunt.hpp new file mode 100644 index 00000000..b8aad8c6 --- /dev/null +++ b/src/hacks/AutoTaunt.hpp @@ -0,0 +1,20 @@ +/* + * AutoTaunt.hpp + * + * Created on: Jul 27, 2017 + * Author: nullifiedcat + */ + +#pragma once + +class CatVar; +class InitRoutine; + +namespace hacks { namespace tf { namespace autotaunt { + +extern CatVar enabled; +extern CatVar chance; + +extern InitRoutine init; + +}}} diff --git a/src/init.cpp b/src/init.cpp new file mode 100644 index 00000000..0f6516c9 --- /dev/null +++ b/src/init.cpp @@ -0,0 +1,17 @@ +/* + * init.cpp + * + * Created on: Jul 27, 2017 + * Author: nullifiedcat + */ + +#include "init.hpp" + +std::stack& init_stack() { + static std::stack stack; + return stack; +} + +InitRoutine::InitRoutine(void(*func)()) { + init_stack().push(func); +} diff --git a/src/init.hpp b/src/init.hpp new file mode 100644 index 00000000..92f6469f --- /dev/null +++ b/src/init.hpp @@ -0,0 +1,19 @@ +/* + * init.hpp + * + * Created on: Jul 27, 2017 + * Author: nullifiedcat + */ + +#pragma once + +#include "beforecheaders.h" +#include +#include "aftercheaders.h" + +std::stack& init_stack(); + +class InitRoutine { +public: + InitRoutine(void(*func)()); +};