This commit is contained in:
nullifiedcat 2017-07-27 19:42:18 +03:00
parent 85a10ee8c7
commit 5f78c68a76
6 changed files with 106 additions and 9 deletions

View File

@ -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<Color*>(&white), "kathook");
g_ICvar->ConsoleColorPrintf(*reinterpret_cast<Color*>(&blu), " by ");
g_ICvar->ConsoleColorPrintf(*reinterpret_cast<Color*>(&red), "nullifiedcat\n");
g_ICvar->ConsoleColorPrintf(*reinterpret_cast<Color*>(&white), GetVersion().c_str());
g_ICvar->ConsoleColorPrintf(*reinterpret_cast<Color*>(&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() {

View File

@ -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) {

38
src/hacks/AutoTaunt.cpp Normal file
View File

@ -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);
});
}}}

20
src/hacks/AutoTaunt.hpp Normal file
View File

@ -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;
}}}

17
src/init.cpp Normal file
View File

@ -0,0 +1,17 @@
/*
* init.cpp
*
* Created on: Jul 27, 2017
* Author: nullifiedcat
*/
#include "init.hpp"
std::stack<void(*)()>& init_stack() {
static std::stack<void(*)()> stack;
return stack;
}
InitRoutine::InitRoutine(void(*func)()) {
init_stack().push(func);
}

19
src/init.hpp Normal file
View File

@ -0,0 +1,19 @@
/*
* init.hpp
*
* Created on: Jul 27, 2017
* Author: nullifiedcat
*/
#pragma once
#include "beforecheaders.h"
#include <stack>
#include "aftercheaders.h"
std::stack<void(*)()>& init_stack();
class InitRoutine {
public:
InitRoutine(void(*func)());
};