From f8ec03e1ecedc4531388a77c1afc4811bc203e3f Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Sun, 29 Jul 2018 13:39:30 +0300 Subject: [PATCH] Autostuff --- include/hacks/Backtrack.hpp | 2 +- include/hacks/FollowBot.hpp | 9 +++--- include/hacks/KillSay.hpp | 14 ++------- include/tfmm.hpp | 8 +++-- include/votelogger.hpp | 5 ++-- src/hacks/AntiBackstab.cpp | 2 +- src/hacks/AutoBackstab.cpp | 20 ++++++------- src/hacks/AutoDeadringer.cpp | 7 +++-- src/hacks/AutoDetonator.cpp | 2 +- src/hacks/AutoHeal.cpp | 31 ++++++++++--------- src/hacks/AutoJoin.cpp | 10 +++---- src/hacks/AutoReflect.cpp | 11 +++---- src/hacks/AutoSticky.cpp | 12 ++++---- src/hacks/Backtrack.cpp | 39 +++++++++++------------- src/hacks/Bunnyhop.cpp | 11 ++----- src/hacks/FollowBot.cpp | 29 +++++++++++++----- src/hacks/KillSay.cpp | 58 +++++++++++++++++++----------------- src/hacks/Misc.cpp | 2 +- src/tfmm.cpp | 33 ++++++++++---------- src/votelogger.cpp | 35 ++++++++-------------- 20 files changed, 162 insertions(+), 178 deletions(-) diff --git a/include/hacks/Backtrack.hpp b/include/hacks/Backtrack.hpp index 6746addc..5adb045b 100644 --- a/include/hacks/Backtrack.hpp +++ b/include/hacks/Backtrack.hpp @@ -54,10 +54,10 @@ struct CIncomingSequence }; typedef boost::circular_buffer_space_optimized circular_buf; extern circular_buf sequences; -extern int ticks; extern BacktrackData headPositions[32][66]; extern BestTickData sorted_ticks[66]; bool isBacktrackEnabled(); float getLatency(); +int getTicks(); } diff --git a/include/hacks/FollowBot.hpp b/include/hacks/FollowBot.hpp index 263f23ad..ed61bd59 100644 --- a/include/hacks/FollowBot.hpp +++ b/include/hacks/FollowBot.hpp @@ -10,12 +10,11 @@ namespace hacks::shared::followbot { -// Followed entity, externed for highlight color -extern int follow_target; -extern bool followcart; -extern CatCommand follow_steam; -extern unsigned steamid; void DrawTick(); void WorldTick(); int ClassPriority(CachedEntity *ent); + +bool isEnabled(); +int getTarget(); + } diff --git a/include/hacks/KillSay.hpp b/include/hacks/KillSay.hpp index 7f75ac9c..a05e7642 100755 --- a/include/hacks/KillSay.hpp +++ b/include/hacks/KillSay.hpp @@ -9,20 +9,12 @@ #include "common.hpp" -class CatCommand; - -class KillSayEventListener : public IGameEventListener2 -{ - virtual void FireGameEvent(IGameEvent *event); -}; - namespace hacks::shared::killsay { -void Init(); -void Shutdown(); -void Reload(); -std::string ComposeKillSay(IGameEvent *event); +void init(); +void shutdown(); +void reload(); extern const std::vector builtin_default; extern const std::vector builtin_nonecore_offensive; diff --git a/include/tfmm.hpp b/include/tfmm.hpp index b786a79b..65bfda1d 100755 --- a/include/tfmm.hpp +++ b/include/tfmm.hpp @@ -10,8 +10,10 @@ namespace tfmm { -void queue_start(); -void queue_leave(); -void dcandabandon(); +void startQueue(); +void leaveQueue(); +void disconnectAndAbandon(); void abandon(); +int getQueue(); + } diff --git a/include/votelogger.hpp b/include/votelogger.hpp index 55cfc009..2b6b92a4 100755 --- a/include/votelogger.hpp +++ b/include/votelogger.hpp @@ -12,7 +12,6 @@ class bf_read; namespace votelogger { -void user_message(bf_read &buffer, int type); -extern Timer antikick; -extern bool active; +void dispatchUserMessage(bf_read &buffer, int type); + } diff --git a/src/hacks/AntiBackstab.cpp b/src/hacks/AntiBackstab.cpp index 80fc076d..bbf075fa 100644 --- a/src/hacks/AntiBackstab.cpp +++ b/src/hacks/AntiBackstab.cpp @@ -101,7 +101,7 @@ void CreateMove() { noaa = true; pitchdown->SetValue(180); - g_pUserCmd->viewangles.x = 140.0f; + current_user_cmd->viewangles.x = 140.0f; if (silent) g_pLocalPlayer->bUseSilentAngles = true; if (sayno) diff --git a/src/hacks/AutoBackstab.cpp b/src/hacks/AutoBackstab.cpp index b0d49de2..023760b8 100644 --- a/src/hacks/AutoBackstab.cpp +++ b/src/hacks/AutoBackstab.cpp @@ -64,7 +64,7 @@ bool CanBackstab(CachedEntity *tar, Vector Local_ang) } void CreateMove() { - if (!enabled) + if (!enable) return; if (!CE_GOOD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer() || !CE_GOOD(LOCAL_W)) return; @@ -85,7 +85,7 @@ void CreateMove() if (CE_GOOD(target) && target != LOCAL_E && target->m_iTeam() != LOCAL_E->m_iTeam() && target->m_bAlivePlayer() && target->m_Type() == ENTITY_PLAYER && - !hacks::shared::backtrack::enable && + !hacks::shared::backtrack::isBacktrackEnabled() && CanBackstab(target, g_pLocalPlayer->v_OrigViewangles)) { float swingrange = @@ -97,9 +97,9 @@ void CreateMove() if ((min1.x <= max2.x && max1.x >= min2.x) && (min1.y <= max2.y && max1.y >= min2.y) && (min1.z <= max2.z && max1.z >= min2.z)) - g_pUserCmd->buttons |= IN_ATTACK; + current_user_cmd->buttons |= IN_ATTACK; } - else if (!hacks::shared::backtrack::enable) + else if (!hacks::shared::backtrack::isBacktrackEnabled()) { CachedEntity *tar = nullptr; float bestscr = 9999.9f; @@ -143,8 +143,8 @@ void CreateMove() eyeang.y = i; if (CanBackstab(tar, eyeang)) { - g_pUserCmd->viewangles.y = eyeang.y; - g_pUserCmd->buttons |= IN_ATTACK; + current_user_cmd->viewangles.y = eyeang.y; + current_user_cmd->buttons |= IN_ATTACK; if (silent) g_pLocalPlayer->bUseSilentAngles = true; } @@ -153,13 +153,13 @@ void CreateMove() } else { - if (!hacks::shared::backtrack::enable) + if (!hacks::shared::backtrack::isBacktrackEnabled()) return; if (hacks::shared::backtrack::iBestTarget == -1) return; int iBestTarget = hacks::shared::backtrack::iBestTarget; int tickcnt = 0; - int tickus = (float(hacks::shared::backtrack::latency) > 800.0f || float(hacks::shared::backtrack::latency) < 200.0f) ? 12 : 24; + int tickus = (float(hacks::shared::backtrack::getLatency()) > 800.0f || float(hacks::shared::backtrack::getLatency()) < 200.0f) ? 12 : 24; for (auto i : hacks::shared::backtrack::headPositions[iBestTarget]) { bool good_tick = false; @@ -188,8 +188,8 @@ void CreateMove() NET_FLOAT(RAW_ENT(tar), netvar.m_flSimulationTime); angles.y = i.viewangles; simtime = i.simtime; - g_pUserCmd->tick_count = i.tickcount; - g_pUserCmd->buttons |= IN_ATTACK; + current_user_cmd->tick_count = i.tickcount; + current_user_cmd->buttons |= IN_ATTACK; break; } } diff --git a/src/hacks/AutoDeadringer.cpp b/src/hacks/AutoDeadringer.cpp index d79e0908..1e198649 100644 --- a/src/hacks/AutoDeadringer.cpp +++ b/src/hacks/AutoDeadringer.cpp @@ -4,6 +4,7 @@ * Created on: Apr 12, 2018 * Author: bencat07 */ +#include #include "common.hpp" static settings::Bool enable{ "auto-deadringer.enable", "0" }; @@ -58,7 +59,7 @@ void CreateMove() return; if (CE_INT(LOCAL_E, netvar.iHealth) < (int) trigger_health && NearbyEntities() > 1) - g_pUserCmd->buttons |= IN_ATTACK2; + current_user_cmd->buttons |= IN_ATTACK2; for (int i = 0; i < HIGHEST_ENTITY; i++) { CachedEntity *ent = ENTITY(i); @@ -71,9 +72,9 @@ void CreateMove() if (ent->m_Type() != ENTITY_PROJECTILE) continue; if (ent->m_bCritProjectile() && ent->m_flDistance() <= 1000.0f) - g_pUserCmd->buttons |= IN_ATTACK2; + current_user_cmd->buttons |= IN_ATTACK2; if (ent->m_flDistance() < 300.0f) - g_pUserCmd->buttons |= IN_ATTACK2; + current_user_cmd->buttons |= IN_ATTACK2; } } } diff --git a/src/hacks/AutoDetonator.cpp b/src/hacks/AutoDetonator.cpp index 8d65cb84..b8f4addf 100644 --- a/src/hacks/AutoDetonator.cpp +++ b/src/hacks/AutoDetonator.cpp @@ -120,7 +120,7 @@ void CreateMove() if (VisCheckEntFromEnt(flare, target)) { // Detonate - g_pUserCmd->buttons |= IN_ATTACK2; + current_user_cmd->buttons |= IN_ATTACK2; return; } diff --git a/src/hacks/AutoHeal.cpp b/src/hacks/AutoHeal.cpp index 0bc1f2b5..c976605e 100644 --- a/src/hacks/AutoHeal.cpp +++ b/src/hacks/AutoHeal.cpp @@ -285,7 +285,7 @@ void DoResistSwitching() vaccinator_change_stage = 0; return; } - if (g_pUserCmd->buttons & IN_RELOAD) + if (current_user_cmd->buttons & IN_RELOAD) { vaccinator_change_ticks = 8; return; @@ -294,7 +294,7 @@ void DoResistSwitching() { if (vaccinator_change_ticks <= 0) { - g_pUserCmd->buttons |= IN_RELOAD; + current_user_cmd->buttons |= IN_RELOAD; vaccinator_change_stage--; vaccinator_change_ticks = 8; } @@ -406,10 +406,10 @@ void CreateMove() } if (pop && CurrentResistance() == my_opt) { - g_pUserCmd->buttons |= IN_ATTACK2; + current_user_cmd->buttons |= IN_ATTACK2; } } - if (!force_healing_target && !enabled) + if (!force_healing_target && !enable) return; if (GetWeaponMode() != weapon_medigun) return; @@ -420,11 +420,11 @@ void CreateMove() { Vector out; GetHitbox(target, 7, out); - AimAt(g_pLocalPlayer->v_Eye, out, g_pUserCmd); - g_pUserCmd->buttons |= IN_ATTACK; + AimAt(g_pLocalPlayer->v_Eye, out, current_user_cmd); + current_user_cmd->buttons |= IN_ATTACK; } } - if (!enabled) + if (!enable) return; UpdateData(); int old_target = m_iCurrentHealingTarget; @@ -444,11 +444,11 @@ void CreateMove() Vector out; GetHitbox(target, 7, out); - AimAt(g_pLocalPlayer->v_Eye, out, g_pUserCmd); + AimAt(g_pLocalPlayer->v_Eye, out, current_user_cmd); if (silent) g_pLocalPlayer->bUseSilentAngles = true; if (!m_iNewTarget && (g_GlobalVars->tickcount % 300)) - g_pUserCmd->buttons |= IN_ATTACK; + current_user_cmd->buttons |= IN_ATTACK; /*if (m_iNewTarget || !(g_GlobalVars->tickcount % 300)) { if (silent) g_pLocalPlayer->bUseSilentAngles = true; AimAt(g_pLocalPlayer->v_Eye, out, g_pUserCmd); @@ -461,15 +461,14 @@ void CreateMove() SetResistance(opt); if (pop && CurrentResistance() == opt) { - g_pUserCmd->buttons |= IN_ATTACK2; + current_user_cmd->buttons |= IN_ATTACK2; } } else { if (pop_uber_auto && ShouldPop()) - g_pUserCmd->buttons |= IN_ATTACK2; + current_user_cmd->buttons |= IN_ATTACK2; } - return; } std::vector data(32); @@ -558,18 +557,18 @@ int HealingPriority(int idx) #if ENABLE_IPC if (ipc::peer) { - if (hacks::shared::followbot::followbot && - hacks::shared::followbot::follow_target == idx) + if (hacks::shared::followbot::isEnabled() && + hacks::shared::followbot::getTarget() == idx) { priority *= 6.0f; } } #endif - player_info_s info; +/* player_info_s info; g_IEngine->GetPlayerInfo(idx, &info); info.name[31] = 0; if (strcasestr(info.name, ignore.GetString())) - priority = 0.0f; + priority = 0.0f;*/ return priority; } diff --git a/src/hacks/AutoJoin.cpp b/src/hacks/AutoJoin.cpp index 34a7d92e..2e815202 100644 --- a/src/hacks/AutoJoin.cpp +++ b/src/hacks/AutoJoin.cpp @@ -88,15 +88,15 @@ void updateSearch() re::CTFPartyClient *pc = re::CTFPartyClient::GTFPartyClient(); if (current_user_cmd && gc && gc->BConnectedToMatchServer(false) && gc->BHaveLiveMatch()) - tfmm::queue_leave(); + tfmm::leaveQueue(); if (gc && !gc->BConnectedToMatchServer(false) && queuetime.test_and_set(10 * 1000 * 60) && !gc->BHaveLiveMatch()) - tfmm::queue_leave(); + tfmm::leaveQueue(); if (gc && !gc->BConnectedToMatchServer(false) && !gc->BHaveLiveMatch()) - if (!(pc && pc->BInQueueForMatchGroup(int(tfmm::queue)))) + if (!(pc && pc->BInQueueForMatchGroup(tfmm::getQueue()))) { logging::Info("Starting queue"); - tfmm::queue_start(); + tfmm::startQueue(); } #if LAGBOT_MODE if (req_timer.test_and_set(1800000)) @@ -128,7 +128,7 @@ void update() #endif } -void autojoin::resetQueueTimer() +void resetQueueTimer() { queuetime.update(); } diff --git a/src/hacks/AutoReflect.cpp b/src/hacks/AutoReflect.cpp index 475014f8..ace818d2 100644 --- a/src/hacks/AutoReflect.cpp +++ b/src/hacks/AutoReflect.cpp @@ -45,7 +45,7 @@ void CreateMove() return; // If user settings allow, return if local player is in attack - if (idle_only && (g_pUserCmd->buttons & IN_ATTACK)) + if (idle_only && (current_user_cmd->buttons & IN_ATTACK)) return; // Create some book-keeping vars @@ -121,16 +121,13 @@ void CreateMove() if (!legit) { // Aim at predicted projectile - AimAt(g_pLocalPlayer->v_Eye, closest_vec, g_pUserCmd); + AimAt(g_pLocalPlayer->v_Eye, closest_vec, current_user_cmd); // Use silent angles g_pLocalPlayer->bUseSilentAngles = true; } // Airblast - g_pUserCmd->buttons |= IN_ATTACK2; - - // Function is finished, return - return; + current_user_cmd->buttons |= IN_ATTACK2; } // Function to determine whether an ent is good to reflect @@ -196,7 +193,7 @@ void Draw() if (fov_draw) { // It cant use fovs greater than 180, so we check for that - if (float(fov) > 0.0f && float(fov) < 180) + if (*fov > 0.0f && *fov < 180) { // Dont show ring while player is dead if (LOCAL_E->m_bAlivePlayer()) diff --git a/src/hacks/AutoSticky.cpp b/src/hacks/AutoSticky.cpp index dfa62ed2..0d46e3e5 100644 --- a/src/hacks/AutoSticky.cpp +++ b/src/hacks/AutoSticky.cpp @@ -83,7 +83,7 @@ bool IsTarget(CachedEntity *ent) } else if (ent->m_Type() == ENTITY_BUILDING) { - return buildings; + return *buildings; } // Target isnt a good type @@ -148,12 +148,12 @@ void CreateMove() { // Aim at bomb AimAt(g_pLocalPlayer->v_Eye, bomb->m_vecOrigin(), - g_pUserCmd); + current_user_cmd); // Use silent g_pLocalPlayer->bUseSilentAngles = true; // Detonate - g_pUserCmd->buttons |= IN_ATTACK2; + current_user_cmd->buttons |= IN_ATTACK2; // Return as its a waste to check anymore, we detonated // and all the rest of the stickys are gone @@ -166,12 +166,12 @@ void CreateMove() { // Aim at bomb AimAt(g_pLocalPlayer->v_Eye, bomb->m_vecOrigin(), - g_pUserCmd); + current_user_cmd); // Use silent g_pLocalPlayer->bUseSilentAngles = true; // Detonate - g_pUserCmd->buttons |= IN_ATTACK2; + current_user_cmd->buttons |= IN_ATTACK2; // Return as its a waste to check anymore, we detonated // and all the rest of the stickys are gone @@ -181,7 +181,5 @@ void CreateMove() } } } - // End of function, just return - return; } } diff --git a/src/hacks/Backtrack.cpp b/src/hacks/Backtrack.cpp index ad7d3bc4..45c665e7 100644 --- a/src/hacks/Backtrack.cpp +++ b/src/hacks/Backtrack.cpp @@ -15,9 +15,9 @@ static settings::Bool enable{ "backtrack.enable", "false" }; static settings::Bool draw_bt{ "backtrack.draw", "false" }; -static settings::Float latency{ "backtrack.latency", "false" }; -static settings::Float mindistance{ "backtrack.min-distance", "false" }; -static settings::Int slots{ "backtrack.slots", "false" }; +static settings::Int latency{ "backtrack.latency", "0" }; +static settings::Float mindistance{ "backtrack.min-distance", "60" }; +static settings::Int slots{ "backtrack.slots", "0" }; namespace hacks::shared::backtrack { @@ -61,8 +61,6 @@ void AddLatencyToNetchan(INetChannel *ch, float Latency) } } } -bool installed = false; -int ticks = 12; void Init() { for (int i = 0; i < 32; i++) @@ -71,14 +69,6 @@ void Init() BacktrackData{ 0, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, 0, 0, { 0, 0, 0 } }; - if (!installed) - { - latency.InstallChangeCallback( - [](IConVar *var, const char *pszOldValue, float flOldValue) { - ticks = max(min(int((float) latency) / 15, 65), 12); - }); - installed = true; - } } int BestTick = 0; @@ -98,7 +88,7 @@ void Run() } shouldDrawBt = true; - CUserCmd *cmd = g_pUserCmd; + CUserCmd *cmd = current_user_cmd; float bestFov = 99999; BestTick = 0; iBestTarget = -1; @@ -135,7 +125,7 @@ void Run() Vector hitbox_spine = pEntity->hitboxes.GetHitbox(3)->center; Vector ent_orig = pEntity->InternalEntity()->GetAbsOrigin(); auto hdr = g_IModelInfo->GetStudiomodel(RAW_ENT(pEntity)->GetModel()); - headPositions[i][cmd->command_number % ticks] = + headPositions[i][cmd->command_number % getTicks()] = BacktrackData{ cmd->tick_count, hitboxpos, min, max, hitbox_spine, viewangles, simtime, ent_orig }; float FOVDistance = GetFov(g_pLocalPlayer->v_OrigViewangles, @@ -159,17 +149,17 @@ void Run() float bestFOV = 180.0f; float distance, prev_distance_ticks = 9999; - for (int i = 0; i < ticks; ++i) + for (int i = 0; i < getTicks(); ++i) sorted_ticks[i] = BestTickData{ INT_MAX, i }; - for (int t = 0; t < ticks; ++t) + for (int t = 0; t < getTicks(); ++t) { if (headPositions[iBestTarget][t].tickcount) sorted_ticks[t] = BestTickData{ headPositions[iBestTarget][t].tickcount, t }; } - std::sort(sorted_ticks, sorted_ticks + ticks); - int tickus = (float(latency) > 800.0f || float(latency) < 200.0f) ? 12 : 24; - for (int t = 0; t < ticks; ++t) + std::sort(sorted_ticks, sorted_ticks + getTicks()); + int tickus = (*latency > 800 || *latency < 200) ? 12 : 24; + for (int t = 0; t < getTicks(); ++t) { bool good_tick = false; @@ -224,10 +214,10 @@ void Draw() return; if (!shouldDrawBt) return; - int tickus = (float(latency) > 800.0f || float(latency) < 200.0f) ? 12 : 24; + int tickus = (*latency > 800 || *latency < 200.0f) ? 12 : 24; for (int i = 0; i < g_IEngine->GetMaxClients(); i++) { - for (int j = 0; j < ticks; j++) + for (int j = 0; j < getTicks(); j++) { bool good_tick = false; @@ -309,4 +299,9 @@ float getLatency() { return *latency; } + +int getTicks() +{ + return max(min(*latency / 15, 65), 12); +} } diff --git a/src/hacks/Bunnyhop.cpp b/src/hacks/Bunnyhop.cpp index 430281ff..fb541479 100644 --- a/src/hacks/Bunnyhop.cpp +++ b/src/hacks/Bunnyhop.cpp @@ -24,17 +24,15 @@ void CreateMove() // Check user settings if bhop is enabled if (!enable) return; - if (!g_pUserCmd) - return; // Check if there is usercommands - if (!g_pUserCmd->command_number) + if (!current_user_cmd->command_number) return; // var for "if on ground" from the flags netvar bool ground = CE_INT(g_pLocalPlayer->entity, netvar.iFlags) & (1 << 0); // Var for if the player is pressing jump - bool jump = (g_pUserCmd->buttons & IN_JUMP); + bool jump = (current_user_cmd->buttons & IN_JUMP); // Check if player is not on the ground and player is holding their jump key if (!ground && jump) @@ -44,15 +42,12 @@ void CreateMove() // the ground or lets go of jump if (ticks_last_jump++ >= 9) { - g_pUserCmd->buttons = g_pUserCmd->buttons & ~IN_JUMP; + current_user_cmd->buttons = current_user_cmd->buttons & ~IN_JUMP; } } // If the players jump cmd has been used, then we reset our var if (!jump) ticks_last_jump = 0; - - // Finish the function with return - return; } } diff --git a/src/hacks/FollowBot.cpp b/src/hacks/FollowBot.cpp index 89bd5f61..5153dc7c 100644 --- a/src/hacks/FollowBot.cpp +++ b/src/hacks/FollowBot.cpp @@ -11,18 +11,18 @@ #include #include -static settings::Bool followbot{ "follow-bot.enable", "false" }; +static settings::Bool enable{ "follow-bot.enable", "false" }; static settings::Bool roambot{ "follow-bot.roaming", "false" }; static settings::Bool draw_crumb{ "follow-bot.draw-crumbs", "false" }; -static settings::Bool follow_distance{ "follow-bot.distance", "175" }; -static settings::Bool follow_activation{ "follow-bot.max-range", "1000" }; +static settings::Float follow_distance{ "follow-bot.distance", "175" }; +static settings::Float follow_activation{ "follow-bot.max-range", "1000" }; static settings::Bool mimic_slot{ "follow-bot.mimic-slot", "false" }; static settings::Bool always_medigun{ "follow-bot.always-medigun", "false" }; static settings::Bool sync_taunt{ "follow-bot.taunt-sync", "false" }; static settings::Bool change{ "follow-bot.change-roaming-target", "false" }; static settings::Bool autojump{ "follow-bot.jump-if-stuck", "true" }; static settings::Bool afk{ "follow-bot.switch-afk", "true" }; -static settings::Bool afktime{ "follow-bot.afk-time", "15000" }; +static settings::Int afktime{ "follow-bot.afk-time", "15000" }; static settings::Bool corneractivate{ "follow-bot.corners", "true" }; namespace hacks::shared::followbot @@ -44,6 +44,8 @@ CatCommand follow_steam("fb_steam", "Follow Steam Id", static std::vector breadcrumbs; static const int crumb_limit = 64; // limit +static bool followcart{ false }; + // Followed entity, externed for highlight color int follow_target = 0; static bool inited; @@ -167,7 +169,7 @@ Timer waittime{}; int lastent = 0; void WorldTick() { - if (!followbot) + if (!enable) { follow_target = 0; return; @@ -220,7 +222,7 @@ void WorldTick() if (corneractivate) { Vector indirectOrigin = VischeckCorner( - LOCAL_E, entity, float(follow_activation) / 2, + LOCAL_E, entity, *follow_activation / 2, true); // get the corner location that the // future target is visible from std::pair corners; @@ -285,7 +287,8 @@ void WorldTick() continue; const model_t *model = ENTITY(follow_target)->InternalEntity()->GetModel(); - if (followcart && model && + // FIXME follow cart/point + /*if (followcart && model && (lagexploit::pointarr[0] || lagexploit::pointarr[1] || lagexploit::pointarr[2] || lagexploit::pointarr[3] || lagexploit::pointarr[4]) && @@ -294,7 +297,7 @@ void WorldTick() model == lagexploit::pointarr[2] || model == lagexploit::pointarr[3] || model == lagexploit::pointarr[4])) - follow_target = entity->m_IDX; + follow_target = entity->m_IDX;*/ if (entity->m_Type() != ENTITY_PLAYER) continue; // favor closer entitys @@ -530,6 +533,16 @@ void DrawTick() #endif } +int getTarget() +{ + return follow_target; +} + +bool isEnabled() +{ + return *enable; +} + #if ENABLE_IPC static CatCommand follow_me("fb_follow_me", "IPC connected bots will follow you", []() { diff --git a/src/hacks/KillSay.cpp b/src/hacks/KillSay.cpp index 0d137789..c87ad141 100644 --- a/src/hacks/KillSay.cpp +++ b/src/hacks/KillSay.cpp @@ -12,11 +12,14 @@ static settings::Int killsay_mode{ "killsay.mode", "0" }; static settings::String filename{ "killsay.file", "killsays.txt" }; + +static CatCommand reload_command("killsay_reload", "Reload killsays", []() { + hacks::shared::killsay::reload(); +}); + namespace hacks::shared::killsay { -static CatCommand reload("killsay_reload", "Reload killsays", Reload); - const std::string tf_classes_killsay[] = { "class", "scout", "sniper", "soldier", "demoman", "medic", "heavy", "pyro", "spy", @@ -79,30 +82,37 @@ std::string ComposeKillSay(IGameEvent *event) return msg; } -KillSayEventListener &getListener() + +class KillSayEventListener : public IGameEventListener2 { - static KillSayEventListener listener; - return listener; + void FireGameEvent(IGameEvent *event) override + { + if (!killsay_mode) + return; + std::string message = hacks::shared::killsay::ComposeKillSay(event); + if (message.size()) + { + chat_stack::Say(message, false); + } + } +}; + +static KillSayEventListener listener{}; + +void reload() +{ + file.Load(*filename); } -void Reload() +void init() { - file.Load(std::string(filename.GetString())); -} - -void Init() -{ - g_IEventManager2->AddListener(&getListener(), (const char *) "player_death", + g_IEventManager2->AddListener(&listener, (const char *) "player_death", false); - filename.InstallChangeCallback( - [](IConVar *var, const char *pszOV, float flOV) { - file.TryLoad(std::string(filename.GetString())); - }); } -void Shutdown() +void shutdown() { - g_IEventManager2->RemoveListener(&getListener()); + g_IEventManager2->RemoveListener(&listener); } // Thanks HellJustFroze for linking me http://daviseford.com/shittalk/ @@ -153,13 +163,5 @@ const std::vector builtin_nonecore_mlg = { }; } -void KillSayEventListener::FireGameEvent(IGameEvent *event) -{ - if (!hacks::shared::killsay::killsay_mode) - return; - std::string message = hacks::shared::killsay::ComposeKillSay(event); - if (message.size()) - { - chat_stack::Say(message, false); - } -} + + diff --git a/src/hacks/Misc.cpp b/src/hacks/Misc.cpp index e60728c4..0c25ec70 100644 --- a/src/hacks/Misc.cpp +++ b/src/hacks/Misc.cpp @@ -79,7 +79,7 @@ CatCommand void CreateMove() { -#if not LAGBOT_MODE +#if !LAGBOT_MODE // Crithack static IClientEntity *localplayer, *weapon, *last_weapon = nullptr; static int tries, cmdn, md5seed, rseed, c, b; diff --git a/src/tfmm.cpp b/src/tfmm.cpp index f665bbeb..94fa8fec 100644 --- a/src/tfmm.cpp +++ b/src/tfmm.cpp @@ -9,12 +9,18 @@ #include "common.hpp" #include "hacks/AutoJoin.hpp" + +settings::Int queue{ "autoqueue.mode", "7" }; + CatCommand cmd_queue_start("mm_queue_casual", "Start casual queue", - []() { tfmm::queue_start(); }); + []() { tfmm::startQueue(); }); CatCommand cmd_abandon("mm_abandon", "Abandon match", []() { tfmm::abandon(); }); +CatCommand abandoncmd("disconnect_and_abandon", "Disconnect and abandon", + []() { tfmm::disconnectAndAbandon(); }); + CatCommand get_state("mm_state", "Get party state", []() { re::CTFParty *party = re::CTFParty::GetParty(); if (!party) @@ -25,12 +31,15 @@ CatCommand get_state("mm_state", "Get party state", []() { logging::Info("State: %d", re::CTFParty::state_(party)); }); -settings::Int queue{ "autoqueue_mode", "7" }; - namespace tfmm { -void queue_start() +int getQueue() +{ + return *queue; +} + +void startQueue() { re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient(); if (client) @@ -43,7 +52,7 @@ void queue_start() else logging::Info("queue_start: CTFPartyClient == null!"); } -void queue_leave() +void leaveQueue() { re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient(); if (client) @@ -51,9 +60,8 @@ void queue_leave() else logging::Info("queue_start: CTFPartyClient == null!"); } -Timer abandont{}; -void dcandabandon() +void disconnectAndAbandon() { re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient(); re::CTFGCClientSystem *gc = re::CTFGCClientSystem::GTFGCClientSystem(); @@ -63,20 +71,13 @@ void dcandabandon() { logging::Info("your party client is gay!"); if (gc) - queue_leave(); + leaveQueue(); else logging::Info("your gc is gay!"); } if (gc && client) - while (1) - if (abandont.test_and_set(4000)) - { - queue_leave(); - break; - } + leaveQueue(); } -CatCommand abandoncmd("disconnect_and_abandon", "Disconnect and abandon", - []() { dcandabandon(); }); void abandon() { diff --git a/src/votelogger.cpp b/src/votelogger.cpp index 1812f98e..5a843252 100644 --- a/src/votelogger.cpp +++ b/src/votelogger.cpp @@ -9,24 +9,15 @@ #include #include -static settings::Bool enable{ "vote-log.enable", "false" }; -static settings::Bool requeue{ "vote-log.requeue", "false" }; +static settings::Bool requeue{ "hack.requeue-on-kick", "false" }; namespace votelogger { -Timer antikick{}; -bool active = false; +static bool was_local_player{ false }; -const std::string tf_classes[] = { "class", "scout", "sniper", "soldier", - "demoman", "medic", "heavy", "pyro", - "spy", "engineer" }; -void user_message(bf_read &buffer, int type) +void dispatchUserMessage(bf_read &buffer, int type) { - - bool islocalplayer = false; - if (!enable) - return; switch (type) { case 45: @@ -34,27 +25,25 @@ void user_message(bf_read &buffer, int type) break; case 46: { - islocalplayer = false; - unsigned char caller = buffer.ReadByte(); + was_local_player = false; + auto caller = (unsigned char)buffer.ReadByte(); // unknown buffer.ReadByte(); char reason[64]; char name[64]; buffer.ReadString(reason, 64, false, nullptr); buffer.ReadString(name, 64, false, nullptr); - unsigned char eid = buffer.ReadByte(); + auto eid = (unsigned char)buffer.ReadByte(); buffer.Seek(0); eid >>= 1; unsigned steamID = 0; - player_info_s info; + player_info_s info{}; if (g_IEngine->GetPlayerInfo(eid, &info)) steamID = info.friendsID; - if (eid == LOCAL_E->m_IDX || - playerlist::AccessData(steamID).state == - playerlist::k_EState::FRIEND) + if (eid == LOCAL_E->m_IDX) { - islocalplayer = true; + was_local_player = true; } logging::Info("Vote called to kick %s [U:1:%u] for %s", name, steamID, @@ -63,8 +52,8 @@ void user_message(bf_read &buffer, int type) } case 47: logging::Info("Vote passed"); - if (islocalplayer && requeue) - tfmm::queue_start(); + if (was_local_player && requeue) + tfmm::startQueue(); break; case 48: logging::Info("Vote failed"); @@ -72,6 +61,8 @@ void user_message(bf_read &buffer, int type) case 49: logging::Info("VoteSetup?"); break; + default: + break; } } }