refactoring

This commit is contained in:
nullifiedcat 2018-07-29 12:58:03 +03:00
parent b670d24700
commit bf6c8d8fdc
33 changed files with 326 additions and 392 deletions

View File

@ -56,7 +56,6 @@
#include <visual/atlas.hpp> #include <visual/atlas.hpp>
#include <visual/EffectChams.hpp> #include <visual/EffectChams.hpp>
#include <visual/drawmgr.hpp> #include <visual/drawmgr.hpp>
#include "visual/menu/compatlayer.hpp"
#endif #endif
#include "core/profiler.hpp" #include "core/profiler.hpp"
@ -104,7 +103,7 @@
#include "copypasted/CSignature.h" #include "copypasted/CSignature.h"
#if ENABLE_GUI #if ENABLE_GUI
#include "visual/menu/GUI.h" // FIXME add gui
#endif #endif
#include <core/sdk.hpp> #include <core/sdk.hpp>

View File

@ -9,8 +9,6 @@
#include <stdio.h> #include <stdio.h>
typedef void(fn_Msg_t)(const char *msg, va_list);
#ifdef __cplusplus #ifdef __cplusplus
namespace logging namespace logging
{ {

View File

@ -8,7 +8,10 @@
#pragma once #pragma once
#include <boost/circular_buffer.hpp> #include <boost/circular_buffer.hpp>
#include <time.h> #include <time.h>
#include <mathlib/vector.h>
class Vector; class Vector;
class CUserCmd;
class ConVar; class ConVar;
extern int g_AppID; extern int g_AppID;
@ -43,7 +46,8 @@ public:
brutestruct brute; brutestruct brute;
}; };
class CUserCmd; bool isHackActive();
extern CUserCmd *g_pUserCmd;
extern CUserCmd *current_user_cmd;
extern GlobalSettings g_Settings; extern GlobalSettings g_Settings;

View File

@ -11,7 +11,7 @@
namespace hacks::tf::autoheal namespace hacks::tf::autoheal
{ {
// TODO extern CatVar target_only;
void CreateMove(); void CreateMove();
struct patient_data_s struct patient_data_s

View File

@ -42,6 +42,7 @@ target_sources(cathook PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/ESP.hpp" "${CMAKE_CURRENT_LIST_DIR}/ESP.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Radar.hpp" "${CMAKE_CURRENT_LIST_DIR}/Radar.hpp"
"${CMAKE_CURRENT_LIST_DIR}/SkinChanger.hpp" "${CMAKE_CURRENT_LIST_DIR}/SkinChanger.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Thirdperson.hpp"
"${CMAKE_CURRENT_LIST_DIR}/SpyAlert.hpp") "${CMAKE_CURRENT_LIST_DIR}/SpyAlert.hpp")
endif() endif()

View File

@ -22,50 +22,3 @@ extern int last_number;
extern float last_bucket; extern float last_bucket;
} }
/*class Misc : public IHack {
public:
Misc();
virtual void ProcessUserCmd(CUserCmd*) override;
virtual void Draw() override;
CatVar* v_bDebugInfo;
ConCommand* c_Name;
ConVar* v_bInfoSpam;
ConVar* v_bFastCrouch;
CatVar* v_bFlashlightSpam;
CatVar* v_bMinigunJump; // TF2C
CatVar* v_bDebugCrits; // TF2C
CatVar* v_bAntiAFK;
CatVar* v_bHookInspect;
CatVar* v_iFakeLag;
CatVar* v_bCritHack;
CatVar* v_bTauntSlide;
CatVar* v_bSuppressCrits;
//ConVar* v_bDumpEventInfo;
ConCommand* c_SaveSettings;
ConCommand* c_Unrestricted;
ConCommand* c_DumpItemAttributes;
ConCommand* c_SayLine;
ConCommand* c_Shutdown;
ConCommand* c_AddFriend;
ConCommand* c_AddRage;
ConCommand* c_DumpVars;
ConCommand* c_DumpPlayers;
ConCommand* c_Teamname;
ConCommand* c_Lockee;
ConCommand* c_Info;
ConCommand* c_DumpConds;
ConCommand* c_Reset;
ConCommand* c_Disconnect;
ConCommand* c_Schema;
ConCommand* c_DisconnectVAC;
CatVar* v_bCleanChat;
};
void Schema_Reload();
void CC_Misc_Disconnect_VAC();
DECLARE_HACK_SINGLETON(Misc);*/

View File

@ -22,7 +22,7 @@ extern const std::vector<std::string> builtin_lmaobox;
extern const std::vector<std::string> builtin_lithium; extern const std::vector<std::string> builtin_lithium;
bool isActive(); bool isActive();
void Init(); void init();
void CreateMove(); void createMove();
void Reload(); void reload();
} }

View File

@ -0,0 +1,12 @@
/*
Created on 29.07.18.
*/
#pragma once
namespace hacks::tf::thirdperson
{
void frameStageNotify();
}

View File

@ -29,7 +29,6 @@
#include "AntiCheat.hpp" #include "AntiCheat.hpp"
#include "AutoDeadringer.hpp" #include "AutoDeadringer.hpp"
#include "Bunnyhop.hpp" #include "Bunnyhop.hpp"
#include "LagExploit.hpp"
#include "SeedPrediction.hpp" #include "SeedPrediction.hpp"
#endif #endif
#if ENABLE_VISUALS #if ENABLE_VISUALS
@ -43,7 +42,6 @@
#include "AntiBackstab.hpp" #include "AntiBackstab.hpp"
#include "AutoBackstab.hpp" #include "AutoBackstab.hpp"
#include "FollowBot.hpp" #include "FollowBot.hpp"
#include "HealArrows.hpp"
#include "Misc.hpp" #include "Misc.hpp"
#include "Trigger.hpp" #include "Trigger.hpp"
#include "KillSay.hpp" #include "KillSay.hpp"

View File

@ -6,6 +6,7 @@ target_sources(cathook PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/EffectChams.hpp" "${CMAKE_CURRENT_LIST_DIR}/EffectChams.hpp"
"${CMAKE_CURRENT_LIST_DIR}/EffectGlow.hpp" "${CMAKE_CURRENT_LIST_DIR}/EffectGlow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.hpp" "${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.hpp"
"${CMAKE_CURRENT_LIST_DIR}/EventLogging.hpp"
"${CMAKE_CURRENT_LIST_DIR}/SDLHooks.hpp") "${CMAKE_CURRENT_LIST_DIR}/SDLHooks.hpp")
if(EnableGUI) if(EnableGUI)

View File

@ -0,0 +1,9 @@
/*
Created on 29.07.18.
*/
#pragma once
namespace event_logging
{
}

View File

@ -6,42 +6,10 @@
#include "MiscTemporary.hpp" #include "MiscTemporary.hpp"
std::array<Timer, 32> timers{}; std::array<Timer, 32> timers{};
std::array<int, 32> bruteint{}; std::array<int, 32> bruteint{};
CatVar minigun_jump(CV_SWITCH, "minigun_jump", "0", "TF2C minigun jump",
"Allows jumping while shooting with minigun");
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)");
CatVar engine_pred(CV_SWITCH, "engine_prediction", "0", "Engine Prediction");
CatVar debug_projectiles(CV_SWITCH, "debug_projectiles", "0",
"Debug Projectiles");
CatVar fakelag_amount(CV_INT, "fakelag", "0", "Bad Fakelag");
CatVar serverlag_amount(
CV_INT, "serverlag", "0", "serverlag",
"Lag the server by spamming this many voicecommands per tick");
CatVar servercrash(CV_SWITCH, "servercrash", "0", "crash servers",
"Crash servers by spamming signon net messages");
CatVar semiauto(CV_INT, "semiauto", "0", "Semiauto");
bool *bSendPackets = nullptr;
CatVar resolver(CV_SWITCH, "resolver", "0", "Resolve angles");
CatVar crypt_chat(
CV_SWITCH, "chat_crypto", "1", "Crypto chat",
"Start message with !! and it will be only visible to cathook users");
int spectator_target; int spectator_target;
CLC_VoiceData *voicecrash{}; CLC_VoiceData *voicecrash{};
bool firstcm = false; bool firstcm = false;
Timer DelayTimer{}; Timer DelayTimer{};
CatVar delay(
CV_INT, "delay", "0", "Delay",
"Delay actions like chat spam and serverlag/crash by this many seconds.");
CatVar adjust(CV_INT, "serverlag_ramp", "0", "Ramp lag",
"keep lag around this many seconds");
float prevflow = 0.0f; float prevflow = 0.0f;
int prevflowticks = 0; int prevflowticks = 0;

View File

@ -26,7 +26,7 @@ void Update()
} }
if (i == g_IEngine->GetLocalPlayer()) if (i == g_IEngine->GetLocalPlayer())
{ {
d.push(g_pUserCmd->viewangles); d.push(current_user_cmd->viewangles);
} }
else else
{ {

View File

@ -109,10 +109,10 @@ void LogMessage(int eid, std::string message)
{ {
return; return;
} }
if (no_spam && hacks::shared::spam::spam_source and if (no_spam && hacks::shared::spam::isActive() and
eid == g_IEngine->GetLocalPlayer()) eid == g_IEngine->GetLocalPlayer())
return; return;
player_info_s info; player_info_s info{};
if (not g_IEngine->GetPlayerInfo(eid, &info)) if (not g_IEngine->GetPlayerInfo(eid, &info))
return; return;
if (no_ipc && if (no_ipc &&

View File

@ -9,7 +9,7 @@
std::stack<void (*)()> &init_stack() std::stack<void (*)()> &init_stack()
{ {
static std::stack<void (*)()> stack; static std::stack<void (*)()> stack{};
return stack; return stack;
} }

View File

@ -9,10 +9,13 @@
#include <string.h> #include <string.h>
#include <pwd.h> #include <pwd.h>
#include <settings/Bool.hpp>
#include "common.hpp" #include "common.hpp"
FILE *logging::handle = 0; settings::Bool log_to_console{ "hack.log-console", "false" };
FILE *logging::handle{ nullptr };
void logging::Initialize() void logging::Initialize()
{ {
@ -24,7 +27,7 @@ void logging::Initialize()
void logging::Info(const char *fmt, ...) void logging::Info(const char *fmt, ...)
{ {
if (logging::handle == 0) if (logging::handle == nullptr)
logging::Initialize(); logging::Initialize();
char *buffer = new char[1024]; char *buffer = new char[1024];
va_list list; va_list list;
@ -45,7 +48,7 @@ void logging::Info(const char *fmt, ...)
#if ENABLE_VISUALS #if ENABLE_VISUALS
if (g_ICvar) if (g_ICvar)
{ {
if (console_logging.convar_parent && console_logging) if (*log_to_console)
g_ICvar->ConsolePrintf("%s", result); g_ICvar->ConsolePrintf("%s", result);
} }
#endif #endif
@ -56,5 +59,5 @@ void logging::Info(const char *fmt, ...)
void logging::Shutdown() void logging::Shutdown()
{ {
fclose(logging::handle); fclose(logging::handle);
logging::handle = 0; logging::handle = nullptr
} }

View File

@ -23,10 +23,10 @@ namespace criticals
int find_next_random_crit_for_weapon(IClientEntity *weapon) int find_next_random_crit_for_weapon(IClientEntity *weapon)
{ {
int tries = 0, number = g_pUserCmd->command_number, found = 0, seed, int tries = 0, number = current_user_cmd->command_number, found = 0, seed,
seed_md5, seed_backup; seed_md5, seed_backup;
crithack_saved_state state; crithack_saved_state state{};
state.Save(weapon); state.Save(weapon);
seed_backup = *g_PredictionRandomSeed; seed_backup = *g_PredictionRandomSeed;
@ -56,7 +56,7 @@ void unfuck_bucket(IClientEntity *weapon)
static float last_bucket; static float last_bucket;
static int last_weapon; static int last_weapon;
if (g_pUserCmd->command_number) if (current_user_cmd->command_number)
changed = false; changed = false;
float &bucket = re::C_TFWeaponBase::crit_bucket_(weapon); float &bucket = re::C_TFWeaponBase::crit_bucket_(weapon);
@ -92,15 +92,17 @@ static const model_t *lastweapon = nullptr;
bool force_crit(IClientEntity *weapon) bool force_crit(IClientEntity *weapon)
{ {
if (lastnumber < g_pUserCmd->command_number || auto command_number = current_user_cmd->command_number;
if (lastnumber < command_number ||
lastweapon != weapon->GetModel() || lastweapon != weapon->GetModel() ||
lastnumber - g_pUserCmd->command_number > 1000) lastnumber - command_number > 1000)
{ {
if (cached_calculation.init_command > g_pUserCmd->command_number || if (cached_calculation.init_command > command_number ||
g_pUserCmd->command_number - cached_calculation.init_command > command_number - cached_calculation.init_command >
4096 || 4096 ||
(g_pUserCmd->command_number && (command_number &&
(cached_calculation.command_number < g_pUserCmd->command_number))) (cached_calculation.command_number < command_number)))
cached_calculation.weapon_entity = 0; cached_calculation.weapon_entity = 0;
if (cached_calculation.weapon_entity == weapon->entindex()) if (cached_calculation.weapon_entity == weapon->entindex())
return bool(cached_calculation.command_number); return bool(cached_calculation.command_number);
@ -109,7 +111,7 @@ bool force_crit(IClientEntity *weapon)
} }
else else
number = lastnumber; number = lastnumber;
logging::Info("Found critical: %d -> %d", g_pUserCmd->command_number, logging::Info("Found critical: %d -> %d", command_number,
number); number);
lastweapon = weapon->GetModel(); lastweapon = weapon->GetModel();
lastnumber = number; lastnumber = number;
@ -117,16 +119,16 @@ bool force_crit(IClientEntity *weapon)
{ {
if (!crit_legiter) if (!crit_legiter)
{ {
if (number && number != g_pUserCmd->command_number) if (number && number != command_number)
command_number_mod[g_pUserCmd->command_number] = number; command_number_mod[command_number] = number;
cached_calculation.command_number = number; cached_calculation.command_number = number;
cached_calculation.weapon_entity = LOCAL_W->m_IDX; cached_calculation.weapon_entity = LOCAL_W->m_IDX;
} }
else else
{ {
if (number && number - 30 < g_pUserCmd->command_number) if (number && number - 30 < command_number)
command_number_mod[g_pUserCmd->command_number] = number; command_number_mod[command_number] = number;
cached_calculation.command_number = number; cached_calculation.command_number = number;
cached_calculation.weapon_entity = LOCAL_W->m_IDX; cached_calculation.weapon_entity = LOCAL_W->m_IDX;
@ -136,22 +138,22 @@ bool force_crit(IClientEntity *weapon)
{ {
if (!crit_legiter) if (!crit_legiter)
{ {
if (g_pUserCmd->command_number != number && number && if (command_number != number && number &&
number != g_pUserCmd->command_number) number != command_number)
g_pUserCmd->buttons &= ~IN_ATTACK; current_user_cmd->buttons &= ~IN_ATTACK;
else else
g_pUserCmd->buttons |= IN_ATTACK; current_user_cmd->buttons |= IN_ATTACK;
} }
else else
{ {
if (g_pUserCmd->command_number + 30 > number && number && if (command_number + 30 > number && number &&
number != g_pUserCmd->command_number) number != command_number)
g_pUserCmd->buttons &= ~IN_ATTACK; current_user_cmd->buttons &= ~IN_ATTACK;
else else
g_pUserCmd->buttons |= IN_ATTACK; current_user_cmd->buttons |= IN_ATTACK;
} }
} }
return !!number; return number != 0;
} }
void create_move() void create_move()
@ -162,20 +164,20 @@ void create_move()
return; return;
if (CE_BAD(LOCAL_W)) if (CE_BAD(LOCAL_W))
return; return;
if (g_pUserCmd->command_number) if (current_user_cmd->command_number)
lastusercmd = g_pUserCmd->command_number; lastusercmd = current_user_cmd->command_number;
IClientEntity *weapon = RAW_ENT(LOCAL_W); IClientEntity *weapon = RAW_ENT(LOCAL_W);
if (!re::C_TFWeaponBase::IsBaseCombatWeapon(weapon)) if (!re::C_TFWeaponBase::IsBaseCombatWeapon(weapon))
return; return;
if (!re::C_TFWeaponBase::AreRandomCritsEnabled(weapon)) if (!re::C_TFWeaponBase::AreRandomCritsEnabled(weapon))
return; return;
unfuck_bucket(weapon); unfuck_bucket(weapon);
if ((g_pUserCmd->buttons & IN_ATTACK) && crit_key && crit_key.isKeyDown() && if ((current_user_cmd->buttons & IN_ATTACK) && crit_key && crit_key.isKeyDown() &&
g_pUserCmd->command_number) current_user_cmd->command_number)
{ {
force_crit(weapon); force_crit(weapon);
} }
else if ((g_pUserCmd->buttons & IN_ATTACK) && g_pUserCmd->command_number && else if ((current_user_cmd->buttons & IN_ATTACK) && current_user_cmd->command_number &&
GetWeaponMode() == weapon_melee && crit_melee && GetWeaponMode() == weapon_melee && crit_melee &&
g_pLocalPlayer->weapon()->m_iClassID() != CL_CLASS(CTFKnife)) g_pLocalPlayer->weapon()->m_iClassID() != CL_CLASS(CTFKnife))
{ {
@ -204,7 +206,7 @@ void draw()
return; return;
if (crit_info && CE_GOOD(LOCAL_W)) if (crit_info && CE_GOOD(LOCAL_W))
{ {
if (crit_key.KeyDown()) if (crit_key.isKeyDown())
{ {
AddCenterString("FORCED CRITS!", colors::red); AddCenterString("FORCED CRITS!", colors::red);
} }

View File

@ -5,21 +5,17 @@
* Author: nullifiedcat * Author: nullifiedcat
*/ */
#include <globals.h>
#include <settings/Bool.hpp>
#include "common.hpp" #include "common.hpp"
static settings::Bool global_enable{ "hack.enable", "true" };
time_t time_injected{ 0 }; time_t time_injected{ 0 };
int g_AppID = 0; int g_AppID = 0;
void ThirdpersonCallback(IConVar *var, const char *pOldValue, float flOldValue)
{
if (force_thirdperson.convar_parent && !force_thirdperson)
{
if (g_pLocalPlayer && CE_GOOD(g_pLocalPlayer->entity))
CE_INT(g_pLocalPlayer->entity, netvar.nForceTauntCam) = 0;
}
}
ConVar *sv_client_min_interp_ratio; ConVar *sv_client_min_interp_ratio;
ConVar *cl_interp_ratio; ConVar *cl_interp_ratio;
ConVar *cl_interp; ConVar *cl_interp;
@ -29,28 +25,7 @@ unsigned long tickcount = 0;
char *force_name_newlined = new char[32]{ 0 }; char *force_name_newlined = new char[32]{ 0 };
bool need_name_change = true; bool need_name_change = true;
int last_cmd_number = 0; int last_cmd_number = 0;
CatVar force_name(CV_STRING, "name", "", "Force name");
CatVar
cathook(CV_SWITCH, "enabled", "1", "CatHook enabled",
"Disabling this completely disables cathook (can be re-enabled)");
// CatVar send_packets(CV_SWITCH, "sendpackets", "1", "Send packets", "Internal
// use");
CatVar show_antiaim(CV_SWITCH, "thirdperson_angles", "1", "Real TP angles",
"You can see your own AA/Aimbot angles in thirdperson");
CatVar force_thirdperson(CV_SWITCH, "thirdperson", "0", "Thirdperson",
"Enable thirdperson view");
CatVar console_logging(
CV_SWITCH, "log", "0", "Debug Log",
"Disable this if you don't need cathook messages in your console");
// CatVar fast_outline(CV_SWITCH, "fastoutline", "0", "Low quality outline",
// "Might increase performance when there is a lot of ESP text to draw");
CatVar roll_speedhack(CV_KEY, "rollspeedhack", "0", "Roll Speedhack",
"Roll speedhack key");
char *disconnect_reason_newlined = new char[256]{ 0 };
CatVar disconnect_reason(CV_STRING, "disconnect_reason", "",
"Disconnect reason", "A custom disconnect reason");
CatVar event_log(CV_SWITCH, "events", "0", "Advanced Events");
void GlobalSettings::Init() void GlobalSettings::Init()
{ {
sv_client_min_interp_ratio = g_ICvar->FindVar("sv_client_min_interp_ratio"); sv_client_min_interp_ratio = g_ICvar->FindVar("sv_client_min_interp_ratio");
@ -58,26 +33,14 @@ void GlobalSettings::Init()
cl_interp = g_ICvar->FindVar("cl_interp"); cl_interp = g_ICvar->FindVar("cl_interp");
cl_interpolate = g_ICvar->FindVar("cl_interpolate"); cl_interpolate = g_ICvar->FindVar("cl_interpolate");
force_thirdperson.OnRegister([](CatVar *var) {
var->convar_parent->InstallChangeCallback(ThirdpersonCallback);
});
force_name.InstallChangeCallback(
[](IConVar *var, const char *old, float oldfl) {
std::string nl(force_name.GetString());
ReplaceString(nl, "\\n", "\n");
strncpy(force_name_newlined, nl.c_str(), 31);
(void) oldfl;
});
disconnect_reason.InstallChangeCallback(
[](IConVar *var, const char *old, float oldfl) {
std::string nl(disconnect_reason.GetString());
ReplaceString(nl, "\\n", "\n");
strncpy(disconnect_reason_newlined, nl.c_str(), 255);
(void) oldfl;
});
bInvalid = true; bInvalid = true;
} }
CUserCmd *g_pUserCmd = nullptr; CUserCmd *current_user_cmd{ nullptr };
GlobalSettings g_Settings; bool isHackActive()
{
return *global_enable;
}
GlobalSettings g_Settings{};

View File

@ -102,129 +102,6 @@ std::stack<std::string> &hack::command_stack()
return stack; return stack;
} }
#if ENABLE_VISUALS /* Why would we need colored chat stuff in textmode? \
*/
#define red 184, 56, 59, 255
#define blu 88, 133, 162, 255
class AdvancedEventListener : public IGameEventListener
{
public:
virtual void FireGameEvent(KeyValues *event)
{
if (!event_log)
return;
const char *name = event->GetName();
if (!strcmp(name, "player_connect_client"))
PrintChat("\x07%06X%s\x01 \x07%06X%s\x01 joining", 0xa06ba0,
event->GetString("name"), 0x914e65,
event->GetString("networkid"));
else if (!strcmp(name, "player_activate"))
{
int uid = event->GetInt("userid");
int entity = g_IEngine->GetPlayerForUserID(uid);
player_info_s info;
if (g_IEngine->GetPlayerInfo(entity, &info))
PrintChat("\x07%06X%s\x01 connected", 0xa06ba0, info.name);
}
else if (!strcmp(name, "player_disconnect"))
{
CachedEntity *player =
ENTITY(g_IEngine->GetPlayerForUserID(event->GetInt("userid")));
PrintChat("\x07%06X%s\x01 \x07%06X%s\x01 disconnected",
colors::chat::team(player->m_iTeam()),
event->GetString("name"), 0x914e65,
event->GetString("networkid"));
}
else if (!strcmp(name, "player_team"))
{
if (event->GetBool("disconnect") != 1)
{
int oteam = event->GetInt("oldteam");
int nteam = event->GetInt("team");
const char *oteam_s = teamname(oteam);
const char *nteam_s = teamname(nteam);
PrintChat("\x07%06X%s\x01 changed team (\x07%06X%s\x01 -> "
"\x07%06X%s\x01)",
0xa06ba0, event->GetString("name"),
colors::chat::team(oteam), oteam_s,
colors::chat::team(nteam), nteam_s);
}
}
else if (!strcmp(name, "player_hurt"))
{
int victim = event->GetInt("userid");
int attacker = event->GetInt("attacker");
int health = event->GetInt("health");
player_info_s kinfo;
player_info_s vinfo;
g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(victim),
&vinfo);
g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(attacker),
&kinfo);
CachedEntity *vic = ENTITY(g_IEngine->GetPlayerForUserID(victim));
CachedEntity *att = ENTITY(g_IEngine->GetPlayerForUserID(attacker));
PrintChat(
"\x07%06X%s\x01 hurt \x07%06X%s\x01 down to \x07%06X%d\x01hp",
colors::chat::team(att->m_iTeam()), kinfo.name,
colors::chat::team(vic->m_iTeam()), vinfo.name, 0x2aaf18,
health);
}
else if (!strcmp(name, "player_death"))
{
int victim = event->GetInt("userid");
int attacker = event->GetInt("attacker");
player_info_s kinfo;
player_info_s vinfo;
g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(victim),
&vinfo);
g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(attacker),
&kinfo);
CachedEntity *vic = ENTITY(g_IEngine->GetPlayerForUserID(victim));
CachedEntity *att = ENTITY(g_IEngine->GetPlayerForUserID(attacker));
PrintChat("\x07%06X%s\x01 killed \x07%06X%s\x01",
colors::chat::team(att->m_iTeam()), kinfo.name,
colors::chat::team(vic->m_iTeam()), vinfo.name);
}
else if (!strcmp(name, "player_spawn"))
{
int id = event->GetInt("userid");
player_info_s info;
g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(id), &info);
CachedEntity *player = ENTITY(g_IEngine->GetPlayerForUserID(id));
PrintChat("\x07%06X%s\x01 (re)spawned",
colors::chat::team(player->m_iTeam()), info.name);
}
else if (!strcmp(name, "player_changeclass"))
{
int id = event->GetInt("userid");
player_info_s info;
g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(id), &info);
CachedEntity *player = ENTITY(g_IEngine->GetPlayerForUserID(id));
PrintChat("\x07%06X%s\x01 changed to \x07%06X%s\x01",
colors::chat::team(player->m_iTeam()), info.name,
0xa06ba0, classname(event->GetInt("class")));
}
else if (!strcmp(name, "vote_cast"))
{
int vote_option = event->GetInt("vote_option");
int team = event->GetInt("team");
int idx = event->GetInt("entityid");
player_info_s info;
const char *team_s = teamname(team);
g_IEngine->GetPlayerInfo(idx, &info);
PrintChat(
"\x07%06X%s\x01 Voted \x07%06X%d\x01 on team \x07%06X%s\x01",
colors::chat::team(team), info.name, colors::chat::team(team),
vote_option, colors::chat::team(team), team_s);
};
}
};
AdvancedEventListener adv_event_listener{};
#endif /* TEXTMODE */
void hack::ExecuteCommand(const std::string command) void hack::ExecuteCommand(const std::string command)
{ {
std::lock_guard<std::mutex> guard(hack::command_stack_mutex); std::lock_guard<std::mutex> guard(hack::command_stack_mutex);
@ -374,10 +251,7 @@ free(logname);*/
#if ENABLE_VISUALS #if ENABLE_VISUALS
draw::Initialize(); draw::Initialize();
#if ENABLE_GUI #if ENABLE_GUI
// FIXME put gui here
g_pGUI = new CatGUI();
g_pGUI->Setup();
#endif #endif
#endif /* TEXTMODE */ #endif /* TEXTMODE */
@ -505,7 +379,6 @@ free(logname);*/
#endif #endif
sdl_hooks::applySdlHooks(); sdl_hooks::applySdlHooks();
logging::Info("SDL hooking done"); logging::Info("SDL hooking done");
g_IGameEventManager->AddListener(&adv_event_listener, false);
#endif /* TEXTMODE */ #endif /* TEXTMODE */
#if not LAGBOT_MODE #if not LAGBOT_MODE

View File

@ -38,8 +38,6 @@ bool UnassignedClass()
Timer autoqueue_timer{}; Timer autoqueue_timer{};
Timer queuetime{}; Timer queuetime{};
Timer req_timer{}; Timer req_timer{};
/*CatVar party_bypass(CV_SWITCH, "party_bypass", "0", "Party Bypass",
"Bypass Party restrictions");*/
void UpdateSearch() void UpdateSearch()
{ {
// segfaults for no reason // segfaults for no reason

View File

@ -27,14 +27,6 @@ static settings::Float fovcircle_opacity{ "autoreflect.draw-fov-opacity", "0.7"
namespace hacks::tf::autoreflect namespace hacks::tf::autoreflect
{ {
// TODO setup proj sorting
// TODO CatVar big_proj(CV_SWITCH, "reflect_big_projectile", "0", "Reflect big
// projectiles", "Reflect Rockets");
// TODO CatVar small_proj(CV_SWITCH, "reflect_small_projectile", "0", "Reflect
// small projectiles", "Reflect Huntsman arrows, Crusaders bolts");
// TODO CatVar misc_proj(CV_SWITCH, "reflect_misc_projectile", "0", "Reflect
// other", "Reflect jarate, milk");
// Function called by game for movement // Function called by game for movement
void CreateMove() void CreateMove()
{ {

View File

@ -39,5 +39,6 @@ if(EnableVisuals)
"${CMAKE_CURRENT_LIST_DIR}/ESP.cpp" "${CMAKE_CURRENT_LIST_DIR}/ESP.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Radar.cpp" "${CMAKE_CURRENT_LIST_DIR}/Radar.cpp"
"${CMAKE_CURRENT_LIST_DIR}/SkinChanger.cpp" "${CMAKE_CURRENT_LIST_DIR}/SkinChanger.cpp"
"${CMAKE_CURRENT_LIST_DIR}/SpyAlert.cpp") "${CMAKE_CURRENT_LIST_DIR}/SpyAlert.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Thirdperson.cpp")
endif() endif()

View File

@ -79,8 +79,6 @@ static settings::Bool online_software{ "esp.online.software", "true" };
namespace hacks::shared::esp namespace hacks::shared::esp
{ {
// CatVar draw_hitbox(CV_SWITCH, "esp_hitbox", "1", "Draw Hitbox");
// Unknown // Unknown
std::mutex threadsafe_mutex; std::mutex threadsafe_mutex;
// Storage array for keeping strings and other data // Storage array for keeping strings and other data

View File

@ -22,40 +22,6 @@
namespace hacks::shared::misc namespace hacks::shared::misc
{ {
static CatVar debug_info(CV_SWITCH, "debug_info", "0", "Debug info",
"Shows some debug info in-game");
static CatVar flashlight_spam(CV_SWITCH, "flashlight", "0", "Flashlight spam",
"HL2DM flashlight spam");
static CatVar
auto_balance_spam(CV_SWITCH, "request_balance_spam", "0",
"Inf Auto Balance Spam",
"Use to send a autobalance request to the server that "
"doesnt prevent you from using it again\nCredits to "
"Blackfire");
static CatVar
anti_afk(CV_SWITCH, "anti_afk", "0", "Anti-AFK",
"Sends random commands to prevent being kicked from server");
static CatVar auto_strafe(CV_SWITCH, "auto_strafe", "0", "Auto-Strafe",
"Automaticly airstrafes for you.");
static CatVar
render_zoomed(CV_SWITCH, "render_zoomed", "0",
"Render model when zoomed-in",
"Renders player model while being zoomed in as Sniper");
static CatVar nopush_enabled(CV_SWITCH, "nopush_enabled", "0", "No Push",
"Prevents other players from pushing you around.");
static CatVar no_homo(CV_SWITCH, "no_homo", "1", "No Homo", "read if gay");
// Taunting stuff
static CatVar tauntslide(CV_SWITCH, "tauntslide", "0", "TF2C tauntslide",
"Allows moving and shooting while taunting");
static CatVar tauntslide_tf2(CV_SWITCH, "tauntslide_tf2", "0", "Tauntslide",
"Allows free movement while taunting with movable "
"taunts\nOnly works in tf2");
static CatVar
show_spectators(CV_SWITCH, "show_spectators", "0", "Show spectators",
"Show who's spectating you\nonly works in valve servers");
static CatVar god_mode(CV_SWITCH, "godmode", "0", "no description",
"no description");
void *C_TFPlayer__ShouldDraw_original = nullptr; void *C_TFPlayer__ShouldDraw_original = nullptr;
bool C_TFPlayer__ShouldDraw_hook(IClientEntity *thisptr) bool C_TFPlayer__ShouldDraw_hook(IClientEntity *thisptr)

View File

@ -11,7 +11,6 @@ constexpr double MIN_CLOCKRES = 0.25;
constexpr double MAX_CLOCKRES = 8192.5; constexpr double MAX_CLOCKRES = 8192.5;
double clockRes; double clockRes;
float seedFraction = 0.0f; float seedFraction = 0.0f;
//static CatVar enableSeedPrediction(CV_SWITCH, "seed_prediction", "1", "Seed Predcition", "Enable Seed prediction");
namespace hacks::tf2::seedprediction namespace hacks::tf2::seedprediction
{ {
buf bases{9999}; buf bases{9999};

View File

@ -110,7 +110,7 @@ bool PlayerPassesQuery(Query query, int idx)
Query QueryFromSubstring(const std::string &string) Query QueryFromSubstring(const std::string &string)
{ {
Query result; Query result{};
bool read = true; bool read = true;
for (auto it = string.begin(); read && *it; it++) for (auto it = string.begin(); read && *it; it++)
{ {
@ -211,13 +211,6 @@ int QueryPlayer(Query query)
return index_result; return index_result;
} }
void Init()
{
filename.installChangeCallback([](settings::VariableBase<std::string>& var, std::string after) {
file.TryLoad(after);
});
}
bool SubstituteQueries(std::string &input) bool SubstituteQueries(std::string &input)
{ {
size_t index = input.find("%query:"); size_t index = input.find("%query:");
@ -252,7 +245,14 @@ bool FormatSpamMessage(std::string &message)
return SubstituteQueries(message); return SubstituteQueries(message);
} }
void CreateMove() void init()
{
filename.installChangeCallback([](settings::VariableBase<std::string>& var, std::string after) {
file.TryLoad(after);
});
}
void createMove()
{ {
IF_GAME(IsTF2()) IF_GAME(IsTF2())
{ {
@ -380,11 +380,16 @@ void CreateMove()
} }
} }
void Reload() void reload()
{ {
file.Load(std::string(filename.GetString())); file.Load(std::string(filename.GetString()));
} }
bool isActive()
{
return bool(spam_source);
}
const std::vector<std::string> builtin_default = { const std::vector<std::string> builtin_default = {
"cathook - more fun than a ball of yarn!", "GNU/Linux is the best OS!", "cathook - more fun than a ball of yarn!", "GNU/Linux is the best OS!",
"visit youtube.com/c/nullifiedcat for more information!", "visit youtube.com/c/nullifiedcat for more information!",
@ -423,9 +428,4 @@ const std::vector<std::string> builtin_lithium = {
"SAVE YOUR MONEY AND GET LITHIUMCHEAT! IT IS FREE!", "SAVE YOUR MONEY AND GET LITHIUMCHEAT! IT IS FREE!",
"GOT ROLLED BY LITHIUM? HEY, THAT MEANS IT'S TIME TO GET LITHIUMCHEAT!!" "GOT ROLLED BY LITHIUM? HEY, THAT MEANS IT'S TIME TO GET LITHIUMCHEAT!!"
}; };
bool isActive()
{
return bool(spam_source);
}
} }

41
src/hacks/Thirdperson.cpp Normal file
View File

@ -0,0 +1,41 @@
/*
Created on 29.07.18.
*/
#include <hacks/Thirdperson.hpp>
#include <settings/Bool.hpp>
#include <localplayer.hpp>
#include <entitycache.hpp>
#include <core/sdk.hpp>
static settings::Bool enable{ "visual.thirdperson.enable", "false" };
static settings::Bool angles{ "visual.thirdperson.real-angles", "false" };
static bool was_enabled{ false };
void hacks::tf::thirdperson::frameStageNotify()
{
if (CE_BAD(LOCAL_E))
return;
if (enable)
{
// Add thirdperson
if (!g_pLocalPlayer->life_state)
CE_INT(LOCAL_E, netvar.nForceTauntCam) = 1;
was_enabled = true;
}
if (!enable && was_enabled)
{
// Remove thirdperson
CE_INT(LOCAL_E, netvar.nForceTauntCam) = 0;
was_enabled = false;
}
if (angles && g_IInput->CAM_IsThirdPerson())
{
CE_FLOAT(LOCAL_E, netvar.deadflag + 4) =
g_Settings.brute.last_angles[LOCAL_E->m_IDX].x;
CE_FLOAT(LOCAL_E, netvar.deadflag + 8) =
g_Settings.brute.last_angles[LOCAL_E->m_IDX].y;
}
}

View File

@ -446,7 +446,7 @@ std::pair<float, float> ComputeMove(const Vector &a, const Vector &b)
float speed = sqrt(vsilent.x * vsilent.x + vsilent.y * vsilent.y); float speed = sqrt(vsilent.x * vsilent.x + vsilent.y * vsilent.y);
Vector ang; Vector ang;
VectorAngles(vsilent, ang); VectorAngles(vsilent, ang);
float yaw = DEG2RAD(ang.y - g_pUserCmd->viewangles.y); float yaw = DEG2RAD(ang.y - current_user_cmd->viewangles.y);
return { cos(yaw) * 450, -sin(yaw) * 450 }; return { cos(yaw) * 450, -sin(yaw) * 450 };
} }

View File

@ -65,8 +65,3 @@ static CatCommand minus_use_action_slot_item_server(
g_IEngine->ServerCmdKeyValues(kv); g_IEngine->ServerCmdKeyValues(kv);
}); });
// TODO replace \\n with \n
// TODO name \\n = \n
// static CatVar queue_messages(CV_SWITCH, "chat_queue", "0", "Queue messages",
// "Use this if you want to use spam/killsay and still be able to chat normally
// (without having your msgs eaten by valve cooldown)");

View File

@ -104,21 +104,7 @@ DEFINE_HOOKED_METHOD(FrameStageNotify, void, void *this_,
if (CE_GOOD(LOCAL_E) && no_zoom) if (CE_GOOD(LOCAL_E) && no_zoom)
RemoveCondition<TFCond_Zoomed>(LOCAL_E); RemoveCondition<TFCond_Zoomed>(LOCAL_E);
} }
if (force_thirdperson && !g_pLocalPlayer->life_state && hacks::tf::thirdperson::frameStageNotify();
CE_GOOD(g_pLocalPlayer->entity))
{
CE_INT(g_pLocalPlayer->entity, netvar.nForceTauntCam) = 1;
}
if (stage == 5 && show_antiaim && g_IInput->CAM_IsThirdPerson())
{
if (CE_GOOD(g_pLocalPlayer->entity))
{
CE_FLOAT(g_pLocalPlayer->entity, netvar.deadflag + 4) =
g_Settings.brute.last_angles[LOCAL_E->m_IDX].x;
CE_FLOAT(g_pLocalPlayer->entity, netvar.deadflag + 8) =
g_Settings.brute.last_angles[LOCAL_E->m_IDX].y;
}
}
} }
return original::FrameStageNotify(this_, stage); return original::FrameStageNotify(this_, stage);
} }

View File

@ -6,6 +6,7 @@ target_sources(cathook PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/EffectChams.cpp" "${CMAKE_CURRENT_LIST_DIR}/EffectChams.cpp"
"${CMAKE_CURRENT_LIST_DIR}/EffectGlow.cpp" "${CMAKE_CURRENT_LIST_DIR}/EffectGlow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.cpp" "${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.cpp"
"${CMAKE_CURRENT_LIST_DIR}/EventLogging.cpp"
"${CMAKE_CURRENT_LIST_DIR}/SDLHooks.cpp") "${CMAKE_CURRENT_LIST_DIR}/SDLHooks.cpp")
if(EnableGUI) if(EnableGUI)

View File

@ -29,9 +29,6 @@ static settings::Bool chamsself{ "chams.self", "true" };
static settings::Bool rainbow{ "chams.self-rainbow", "true" }; static settings::Bool rainbow{ "chams.self-rainbow", "true" };
static settings::Bool disco_chams{ "chams.disco", "false" }; static settings::Bool disco_chams{ "chams.disco", "false" };
// static CatVar chams_experimental(CV_SWITCH, "chams_effect", "0",
// "Experimental Chams");
namespace effect_chams namespace effect_chams
{ {

176
src/visual/EventLogging.cpp Normal file
View File

@ -0,0 +1,176 @@
/*
Created on 29.07.18.
*/
#include <EventLogging.hpp>
#include <settings/Bool.hpp>
#include <helpers.hpp>
#include <colors.hpp>
#include <init.hpp>
static settings::Bool enable{ "chat.log-events", "false" };
static void handlePlayerConnectClient(KeyValues *kv)
{
PrintChat("\x07%06X%s\x01 \x07%06X%s\x01 joining", 0xa06ba0,
kv->GetString("name"), 0x914e65,
kv->GetString("networkid"));
}
static void handlePlayerActivate(KeyValues *kv)
{
int uid = kv->GetInt("userid");
int entity = g_IEngine->GetPlayerForUserID(uid);
player_info_s info{};
if (g_IEngine->GetPlayerInfo(entity, &info))
PrintChat("\x07%06X%s\x01 connected", 0xa06ba0, info.name);
}
static void handlePlayerDisconnect(KeyValues *kv)
{
CachedEntity *player =
ENTITY(g_IEngine->GetPlayerForUserID(kv->GetInt("userid")));
if (player == nullptr)
return;
PrintChat("\x07%06X%s\x01 \x07%06X%s\x01 disconnected",
colors::chat::team(player->m_iTeam()),
kv->GetString("name"), 0x914e65,
kv->GetString("networkid"));
}
static void handlePlayerTeam(KeyValues *kv)
{
if (kv->GetBool("disconnect"))
return;
int oteam = kv->GetInt("oldteam");
int nteam = kv->GetInt("team");
const char *oteam_s = teamname(oteam);
const char *nteam_s = teamname(nteam);
PrintChat("\x07%06X%s\x01 changed team (\x07%06X%s\x01 -> "
"\x07%06X%s\x01)",
0xa06ba0, kv->GetString("name"),
colors::chat::team(oteam), oteam_s,
colors::chat::team(nteam), nteam_s);
}
static void handlePlayerHurt(KeyValues *kv)
{
int victim = kv->GetInt("userid");
int attacker = kv->GetInt("attacker");
int health = kv->GetInt("health");
player_info_s kinfo{};
player_info_s vinfo{};
g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(victim),
&vinfo);
g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(attacker),
&kinfo);
CachedEntity *vic = ENTITY(g_IEngine->GetPlayerForUserID(victim));
CachedEntity *att = ENTITY(g_IEngine->GetPlayerForUserID(attacker));
if (vic == nullptr || att == nullptr)
return;
PrintChat(
"\x07%06X%s\x01 hurt \x07%06X%s\x01 down to \x07%06X%d\x01hp",
colors::chat::team(att->m_iTeam()), kinfo.name,
colors::chat::team(vic->m_iTeam()), vinfo.name, 0x2aaf18,
health);
}
static void handlePlayerDeath(KeyValues *kv)
{
int victim = kv->GetInt("userid");
int attacker = kv->GetInt("attacker");
player_info_s kinfo{};
player_info_s vinfo{};
g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(victim),
&vinfo);
g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(attacker),
&kinfo);
CachedEntity *vic = ENTITY(g_IEngine->GetPlayerForUserID(victim));
CachedEntity *att = ENTITY(g_IEngine->GetPlayerForUserID(attacker));
if (vic == nullptr || att == nullptr)
return;
PrintChat("\x07%06X%s\x01 killed \x07%06X%s\x01",
colors::chat::team(att->m_iTeam()), kinfo.name,
colors::chat::team(vic->m_iTeam()), vinfo.name);
}
static void handlePlayerSpawn(KeyValues *kv)
{
int id = kv->GetInt("userid");
player_info_s info{};
g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(id), &info);
CachedEntity *player = ENTITY(g_IEngine->GetPlayerForUserID(id));
if (player == nullptr)
return;
PrintChat("\x07%06X%s\x01 (re)spawned",
colors::chat::team(player->m_iTeam()), info.name);
}
static void handlePlayerChangeClass(KeyValues *kv)
{
int id = kv->GetInt("userid");
player_info_s info{};
g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(id), &info);
CachedEntity *player = ENTITY(g_IEngine->GetPlayerForUserID(id));
if (player == nullptr)
return;
PrintChat("\x07%06X%s\x01 changed to \x07%06X%s\x01",
colors::chat::team(player->m_iTeam()), info.name,
0xa06ba0, classname(kv->GetInt("class")));
}
static void handleVoteCast(KeyValues *kv)
{
int vote_option = kv->GetInt("vote_option");
int team = kv->GetInt("team");
int idx = kv->GetInt("entityid");
player_info_s info{};
const char *team_s = teamname(team);
if (g_IEngine->GetPlayerInfo(idx, &info))
PrintChat(
"\x07%06X%s\x01 Voted \x07%06X%d\x01 on team \x07%06X%s\x01",
colors::chat::team(team), info.name, colors::chat::team(team),
vote_option, colors::chat::team(team), team_s);
}
class LoggingEventListener: public IGameEventListener
{
public:
void FireGameEvent(KeyValues *event) override
{
if (!enable)
return;
const char *name = event->GetName();
if (!strcmp(name, "player_connect_client"))
handlePlayerConnectClient(event);
else if (!strcmp(name, "player_activate"))
handlePlayerActivate(event);
else if (!strcmp(name, "player_disconnect"))
handlePlayerDisconnect(event);
else if (!strcmp(name, "player_team"))
handlePlayerTeam(event);
else if (!strcmp(name, "player_hurt"))
handlePlayerHurt(event);
else if (!strcmp(name, "player_death"))
handlePlayerDeath(event);
else if (!strcmp(name, "player_spawn"))
handlePlayerSpawn(event);
else if (!strcmp(name, "player_changeclass"))
handlePlayerChangeClass(event);
else if (!strcmp(name, "vote_cast"))
handleVoteCast(event);
}
};
LoggingEventListener listener{};
InitRoutine init([]() {
g_IGameEventManager->AddListener(&listener, false);
});