From f59a41d0c4abfd2c979df9a448561786fb5d678e Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Thu, 23 Mar 2017 19:01:15 +0300 Subject: [PATCH] ADDED: Weapon name ESP (unlocalized), cat_fb_mimic_slot, fixed crash on running connect console command using IPC (and disconnect too) --- src/hack.cpp | 7 ++++++- src/hack.h | 3 ++- src/hacks/ESP.cpp | 7 +++++++ src/hacks/FollowBot.cpp | 14 ++++++++++++++ src/hacks/Misc.cpp | 1 + src/hooks/PaintTraverse.cpp | 11 ++++++----- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/hack.cpp b/src/hack.cpp index 2b951935..747cc0dd 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -53,15 +53,20 @@ bool hack::shutdown = false; +std::mutex hack::command_stack_mutex; std::stack& hack::command_stack() { static std::stack stack; return stack; } +void hack::ExecuteCommand(const std::string command) { + std::lock_guard guard(hack::command_stack_mutex); + hack::command_stack().push(command); +} + void hack::InitHacks() { } -//std::mutex hack::command_stack_mutex; ConCommand* hack::c_Cat = 0; void hack::CC_Cat(const CCommand& args) { diff --git a/src/hack.h b/src/hack.h index 3620be9e..8719f7d2 100644 --- a/src/hack.h +++ b/src/hack.h @@ -23,8 +23,9 @@ class CCommand; namespace hack { -//extern std::mutex command_stack_mutex; +extern std::mutex command_stack_mutex; std::stack& command_stack(); +void ExecuteCommand(const std::string command); extern bool shutdown; diff --git a/src/hacks/ESP.cpp b/src/hacks/ESP.cpp index 4fab4a26..3220dd72 100644 --- a/src/hacks/ESP.cpp +++ b/src/hacks/ESP.cpp @@ -12,6 +12,7 @@ namespace hacks { namespace shared { namespace esp { +CatVar show_weapon(CV_SWITCH, "esp_weapon", "1", "Show weapon name", "Show which weapon does the enemy use"); CatVar local_esp(CV_SWITCH, "esp_local", "1", "ESP Local Player", "Shows local player ESP in thirdperson"); CatVar buildings(CV_SWITCH, "esp_buildings", "1", "Building ESP", "Show buildings"); CatVar enabled(CV_SWITCH, "esp_enabled", "0", "ESP", "Master ESP switch"); @@ -308,6 +309,12 @@ void ProcessEntity(CachedEntity* ent) { AddEntityString(ent, "CRIT BOOSTED"); } } + CachedEntity* weapon = ENTITY(CE_INT(ent, netvar.hActiveWeapon) & 0xFFF); + if (CE_GOOD(weapon)) { + if (show_weapon) { + AddEntityString(ent, std::string(vfunc(weapon->m_pEntity, 398, 0)(weapon->m_pEntity))); + } + } } return; } diff --git a/src/hacks/FollowBot.cpp b/src/hacks/FollowBot.cpp index e40d1726..d03b17ba 100644 --- a/src/hacks/FollowBot.cpp +++ b/src/hacks/FollowBot.cpp @@ -34,6 +34,7 @@ CatCommand follow_entity("fb_follow_entity", "Follows entity with specified enti logging::Info("not yet implemented."); }); CatVar bot(CV_SWITCH, "fb_bot", "0", "This player is a bot", "Set to 1 in followbots' configs"); +CatVar mimic_slot(CV_SWITCH, "fb_mimic_slot", "1", "Mimic selected weapon", "If enabled, this bot will select same weapon slot as the owner"); // I've spent 2 days on writing this method. // I couldn't succeed. @@ -107,6 +108,19 @@ void DoWalking() { } } CachedEntity* found_entity = ENTITY(following_idx); + + if (mimic_slot) { + CachedEntity* owner_weapon = ENTITY(CE_INT(found_entity, netvar.hActiveWeapon) & 0xFFF); + if (CE_GOOD(owner_weapon) && CE_GOOD(g_pLocalPlayer->weapon())) { + // FIXME proper classes + const int my_slot = vfunc(g_pLocalPlayer->weapon()->m_pEntity, 395, 0)(g_pLocalPlayer->weapon()->m_pEntity); + const int owner_slot = vfunc(owner_weapon->m_pEntity, 395, 0)(owner_weapon->m_pEntity); + if (my_slot != owner_slot) { + g_IEngine->ExecuteClientCmd(format("slot", owner_slot + 1).c_str()); + } + } + } + if (!found_entity->IsVisible()) { if (!lost_time) { lost_time = g_GlobalVars->curtime; diff --git a/src/hacks/Misc.cpp b/src/hacks/Misc.cpp index e6bef42b..4380fcf0 100644 --- a/src/hacks/Misc.cpp +++ b/src/hacks/Misc.cpp @@ -77,6 +77,7 @@ void Draw() { if (!debug_info) return; if (CE_GOOD(g_pLocalPlayer->weapon())) { + AddSideString(format("Slot: ", vfunc(g_pLocalPlayer->weapon()->m_pEntity, 395, 0)(g_pLocalPlayer->weapon()->m_pEntity))); /*AddSideString(colors::white, "Weapon: %s [%i]", RAW_ENT(g_pLocalPlayer->weapon())->GetClientClass()->GetName(), g_pLocalPlayer->weapon()->m_iClassID); //AddSideString(colors::white, "flNextPrimaryAttack: %f", CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flNextPrimaryAttack)); //AddSideString(colors::white, "nTickBase: %f", (float)(CE_INT(g_pLocalPlayer->entity, netvar.nTickBase)) * gvars->interval_per_tick); diff --git a/src/hooks/PaintTraverse.cpp b/src/hooks/PaintTraverse.cpp index 0699ce05..c781fa73 100644 --- a/src/hooks/PaintTraverse.cpp +++ b/src/hooks/PaintTraverse.cpp @@ -72,12 +72,13 @@ void PaintTraverse_hook(void* p, unsigned int vp, bool fr, bool ar) { draw_flag = false; { - while (!hack::command_stack().empty()) { - logging::Info("executing %s", hack::command_stack().top().c_str()); - g_IEngine->ExecuteClientCmd(hack::command_stack().top().c_str()); - hack::command_stack().pop(); - } + std::lock_guard guard(hack::command_stack_mutex); + while (!hack::command_stack().empty()) { + logging::Info("executing %s", hack::command_stack().top().c_str()); + g_IEngine->ClientCmd_Unrestricted(hack::command_stack().top().c_str()); + hack::command_stack().pop(); } + } if (disable_visuals) return;