Menu Rewrite (BEFORE)
This commit is contained in:
parent
fc52c41ebf
commit
39a872dafa
@ -7,6 +7,12 @@ SteamID DRM
|
||||
HWID:
|
||||
/etc/machine-id
|
||||
/etc/fstab
|
||||
|
||||
fullbright toggle
|
||||
instant taunt
|
||||
TTS
|
||||
noise spam
|
||||
Auto backstab, noise maker spam, kill say, team name spam (pre round team name spam thing), insta taunt (taunts for like .5 ms and then you can do it again lithium has it) auto vacc, namesteal, autovote, fix the menu im to lazy to hit x when i want to close the cheat, custom esp, voice command spam (not like 1 voice command every 1 ms but like just spamming it on the menu)
|
||||
|
||||
FIX crash
|
||||
FIX conds
|
||||
|
47
cathook/src/chatstack.cpp
Normal file
47
cathook/src/chatstack.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* chatstack.cpp
|
||||
*
|
||||
* Created on: Jan 24, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "chatstack.h"
|
||||
#include "common.h"
|
||||
#include "sdk.h"
|
||||
|
||||
ChatStack::ChatStack() {
|
||||
m_Buffer = new char[256 * CHATSTACK_SIZE];
|
||||
m_nStackDepth = 0;
|
||||
}
|
||||
|
||||
ChatStack::~ChatStack() {
|
||||
delete [] m_Buffer;
|
||||
}
|
||||
|
||||
void ChatStack::OnCreateMove() {
|
||||
if (m_nStackDepth <= 0) return;
|
||||
if (m_fLastSay > interfaces::gvars->curtime) m_fLastSay = 0;
|
||||
if (interfaces::gvars->curtime - CHATSTACK_INTERVAL <= m_fLastSay) return;
|
||||
const char* msg = Pop();
|
||||
const char* cmd = strfmt("say \"%s\"", msg);
|
||||
interfaces::engineClient->ServerCmd(cmd);
|
||||
m_fLastSay = interfaces::gvars->curtime;
|
||||
delete [] cmd;
|
||||
}
|
||||
|
||||
void ChatStack::Push(const char* message) {
|
||||
if (m_nStackDepth >= CHATSTACK_SIZE) return;
|
||||
strncpy(&m_Buffer[m_nStackDepth++ * 256], message, 255);
|
||||
}
|
||||
|
||||
const char* ChatStack::Pop() {
|
||||
if (m_nStackDepth <= 0) return 0;
|
||||
return (const char*)&m_Buffer[(--m_nStackDepth) * 256];
|
||||
}
|
||||
|
||||
|
||||
void ChatStack::Reset() {
|
||||
m_nStackDepth = 0;
|
||||
}
|
||||
|
||||
ChatStack* g_pChatStack = 0;
|
29
cathook/src/chatstack.h
Normal file
29
cathook/src/chatstack.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* chatstack.h
|
||||
*
|
||||
* Created on: Jan 24, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#ifndef CHATSTACK_H_
|
||||
#define CHATSTACK_H_
|
||||
|
||||
#define CHATSTACK_SIZE 32
|
||||
#define CHATSTACK_INTERVAL 0.8f
|
||||
|
||||
class ChatStack {
|
||||
public:
|
||||
ChatStack();
|
||||
~ChatStack();
|
||||
void OnCreateMove();
|
||||
void Reset();
|
||||
void Push(const char* message);
|
||||
const char* Pop();
|
||||
int m_nStackDepth;
|
||||
char* m_Buffer;
|
||||
float m_fLastSay;
|
||||
};
|
||||
|
||||
extern ChatStack* g_pChatStack;
|
||||
|
||||
#endif /* CHATSTACK_H_ */
|
@ -27,6 +27,8 @@
|
||||
#include "prediction.h"
|
||||
#include "conditions.h"
|
||||
#include "ipc/ipcctl.h"
|
||||
#include "chatstack.h"
|
||||
#include "textfile.h"
|
||||
|
||||
#include "hacks/hacklist.h"
|
||||
#include "glowobjects.h"
|
||||
|
@ -35,6 +35,7 @@ int CatEnum::Minimum() {
|
||||
bool CatVar::GetBool() { return m_pConVar->GetBool(); }
|
||||
int CatVar::GetInt() { return m_pConVar->GetInt(); }
|
||||
float CatVar::GetFloat() { return m_pConVar->GetFloat(); }
|
||||
const char* CatVar::GetString() { return m_pConVar->GetString(); }
|
||||
|
||||
void CatVar::Increment(int factor) {
|
||||
if (!m_pConVar) return;
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
bool GetBool();
|
||||
int GetInt();
|
||||
float GetFloat();
|
||||
const char* GetString();
|
||||
|
||||
void Increment(int factor = 1);
|
||||
void Decrement(int factor = 1);
|
||||
|
@ -85,7 +85,7 @@ void AddCenterString(Color fg, Color bg, const char* fmt, ...) {
|
||||
// TODO globals
|
||||
unsigned long draw::font_handle = 0;
|
||||
unsigned long draw::panel_top = 0;
|
||||
unsigned long draw::font_handle_large = 0;
|
||||
unsigned long draw::font_handle_menu = 0;
|
||||
int draw::width = 0;
|
||||
int draw::height = 0;
|
||||
|
||||
@ -286,15 +286,15 @@ ESPStringCompound::ESPStringCompound() {
|
||||
|
||||
void draw::Initialize() {
|
||||
draw::font_handle = interfaces::surface->CreateFont();
|
||||
draw::font_handle_large = interfaces::surface->CreateFont();
|
||||
draw::font_handle_menu = interfaces::surface->CreateFont();
|
||||
interfaces::surface->SetFontGlyphSet(draw::font_handle, "Ubuntu Mono Bold", 14, 0, 0, 0, 0x0); // Ubuntu Mono Bold
|
||||
interfaces::surface->SetFontGlyphSet(draw::font_handle_large, "TF2 BUILD", 32, 500, 0, 0, 0x200);
|
||||
interfaces::surface->SetFontGlyphSet(draw::font_handle_menu, "Verdana", 12, 0, 0, 0, 0x0);
|
||||
}
|
||||
|
||||
void draw::DrawString(unsigned long font, int x, int y, Color color, const wchar_t* text) {
|
||||
interfaces::surface->DrawSetTextPos(x, y);
|
||||
interfaces::surface->DrawSetTextColor(color);
|
||||
interfaces::surface->DrawSetTextFont(draw::font_handle);
|
||||
interfaces::surface->DrawSetTextFont(font);
|
||||
//interfaces::surface->DrawPrintText(text, wcslen(text));
|
||||
interfaces::surface->DrawUnicodeString(text, vgui::FONT_DRAW_DEFAULT);
|
||||
}
|
||||
@ -329,9 +329,23 @@ void draw::DrawString(int x, int y, Color color, const char* text, ...) {
|
||||
vsprintf(buffer, text, list);
|
||||
va_end(list);
|
||||
swprintf(string, 1024, L"%s", buffer);
|
||||
draw::DrawString(draw::font_handle, x + 1, y + 1, colors::black, string);
|
||||
draw::DrawString(draw::font_handle, x, y, color, string);
|
||||
}
|
||||
|
||||
void draw::DrawString(unsigned font_handle, int x, int y, Color color, const char* text, ...) {
|
||||
if (!text) return;
|
||||
va_list list;
|
||||
char buffer[1024] = { '\0' };
|
||||
wchar_t string[1024] = { '\0' };
|
||||
va_start(list, text);
|
||||
vsprintf(buffer, text, list);
|
||||
va_end(list);
|
||||
swprintf(string, 1024, L"%s", buffer);
|
||||
draw::DrawString(font_handle, x + 1, y + 1, colors::black, string);
|
||||
draw::DrawString(font_handle, x, y, color, string);
|
||||
}
|
||||
|
||||
bool draw::EntityCenterToScreen(CachedEntity* entity, Vector& out) {
|
||||
if (!entity) return false;
|
||||
Vector world;
|
||||
|
@ -65,7 +65,7 @@ extern int g_nStringsCenter;
|
||||
namespace draw {
|
||||
|
||||
extern unsigned long font_handle;
|
||||
extern unsigned long font_handle_large;
|
||||
extern unsigned long font_handle_menu;
|
||||
extern unsigned long panel_top;
|
||||
extern int width;
|
||||
extern int height;
|
||||
@ -79,6 +79,7 @@ bool WorldToScreen(Vector &origin, Vector &screen);
|
||||
bool EntityCenterToScreen(CachedEntity* entity, Vector& out);
|
||||
void OutlineRect(int x, int y, int w, int h, Color color);
|
||||
void GetStringLength(char* string, int& length, int& height);
|
||||
void DrawString(unsigned font_handle, int x, int y, Color color, const char* text, ...);
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,13 +24,19 @@ void GUI_List::Move(int x, int y) {
|
||||
|
||||
void GUI_List::Draw() {
|
||||
IGUIListElement* current = m_pFirst;
|
||||
draw::DrawRect(x, y, LIST_WIDTH, m_nElementCount * VERTICAL_SPACING, colors::Transparent(colors::black));
|
||||
int curidx = 0;
|
||||
while (current) {
|
||||
current->Draw(x + 1, y + 1 + curidx++ * VERTICAL_SPACING, (current == m_pSelected));
|
||||
if (current == m_pSelected) {
|
||||
draw::DrawRect(x, y + curidx * VERTICAL_SPACING - curidx, LIST_WIDTH, VERTICAL_SPACING, colors::Transparent(colors::pink, 0.1f));
|
||||
} else {
|
||||
//draw::DrawRect(x, y + curidx * VERTICAL_SPACING, LIST_WIDTH, VERTICAL_SPACING, colors::Transparent(colors::black));
|
||||
}
|
||||
draw::OutlineRect(x, y + curidx * VERTICAL_SPACING - curidx, LIST_WIDTH, VERTICAL_SPACING, colors::pink);
|
||||
current->Draw(x + 1, y + 1 + curidx++ * VERTICAL_SPACING - curidx, (current == m_pSelected));
|
||||
|
||||
current = current->m_pNext;
|
||||
}
|
||||
draw::OutlineRect(x, y, LIST_WIDTH, m_nElementCount * VERTICAL_SPACING, colors::pink);
|
||||
//draw::OutlineRect(x, y, LIST_WIDTH, m_nElementCount * VERTICAL_SPACING, colors::pink);
|
||||
}
|
||||
|
||||
void GUI_List::AddElement(IGUIListElement* element) {
|
||||
@ -94,6 +100,22 @@ void GUI_List::KeyEvent(ButtonCode_t key) {
|
||||
}
|
||||
}
|
||||
|
||||
GUIListElement_TitleList::GUIListElement_TitleList(const char* title) {
|
||||
m_pszTitle = title; // TODO strcpy
|
||||
m_pNext = 0;
|
||||
m_pPrev = 0;
|
||||
}
|
||||
|
||||
void GUIListElement_TitleList::Draw(int x, int y, bool selected) {
|
||||
int l, h;
|
||||
draw::GetStringLength((char*)m_pszTitle, l, h);
|
||||
draw::DrawString(draw::font_handle_menu, x + (LIST_WIDTH - l) / 2, y, colors::white, "%s", m_pszTitle);
|
||||
}
|
||||
|
||||
void GUIListElement_TitleList::KeyEvent(ButtonCode_t key) {
|
||||
return;
|
||||
}
|
||||
|
||||
GUIListElement_Var::GUIListElement_Var(CatVar* var) {
|
||||
m_pCatVar = var;
|
||||
m_pNext = 0;
|
||||
@ -103,34 +125,34 @@ GUIListElement_Var::GUIListElement_Var(CatVar* var) {
|
||||
void GUIListElement_Var::Draw(int x, int y, bool selected) {
|
||||
switch (m_pCatVar->m_Type) {
|
||||
case CatVar_t::CV_SWITCH: {
|
||||
draw::DrawString(x, y, selected ? colors::pink : colors::Transparent(colors::pink), "%s", m_pCatVar->GetConVar()->GetHelpText());
|
||||
draw::DrawString(draw::font_handle_menu, x, y, colors::white, "%s", m_pCatVar->GetConVar()->GetHelpText());
|
||||
int l, h;
|
||||
bool enabled = m_pCatVar->GetConVar()->GetInt();
|
||||
draw::GetStringLength(enabled ? (char*)"ON" : (char*)"OFF", l, h);
|
||||
draw::DrawString(x + LIST_WIDTH - l - 3, y, selected ? colors::pink : colors::Transparent(colors::pink), enabled ? "ON" : "OFF");
|
||||
draw::DrawString(draw::font_handle_menu, x + LIST_WIDTH - l - 3, y, colors::white, enabled ? "ON" : "OFF");
|
||||
} break;
|
||||
case CatVar_t::CV_FLOAT: {
|
||||
draw::DrawString(x, y, selected ? colors::pink : colors::Transparent(colors::pink), "%s", m_pCatVar->GetConVar()->GetHelpText());
|
||||
draw::DrawString(draw::font_handle_menu, x, y, colors::white, "%s", m_pCatVar->GetConVar()->GetHelpText());
|
||||
int l, h;
|
||||
draw::GetStringLength(strfmt("%.1f", m_pCatVar->GetConVar()->GetFloat()), l, h);
|
||||
draw::DrawString(x + LIST_WIDTH - l - 3, y, selected ? colors::pink : colors::Transparent(colors::pink), "%.1f", m_pCatVar->GetConVar()->GetFloat());
|
||||
draw::DrawString(draw::font_handle_menu, x + LIST_WIDTH - l - 3, y, colors::white, "%.1f", m_pCatVar->GetConVar()->GetFloat());
|
||||
} break;
|
||||
case CatVar_t::CV_INT: {
|
||||
draw::DrawString(x, y, selected ? colors::pink : colors::Transparent(colors::pink), "%s", m_pCatVar->GetConVar()->GetHelpText());
|
||||
draw::DrawString(draw::font_handle_menu, x, y, colors::white, "%s", m_pCatVar->GetConVar()->GetHelpText());
|
||||
int l, h;
|
||||
draw::GetStringLength(strfmt("%i", m_pCatVar->GetConVar()->GetInt()), l, h);
|
||||
draw::DrawString(x + LIST_WIDTH - l - 3, y, selected ? colors::pink : colors::Transparent(colors::pink), "%i", m_pCatVar->GetConVar()->GetInt());
|
||||
draw::DrawString(draw::font_handle_menu, x + LIST_WIDTH - l - 3, y, colors::white, "%i", m_pCatVar->GetConVar()->GetInt());
|
||||
} break;
|
||||
case CatVar_t::CV_ENUM: {
|
||||
draw::DrawString(x, y, selected ? colors::pink : colors::Transparent(colors::pink), "%s", m_pCatVar->GetConVar()->GetHelpText());
|
||||
draw::DrawString(draw::font_handle_menu, x, y, colors::white, "%s", m_pCatVar->GetConVar()->GetHelpText());
|
||||
int l, h;
|
||||
const char* str = m_pCatVar->m_EnumType->Name(m_pCatVar->GetInt());
|
||||
if (str) {
|
||||
draw::GetStringLength((char*)str, l, h);
|
||||
draw::DrawString(x + LIST_WIDTH - l - 3, y, selected ? colors::pink : colors::Transparent(colors::pink), str);
|
||||
draw::DrawString(draw::font_handle_menu, x + LIST_WIDTH - l - 3, y, colors::white, str);
|
||||
} else {
|
||||
draw::GetStringLength(strfmt("%i", m_pCatVar->GetConVar()->GetInt()), l, h);
|
||||
draw::DrawString(x + LIST_WIDTH - l - 3, y, selected ? colors::pink : colors::Transparent(colors::pink), "%i", m_pCatVar->GetConVar()->GetInt());
|
||||
draw::DrawString(draw::font_handle_menu, x + LIST_WIDTH - l - 3, y, colors::white, "%i", m_pCatVar->GetConVar()->GetInt());
|
||||
}
|
||||
} break;
|
||||
}
|
||||
@ -161,7 +183,12 @@ GUIListElement_SubList::GUIListElement_SubList(GUI_List* list) {
|
||||
}
|
||||
|
||||
void GUIListElement_SubList::Draw(int x, int y, bool selected) {
|
||||
draw::DrawString(x, y, selected ? colors::pink : colors::Transparent(colors::pink), "> %s", m_pList->m_pszListTitle);
|
||||
if (selected) {
|
||||
draw::DrawString(draw::font_handle_menu, x, y, colors::white, "[-] %s", m_pList->m_pszListTitle);
|
||||
} else {
|
||||
draw::DrawString(draw::font_handle_menu, x, y, colors::white, "[+] %s", m_pList->m_pszListTitle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GUIListElement_SubList::KeyEvent(ButtonCode_t key) {
|
||||
@ -169,7 +196,7 @@ void GUIListElement_SubList::KeyEvent(ButtonCode_t key) {
|
||||
case ButtonCode_t::KEY_ENTER:
|
||||
case ButtonCode_t::KEY_SPACE:
|
||||
case ButtonCode_t::KEY_RIGHT:
|
||||
m_pList->Move(m_pParentList->x + LIST_WIDTH + 3, m_pParentList->y + VERTICAL_SPACING * m_nIndex);
|
||||
m_pList->Move(m_pParentList->x + LIST_WIDTH - 1, m_pParentList->y + VERTICAL_SPACING * m_nIndex - m_nIndex);
|
||||
g_pGUI->PushList(m_pList->m_pszListID);
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,8 @@
|
||||
#include "../cvwrapper.h"
|
||||
#include "../sdk.h"
|
||||
|
||||
#define VERTICAL_SPACING 14
|
||||
#define LIST_WIDTH 200
|
||||
#define VERTICAL_SPACING 16
|
||||
#define LIST_WIDTH 220
|
||||
|
||||
class IGUIListElement;
|
||||
|
||||
@ -64,4 +64,13 @@ public:
|
||||
GUI_List* m_pList;
|
||||
};
|
||||
|
||||
class GUIListElement_TitleList : public IGUIListElement {
|
||||
public:
|
||||
GUIListElement_TitleList(const char* title);
|
||||
void Draw(int x, int y, bool selected);
|
||||
void KeyEvent(ButtonCode_t key);
|
||||
|
||||
const char* m_pszTitle;
|
||||
};
|
||||
|
||||
#endif /* CONTROLS_H_ */
|
||||
|
@ -16,6 +16,7 @@ GUI::GUI() {
|
||||
m_nStackSize = 0;
|
||||
m_ListStack = new GUI_List*[LISTS_MAX]();
|
||||
m_Lists = new GUI_List*[LISTS_MAX]();
|
||||
m_pLastHoveredElement = 0;
|
||||
}
|
||||
|
||||
void GUI::AddList(GUI_List* list) {
|
||||
@ -41,12 +42,18 @@ void GUI::PopList() {
|
||||
}
|
||||
|
||||
void GUI::Draw() {
|
||||
if (!v_bGUIVisible || !v_bGUIVisible->GetBool()) return;
|
||||
if (!v_bGUIVisible || !v_bGUIVisible->GetBool()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_nStackSize; i++) {
|
||||
GUI_List* list = m_ListStack[i];
|
||||
if (list)
|
||||
list->Draw();
|
||||
}
|
||||
|
||||
draw::DrawRect(m_nMouseX - 5, m_nMouseY - 5, 10, 10, colors::Transparent(colors::white));
|
||||
draw::OutlineRect(m_nMouseX - 5, m_nMouseY - 5, 10, 10, colors::pink);
|
||||
}
|
||||
|
||||
void GUI::UpdateKeys() {
|
||||
@ -61,14 +68,27 @@ void GUI::UpdateKeys() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_bKeysInit) m_bKeysInit = 1;
|
||||
}
|
||||
|
||||
void GUIVisibleCallback(IConVar* var, const char* pOldValue, float flOldValue) {
|
||||
if (g_pGUI->v_bGUIVisible) {
|
||||
interfaces::input->SetCursorPosition(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::UpdateMouse() {
|
||||
m_nMouseX = interfaces::input->GetAnalogValue(AnalogCode_t::MOUSE_X);
|
||||
m_nMouseY = interfaces::input->GetAnalogValue(AnalogCode_t::MOUSE_Y);
|
||||
}
|
||||
|
||||
bool GUI::KeyEvent(ButtonCode_t key) {
|
||||
// logging::Info("pressed %i", key);
|
||||
if (m_bPressedState[key]) {
|
||||
if (key == KEY_INSERT)
|
||||
if (key == KEY_INSERT) {
|
||||
v_bGUIVisible->m_pConVar->SetValue(!v_bGUIVisible->GetBool());
|
||||
}
|
||||
if (!v_bGUIVisible || !v_bGUIVisible->GetBool()) return false;
|
||||
if (key == KEY_BACKSPACE) {
|
||||
PopList();
|
||||
@ -93,23 +113,28 @@ bool GUI::KeyEvent(ButtonCode_t key) {
|
||||
#define ADD_VAR(list, var) \
|
||||
list_##list->AddElement(new GUIListElement_Var(var));
|
||||
|
||||
#define ADD_TITLE(list, name) \
|
||||
list_##list->AddElement(new GUIListElement_TitleList(name));
|
||||
|
||||
|
||||
void GUI::Setup() {
|
||||
v_bGUIVisible = CREATE_CV(CV_SWITCH, "gui_visible", "0", "Shows/hides the GUI");
|
||||
|
||||
CREATE_LIST(main, "MAIN");
|
||||
CREATE_LIST(aimbot, "Aimbot");
|
||||
CREATE_LIST(aimbot, "Aim Bot");
|
||||
CREATE_LIST(antiaim, "Anti-Aim");
|
||||
CREATE_LIST(autoheal, "Auto Heal");
|
||||
CREATE_LIST(autoreflect, "Auto Reflect");
|
||||
CREATE_LIST(autosticky, "Auto Sticky");
|
||||
CREATE_LIST(esp, "ESP");
|
||||
CREATE_LIST(bhop, "Bunnyhop");
|
||||
CREATE_LIST(trigger, "Triggerbot");
|
||||
CREATE_LIST(bhop, "Bunny Hop");
|
||||
CREATE_LIST(trigger, "Trigger Bot");
|
||||
CREATE_LIST(spy, "Spy Alert");
|
||||
|
||||
list_main->Move(100, 100);
|
||||
|
||||
ADD_TITLE(main, ">>> CatHook <<<");
|
||||
|
||||
ADD_SUBLIST(main, aimbot);
|
||||
ADD_SUBLIST(main, antiaim);
|
||||
ADD_SUBLIST(main, autoreflect);
|
||||
@ -120,6 +145,8 @@ void GUI::Setup() {
|
||||
ADD_SUBLIST(main, trigger);
|
||||
ADD_SUBLIST(main, spy);
|
||||
|
||||
ADD_TITLE(aimbot, ">>> Aim Bot Menu <<<");
|
||||
|
||||
ADD_VAR(aimbot, g_phAimbot->v_bEnabled);
|
||||
// TODO enums
|
||||
ADD_VAR(aimbot, g_phAimbot->v_eAimKeyMode);
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
void PushList(const char* id);
|
||||
void PopList();
|
||||
void UpdateKeys();
|
||||
void UpdateMouse();
|
||||
|
||||
void Setup();
|
||||
|
||||
@ -38,6 +39,9 @@ public:
|
||||
int m_nListCount;
|
||||
int m_nStackSize;
|
||||
CatVar* v_bGUIVisible;
|
||||
int m_nMouseX;
|
||||
int m_nMouseY;
|
||||
IGUIListElement* m_pLastHoveredElement;
|
||||
};
|
||||
|
||||
extern GUI* g_pGUI;
|
||||
|
@ -180,6 +180,7 @@ void hack::Initialize() {
|
||||
g_GlowObjectManager = *reinterpret_cast<CGlowObjectManager**>(gSignatures.GetClientSignature("C1 E0 05 03 05") + 5);
|
||||
logging::Info("GlowObjectManager: 0x%08x", g_GlowObjectManager);
|
||||
InitStrings();
|
||||
g_pChatStack = new ChatStack();
|
||||
logging::Info("Init done!");
|
||||
}
|
||||
|
||||
|
@ -37,20 +37,20 @@ void KillSayEventListener::FireGameEvent(IGameEvent* event) {
|
||||
SEGV_BEGIN;
|
||||
const char* msg = g_phKillSay->ComposeKillSay(event);
|
||||
if (msg) {
|
||||
g_phKillSay->PushStack(msg);
|
||||
g_pChatStack->Push(msg);
|
||||
delete msg;
|
||||
}
|
||||
SEGV_END;
|
||||
}
|
||||
|
||||
const char* KillSay::ComposeKillSay(IGameEvent* event) {
|
||||
if (m_nKillSays == 0) return 0;
|
||||
if (m_TextFile->GetLineCount() == 0) return 0;
|
||||
if (!event) return 0;
|
||||
int vid = event->GetInt("userid");
|
||||
int kid = event->GetInt("attacker");
|
||||
if (kid == vid) return 0;
|
||||
if (interfaces::engineClient->GetPlayerForUserID(kid) != interfaces::engineClient->GetLocalPlayer()) return 0;
|
||||
char* msg = strfmt("%s", m_KillSays[rand() % m_nKillSays]);
|
||||
char* msg = strfmt("%s", m_TextFile->GetLine(rand() % m_TextFile->GetLineCount()));
|
||||
player_info_s info;
|
||||
interfaces::engineClient->GetPlayerInfo(interfaces::engineClient->GetPlayerForUserID(vid), &info);
|
||||
ReplaceString(msg, "%name%", info.name);
|
||||
@ -70,11 +70,8 @@ const char* KillSay::ComposeKillSay(IGameEvent* event) {
|
||||
KillSay::KillSay() {
|
||||
v_bEnabled = CREATE_CV(CV_SWITCH, "killsay", "0", "KillSay");
|
||||
v_sFileName = CREATE_CV(CV_STRING, "killsay_file", "killsays.txt", "Killsay file (~/.cathook/)");
|
||||
m_Stack = new char256[KILLSAY_STACK_SIZE];
|
||||
CreateConCommand("cat_killsay_reload", CC_KillSay_ReloadFile, "Reload KillSay");
|
||||
m_nStackTop = -1;
|
||||
m_fLastSay = 0.0f;
|
||||
m_nKillSays = 0;
|
||||
m_TextFile = new TextFile(256, 1024);
|
||||
interfaces::eventManager->AddListener(&m_Listener, "player_death", false);
|
||||
}
|
||||
|
||||
@ -83,56 +80,10 @@ KillSay::~KillSay() {
|
||||
}
|
||||
|
||||
void CC_KillSay_ReloadFile(const CCommand& args) {
|
||||
SAFE_CALL(g_phKillSay->LoadFile());
|
||||
SAFE_CALL(g_phKillSay->m_TextFile->LoadFile(g_phKillSay->v_sFileName->m_pConVar->GetString()));
|
||||
}
|
||||
|
||||
void KillSay::LoadFile() {
|
||||
uid_t uid = geteuid();
|
||||
passwd* pw = getpwuid(uid);
|
||||
if (!pw) {
|
||||
logging::Info("can't get the username!");
|
||||
return;
|
||||
}
|
||||
char* filename = strfmt("/home/%s/.cathook/%s", pw->pw_name, v_sFileName->m_pConVar->GetString());
|
||||
FILE* file = fopen(filename, "r");
|
||||
if (!file) {
|
||||
logging::Info("Could not open the file: %s", filename);
|
||||
delete filename;
|
||||
return;
|
||||
}
|
||||
delete filename;
|
||||
for (m_nKillSays = 0; m_nKillSays < KILLSAY_ARRAY_MAX_SIZE; m_nKillSays++) {
|
||||
if(fgets(m_KillSays[m_nKillSays], KILLSAY_MAX_LENGTH, file)) {
|
||||
m_KillSays[m_nKillSays][strlen(m_KillSays[m_nKillSays]) - 1] = '\0';
|
||||
} else break;
|
||||
}
|
||||
}
|
||||
|
||||
void KillSay::PushStack(const char* text) {
|
||||
if (m_nStackTop == KILLSAY_STACK_SIZE - 1) return;
|
||||
strncpy(m_Stack[++m_nStackTop].data, text, 255);
|
||||
//logging::Info("Pushed, new stacktop: %i", m_nStackTop);
|
||||
}
|
||||
|
||||
char256* KillSay::PopStack() {
|
||||
if (m_nStackTop < 0) return 0;
|
||||
return &m_Stack[m_nStackTop--];
|
||||
}
|
||||
|
||||
bool KillSay::CreateMove(void*, float, CUserCmd*) {
|
||||
if (m_nStackTop <= 0) return true;
|
||||
if (interfaces::gvars->realtime - m_fLastSay < 1.0f) return true;
|
||||
char256* killsay = PopStack();
|
||||
if (!killsay) return true;
|
||||
char* cmd = strfmt("say \"%s\"", killsay->data);
|
||||
interfaces::engineClient->ServerCmd(cmd, true);
|
||||
delete cmd;
|
||||
m_fLastSay = interfaces::gvars->realtime;
|
||||
return true;
|
||||
}
|
||||
bool KillSay::CreateMove(void*, float, CUserCmd*) { return true; }
|
||||
void KillSay::PaintTraverse(void*, unsigned int, bool, bool) {}
|
||||
void KillSay::LevelInit(const char*) {
|
||||
m_fLastSay = 0.0f;
|
||||
m_nStackTop = -1;
|
||||
}
|
||||
void KillSay::LevelInit(const char*) {}
|
||||
void KillSay::LevelShutdown() {}
|
||||
|
@ -13,11 +13,7 @@
|
||||
#include "../fixsdk.h"
|
||||
#include <igameevents.h>
|
||||
|
||||
#define KILLSAY_STACK_SIZE 64
|
||||
#define KILLSAY_ARRAY_MAX_SIZE 256
|
||||
#define KILLSAY_MAX_LENGTH 256
|
||||
|
||||
struct char256 { char data[256]; };
|
||||
class TextFile;
|
||||
|
||||
class KillSayEventListener : public IGameEventListener2 {
|
||||
virtual void FireGameEvent(IGameEvent* event);
|
||||
@ -28,20 +24,13 @@ public:
|
||||
DECLARE_HACK_METHODS();
|
||||
KillSay();
|
||||
~KillSay();
|
||||
void PushStack(const char* text);
|
||||
char256* PopStack();
|
||||
const char* ComposeKillSay(IGameEvent* evt);
|
||||
void LoadFile();
|
||||
|
||||
CatVar* v_bEnabled;
|
||||
CatVar* v_sFileName;
|
||||
|
||||
char m_KillSays[KILLSAY_ARRAY_MAX_SIZE][KILLSAY_MAX_LENGTH];
|
||||
int m_nKillSays;
|
||||
TextFile* m_TextFile;
|
||||
KillSayEventListener m_Listener;
|
||||
float m_fLastSay;
|
||||
char256* m_Stack;
|
||||
int m_nStackTop;
|
||||
};
|
||||
|
||||
//void CC_PushKillsayDBG(const CCommand& args);
|
||||
|
@ -19,63 +19,39 @@ Spam::Spam() {
|
||||
v_bSpamNewlines = CREATE_CV(CV_SWITCH, "spam_newlines", "1", "Prepend newlines to messages");
|
||||
v_sSpamFile = CREATE_CV(CV_STRING, "spam_file", "spam.txt", "Spam file (~/.cathook/...)");
|
||||
c_Reload = CreateConCommand(CON_PREFIX "spam_reload", &CC_Spam_ReloadFile, "Reloads spam file");
|
||||
m_nSpam = 0;
|
||||
m_iCurrentIndex = 0;
|
||||
m_fLastSpam = 0;
|
||||
m_TextFile = new TextFile(256, 256);
|
||||
}
|
||||
|
||||
bool Spam::CreateMove(void*, float, CUserCmd*) {
|
||||
if (!v_bSpam->GetBool()) return true;
|
||||
if (interfaces::gvars->curtime - m_fLastSpam < 0.8f) return true;
|
||||
if (interfaces::gvars->curtime < m_fLastSpam) m_fLastSpam = 0.0f;
|
||||
if (m_nSpam == 0) return true;
|
||||
if (m_iCurrentIndex >= m_nSpam || m_iCurrentIndex >= SPAM_MAX_AMOUNT) m_iCurrentIndex = 0;
|
||||
if (m_TextFile->GetLineCount() == 0) return true;
|
||||
if (m_iCurrentIndex >= m_TextFile->GetLineCount() || m_iCurrentIndex < 0) m_iCurrentIndex = 0;
|
||||
char* spam = 0;
|
||||
if (v_bSpamNewlines->GetBool()) {
|
||||
spam = strfmt("say \"\n\n\n\n\n\n\n\n\n\n\n\n%s\"", m_Spam[m_iCurrentIndex]);
|
||||
spam = strfmt("\n\n\n\n\n\n\n\n\n\n\n\n\n%s", m_TextFile->GetLine(m_iCurrentIndex));
|
||||
} else {
|
||||
spam = strfmt("say \"%s\"", m_Spam[m_iCurrentIndex]);
|
||||
spam = strfmt("%s", m_TextFile->GetLine(m_iCurrentIndex));
|
||||
}
|
||||
interfaces::engineClient->ServerCmd(spam);
|
||||
m_fLastSpam = interfaces::gvars->curtime;
|
||||
ReplaceString(spam, "\\n", "\n");
|
||||
g_pChatStack->Push(spam);
|
||||
delete [] spam;
|
||||
m_iCurrentIndex++;
|
||||
m_fLastSpam = interfaces::gvars->curtime;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Spam::LevelInit(const char*) {
|
||||
m_fLastSpam = 0.0f;
|
||||
m_fLastSpam = 0;
|
||||
}
|
||||
|
||||
void Spam::PaintTraverse(void*, unsigned int, bool, bool) {}
|
||||
void Spam::LevelShutdown() {
|
||||
m_fLastSpam = 0.0f;
|
||||
}
|
||||
|
||||
void Spam::LoadFile() {
|
||||
m_fLastSpam = 0.0f;
|
||||
uid_t uid = geteuid();
|
||||
passwd* pw = getpwuid(uid);
|
||||
if (!pw) {
|
||||
logging::Info("can't get the username!");
|
||||
return;
|
||||
}
|
||||
char* filename = strfmt("/home/%s/.cathook/%s", pw->pw_name, v_sSpamFile->m_pConVar->GetString());
|
||||
FILE* file = fopen(filename, "r");
|
||||
if (!file) {
|
||||
logging::Info("Could not open the file: %s", filename);
|
||||
delete filename;
|
||||
return;
|
||||
}
|
||||
delete filename;
|
||||
for (m_nSpam = 0; m_nSpam < SPAM_MAX_AMOUNT; m_nSpam++) {
|
||||
if(fgets(m_Spam[m_nSpam], SPAM_MAX_LENGTH, file)) {
|
||||
m_Spam[m_nSpam][strlen(m_Spam[m_nSpam]) - 1] = '\0';
|
||||
ReplaceString(m_Spam[m_nSpam], "\\n", "\n");
|
||||
} else break;
|
||||
}
|
||||
m_fLastSpam = 0;
|
||||
}
|
||||
|
||||
void CC_Spam_ReloadFile(const CCommand& args) {
|
||||
g_phSpam->LoadFile();
|
||||
g_phSpam->m_TextFile->LoadFile(g_phSpam->v_sSpamFile->GetString());
|
||||
}
|
||||
|
@ -13,18 +13,18 @@
|
||||
#define SPAM_MAX_AMOUNT 64
|
||||
#define SPAM_MAX_LENGTH 256
|
||||
|
||||
class TextFile;
|
||||
|
||||
class Spam : public IHack {
|
||||
public:
|
||||
DECLARE_HACK_METHODS();
|
||||
Spam();
|
||||
void LoadFile();
|
||||
CatVar* v_bSpam;
|
||||
CatVar* v_sSpamFile;
|
||||
CatVar* v_bSpamNewlines;
|
||||
ConCommand* c_Reload;
|
||||
char m_Spam[SPAM_MAX_AMOUNT][SPAM_MAX_LENGTH];
|
||||
int m_nSpam;
|
||||
int m_iCurrentIndex;
|
||||
TextFile* m_TextFile;
|
||||
float m_fLastSpam;
|
||||
};
|
||||
|
||||
|
@ -94,6 +94,8 @@ bool CreateMove_hook(void* thisptr, float inputSample, CUserCmd* cmd) {
|
||||
}
|
||||
}*/
|
||||
g_Settings.bInvalid = false;
|
||||
if (g_pChatStack)
|
||||
g_pChatStack->OnCreateMove();
|
||||
if (CE_GOOD(g_pLocalPlayer->entity)) {
|
||||
if (g_pLocalPlayer->bUseSilentAngles) {
|
||||
Vector vsilent(cmd->forwardmove, cmd->sidemove, cmd->upmove);
|
||||
|
@ -24,6 +24,8 @@ void PaintTraverse_hook(void* p, unsigned int vp, bool fr, bool ar) {
|
||||
static unsigned long panel_scope = 0;
|
||||
bool call_default = true;
|
||||
if (g_Settings.bHackEnabled->GetBool() && panel_scope && g_Settings.bNoZoom->GetBool() && vp == panel_scope) call_default = false;
|
||||
if (g_Settings.bHackEnabled->GetBool())
|
||||
interfaces::surface->SetCursorAlwaysVisible(g_pGUI->v_bGUIVisible->GetBool());
|
||||
if (call_default) SAFE_CALL(((PaintTraverse_t*)hooks::hkPanel->GetMethod(hooks::offPaintTraverse))(p, vp, fr, ar));
|
||||
if (!g_Settings.bHackEnabled->GetBool()) return;
|
||||
// Because of single-multi thread shit I'm gonna put this thing riiiight here.
|
||||
@ -142,6 +144,7 @@ void PaintTraverse_hook(void* p, unsigned int vp, bool fr, bool ar) {
|
||||
}
|
||||
#if GUI_ENABLED == true
|
||||
g_pGUI->UpdateKeys();
|
||||
g_pGUI->UpdateMouse();
|
||||
g_pGUI->Draw();
|
||||
#endif
|
||||
DrawStrings();
|
||||
|
@ -209,6 +209,7 @@ void LevelInit_hook(void* thisptr, const char* newmap) {
|
||||
LEVEL_INIT(SpyAlert, newmap);
|
||||
LEVEL_INIT(Triggerbot, newmap);
|
||||
LEVEL_INIT(Glow, newmap);
|
||||
g_pChatStack->Reset();
|
||||
}
|
||||
|
||||
void LevelShutdown_hook(void* thisptr) {
|
||||
@ -230,6 +231,6 @@ void LevelShutdown_hook(void* thisptr) {
|
||||
LEVEL_SHUTDOWN(SpyAlert);
|
||||
LEVEL_SHUTDOWN(Triggerbot);
|
||||
LEVEL_SHUTDOWN(Glow);
|
||||
|
||||
g_pChatStack->Reset();
|
||||
}
|
||||
|
||||
|
57
cathook/src/textfile.cpp
Normal file
57
cathook/src/textfile.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* textfile.cpp
|
||||
*
|
||||
* Created on: Jan 24, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "textfile.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
TextFile::TextFile(unsigned length, unsigned lines) {
|
||||
m_nCount = lines;
|
||||
m_nLength = length;
|
||||
m_Buffer = new char[length * lines];
|
||||
}
|
||||
|
||||
TextFile::~TextFile() {
|
||||
delete [] m_Buffer;
|
||||
}
|
||||
|
||||
void TextFile::LoadFile(const char* name) {
|
||||
uid_t uid = geteuid();
|
||||
passwd* pw = getpwuid(uid);
|
||||
if (!pw) {
|
||||
logging::Info("can't get the username!");
|
||||
return;
|
||||
}
|
||||
char* filename = strfmt("/home/%s/.cathook/%s", pw->pw_name, name);
|
||||
FILE* file = fopen(filename, "r");
|
||||
if (!file) {
|
||||
logging::Info("Could not open the file: %s", filename);
|
||||
delete filename;
|
||||
return;
|
||||
}
|
||||
delete filename;
|
||||
char* buffer = new char[m_nLength];
|
||||
for (m_nCount = 0; m_nCount < m_nLines; m_nCount++) {
|
||||
if(fgets(buffer, m_nLength - 1, file)) {
|
||||
if (buffer[strlen(buffer) - 1] == '\n')
|
||||
buffer[strlen(buffer) - 1] = '\0';
|
||||
strncpy(&m_Buffer[m_nCount * m_nLength], buffer, m_nLength - 1);
|
||||
} else break;
|
||||
}
|
||||
delete [] buffer;
|
||||
}
|
||||
|
||||
const char* TextFile::GetLine(unsigned line) {
|
||||
if (line < 0 || line >= m_nCount) return 0;
|
||||
return (const char*)&m_Buffer[line * m_nLength];
|
||||
}
|
||||
|
||||
unsigned TextFile::GetLineCount() {
|
||||
return m_nCount;
|
||||
}
|
26
cathook/src/textfile.h
Normal file
26
cathook/src/textfile.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* textfile.h
|
||||
*
|
||||
* Created on: Jan 24, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#ifndef TEXTFILE_H_
|
||||
#define TEXTFILE_H_
|
||||
|
||||
class TextFile {
|
||||
public:
|
||||
TextFile(unsigned length, unsigned lines);
|
||||
~TextFile();
|
||||
void LoadFile(const char* name);
|
||||
unsigned GetLineCount();
|
||||
const char* GetLine(unsigned line);
|
||||
|
||||
unsigned m_nLength;
|
||||
unsigned m_nLines;
|
||||
unsigned m_nCount;
|
||||
const char* m_pszFilename;
|
||||
char* m_Buffer;
|
||||
};
|
||||
|
||||
#endif /* TEXTFILE_H_ */
|
Reference in New Issue
Block a user