This commit is contained in:
nullifiedcat 2018-07-29 13:12:59 +03:00
parent bf6c8d8fdc
commit 56ce98a821
14 changed files with 98 additions and 75 deletions

View File

@ -10,6 +10,7 @@
namespace hacks::shared::autojoin
{
void Update();
void UpdateSearch();
void resetQueueTimer();
void update();
void updateSearch();
}

View File

@ -57,4 +57,7 @@ extern circular_buf sequences;
extern int ticks;
extern BacktrackData headPositions[32][66];
extern BestTickData sorted_ticks[66];
bool isBacktrackEnabled();
float getLatency();
}

View File

@ -72,7 +72,7 @@ IgnoreReason shouldTarget(CachedEntity *entity)
{
if (hoovy && IsHoovy(entity))
return IgnoreReason::IS_HOOVY;
if (settings::taunting && HasCondition<TFCond_Taunting>(entity))
if (taunting && HasCondition<TFCond_Taunting>(entity))
return IgnoreReason::IS_TAUNTING;
return shouldTargetSteamId(entity->player_info.friendsID);

View File

@ -59,5 +59,5 @@ void logging::Info(const char *fmt, ...)
void logging::Shutdown()
{
fclose(logging::handle);
logging::handle = nullptr
logging::handle = nullptr;
}

View File

@ -383,14 +383,13 @@ free(logname);*/
#endif /* TEXTMODE */
#if not LAGBOT_MODE
hacks::shared::anticheat::Init();
hacks::tf2::healarrow::Init();
#endif
#if ENABLE_VISUALS
#ifndef FEATURE_FIDGET_SPINNER_ENABLED
InitSpinner();
logging::Info("Initialized Fidget Spinner");
#endif
hacks::shared::spam::Init();
hacks::shared::spam::init();
backpacktf::init();
logging::Info("Initialized Backpack.TF integration");
#endif

View File

@ -91,7 +91,7 @@ AimbotCalculatedData_s calculated_data_array[2048]{};
#define IsMelee GetWeaponMode() == weapon_melee
bool BacktrackAimbot()
{
if (!hacks::shared::backtrack::enable || !backtrackAimbot)
if (!hacks::shared::backtrack::isBacktrackEnabled() || !backtrackAimbot)
return false;
if (aimkey && !aimkey.isKeyDown())
return false;
@ -100,14 +100,14 @@ bool BacktrackAimbot()
return false;
if (zoomed_only && !g_pLocalPlayer->bZoomed &&
!(g_pUserCmd->buttons & IN_ATTACK))
!(current_user_cmd->buttons & IN_ATTACK))
return false;
int iBestTarget = hacks::shared::backtrack::iBestTarget;
if (iBestTarget == -1)
return true;
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;
@ -133,7 +133,7 @@ bool BacktrackAimbot()
float &simtime = CE_FLOAT(tar, netvar.m_flSimulationTime);
angles.y = i.viewangles;
simtime = i.simtime;
g_pUserCmd->tick_count = i.tickcount;
current_user_cmd->tick_count = i.tickcount;
Vector tr = (i.hitboxpos - g_pLocalPlayer->v_Eye);
Vector angles2;
VectorAngles(tr, angles2);
@ -147,9 +147,9 @@ bool BacktrackAimbot()
if (!slow_aim)
slow_can_shoot = true;
// Set angles
g_pUserCmd->viewangles = angles2;
current_user_cmd->viewangles = angles2;
if (autoshoot && slow_can_shoot)
g_pUserCmd->buttons |= IN_ATTACK;
current_user_cmd->buttons |= IN_ATTACK;
return true;
}
return true;
@ -158,7 +158,7 @@ bool BacktrackAimbot()
void CreateMove()
{
PROF_SECTION(PT_aimbot_cm);
if (!enabled)
if (!enable)
return;
// Auto-Unzoom
@ -167,7 +167,7 @@ void CreateMove()
if (g_pLocalPlayer->holding_sniper_rifle && g_pLocalPlayer->bZoomed &&
zoomTime.check(3000))
{
g_pUserCmd->buttons |= IN_ATTACK2;
current_user_cmd->buttons |= IN_ATTACK2;
}
}
// We do this as we need to pass whether the aimkey allows aiming to both
@ -188,7 +188,7 @@ void CreateMove()
zoomTime.update();
if (not g_pLocalPlayer->bZoomed)
{
g_pUserCmd->buttons |= IN_ATTACK2;
current_user_cmd->buttons |= IN_ATTACK2;
}
}
}
@ -250,7 +250,7 @@ void CreateMove()
currently_charging_huntsman = true;
// Huntsman was released
if (!(g_pUserCmd->buttons & IN_ATTACK) &&
if (!(current_user_cmd->buttons & IN_ATTACK) &&
currently_charging_huntsman)
{
currently_charging_huntsman = false;
@ -275,7 +275,7 @@ void CreateMove()
currently_charging_pipe = true;
// Grenade was released
if (!(g_pUserCmd->buttons & IN_ATTACK) && currently_charging_pipe)
if (!(current_user_cmd->buttons & IN_ATTACK) && currently_charging_pipe)
{
currently_charging_pipe = false;
Aim(target_entity);
@ -302,8 +302,6 @@ void CreateMove()
DoAutoshoot();
Aim(target_entity);
}
return;
}
// The first check to see if the player should aim in the first place
@ -312,7 +310,7 @@ bool ShouldAim()
// Checks should be in order: cheap -> expensive
// Check for +use
if (g_pUserCmd->buttons & IN_USE)
if (current_user_cmd->buttons & IN_USE)
return false;
// Check if using action slot item
if (g_pLocalPlayer->using_action_slot_item)
@ -329,7 +327,7 @@ bool ShouldAim()
// If zoomed only is on, check if zoomed
if (zoomed_only && g_pLocalPlayer->holding_sniper_rifle)
{
if (!g_pLocalPlayer->bZoomed && !(g_pUserCmd->buttons & IN_ATTACK))
if (!g_pLocalPlayer->bZoomed && !(current_user_cmd->buttons & IN_ATTACK))
return false;
}
// Is taunting?
@ -364,7 +362,7 @@ bool ShouldAim()
// Check if player is zooming
if (g_pLocalPlayer->bZoomed)
{
if (!(g_pUserCmd->buttons & (IN_ATTACK | IN_ATTACK2)))
if (!(current_user_cmd->buttons & (IN_ATTACK | IN_ATTACK2)))
{
if (!CanHeadshot())
return false;
@ -386,9 +384,9 @@ bool ShouldAim()
}
if (auto_spin_up)
{
g_pUserCmd->buttons |= IN_ATTACK2;
current_user_cmd->buttons |= IN_ATTACK2;
}
if (!(g_pUserCmd->buttons & (IN_ATTACK2 | IN_ATTACK)))
if (!(current_user_cmd->buttons & (IN_ATTACK2 | IN_ATTACK)))
{
return false;
}
@ -779,7 +777,7 @@ void Aim(CachedEntity *entity)
DoSlowAim(angles);
// Set angles
g_pUserCmd->viewangles = angles;
current_user_cmd->viewangles = angles;
if (silent && !slow_aim)
g_pLocalPlayer->bUseSilentAngles = true;
@ -811,14 +809,14 @@ void DoAutoshoot()
(float) huntsman_autoshoot) &&
begancharge)
{
g_pUserCmd->buttons &= ~IN_ATTACK;
current_user_cmd->buttons &= ~IN_ATTACK;
hacks::shared::antiaim::SetSafeSpace(3);
begancharge = false;
// Pull string if charge isnt enough
}
else
{
g_pUserCmd->buttons |= IN_ATTACK;
current_user_cmd->buttons |= IN_ATTACK;
begancharge = true;
}
return;
@ -833,14 +831,14 @@ void DoAutoshoot()
// Release Sticky if > chargetime
if ((chargetime >= (float) sticky_autoshoot) && begansticky > 3)
{
g_pUserCmd->buttons &= ~IN_ATTACK;
current_user_cmd->buttons &= ~IN_ATTACK;
hacks::shared::antiaim::SetSafeSpace(3);
begansticky = 0;
}
// Else just keep charging
else
{
g_pUserCmd->buttons |= IN_ATTACK;
current_user_cmd->buttons |= IN_ATTACK;
begansticky++;
}
return;
@ -887,10 +885,8 @@ void DoAutoshoot()
attack = false;
if (attack)
g_pUserCmd->buttons |= IN_ATTACK;
current_user_cmd->buttons |= IN_ATTACK;
hacks::shared::antiaim::SetSafeSpace(1);
return;
}
// Grab a vector for a specific ent
@ -1132,32 +1128,35 @@ bool VischeckPredictedEntity(CachedEntity *entity)
return cd.visible;
}
static float slow_change_dist_p = 0;
static float slow_change_dist_y = 0;
// A helper function to find a user angle that isnt directly on the target
// angle, effectively slowing the aiming process
void DoSlowAim(Vector &input_angle)
{
static float slow_change_dist_p = 0;
static float slow_change_dist_y = 0;
auto viewangles = current_user_cmd->viewangles;
// Yaw
if (g_pUserCmd->viewangles.y != input_angle.y)
if (viewangles.y != input_angle.y)
{
// Check if input angle and user angle are on opposing sides of yaw so
// we can correct for that
bool slow_opposing = false;
if (input_angle.y < -90 && g_pUserCmd->viewangles.y > 90 ||
input_angle.y > 90 && g_pUserCmd->viewangles.y < -90)
if (input_angle.y < -90 && viewangles.y > 90 ||
input_angle.y > 90 && viewangles.y < -90)
slow_opposing = true;
// Direction
bool slow_dir = false;
if (slow_opposing)
{
if (input_angle.y > 90 && g_pUserCmd->viewangles.y < -90)
if (input_angle.y > 90 && viewangles.y < -90)
slow_dir = true;
}
else if (g_pUserCmd->viewangles.y > input_angle.y)
else if (viewangles.y > input_angle.y)
slow_dir = true;
// Speed, check if opposing. We dont get a new distance due to the
@ -1165,28 +1164,28 @@ void DoSlowAim(Vector &input_angle)
// our last one.
if (!slow_opposing)
slow_change_dist_y =
std::abs(g_pUserCmd->viewangles.y - input_angle.y) /
std::abs(viewangles.y - input_angle.y) /
(int) slow_aim;
// Move in the direction of the input angle
if (slow_dir)
input_angle.y = g_pUserCmd->viewangles.y - slow_change_dist_y;
input_angle.y = viewangles.y - slow_change_dist_y;
else
input_angle.y = g_pUserCmd->viewangles.y + slow_change_dist_y;
input_angle.y = viewangles.y + slow_change_dist_y;
}
// Pitch
if (g_pUserCmd->viewangles.x != input_angle.x)
if (viewangles.x != input_angle.x)
{
// Get speed
slow_change_dist_p =
std::abs(g_pUserCmd->viewangles.x - input_angle.x) / (int) slow_aim;
std::abs(viewangles.x - input_angle.x) / (int) slow_aim;
// Move in the direction of the input angle
if (g_pUserCmd->viewangles.x > input_angle.x)
input_angle.x = g_pUserCmd->viewangles.x - slow_change_dist_p;
if (viewangles.x > input_angle.x)
input_angle.x = viewangles.x - slow_change_dist_p;
else
input_angle.x = g_pUserCmd->viewangles.x + slow_change_dist_p;
input_angle.x = viewangles.x + slow_change_dist_p;
}
// 0.17 is a good amount in general

View File

@ -6,6 +6,8 @@
*/
#include <settings/Int.hpp>
#include <hacks/AutoJoin.hpp>
#include "common.hpp"
#include "hack.hpp"
@ -32,13 +34,13 @@ bool UnassignedTeam()
bool UnassignedClass()
{
return g_pLocalPlayer->clazz != int(preferred_class);
return g_pLocalPlayer->clazz != *autojoin_class;
}
Timer autoqueue_timer{};
Timer queuetime{};
Timer req_timer{};
void UpdateSearch()
static Timer autoqueue_timer{};
static Timer queuetime{};
static Timer req_timer{};
void updateSearch()
{
// segfaults for no reason
/*static bool calld = false;
@ -84,7 +86,7 @@ void UpdateSearch()
re::CTFGCClientSystem *gc = re::CTFGCClientSystem::GTFGCClientSystem();
re::CTFPartyClient *pc = re::CTFPartyClient::GTFPartyClient();
if (g_pUserCmd && gc && gc->BConnectedToMatchServer(false) &&
if (current_user_cmd && gc && gc->BConnectedToMatchServer(false) &&
gc->BHaveLiveMatch())
tfmm::queue_leave();
if (gc && !gc->BConnectedToMatchServer(false) &&
@ -106,11 +108,10 @@ void UpdateSearch()
#endif
}
Timer timer{};
void Update()
void update()
{
#if !LAGBOT_MODE
if (timer.test_and_set(500))
if (autoqueue_timer.test_and_set(500))
{
if (autojoin_team and UnassignedTeam())
{
@ -126,4 +127,10 @@ void Update()
}
#endif
}
void autojoin::resetQueueTimer()
{
queuetime.update();
}
}

View File

@ -10,6 +10,8 @@
#include <boost/circular_buffer.hpp>
#include <glez/draw.hpp>
#include <settings/Bool.hpp>
#include <hacks/Backtrack.hpp>
static settings::Bool enable{ "backtrack.enable", "false" };
static settings::Bool draw_bt{ "backtrack.draw", "false" };
@ -297,4 +299,14 @@ bool shouldBacktrack()
}
return false;
}
bool isBacktrackEnabled()
{
return *enable;
}
float getLatency()
{
return *latency;
}
}

View File

@ -22,6 +22,7 @@ static settings::Int micspam_on{ "cat-bot.micspam.interval-on", "3" };
static settings::Int micspam_off{ "cat-bot.micspam.interval-off", "60" };
static settings::Bool auto_crouch{ "cat-bot.auto-crouch", "true" };
static settings::Bool random_votekicks{ "cat-bot.votekicks", "false" };
namespace hacks::shared::catbot
{
@ -129,9 +130,9 @@ void update_catbot_list()
class CatBotEventListener : public IGameEventListener2
{
virtual void FireGameEvent(IGameEvent *event)
void FireGameEvent(IGameEvent *event) override
{
if (!enabled)
if (!enable)
return;
int killer_id =
@ -152,9 +153,9 @@ CatBotEventListener &listener()
return object;
}
Timer timer_votekicks{};
Timer timer_catbot_list{};
Timer timer_abandon{};
static Timer timer_votekicks{};
static Timer timer_catbot_list{};
static Timer timer_abandon{};
int count_bots{ 0 };
@ -254,11 +255,11 @@ void smart_crouch()
crouch = false;
}
if (crouch)
g_pUserCmd->buttons |= IN_DUCK;
current_user_cmd->buttons |= IN_DUCK;
}
void update()
{
if (!enabled)
if (!enable)
return;
if (g_Settings.bInvalid)
@ -269,10 +270,10 @@ void update()
if (micspam)
{
if (micspam_on && micspam_on_timer.test_and_set(int(micspam_on) * 1000))
if (micspam_on && micspam_on_timer.test_and_set(*micspam_on * 1000))
g_IEngine->ExecuteClientCmd("+voicerecord");
if (micspam_off &&
micspam_off_timer.test_and_set(int(micspam_off) * 1000))
micspam_off_timer.test_and_set(*micspam_off * 1000))
g_IEngine->ExecuteClientCmd("-voicerecord");
}
@ -295,7 +296,7 @@ void update()
else
continue;
player_info_s info;
player_info_s info{};
if (!g_IEngine->GetPlayerInfo(i, &info))
continue;

View File

@ -20,7 +20,6 @@ static settings::Bool teamname_spam{ "spam.teamname","0" };
namespace hacks::shared::spam
{
static CatCommand reload("spam_reload", "Reload spam file", Reload);
static int last_index;
@ -380,9 +379,9 @@ void createMove()
}
}
void reload()
void reloadSpamFile()
{
file.Load(std::string(filename.GetString()));
file.Load(*filename);
}
bool isActive()
@ -429,3 +428,5 @@ const std::vector<std::string> builtin_lithium = {
"GOT ROLLED BY LITHIUM? HEY, THAT MEANS IT'S TIME TO GET LITHIUMCHEAT!!"
};
}
static CatCommand reload("spam_reload", "Reload spam file", hacks::shared::spam::reloadSpamFile);

View File

@ -104,8 +104,8 @@ void WalkTo(const Vector &vector)
// 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;
current_user_cmd->forwardmove = result.first;
current_user_cmd->sidemove = result.second;
}
// Function to get the corner location that a vischeck to an entity is possible

View File

@ -56,7 +56,7 @@ DEFINE_HOOKED_METHOD(Paint, void, IEngineVGui *this_, PaintMode_t mode)
}
}
#endif
hacks::shared::autojoin::UpdateSearch();
hacks::shared::autojoin::updateSearch();
if (!hack::command_stack().empty())
{
PROF_SECTION(PT_command_stack);

View File

@ -35,7 +35,7 @@ CatCommand connect("ipc_connect", "Connect to IPC server", []() {
logging::Info("Already connected!");
return;
}
peer = new peer_t(std::string(server_name.GetString()), false, false);
peer = new peer_t(*server_name, false, false);
try
{
peer->Connect();

View File

@ -35,10 +35,10 @@ void queue_start()
re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient();
if (client)
{
if (queue == 7)
if (*queue == 7)
client->LoadSavedCasualCriteria();
client->RequestQueueForMatch((int) queue);
hacks::shared::autojoin::queuetime.update();
hacks::shared::autojoin::resetQueueTimer();
}
else
logging::Info("queue_start: CTFPartyClient == null!");