From 1b717af47a46e155d68d096cd17307ae51a5dbba Mon Sep 17 00:00:00 2001 From: BenCat07 Date: Fri, 20 Apr 2018 18:41:10 +0200 Subject: [PATCH] Improve LagExploit and Finally add a better Followbot --- include/hacks/FollowBot.hpp | 58 +- include/hacks/LagExploit.hpp | 7 +- src/hacks/AutoHeal.cpp | 4 +- src/hacks/FollowBot.cpp | 1145 +++++----------------------------- src/hacks/LagExploit.cpp | 207 +++--- src/hacks/Walkbot.cpp | 12 +- src/hooks/CreateMove.cpp | 13 +- src/hooks/others.cpp | 3 + src/ipc.cpp | 1 - src/menu/ncc/Menu.cpp | 4 +- src/visual/drawmgr.cpp | 2 +- 11 files changed, 300 insertions(+), 1156 deletions(-) diff --git a/include/hacks/FollowBot.hpp b/include/hacks/FollowBot.hpp index 50ed5430..da2d07cd 100755 --- a/include/hacks/FollowBot.hpp +++ b/include/hacks/FollowBot.hpp @@ -1,55 +1,23 @@ /* - * FollowBot.h * - * Created on: Mar 19, 2017 - * Author: nullifiedcat + * + * + * */ -#pragma once +#include "common.hpp"; -#if ENABLE_IPC == 1 +namespace hacks { +namespace shared { +namespace followbot { -#include "common.hpp" +// Followed entity, externed for highlight color +extern int follow_target; +extern CatVar followbot; +extern CatVar follow_steam; +void DrawTick(); +void WorldTick(); -namespace hacks -{ -namespace shared -{ -namespace followbot -{ - -enum class EFollowType -{ - VECTOR, // When we need to goto a vector - ENTITY // when we dont have a specific steamid, but we still want to follow - // an entity -}; - -// extern CatCommand move_to_crosshair; -// extern CatCommand follow; -// extern CatCommand follow_entity; -extern CatVar bot; - -extern unsigned follow_steamid; -extern int following_idx; - -bool IsBot(CachedEntity *entity); -void AddMessageHandlers(ipc::peer_t *peer); -void AfterCreateMove(); -#if ENABLE_VISUALS == 1 -void Draw(); -#endif -void CrumbReset(); -void CrumbTopAdd(Vector crumbToAdd); -void CrumbBottomAdd(); -void DoWalking(); -void DrawFollowbot(); -std::pair ComputeMove(const Vector &a, const Vector &b); -void WalkTo(const Vector &vector); -unsigned MakeMask(); -void SelectEntity(int idx); } } } - -#endif diff --git a/include/hacks/LagExploit.hpp b/include/hacks/LagExploit.hpp index a95fcb6a..ae816ed0 100755 --- a/include/hacks/LagExploit.hpp +++ b/include/hacks/LagExploit.hpp @@ -18,11 +18,8 @@ namespace shared { namespace lagexploit { -extern const model_t *point; -extern const model_t *point2; -extern const model_t *point3; -extern const model_t *point4; -extern const model_t *point5; +extern const model_t *pointarr[5]; +extern bool bcalled; void CreateMove(); void Draw(); void AddExploitTicks(int ticks); diff --git a/src/hacks/AutoHeal.cpp b/src/hacks/AutoHeal.cpp index 8219df24..c7627752 100755 --- a/src/hacks/AutoHeal.cpp +++ b/src/hacks/AutoHeal.cpp @@ -554,8 +554,8 @@ int HealingPriority(int idx) #if ENABLE_IPC == 1 if (ipc::peer) { - if (hacks::shared::followbot::bot && - hacks::shared::followbot::following_idx == idx) + if (hacks::shared::followbot::followbot && + hacks::shared::followbot::follow_target == idx) { priority *= 3.0f; } diff --git a/src/hacks/FollowBot.cpp b/src/hacks/FollowBot.cpp index 5a284b47..c5ffdc3a 100755 --- a/src/hacks/FollowBot.cpp +++ b/src/hacks/FollowBot.cpp @@ -1,296 +1,151 @@ + /* - * FollowBot.cpp + * CREDITS TO ONEE-CHAN FOR IMPROVED FOLLOWBOT + * + * * - * Created on: Mar 20, 2017 - * Author: nullifiedcat */ #include "common.hpp" -#if ENABLE_IPC == 1 +namespace hacks { +namespace shared { +namespace followbot { -namespace hacks -{ -namespace shared -{ -namespace followbot -{ -/* Big Followbot TODO list -1. Fix crash when setting followbot_idx var and remove the fix var in its place -*/ +CatVar followbot(CV_SWITCH, "fb", "0", "Followbot Switch", "Set to 1 in followbots' configs"); +static CatVar roambot(CV_SWITCH, "fb_roaming", "1", "Roambot", "Followbot will roam free, finding targets it can"); +static CatVar draw_crumb(CV_SWITCH, "fb_draw", "1", "Draw crumbs", "Self explanitory"); +static CatVar follow_distance(CV_INT, "fb_distance", "175", "Follow Distance", "How close the bots should stay to the target"); +static CatVar follow_activation(CV_INT, "fb_activation", "175", "Activation Distance", "How close a player should be until the followbot will pick them as a target"); +CatVar follow_steam(CV_INT, "fb_steam", "0", "Follow Steam Id", "Set a steam id to let followbot prioritize players"); +CatVar mimic_slot(CV_SWITCH, "fb_mimic_slot", "0", "Mimic weapon slot", "Mimic follow target's weapon slot"); +CatVar always_medigun(CV_SWITCH, "fb_always_medigun", "0", "Always Medigun", "Always use medigun"); +CatVar sync_taunt(CV_SWITCH, "fb_sync_taunt", "0", "Synced taunt", "Taunt when follow target does"); +CatVar change(CV_SWITCH, "fb_switch", "1", "Change followbot target", "Always change roaming target when possible"); +// Something to store breadcrumbs created by followed players +static std::vector breadcrumbs; +static const int crumb_limit = 64; // limit -// User settings -CatVar bot(CV_SWITCH, "fb_bot", "0", "Master Followbot Switch", - "Set to 1 in followbots' configs"); -CatVar follow_distance(CV_FLOAT, "fb_distance", "175", "Follow Distance", - "How close the bots should stay to the target"); -CatVar follow_activation(CV_FLOAT, "fb_activation", "175", - "Activation Distance", - "How close a player should be until the followbot " - "will pick them as a target"); -CatVar mimic_slot( - CV_SWITCH, "fb_mimic_slot", "0", "Mimic selected weapon", - "If enabled, this bot will select same weapon slot as the owner"); -CatVar always_medigun(CV_SWITCH, "fb_always_medigun", "0", "Always use Medigun", - "Medics will always use Medigun"); -CatVar crumb_draw(CV_SWITCH, "fb_crumb_draw", "1", "Draw Crumbs", - "Draws the path made for the followbot"); -CatVar roaming(CV_SWITCH, "fb_roaming", "0", "Roaming", - "Allows the bot to find a different target if it cant find one " - "using the steam id"); -CatVar sync_taunt(CV_SWITCH, "fb_sync_taunt", "0", "Mimic taunts", - "Bots will taunt if target is taunting"); +// Followed entity, externed for highlight color +int follow_target = 0; -// Var to store the current steamid to follow -unsigned follow_steamid{ 1 }; +void WorldTick() { + if (!followbot) { + follow_target = 0; + return; + } -// Vars that decides how the followbot will act and move -EFollowType current_follow_type = EFollowType::ENTITY; -CachedEntity *target_last = 0; -int following_idx = 0; -bool allow_moving = true; + // We need a local player to control + if (CE_BAD(LOCAL_E)) { + follow_target = 0; + return; + } -// Arrays to store selected ents -std::set selection{}; -std::set selection_secondary{}; + // Still good check + if (follow_target) { + // Overflow protection + if (breadcrumbs.size() > crumb_limit) + follow_target =0; + // Still good check + else if (CE_BAD(ENTITY(follow_target))) + follow_target = 0; + } -// Vars for vector followbot -float destination_point_time{ 0.0f }; -Vector destination_point{}; + // Target Selection + if (!follow_target) { + breadcrumbs.clear(); // no target == no path -// Var that control jumping and the followbot -float idle_time = 0; - -// Vars for breadcrumb followbot - -// An array for storing the breadcrumbs -static Vector breadcrumbs[256]; -// Int for storing length of array -constexpr int MAX_CRUMBS = 256; -// Array Bookkeeping vars -int crumbBottom = 0; -int crumbTop = 0; -int crumbArrayLength = 0; -// Used for states for the followbot -float crumb_prune_timeout = 0; -bool crumbStopped = true; -bool crumbFindNew = false; -bool crumbForceMove = false; - -// Function called after create move -void AfterCreateMove() -{ - - // Primary Selection handling and selection clearing - auto it = selection.begin(); - while (it != selection.end()) - { - int idx = *it; - CachedEntity *entity = ENTITY(idx); - if (CE_BAD(entity)) - { - selection.erase(it++); - } - else - { -#if ENABLE_VISUALS == 1 - hacks::shared::esp::AddEntityString(entity, "[SELECTED]", - colors::orange); - if (fmod(g_GlobalVars->curtime, 2.0f) < 1.0f) - { - hacks::shared::esp::SetEntityColor(entity, colors::yellow); - } -#endif - ++it; - } + if (follow_steam) { + // Find a target with the steam id, as it is prioritized + auto ent_count = g_IEngine->GetMaxClients(); + for (int i = 0; i < ent_count; i++) { + auto entity = ENTITY(i); + if (CE_BAD(entity)) // Exist + dormant + continue; + if (entity->m_Type != ENTITY_PLAYER) + continue; + player_info_s info; + g_IEngine->GetPlayerInfo(entity->m_IDX, &info); + if ((int)follow_steam != info.friendsID) // steamid check + continue; + if (!entity->m_bAlivePlayer) // Dont follow dead players + continue; + if (!VisCheckEntFromEnt(LOCAL_E, entity)) + continue; + follow_target = entity->m_IDX; + break; + } } - - // Secondary Selection handling - it = selection_secondary.begin(); - while (it != selection_secondary.end()) - { - int idx = *it; - CachedEntity *entity = ENTITY(idx); - if (CE_BAD(entity)) - { - selection_secondary.erase(it++); - } - else - { -#if ENABLE_VISUALS == 1 - hacks::shared::esp::AddEntityString( - entity, "[SELECTED (SECONDARY)]", colors::orange); - if (fmod(g_GlobalVars->curtime, 2.0f) < 1.0f) - { - hacks::shared::esp::SetEntityColor(entity, colors::yellow); - } -#endif - ++it; - } + // If we dont have a follow target from that, we look again for someone else who is suitable + if ((!follow_target || change) && roambot) { + // Try to get a new target + auto ent_count = g_IEngine->GetMaxClients(); + for (int i = 0; i < ent_count; i++) { + auto entity = ENTITY(i); + if (CE_BAD(entity)) // Exist + dormant + continue; + if (entity->m_Type != ENTITY_PLAYER) + continue; + if (entity == LOCAL_E) // Follow self lol + continue; + if (!entity->m_bAlivePlayer || entity->m_iTeam == LOCAL_E->m_iTeam) // Dont follow dead players + continue; + if (follow_activation && entity->m_flDistance > (float)follow_activation) + continue; + if (!VisCheckEntFromEnt(LOCAL_E, entity)) + continue; + if (follow_target && ENTITY(follow_target)->m_flDistance > entity->m_flDistance) // favor closer entitys + continue; + // ooooo, a target + follow_target = entity->m_IDX; + } } + // last check for entity before we continue + if (!follow_target) + return; + } - // Processing Selection is done, attemt to walk - DoWalking(); -} + // If the player is close enough, we dont need to follow the path + CachedEntity* followtar = ENTITY(follow_target); + auto tar_orig = followtar->m_vecOrigin; + auto loc_orig = LOCAL_E->m_vecOrigin; + auto dist_to_target = loc_orig.DistTo(tar_orig); + if (dist_to_target < 30) + breadcrumbs.clear(); -// Function for followbots to use for following, weapon selection, etc... -void DoWalking() -{ + // Update timer on new target + static Timer idle_time{}; + if (breadcrumbs.empty()) + idle_time.update(); - if (!bot) - return; + // New crumbs, we add one if its empty so we have something to follow + if ((breadcrumbs.empty() || tar_orig.DistTo(breadcrumbs.at(breadcrumbs.size() - 1)) > 40.0F) && DistanceToGround(ENTITY(follow_target)) < 30) + breadcrumbs.push_back(tar_orig); - // Get our best target, preferably from a steamid + // Prune old and close crumbs that we wont need anymore, update idle timer too + while (breadcrumbs.size() > 1 && loc_orig.DistTo(breadcrumbs.at(0)) < 60.f) { + idle_time.update(); + breadcrumbs.erase(breadcrumbs.begin()); + } - // following_idx = 0; - CachedEntity *best_target = nullptr; - CachedEntity *target_priority = nullptr; + // Follow the crumbs when too far away, or just starting to follow + if (dist_to_target > (float)follow_distance) { - // Get ent from steamid - for (int i = 1; i < HIGHEST_ENTITY; i++) - { - - CachedEntity *ent = ENTITY(i); - - if (CE_BAD(ent)) - continue; - if (ent == LOCAL_E) - continue; - if (ent->m_Type != ENTITY_PLAYER) - continue; - if (!ent->m_bAlivePlayer) - continue; - if (ent->m_bEnemy) - continue; - if (g_pLocalPlayer->v_Origin.DistTo(ent->m_vecOrigin) > 3400.0F) - continue; - - if (ent->player_info.friendsID == follow_steamid) - { - target_priority = ent; - break; - } + // Check for idle + if (idle_time.test_and_set(3000)) { + follow_target = 0; + return; } - - // Check Steam id target - if (CE_GOOD(target_priority)) - { - // If last target isnt the priority, vis check it - if (target_last != target_priority) - { - if (target_priority->IsVisible()) - { - target_last = target_priority; - best_target = target_priority; - crumbStopped = true; - } - } - else - { - best_target = target_priority; - } - } - - // If we cant use steam id target, try someone else - if (roaming && CE_BAD(best_target)) - { - - // Check last target if good - if (CE_GOOD(target_last)) - { - if (g_pLocalPlayer->v_Origin.DistTo(target_last->m_vecOrigin) < - 3400.0F && - target_last->m_bAlivePlayer && !crumbStopped) - { - best_target = target_last; - } - } - - // Without good target we must find a new one - if (CE_BAD(best_target) || - g_GlobalVars->curtime - 2.5F > crumb_prune_timeout) - { - - float target_highest_score = -256; - CachedEntity *ent; - target_last = nullptr; - crumbStopped = true; - - for (int i = 0; i < HIGHEST_ENTITY; i++) - { - ent = ENTITY(i); - - if (CE_BAD(ent)) - continue; - if (ent == LOCAL_E) - continue; - if (!ent->m_bAlivePlayer) - continue; - if (IsBot(ent)) - continue; - - if (ent->m_bEnemy) - continue; - if (g_pLocalPlayer->v_Origin.DistTo(ent->m_vecOrigin) > 3400.0F) - continue; - // Check activation distance - if (g_pLocalPlayer->v_Origin.DistTo(ent->m_vecOrigin) > - (float) follow_activation) - continue; - if (!ent->IsVisible()) - continue; - - // Distance Priority works in our case - float scr = - 4096.0f - g_pLocalPlayer->v_Origin.DistTo(ent->m_vecOrigin); - if (scr > target_highest_score) - { - target_highest_score = scr; - target_last = ent; - best_target = ent; - } - } - } - } - - CachedEntity *found_entity = best_target; - // TODO, setting following_idx causes a crash for an unknown reason, probs - // to do with autoheal. I created a different var to take its place and - // prevent the crash but i need to fix the crash with the externed var. For - // now this works and it will stay like this untill I find a way to fix it - int following_idx2 = 0; - if (CE_GOOD(found_entity)) - { - following_idx2 = found_entity->m_IDX; -#if ENABLE_VISUALS == 1 - hacks::shared::esp::AddEntityString(found_entity, "[FOLLOWING]", - colors::green); - hacks::shared::esp::SetEntityColor(found_entity, colors::green); -#endif - } - else - { - crumbStopped = true; - return; - } - - // Slot Changer/Mimicer - - // Set a static var for last slot check + if (sync_taunt && HasCondition(ENTITY(follow_target))) + g_IEngine->ClientCmd("taunt"); static float last_slot_check = 0.0f; - - // If curtime is less than the last time we checked the slot, then reset our - // check timer if (g_GlobalVars->curtime < last_slot_check) - last_slot_check = 0.0f; - - // If we have a follow target, user settings tell us that we should mess - // with the slot, the local player is alive, and our target is alive - if (following_idx2 && (always_medigun || mimic_slot) && + last_slot_check = 0.0f; + if (follow_target && (always_medigun || mimic_slot) && (g_GlobalVars->curtime - last_slot_check > 1.0f) && !g_pLocalPlayer->life_state && - !CE_BYTE(found_entity, netvar.iLifeState)) + !CE_BYTE(ENTITY(follow_target), netvar.iLifeState)) { // We are checking our slot so reset the timer @@ -298,7 +153,7 @@ void DoWalking() // Get the follow targets active weapon int owner_weapon_eid = - (CE_INT(found_entity, netvar.hActiveWeapon) & 0xFFF); + (CE_INT(ENTITY(follow_target), netvar.hActiveWeapon) & 0xFFF); IClientEntity *owner_weapon = g_IEntityList->GetClientEntity(owner_weapon_eid); @@ -340,721 +195,59 @@ void DoWalking() } } } - } - - // Main followbot code - - // Switch to different types of following mechanisms depending on the type - // we need to go to - switch (current_follow_type) - { - case EFollowType::VECTOR: // If were using a vector to follow, we just go - // directly to it - - // If destination_point_time is more than curtime than we reset it to - // zero - if (destination_point_time > g_GlobalVars->curtime) - destination_point_time = 0.0f; - - // If we havent reached our destination and the destination point - // timeout isnt more than 5 seconds, then we continue to walk to the - // destination point - if (g_GlobalVars->curtime - destination_point_time < 5.0f) - { - - // Walk to the point - followbot::WalkTo(destination_point); - - // If we have reached the destination point then we want to disable - // the vector followbot - if (g_pLocalPlayer->v_Origin.DistTo(destination_point) < 50.0f) - { - current_follow_type = EFollowType::ENTITY; - } - } - // Break from the switch - break; - - case EFollowType::ENTITY: // If were using a player to follow, we use the - // breadcrumb followbot - - if (CE_GOOD(found_entity)) - { - // If the bot is lost but it finds the player again, start the - // followbot again. - if (crumbStopped) - { - crumbForceMove = true; - CrumbReset(); - } - } - else - { - // If the entity we have isnt good, we stop the crumb followbot - crumbStopped = true; - } - - // Breadcrumb followbot - if (!crumbStopped) - { - - // Generate new breadcrumbs made by the player only if they are - // close to the ground. If the bot is told to generate a starting - // point, it does that as well. - if ((found_entity->m_vecOrigin.DistTo(breadcrumbs[crumbTop]) > - 40.0F || - crumbFindNew) && - DistanceToGround(found_entity) < 40) - { - - // Add to the crumb. - CrumbTopAdd(found_entity->m_vecOrigin); - - // If the bot was forced to select a point, we tell it that we - // no longer need a new one and clear the bottom crumb to use - // the newest one - if (crumbFindNew) - { - crumbFindNew = false; - CrumbBottomAdd(); - } - } - - // Prune used crumbs from the stack to make way for new ones when - // you get close to them. - if (g_pLocalPlayer->v_Origin.DistTo(breadcrumbs[crumbBottom]) < - 40.0F) - { - - // Debug Logging - logging::Info("Pruning"); - - // When the bot is forced to move to the player, since they have - // reached their destination we reset the var - crumbForceMove = false; - - // Check 15 times for close crumbs to prune, this allows simple - // miss steps to be smoothed out as well as make room for new - // crumbs - for (int i = 0; i < 15; i++) - { - - // When one is close or too high, just bump the array and - // reset the stuck timer - if (g_pLocalPlayer->v_Origin.DistTo( - breadcrumbs[crumbBottom]) < 60.0F && - crumbArrayLength > 1) - { - CrumbBottomAdd(); - - // When pruning is finished. Break the loop - } - else - { - crumb_prune_timeout = g_GlobalVars->curtime; - logging::Info("Finish Prune"); - break; - } - } - // Reset stuck timer - crumb_prune_timeout = g_GlobalVars->curtime; - } - - // When player to follow is too far away. the bot cant see the - // player or the bot is forced to the player, then follow - // breadcrumbs if movement is allowed - if ((g_pLocalPlayer->v_Origin.DistTo(found_entity->m_vecOrigin) > - (float) follow_distance || - crumbForceMove) && - crumbArrayLength >= 1 && allow_moving) - { - followbot::WalkTo(breadcrumbs[crumbBottom]); - - // If a crumb hasnt been pruned in a while, it probably cant - // travel to it so reset and wait for the player to collect it. - if (g_GlobalVars->curtime - 2.5F > crumb_prune_timeout) - { - crumbStopped = true; - logging::Info("Cannot goto next crumb!\nCrumb Lost!"); - } - - // If the bot is next to the player then we clear our crumbs as - // theres no need to follow previously generated ones. - } - else if (g_pLocalPlayer->v_Origin.DistTo( - found_entity->m_vecOrigin) < 100.0F && - found_entity->IsVisible()) - { - CrumbReset(); - crumbForceMove = false; - } - } - } - - // If we have a follow target, then we attempt to mimic their conditions - if (following_idx2) - { - - // If follow target is too far away and the local player is zoomed, then - // unzoom - if (found_entity->m_vecOrigin.DistTo(LOCAL_E->m_vecOrigin) > 325.0f) - { - if (g_pLocalPlayer->bZoomed) - g_pUserCmd->buttons |= IN_ATTACK2; - } - - // If found target is heavy and the local player is too, - if (CE_INT(found_entity, netvar.iClass) == tf_heavy && - g_pLocalPlayer->clazz == tf_heavy) - { - - // If found target is spun up, then spin up too - if (HasCondition(found_entity)) - { - g_pUserCmd->buttons |= IN_ATTACK2; - } - } - - // If found target is zoomed - if (HasCondition(found_entity)) - { - - // If the local player isnt zoomed and its class is sniper, then - // zoom in to mimic the followed target - if (!g_pLocalPlayer->bZoomed && g_pLocalPlayer->clazz == tf_sniper) - { - g_pUserCmd->buttons |= IN_ATTACK2; - } - } - - // If user settings allow, we attemt to mimic taunting player - if (sync_taunt) - { - - // Check if target is taunting - if (HasCondition(found_entity)) - { - - // Check if local player isnt taunting - if (!HasCondition(LOCAL_E)) - { - g_IEngine->ExecuteClientCmd("taunt"); - } - } - } - - // Check if target is crouching - if (CE_INT(found_entity, netvar.iFlags) & FL_DUCKING) - { - - // Check if local player isnt taunting - if (!g_pUserCmd->buttons & IN_DUCK) - { - g_pUserCmd->buttons |= IN_DUCK; - } - } - } +} + WalkTo(breadcrumbs.at(0)); + } else + idle_time.update(); } -// Used on a bot to select a target to follow -CatCommand follow("fb_follow", "Follows you (or player with SteamID specified)", - [](const CCommand &args) { - - // Set our target steam id to the argument put into the - // command - follow_steamid = strtol(args.Arg(1), nullptr, 10); - - // Tell the followbot to follow entities - current_follow_type = EFollowType::ENTITY; - // Allow the followbot to move - allow_moving = true; - }); - -// Used by the main player to send an ipc request to the bots to follow -CatCommand follow_me("fb_follow_me", "Makes all bots follow you", []() { - - // Check if the ipc server is connected - if (ipc::peer) - { - // Get our steam id - unsigned id = g_ISteamUser->GetSteamID().GetAccountID(); - // Send our id through the ipc server - ipc::peer->SendMessage((const char *) &id, 0, - ipc::commands::set_follow_steamid, 0, 0); - } -}); - -// User command for cat_fb_tool -CatCommand tool("fb_tool", "Followbot multitool", [](const CCommand &args) { - - // Check if ipc server is connected - if (!ipc::peer) - return; - - // If argument is "select" - if (!strcmp(args.Arg(1), "select")) - { - logging::Info("FB TOOL -> SELECT"); - - // Check if the shift key is depressed - if (g_IInputSystem->IsButtonDown(ButtonCode_t::KEY_LSHIFT)) - { - - // Shift cleans selection.. - selection.clear(); - selection_secondary.clear(); - logging::Info("Selection cleared!"); - - // If the shift key isnt depressed - } - else - { - - // Make a var and try to get an ent of what we are looking at - int eindex = 0; - WhatIAmLookingAt(&eindex, nullptr); - logging::Info("Selecting entity..."); - - // If the entity isnt null, Add the entity to the selection - if (eindex) - { - SelectEntity(eindex); - } - } - - // If argument is "move" - } - else if (!strcmp(args.Arg(1), "move")) - { - logging::Info("FB TOOL -> MOVE"); - - // Create a vector and attemt to get an end vector from it - Vector destination; - WhatIAmLookingAt(nullptr, &destination); - - // Send the vector through the ipc server and tell the bots to move to - // it - float array[3] = { destination.x, destination.y, destination.z }; - ipc::peer->SendMessage((const char *) array, MakeMask(), - ipc::commands::move_to_vector, nullptr, 0); - - // If argument is "stay" - } - else if (!strcmp(args.Arg(1), "stay")) - { - logging::Info("FB TOOL -> STAY"); - - // Send a message through the ipc server to notify the bots to stop - // moving - ipc::peer->SendMessage(nullptr, MakeMask(), ipc::commands::stop_moving, - nullptr, 0); - - // If argument is "follow" - } - else if (!strcmp(args.Arg(1), "follow")) - { - logging::Info("FB TOOL -> FOLLOW"); - - // Send a message through the ipc server to notify the bots to start - // moving - ipc::peer->SendMessage(nullptr, MakeMask(), ipc::commands::start_moving, - nullptr, 0); - } -}); - -// Helper Functions for bot selection - -void SelectEntity(int idx) -{ - logging::Info("Selecting entity %i", idx); - CachedEntity *entity = ENTITY(idx); - if (CE_BAD(entity)) - return; - std::set ¤t_selection = - IsBot(entity) ? selection : selection_secondary; - if (current_selection.find(idx) != current_selection.end()) - { - current_selection.erase(current_selection.find(idx)); - logging::Info("Deselected!"); - } - else - { - current_selection.insert(idx); - logging::Info("Selected!"); +void DrawTick(){ + if (!followbot || !draw_crumb) return; + if (breadcrumbs.size() < 2) return; + for (size_t i = 0; i < breadcrumbs.size() - 1; i++) { + Vector wts1, wts2; + if (draw::WorldToScreen(breadcrumbs.at(i), wts1) && draw::WorldToScreen(breadcrumbs.at(i + 1), wts2)) { + draw_api::draw_line(wts1.x, wts1.y, wts2.x - wts1.x, wts2.y - wts1.y, colors::white, 0.1f); } + } + Vector wts; + if (!draw::WorldToScreen(breadcrumbs.at(0), wts)) return; + draw_api::draw_rect(wts.x - 4, wts.y - 4, 8, 8, colors::white); + draw_api::draw_rect_outlined(wts.x - 4, wts.y - 4, 7, 7, colors::white, 1.0f); } -// A Function to tell whether an entity input into it is a bot -bool IsBot(CachedEntity *entity) -{ - if (!ipc::peer) - return false; - if (entity->m_Type == ENTITY_PLAYER) - { - if (ipc::peer) - { - for (unsigned i = 0; i < cat_ipc::max_peers; i++) - { - if (!ipc::peer->memory->peer_data[i].free && - ipc::peer->memory->peer_user_data[i].friendid == - entity->player_info.friendsID) - { - return true; - } - } - } - } - return false; -} - -// :thinking: -unsigned MakeMask() -{ - unsigned result = 0; - if (!ipc::peer) - return 0; - // O(n^2) ik - for (const auto &idx : selection) - { - CachedEntity *ent = ENTITY(idx); - if (CE_BAD(ent)) - continue; - for (unsigned i = 0; i < cat_ipc::max_peers; i++) - { - if (!ipc::peer->memory->peer_data[i].free && - ipc::peer->memory->peer_user_data[i].friendid == - ent->player_info.friendsID) - { - result |= (1 << i); - } - } - } - return result; -} - -// Ipc message handlers. When an ipc event comes from an ipc server, its called -// below -void AddMessageHandlers(ipc::peer_t *peer) -{ - - // When the ipc server gives us a steam id to follow, we run the following - peer->SetCommandHandler(ipc::commands::set_follow_steamid, - [](cat_ipc::command_s &command, void *payload) { - // Log in console the steam id that were - // following - logging::Info("IPC Message: now following %ld", - *(unsigned *) &command.cmd_data); - // Set our steam id that we want to follow - hacks::shared::followbot::follow_steamid = - *(unsigned *) &command.cmd_data; - // Tell the followbot to follow entities - current_follow_type = EFollowType::ENTITY; - }); - - // When the ipc server gives us a vector to follow, we run the following - peer->SetCommandHandler( - ipc::commands::move_to_vector, - [](cat_ipc::command_s &command, void *payload) { - // Create a var to recieve the payload with - float *data = (float *) &command.cmd_data; - // Log in console the vector that we will attemt to goto - logging::Info("IPC Message: moving to %.2f %.2f %.2f", data[0], - data[1], data[2]); - // Set our dest info with the payload data - destination_point = Vector(data[0], data[1], data[2]); - destination_point_time = g_GlobalVars->curtime; - // Notify the followbot to follow vectors - current_follow_type = EFollowType::VECTOR; - }); - - // When the ipc server tells us to start moving, we run the following - peer->SetCommandHandler(ipc::commands::start_moving, - [](cat_ipc::command_s &command, void *payload) { - allow_moving = true; - }); - - // When the ipc server tells us to stop moving, we run the following - peer->SetCommandHandler(ipc::commands::stop_moving, - [](cat_ipc::command_s &command, void *payload) { - allow_moving = false; - }); -} - -// Function for when you want to goto a vector -void WalkTo(const Vector &vector) -{ - - // Check if the local player is not moving - if (CE_VECTOR(LOCAL_E, netvar.vVelocity).IsZero(3.5f)) - { - // Set idle time if we havent already - if (!idle_time) - idle_time = g_GlobalVars->curtime; - - // If the time idle is over 2 seconds - if (g_GlobalVars->curtime - idle_time > 2.0f) - { - // If the player isnt zoomed, then jump - if (!g_pLocalPlayer->bZoomed) - g_pUserCmd->buttons |= IN_JUMP; - - // Since the vector is close enough we reset our idle timer - } - else - { - idle_time++; - } - } - - // Calculate how to get to a vector - auto result = ::ComputeMove(LOCAL_E->m_vecOrigin, vector); - // Push our move to usercmd - g_pUserCmd->forwardmove = result.first; - g_pUserCmd->sidemove = result.second; -} - -// I've spent 2 days on writing this method. -// I couldn't succeed. -// Just removed everything and put movement fix code from createmove here. -// Helper function for WalkTo -std::pair ComputeMove(const Vector &a, const Vector &b) -{ - Vector diff = (b - a); - if (diff.Length() == 0) - return { 0, 0 }; - const float x = diff.x; - const float y = diff.y; - Vector vsilent(x, y, 0); - float speed = sqrt(vsilent.x * vsilent.x + vsilent.y * vsilent.y); - Vector ang; - VectorAngles(vsilent, ang); - float yaw = DEG2RAD(ang.y - g_pUserCmd->viewangles.y); - return { cos(yaw) * 450, -sin(yaw) * 450 }; -} - -// Crumb Followbot Helper functions - -// A function to reset the crumb followbot -void CrumbReset() -{ - - // We just reset the bookkeeping vars for the array, no need to clear the - // array as everything will be re-written anyways - crumbTop = 0; - crumbBottom = 0; - crumbArrayLength = 0; - crumb_prune_timeout = g_GlobalVars->curtime; - crumbFindNew = true; - crumbStopped = false; - logging::Info("Crumb Reset"); -} - -// A function to place a crumb into the array -void CrumbTopAdd(Vector crumbToAdd) -{ - - // Once the crumbs have hit the limit of the array, loop around and over - // write unused spots - if (crumbTop >= MAX_CRUMBS + 15) - { - CrumbReset(); - } - else - { - // Else, bump the top number market of the array - crumbTop++; - } - - // Put the newly determined crumb into the array and add to the length - crumbArrayLength++; - breadcrumbs[crumbTop] = crumbToAdd; - logging::Info("Crumb Top add"); - - // The array can only hold so many crumbs, once it goes over its cap, stop - // the bot to prevent un-needed movement - if (crumbArrayLength > MAX_CRUMBS) - { - CrumbReset(); - crumbStopped = true; - logging::Info("Crumb Overload!\nDumping array"); - } -} - -// A function to free a crumb from the array -void CrumbBottomAdd() -{ - - // Once the crumbs have hit the limit of the array, loop around and over - // write unused spots - if (crumbBottom == MAX_CRUMBS) - { - crumbBottom = 0; - } - else - { - // Else, bump the top number market of the array - crumbBottom++; - } - - // Subtract from the length to make room for more crumbs - crumbArrayLength--; - logging::Info("Crumb Bottom add"); - - // A check to detect if too many crumbs have been removed. Without crumbs - // the bot will just use random variables in the array. To prevent - // un-nessasary movement, just clear the array and wait for player - if (crumbArrayLength < 0) - { - CrumbReset(); - crumbStopped = true; - logging::Info("Crumb Over-Prune!\nDumping array"); - } -} -#if ENABLE_VISUALS == 1 -// Function called when we need to draw onto the screen -void Draw() -{ - - // Dont draw if bot isnt true - if (!bot) - return; - - // If user settings allow, draw our breadcrumbs - if (crumb_draw) - DrawFollowbot(); -} - -// A Function for when we want to draw out the crumbs in the array onto the -// screen -void DrawFollowbot() -{ - - // Usefull debug info to know - AddSideString(format("Array Length: ", crumbArrayLength)); - AddSideString(format("Top Crumb: ", crumbTop)); - AddSideString(format("Bottom Crumb: ", crumbBottom)); - AddSideString(format("Crumb Stopped: ", crumbStopped)); - AddSideString(format("Curtime: ", g_GlobalVars->curtime)); - AddSideString(format("Timeout: ", crumb_prune_timeout)); - - // Disabled as the enum was misbehaving for an unknown reason - - /*switch (current_follow_type) { - case EFollowType::VECTOR: // If our follow type is a vector, then we just - draw a rect on the vector - - // Create a vector for the screen, run world to screen to bring the - world vector into the screen vector, then draw a rect at the point Vector - scn; draw::WorldToScreen(destination_point, scn); draw_api::FilledRect(scn.x - - 3, scn.y - 3, 6, 6); - // Return as we are finished - break; - - case EFollowType::ENTITY: // If our follow type is entity, then we draw out - the crumbs here logging::Info("Drawcrumb1"); - // Check if we have enough crumbs to draw a line between - if (crumbArrayLength < 2) { - - // If not, we check if we have 1 point and draw on it - if (crumbArrayLength == 1) { - - // Get the entity vector to screen and draw a rect on it - Vector scn; - draw::WorldToScreen(breadcrumbs[crumbBottom], scn); - draw_api::FilledRect(scn.x - 3, scn.y - 3, 6, 6); - } - - // Return as we have nothing else to do - break; - } - - // Create book keeping vars to draw with - Vector scnSrt, scnEnd; - int tmpCrumb1, tmpCrumb2; - - // For loop to draw through the crumbs - for (int i = 0; i < crumbArrayLength; i++) { - - // We need 2 crumbs to draw a line, so we get the number in the - array for 2 crumbs tmpCrumb1 = crumbBottom + i; tmpCrumb2 = crumbBottom + i - + 1; - - // Correction for array numbers when one goes over our limit - if (tmpCrumb1 >= MAX_CRUMBS) - tmpCrumb1 - MAX_CRUMBS; - if (tmpCrumb2 >= MAX_CRUMBS) - tmpCrumb1 - MAX_CRUMBS; - - // Take our 2 crumbs and get a position on the screen - draw::WorldToScreen(breadcrumbs[tmpCrumb1], scnSrt); - draw::WorldToScreen(breadcrumbs[tmpCrumb2], scnEnd); - - // Draw a line from one crumb to the other - draw_api::Line(scnSrt.x, scnSrt.y, scnEnd.x - scnSrt.x, scnEnd.y - - scnSrt.y, colors::white); - - // If this is our first iteration, draw a box on 1 - if (i == 1) - draw_api::FilledRect(scnSrt.x - 3, scnSrt.y - 3, 6, 6); - } - break; - }*/ - - // Not using switch due to switch not working correctly - if (crumbArrayLength < 2) - { - - // If not, we check if we have 1 point and draw on it - if (crumbArrayLength == 1) - { - - // Get the entity vector to screen and draw a rect on it - Vector scn; - draw::WorldToScreen(breadcrumbs[crumbBottom], scn); - draw_api::draw_rect(scn.x - 3, scn.y - 3, 6, 6, colors::white); - } - - // Return as we have nothing else to do - return; - } - - // Create book keeping vars to draw with - Vector scnSrt, scnEnd; - int tmpCrumb1, tmpCrumb2; - - // For loop to draw through the crumbs - for (int i = 0; i < crumbArrayLength; i++) - { - - // We need 2 crumbs to draw a line, so we get the number in the array - // for 2 crumbs - tmpCrumb1 = crumbBottom + i; - tmpCrumb2 = crumbBottom + i + 1; - - // Correction for array numbers when one goes over our limit - if (tmpCrumb1 >= MAX_CRUMBS) - tmpCrumb1 - MAX_CRUMBS; - if (tmpCrumb2 >= MAX_CRUMBS) - tmpCrumb2 - MAX_CRUMBS; - - // Take our 2 crumbs and get a position on the screen - draw::WorldToScreen(breadcrumbs[tmpCrumb1], scnSrt); - draw::WorldToScreen(breadcrumbs[tmpCrumb2], scnEnd); - - // Draw a line from one crumb to the other - draw_api::draw_line(scnSrt.x, scnSrt.y, scnEnd.x - scnSrt.x, - scnEnd.y - scnSrt.y, colors::white, 0.5f); - - // If this is our first iteration, draw a box on 1 - if (i == 0) - draw_api::draw_rect(scnSrt.x - 3, scnSrt.y - 3, 6, 6, - colors::white); - } +static CatCommand follow_me("fb_follow_me", "IPC connected bots will follow you", [](){ + if (!ipc::peer) { + logging::Info("IPC isnt connected"); return; -} -#endif + } + auto local_ent = LOCAL_E; + if (!local_ent) { + logging::Info("Cant get a local player"); + return; + } + player_info_s info; + g_IEngine->GetPlayerInfo(local_ent->m_IDX, &info); + auto steam_id = info.friendsID; + if (!steam_id) { + logging::Info("Cant get steam-id, the game module probably doesnt support it."); + return; + } + // Construct the command + std::string tmp = CON_PREFIX + follow_steam.name + " " + std::to_string(steam_id); + if (tmp.length() >= 63) + { + ipc::peer->SendMessage( + 0, 0, ipc::commands::execute_client_cmd_long, + tmp.c_str(), tmp.length() + 1); + } + else + { + ipc::peer->SendMessage(tmp.c_str(), 0, + ipc::commands::execute_client_cmd, + 0, 0); + } +}); } } } - -#endif diff --git a/src/hacks/LagExploit.cpp b/src/hacks/LagExploit.cpp index 17a01a44..f03d538d 100644 --- a/src/hacks/LagExploit.cpp +++ b/src/hacks/LagExploit.cpp @@ -46,15 +46,12 @@ CatVar master_switch(CV_SWITCH, "se_master", "1", "Enable sequence exploit", "disables everything else that uses it"); CatVar value(CV_INT, "se_value", "900", "Sequence exploit value", "Value of user cmds to spam with"); - +CatVar cap_range(CV_FLOAT, "se_cap_range", "200.0f", "Autocap range", "Autocap range, increase if you notice that you only lagy once you are already in the cap zone"); CatCommand do_lagexploit("se_do", "Sequence exploit (for use in scripts)", []() { AddExploitTicks(6); }); -int exticks = 0; -const model_t *point = nullptr; -const model_t *point2 = nullptr; -const model_t *point3 = nullptr; -const model_t *point4 = nullptr; -const model_t *point5 = nullptr; +int exticks = 0; +const model_t *pointarr[5] = { nullptr, nullptr, nullptr, nullptr, nullptr }; +bool bcalled = false; void AddExploitTicks(int ticks) { exticks = std::max(ticks, exticks); @@ -159,9 +156,8 @@ void CreateMove() if (!g_pUserCmd->command_number) return; int amount = 0; - for (int i = 1; i < HIGHEST_ENTITY; i++) - { - if (!point2) + if (!bcalled) + for (int i = 1; i < HIGHEST_ENTITY; i++) { CachedEntity *pEnt = ENTITY(i); if (!CE_GOOD(pEnt)) @@ -170,51 +166,23 @@ void CreateMove() if (!model) continue; const char *model_name = g_IModelInfo->GetModelName(model); + if (strstr("models/props_gameplay/cap_point_base.mdl", model_name)) + pointarr[0] = model; if (strstr("models/props_trainyard/bomb_cart.mdl", model_name)) - point2 = model; - } - if (!point3) - { - CachedEntity *pEnt = ENTITY(i); - if (!CE_GOOD(pEnt)) - continue; - const model_t *model = RAW_ENT(pEnt)->GetModel(); - if (!model) - continue; - const char *model_name = g_IModelInfo->GetModelName(model); + pointarr[1] = model; if (strstr("models/props_2fort/trainwheel001.mdl", model_name)) - point3 = model; - } - if (!point4) - { - CachedEntity *pEnt = ENTITY(i); - if (!CE_GOOD(pEnt)) - continue; - const model_t *model = RAW_ENT(pEnt)->GetModel(); - if (!model) - continue; - const char *model_name = g_IModelInfo->GetModelName(model); + pointarr[2] = model; if (strstr("models/custom/dirty_bomb_cart.mdl", model_name)) - point4 = model; - } - if (!point5) - { - CachedEntity *pEnt = ENTITY(i); - if (!CE_GOOD(pEnt)) - continue; - const model_t *model = RAW_ENT(pEnt)->GetModel(); - if (!model) - continue; - const char *model_name = g_IModelInfo->GetModelName(model); + pointarr[3] = model; if (strstr("models/props_trainyard/bomb_cart_red.mdl", model_name)) - point5 = model; + pointarr[4] = model; } - } + bcalled = true; if (cart) { for (int i = 1; i < HIGHEST_ENTITY; i++) { - if (!point2 && !point3 && !point4 && !point5) + if (!pointarr[1] && !pointarr[2] && !pointarr[3] && !pointarr[4]) continue; CachedEntity *pEnt = ENTITY(i); if (!CE_GOOD(pEnt)) @@ -224,8 +192,8 @@ void CreateMove() const model_t *model = RAW_ENT(pEnt)->GetModel(); if (!model) continue; - if (model == point2 || model == point3 || model == point4 || - model == point5) + if (model == pointarr[1] || model == pointarr[2] || + model == pointarr[3] || model == pointarr[4]) { if (!CE_GOOD(LOCAL_E)) continue; @@ -274,22 +242,7 @@ void CreateMove() { for (int i = 1; i < HIGHEST_ENTITY; i++) { - if (!point) - { - CachedEntity *pEnt = ENTITY(i); - if (!CE_GOOD(pEnt)) - continue; - const model_t *model = RAW_ENT(pEnt)->GetModel(); - if (!model) - continue; - const char *model_name = g_IModelInfo->GetModelName(model); - if (strstr("models/props_gameplay/cap_point_base.mdl", - model_name)) - point = model; - else - continue; - } - if (!point) + if (!pointarr[0]) continue; CachedEntity *pEnt = ENTITY(i); if (!CE_GOOD(pEnt)) @@ -299,7 +252,7 @@ void CreateMove() const model_t *model = RAW_ENT(pEnt)->GetModel(); if (!model) continue; - if (model == point) + if (model == pointarr[0]) { if (!CE_GOOD(LOCAL_E)) continue; @@ -310,9 +263,9 @@ void CreateMove() const Vector &min1 = p->OBBMins() + RAW_ENT(LOCAL_E)->GetAbsOrigin(); const Vector &max2 = - c->OBBMaxs() + pEnt->m_vecOrigin + Vector(200, 200, 200); + c->OBBMaxs() + pEnt->m_vecOrigin + Vector((float)cap_range, (float)cap_range, (float)cap_range); const Vector &min2 = - c->OBBMins() + pEnt->m_vecOrigin - Vector(200, 200, 200); + c->OBBMins() + pEnt->m_vecOrigin - Vector((float)cap_range, (float)cap_range, (float)cap_range); 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)) @@ -407,15 +360,11 @@ void CreateMove() (CL_CLASS(CTFPipebombLauncher))) { static bool bSwitch = false; - if ((g_pUserCmd->buttons & IN_ATTACK) && !bSwitch) - { - bSwitch = true; - } - else if (bSwitch) + bSwitch = !bSwitch; + if ((g_pUserCmd->buttons & IN_ATTACK) && bSwitch) { amount = 1 * 50; g_pUserCmd->buttons &= ~IN_ATTACK; - bSwitch = false; } } } @@ -430,53 +379,88 @@ void CreateMove() // SHOUTOUTS TO BLACKFIRE if (doom || razorback) { - static int i = 0; - static int i2 = 0; + // Variablse to store Primary and secondary nextfire times + static float i = 0.0; + static float i2 = 0.0; + // Servertime to predict the next Primary and secondary times in seconds servertime = (float) (CE_INT(g_pLocalPlayer->entity, netvar.nTickBase)) * g_GlobalVars->interval_per_tick; - if (!nextattack || !i || + // If not the holding the same weapon as last tick or i(2) is smaller than 0.1f + // Get a new nextattack(2) + if (!nextattack || i < 0.1f || g_pLocalPlayer->weapon()->m_iClassID != lastwep) nextattack = CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flNextPrimaryAttack); - if (!nextattack2 || !i || + if (!nextattack2 || i2 < 0.1f || g_pLocalPlayer->weapon()->m_iClassID != lastwep) nextattack2 = CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flNextSecondaryAttack); + // If the next attack (2) time would exceed 75 seconds, set it to 75 to prevent + // The server disconnecting you for lagging too much if (servertime - nextattack > 75.0f) nextattack = servertime - 75.0f; if (servertime - nextattack2 > 75.0f) nextattack2 = servertime - 75.0f; + // If doom is active and nextattack is positive (not reloading/holding m1 since a while) + // and you are holding m1 run the Doom code if (doom && servertime - nextattack > 0.0f && g_pUserCmd->buttons & IN_ATTACK) { - if (!i) - i = ((int) servertime - (int) nextattack); - static bool bSwitcc = true; - if (CE_INT(LOCAL_E, netvar.iItemDefinitionIndex) == 58) - bSwitcc = !bSwitcc; - else - bSwitcc = true; - if (bSwitcc) - { - amount = i * 66; - if (CE_INT(g_pLocalPlayer->weapon(), netvar.m_iClip1) == 0) - g_pUserCmd->buttons &= ~IN_ATTACK; - } + // Incase i ever goes below 0.1 recalculate it (or if it's just inited) + if (i < 0.1f) + i = servertime - (int) nextattack; + // Set amount to i * 66 (which lags for i seconds) + amount = i * 66; + // Don't attack if the clip is empty so you also instantly reload + if (!CE_BYTE(g_pLocalPlayer->weapon(), netvar.m_iClip1)) + g_pUserCmd->buttons &= ~IN_ATTACK; } + // If doom is active and nextattack2 is positive (not reloading/holding m2 since a while) + // and you are holding m2 run the Doom code if (doom && servertime - nextattack2 > 0.0f && g_pUserCmd->buttons & IN_ATTACK2) { - if (!i2) - i2 = ((int) servertime - (int) nextattack2); + // Incase i2 ever goes below 0.1 recalculate it (or if it's just inited) + if (i2 < 0.1f) + i2 = servertime - nextattack2; + // Set lagexploit amount (i * 66 = i seconds of lag) amount = i2 * 66; + // if primary ammo is empty don't hold m2, not a byte check since many weapons may not have a secondary clip if (CE_INT(g_pLocalPlayer->weapon(), netvar.m_iClip2) == 0) g_pUserCmd->buttons &= ~IN_ATTACK2; } + // if anti-razorback is active and you can stab through the shieled if (razorback && servertime - nextattack > 3.0f && - (g_pUserCmd->buttons & IN_ATTACK || - g_pUserCmd->buttons & IN_ATTACK2)) + (g_pUserCmd->buttons & IN_ATTACK)) { + CachedEntity* snoiper = nullptr; + for (int ii = 0; i < g_IEngine->GetMaxClients(); i++) { + CachedEntity* snooiper = ENTITY(i); + // nullptr and dormant check + if (CE_BAD(snooiper)) + continue; + // Alive check + if (!snooiper->m_bAlivePlayer) + continue; + // Vischeck + if (!VisCheckEntFromEnt(LOCAL_E, snooiper)) + continue; + // Range should be more than high enough + if (!snooiper->m_flDistance < 200.0f) + continue; + int clazz = CE_INT(snooiper, netvar.iClass); + if (clazz != tf_sniper) + continue; + // found entity + snoiper = snooiper; + // Break if you found an Entity, no need to go on further checking + break; + } + // Return if no snipers were found + if (CE_BAD(snoiper)) + return; + // Only works with knife out obviously if (g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFKnife)) { if (!i) @@ -485,34 +469,41 @@ void CreateMove() g_pUserCmd->buttons |= IN_ATTACK; } } - if (i) - i--; + // If i is not below 0.1f then substract one from it to slowly decrease lag amount + if (i > 0.1f) + i -= 1.0f; + // Set last weapon classid lastwep = g_pLocalPlayer->weapon()->m_iClassID; } + // if Jarate spam active if (piss) { + // Get Servertime servertime = (float) (CE_INT(g_pLocalPlayer->entity, netvar.nTickBase)) * g_GlobalVars->interval_per_tick; + // Get nextattack when it's invalid or the player selected another weapon (which is a tick, not a time like 1 second, but servertime + 1 second) if (!nextattack || g_pLocalPlayer->weapon()->m_iClassID != lastwep) nextattack = CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flNextPrimaryAttack); + // Set last weapon since it's not needed anymore this cycle lastwep = g_pLocalPlayer->weapon()->m_iClassID; + // Check if holding JARAAATE if (CE_INT(g_pLocalPlayer->weapon(), netvar.iItemDefinitionIndex) == 58) { + // Setup Switch variable to not constantly spam jarate, since else the jarate may vanish static int bSwitch = 0; + // Only play Piss.wav once every second + if ((g_pUserCmd->command_number % 66) == 0 && + (g_pUserCmd->buttons & IN_ATTACK)) + announcer::playsound("piss.wav"); + // If in attack and bSwitch is 0 do not attack but increment bSwitch if ((g_pUserCmd->buttons & IN_ATTACK) && !bSwitch) { - static int bswitch2 = 0; - if (bswitch2 > 20) - { - announcer::playsound("piss.wav"); - bswitch2 = 0; - } - bswitch2++; bSwitch++; g_pUserCmd->buttons &= ~IN_ATTACK; } + // Else attack and set bSwitch to 0 once it's over 20 else if (bSwitch) { amount = 21 * 66; @@ -540,13 +531,13 @@ void Draw() #if ENABLE_VISUALS == 1 if (doom && (servertime - nextattack > 0.0f || servertime - nextattack2)) { - auto amount = (int) servertime - (int) nextattack; - auto amount2 = (int) servertime - (int) nextattack2; + auto amount = servertime - nextattack; + auto amount2 = servertime - nextattack2; if (amount > 0.0f) - AddCenterString(format("Fireable Primary amount: ", amount), + AddCenterString(format("Fireable Primary amount: ", (int)amount), colors::orange); if (amount2 > 0.0f) - AddCenterString(format("Fireable Secondary amount: ", amount2), + AddCenterString(format("Fireable Secondary amount: ", (int)amount2), colors::orange); } if (razorback) @@ -569,7 +560,7 @@ void Draw() else if (servertime - nextattack < 21.0f) AddCenterString( format("Can't spam piss, ", - (int) (((float) servertime - (float) nextattack) * 100 / + (int) ((servertime - nextattack) * 100 / 21), "% charge"), colors::red); diff --git a/src/hacks/Walkbot.cpp b/src/hacks/Walkbot.cpp index d18c4eb5..74176925 100644 --- a/src/hacks/Walkbot.cpp +++ b/src/hacks/Walkbot.cpp @@ -1198,8 +1198,8 @@ void Move() if (boost::contains(prvlvlname, "pl_")) { bool ret = false; - if (lagexploit::point || lagexploit::point2 || lagexploit::point3 || - lagexploit::point4 || lagexploit::point5) + if (lagexploit::pointarr[0] || lagexploit::pointarr[1] || lagexploit::pointarr[2] || + lagexploit::pointarr[3] || lagexploit::pointarr[4]) for (int i = 0; i < MAX_ENTITIES; i++) { if (!ret) @@ -1212,10 +1212,10 @@ void Move() const model_t *model = RAW_ENT(ent)->GetModel(); if (model) { - if ((model == lagexploit::point2 || - model == lagexploit::point3 || - model == lagexploit::point4 || - model == lagexploit::point5) && + if ((model == lagexploit::pointarr[1] || + model == lagexploit::pointarr[2] || + model == lagexploit::pointarr[3] || + model == lagexploit::pointarr[4]) && ent->m_flDistance < 400.0f && IsVectorVisible(g_pLocalPlayer->v_Eye, ent->m_vecOrigin)) diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp index dfb83748..85835e41 100644 --- a/src/hooks/CreateMove.cpp +++ b/src/hooks/CreateMove.cpp @@ -252,9 +252,9 @@ bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd) static float last_jointeam_try = 0; CachedEntity *found_entity, *ent; - if (hacks::shared::followbot::bot) + if (hacks::shared::followbot::followbot) { - + hacks::shared::followbot::WorldTick(); if (g_GlobalVars->curtime < last_jointeam_try) { team_joining_state = 0; @@ -287,7 +287,7 @@ bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd) if (CE_BAD(ent)) continue; if (ent->player_info.friendsID == - hacks::shared::followbot::follow_steamid) + (int)hacks::shared::followbot::follow_steam) { found_entity = ent; break; @@ -530,13 +530,6 @@ bool CreateMove_hook(void *thisptr, float inputSample, CUserCmd *cmd) ret = false; } -#if ENABLE_IPC == 1 - if (CE_GOOD(g_pLocalPlayer->entity) && !g_pLocalPlayer->life_state) - { - PROF_SECTION(CM_followbot); - hacks::shared::followbot::AfterCreateMove(); - } -#endif if (cmd) g_Settings.last_angles = cmd->viewangles; } diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index 28f7f818..63a7f711 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -1019,6 +1019,7 @@ void LevelInit_hook(void *_this, const char *newmap) static const LevelInit_t original = (LevelInit_t) hooks::clientmode.GetMethod(offsets::LevelInit()); playerlist::Save(); + hacks::shared::lagexploit::bcalled = false; typedef bool *(*LoadNamedSkys_Fn)(const char *); uintptr_t addr = gSignatures.GetEngineSignature("55 89 E5 57 31 FF 56 8D B5 ? ? ? ? 53 " @@ -1035,10 +1036,12 @@ void LevelInit_hook(void *_this, const char *newmap) #endif logging::Info("Loaded Skybox: %s", succ ? "true" : "false"); ConVar *holiday = g_ICvar->FindVar("tf_forced_holiday"); + if (halloween_mode) holiday->SetValue(2); else if (holiday->m_nValue == 2) holiday->SetValue(2); + g_IEngine->ClientCmd_Unrestricted("exec cat_matchexec"); hacks::shared::aimbot::Reset(); chat_stack::Reset(); diff --git a/src/ipc.cpp b/src/ipc.cpp index a362f6cf..afcde677 100755 --- a/src/ipc.cpp +++ b/src/ipc.cpp @@ -49,7 +49,6 @@ CatCommand connect("ipc_connect", "Connect to IPC server", []() { hack::command_stack().push( std::string((const char *) payload)); }); - hacks::shared::followbot::AddMessageHandlers(peer); user_data_s &data = peer->memory->peer_user_data[peer->client_id]; // Preserve accumulated data diff --git a/src/menu/ncc/Menu.cpp b/src/menu/ncc/Menu.cpp index f27a12bd..12cf6c16 100644 --- a/src/menu/ncc/Menu.cpp +++ b/src/menu/ncc/Menu.cpp @@ -678,7 +678,7 @@ static const std::string list_tf2 = R"( "bptf_enable" "Followbot"[ "Followbot Menu" - "fb_bot" + "fb" "fb_autoteam" "fb_autoclass" "fb_activation" @@ -687,7 +687,7 @@ static const std::string list_tf2 = R"( "fb_sync_taunt" "fb_always_medigun" "fb_roaming" - "fb_crumb_draw" + "fb_draw" ] "Catbot Utilities"[ "Catbot Utilities Menu" diff --git a/src/visual/drawmgr.cpp b/src/visual/drawmgr.cpp index e3294f35..6a50cd45 100644 --- a/src/visual/drawmgr.cpp +++ b/src/visual/drawmgr.cpp @@ -145,7 +145,7 @@ void DrawCheatVisuals() hacks::tf::spyalert::Draw(); } #if ENABLE_IPC == 1 - IF_GAME(IsTF()) hacks::shared::followbot::Draw(); + IF_GAME(IsTF()) hacks::shared::followbot::DrawTick(); #endif { PROF_SECTION(DRAW_esp);