Aimbot: Auto zoom if followbot is "idle"

This commit is contained in:
TotallyNotElite 2019-10-29 14:13:38 +01:00
parent 2f45883735
commit c980649db8
4 changed files with 71 additions and 44 deletions

View File

@ -13,5 +13,6 @@ namespace hacks::shared::followbot
int ClassPriority(CachedEntity *ent); int ClassPriority(CachedEntity *ent);
bool isEnabled(); bool isEnabled();
bool isIdle();
extern int follow_target; extern int follow_target;
} // namespace hacks::shared::followbot } // namespace hacks::shared::followbot

View File

@ -16,6 +16,7 @@
#include "MiscTemporary.hpp" #include "MiscTemporary.hpp"
#include <targethelper.hpp> #include <targethelper.hpp>
#include "hitrate.hpp" #include "hitrate.hpp"
#include "FollowBot.hpp"
#if ENABLE_VISUALS #if ENABLE_VISUALS
#ifndef FEATURE_EFFECTS_DISABLED #ifndef FEATURE_EFFECTS_DISABLED
@ -112,6 +113,41 @@ static bool CarryingHeatmaker()
return CE_INT(LOCAL_W, netvar.iItemDefinitionIndex) == 752; return CE_INT(LOCAL_W, netvar.iItemDefinitionIndex) == 752;
} }
static void doAutoZoom(bool target_found)
{
bool isIdle = target_found ? false : hacks::shared::followbot::isIdle();
// Keep track of our zoom time
static Timer zoomTime{};
// Minigun spun up handler
if (auto_spin_up && g_pLocalPlayer->weapon()->m_iClassID() == CL_CLASS(CTFMinigun))
{
if (target_found)
zoomTime.update();
if (isIdle || !zoomTime.check(5000))
{
current_user_cmd->buttons |= IN_ATTACK2;
}
return;
}
if (auto_zoom && g_pLocalPlayer->holding_sniper_rifle && (target_found || isIdle))
{
if (target_found)
zoomTime.update();
if (not g_pLocalPlayer->bZoomed)
current_user_cmd->buttons |= IN_ATTACK2;
}
else if (!target_found)
{
// Auto-Unzoom
if (auto_unzoom)
if (g_pLocalPlayer->holding_sniper_rifle && g_pLocalPlayer->bZoomed && zoomTime.check(3000))
current_user_cmd->buttons |= IN_ATTACK2;
}
}
// Current Entity // Current Entity
int target_eid{ 0 }; int target_eid{ 0 };
CachedEntity *target = 0; CachedEntity *target = 0;
@ -124,8 +160,6 @@ float cur_proj_grav{ 0.0f };
// If slow aimbot allows autoshoot // If slow aimbot allows autoshoot
bool slow_can_shoot = false; bool slow_can_shoot = false;
bool projectileAimbotRequired; bool projectileAimbotRequired;
// Keep track of our zoom time
Timer zoomTime{};
// Track Backtrack tick for Entity // Track Backtrack tick for Entity
static std::pair<int, int> good_tick = { -1, -1 }; static std::pair<int, int> good_tick = { -1, -1 };
@ -139,14 +173,8 @@ static void CreateMove()
return; return;
if (CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer() || CE_BAD(LOCAL_W)) if (CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer() || CE_BAD(LOCAL_W))
return; return;
// Auto-Unzoom
if (auto_unzoom)
if (g_pLocalPlayer->holding_sniper_rifle && g_pLocalPlayer->bZoomed && zoomTime.test_and_set(3000))
current_user_cmd->buttons |= IN_ATTACK2;
if (g_pLocalPlayer->weapon()->m_iClassID() == CL_CLASS(CTFMinigun)) doAutoZoom(false);
if (auto_spin_up && CE_INT(LOCAL_E, netvar.m_iAmmo + 4) != 0 && !zoomTime.check(1000))
current_user_cmd->buttons |= IN_ATTACK2;
if (LOCAL_W->m_iClassID() == CL_CLASS(CTFMinigun) && CE_INT(LOCAL_E, netvar.m_iAmmo + 4) == 0) if (LOCAL_W->m_iClassID() == CL_CLASS(CTFMinigun) && CE_INT(LOCAL_E, netvar.m_iAmmo + 4) == 0)
return; return;
@ -178,41 +206,16 @@ static void CreateMove()
CachedEntity *target_entity = RetrieveBestTarget(aimkey_status); CachedEntity *target_entity = RetrieveBestTarget(aimkey_status);
if (CE_BAD(target_entity) || !foundTarget) if (CE_BAD(target_entity) || !foundTarget)
return; return;
// Auto-zoom // Auto-zoom
IF_GAME(IsTF()) doAutoZoom(true);
{
if (auto_zoom)
{
if (g_pLocalPlayer->holding_sniper_rifle)
{
zoomTime.update();
if (not g_pLocalPlayer->bZoomed)
current_user_cmd->buttons |= IN_ATTACK2;
}
}
}
// If zoomed only is on, check if zoomed // If zoomed only is on, check if zoomed
if (zoomed_only && g_pLocalPlayer->holding_sniper_rifle) if (zoomed_only && g_pLocalPlayer->holding_sniper_rifle)
{ {
if (!g_pLocalPlayer->bZoomed && !(current_user_cmd->buttons & IN_ATTACK)) if (!g_pLocalPlayer->bZoomed && !(current_user_cmd->buttons & IN_ATTACK))
return; return;
} }
// Minigun spun up handler
if (g_pLocalPlayer->weapon()->m_iClassID() == CL_CLASS(CTFMinigun))
{
int weapon_state = CE_INT(g_pLocalPlayer->weapon(), netvar.iWeaponState);
// If user setting for autospin isnt true, then we check if minigun
// is already zoomed
if ((weapon_state == MinigunState_t::AC_STATE_IDLE || weapon_state == MinigunState_t::AC_STATE_STARTFIRING) && !auto_spin_up)
return;
if (auto_spin_up)
{
zoomTime.update();
current_user_cmd->buttons |= IN_ATTACK2;
}
if (!(current_user_cmd->buttons & (IN_ATTACK2 | IN_ATTACK)))
return;
}
if (!g_IEntityList->GetClientEntity(target_entity->m_IDX)) if (!g_IEntityList->GetClientEntity(target_entity->m_IDX))
return; return;
if (!target_entity->hitboxes.GetHitbox(calculated_data_array[target_entity->m_IDX].hitbox)) if (!target_entity->hitboxes.GetHitbox(calculated_data_array[target_entity->m_IDX].hitbox))

View File

@ -35,6 +35,7 @@ static settings::Boolean corneractivate{ "follow-bot.corners", "true" };
static settings::Int steam_var{ "follow-bot.steamid", "0" }; static settings::Int steam_var{ "follow-bot.steamid", "0" };
static settings::Boolean ignore_textmode{ "follow-bot.ignore-textmode", "true" }; static settings::Boolean ignore_textmode{ "follow-bot.ignore-textmode", "true" };
static settings::Boolean mimic_crouch{ "follow-bot.mimic-crouch", "true" }; static settings::Boolean mimic_crouch{ "follow-bot.mimic-crouch", "true" };
static settings::Boolean autozoom_if_idle{ "follow-bot.autozoom-if-idle", "true" };
namespace nb = hacks::tf2::NavBot; namespace nb = hacks::tf2::NavBot;
@ -83,6 +84,30 @@ static Timer lastJump{};
static Timer crouch_timer{}; // Mimic crouch static Timer crouch_timer{}; // Mimic crouch
static std::array<Timer, PLAYER_ARRAY_SIZE> afkTicks; // for how many ms the player hasn't been moving static std::array<Timer, PLAYER_ARRAY_SIZE> afkTicks; // for how many ms the player hasn't been moving
bool isIdle()
{
if (!enable || !autozoom_if_idle || !follow_target)
return false;
float follow_dist = *follow_distance;
#if ENABLE_IPC
if (ipc::peer)
follow_dist += *additional_distance * ipc::peer->client_id;
#endif
auto target = ENTITY(follow_target);
if (CE_BAD(target))
return false;
auto tar_orig = target->m_vecOrigin();
auto loc_orig = LOCAL_E->m_vecOrigin();
float dist_to_target = loc_orig.DistTo(tar_orig);
// If we are zoomed, we should stop zooming a bit later to avoid zooming in again in a few CMs
float multiplier = (g_pLocalPlayer->holding_sniper_rifle && g_pLocalPlayer->bZoomed) ? 1.05f : 0.95f;
follow_dist = std::clamp(follow_dist * 1.5f * multiplier, 200.0f * multiplier, std::max(500.0f * multiplier, follow_dist));
return dist_to_target <= follow_dist;
}
static void checkAFK() static void checkAFK()
{ {
for (int i = 1; i < g_GlobalVars->maxClients; i++) for (int i = 1; i < g_GlobalVars->maxClients; i++)
@ -598,12 +623,12 @@ static void cm()
// Follow the crumbs when too far away, or just starting to follow // Follow the crumbs when too far away, or just starting to follow
#if ENABLE_IPC #if ENABLE_IPC
float follow_dist = (float) follow_distance; float follow_dist = *follow_distance;
if (ipc::peer) if (ipc::peer)
follow_dist += (float) additional_distance * ipc::peer->client_id; follow_dist += *additional_distance * ipc::peer->client_id;
if (dist_to_target > follow_dist) if (dist_to_target > follow_dist)
#else #else
if (dist_to_target > (float) follow_distance) if (dist_to_target > *follow_distance)
#endif #endif
{ {
// Check for jump // Check for jump

View File

@ -62,8 +62,6 @@ std::vector<KeyValues *> Iterate(KeyValues *event, int depth)
void ProcessAchievement(IGameEvent *ach) void ProcessAchievement(IGameEvent *ach)
{ {
if (CE_BAD(LOCAL_E))
return;
int player_idx = ach->GetInt("player", 0xDEAD); int player_idx = ach->GetInt("player", 0xDEAD);
int achievement = ach->GetInt("achievement", 0xDEAD); int achievement = ach->GetInt("achievement", 0xDEAD);
if (player_idx != 0xDEAD && (achievement == CAT_IDENTIFY || achievement == CAT_REPLY)) if (player_idx != 0xDEAD && (achievement == CAT_IDENTIFY || achievement == CAT_REPLY))
@ -173,8 +171,8 @@ static InitRoutine run_identify([]() {
sendIdentifyMessage(true); sendIdentifyMessage(true);
queue_ca8 = false; queue_ca8 = false;
} }
// 5 minutes between each identify seems ok? // 2 minutes between each identify seems ok?
if (!*identify || CE_BAD(LOCAL_E) || !identify_timer.test_and_set(1000 * 60 * 5)) if (!*identify || CE_BAD(LOCAL_E) || !identify_timer.test_and_set(1000 * 60 * 2))
return; return;
sendIdentifyMessage(false); sendIdentifyMessage(false);
}, },