Fix some backtrack aimbot performance issues

This commit is contained in:
BenCat07 2021-05-05 16:46:02 +02:00 committed by LightCat
parent d63ef2753f
commit 713e601117
2 changed files with 50 additions and 7 deletions

View File

@ -123,6 +123,7 @@
<List width="150"> <List width="150">
<AutoVariable width="fill" target="backtrack.enabled" label="Enable backtracking" tooltip="Allow hitting enemies where they were in the past."/> <AutoVariable width="fill" target="backtrack.enabled" label="Enable backtracking" tooltip="Allow hitting enemies where they were in the past."/>
<AutoVariable width="fill" target="aimbot.backtrack" label="Aim at backtracking" tooltip="Aim at backtrack ticks."/> <AutoVariable width="fill" target="aimbot.backtrack" label="Aim at backtracking" tooltip="Aim at backtrack ticks."/>
<AutoVariable width="fill" target="aimbot.backtrack.only-last-tick" label="Aim at only the last tick" tooltip="Aim at only the last backtrack tick. !DISABLING THIS MAY CAUSE LAG!"/>
<AutoVariable width="fill" target="misc.ping-reducer.enable" label="Ping reducer" tooltip="Try to reduce your ping to the number set below."/> <AutoVariable width="fill" target="misc.ping-reducer.enable" label="Ping reducer" tooltip="Try to reduce your ping to the number set below."/>
<AutoVariable width="fill" target="misc.ping-reducer.target" label="Target ping"/> <AutoVariable width="fill" target="misc.ping-reducer.target" label="Target ping"/>
<AutoVariable width="fill" target="backtrack.latency" label="Fake latency" tooltip="Amount of fake latency." min="0" max="1000" step="25"/> <AutoVariable width="fill" target="backtrack.latency" label="Fake latency" tooltip="Amount of fake latency." min="0" max="1000" step="25"/>
@ -140,7 +141,7 @@
</LabeledObject> </LabeledObject>
</List> </List>
</Box> </Box>
<Box padding="12 6 6 6" width="content" height="content" name="Sandvich aimbot" x="340" y="220"> <Box padding="12 6 6 6" width="content" height="content" name="Sandvich aimbot" x="340" y="230">
<List width="150"> <List width="150">
<AutoVariable width="fill" target="sandwichaim.enable" label="Enable Sandvich aimbot"/> <AutoVariable width="fill" target="sandwichaim.enable" label="Enable Sandvich aimbot"/>
<AutoVariable width="fill" target="sandwichaim.aimkey" label="Aimkey"/> <AutoVariable width="fill" target="sandwichaim.aimkey" label="Aimkey"/>

View File

@ -61,6 +61,7 @@ static settings::Boolean auto_zoom{ "aimbot.auto.zoom", "0" };
static settings::Boolean auto_unzoom{ "aimbot.auto.unzoom", "0" }; static settings::Boolean auto_unzoom{ "aimbot.auto.unzoom", "0" };
static settings::Boolean backtrackAimbot{ "aimbot.backtrack", "0" }; static settings::Boolean backtrackAimbot{ "aimbot.backtrack", "0" };
static settings::Boolean backtrackLastTickOnly("aimbot.backtrack.only-last-tick", "true");
static bool force_backtrack_aimbot = false; static bool force_backtrack_aimbot = false;
static settings::Boolean backtrackVischeckAll{ "aimbot.backtrack.vischeck-all", "0" }; static settings::Boolean backtrackVischeckAll{ "aimbot.backtrack.vischeck-all", "0" };
@ -175,6 +176,27 @@ bool shouldBacktrack(CachedEntity *ent)
return true; return true;
} }
// Reduce Backtrack lag by checking if the ticks hitboxes are within a reasonable FOV range
bool validateTickFOV(tf2::backtrack::BacktrackData &tick)
{
if (fov)
{
bool valid_fov = false;
for (auto &hitbox : tick.hitboxes)
{
float score = GetFov(g_pLocalPlayer->v_OrigViewangles, g_pLocalPlayer->v_Eye, hitbox.center);
// Check if the FOV is within a 2.0f threshhold
if (score < fov + 2.0f)
{
valid_fov = true;
break;
}
}
return valid_fov;
}
return true;
}
// Am I holding Hitman's Heatmaker ? // Am I holding Hitman's Heatmaker ?
static bool CarryingHeatmaker() static bool CarryingHeatmaker()
{ {
@ -514,16 +536,26 @@ CachedEntity *RetrieveBestTarget(bool aimkey_state)
{ {
if (shouldBacktrack(target_last)) if (shouldBacktrack(target_last))
{ {
auto good_ticks = hacks::tf2::backtrack::getGoodTicks(target_last); auto good_ticks_tmp = hacks::tf2::backtrack::getGoodTicks(target_last);
if (good_ticks) if (good_ticks_tmp)
for (auto &bt_tick : *good_ticks) {
auto good_ticks = *good_ticks_tmp;
if (backtrackLastTickOnly)
{ {
good_ticks.clear();
good_ticks.push_back(good_ticks_tmp->back());
}
for (auto &bt_tick : good_ticks)
{
if (!validateTickFOV(bt_tick))
continue;
hacks::tf2::backtrack::MoveToTick(bt_tick); hacks::tf2::backtrack::MoveToTick(bt_tick);
if (IsTargetStateGood(target_last)) if (IsTargetStateGood(target_last))
return target_last; return target_last;
// Restore if bad target // Restore if bad target
hacks::tf2::backtrack::RestoreEntity(target_last->m_IDX); hacks::tf2::backtrack::RestoreEntity(target_last->m_IDX);
} }
}
} }
// Check if previous target is still good // Check if previous target is still good
@ -551,10 +583,19 @@ CachedEntity *RetrieveBestTarget(bool aimkey_state)
static std::optional<hacks::tf2::backtrack::BacktrackData> temp_bt_tick = std::nullopt; static std::optional<hacks::tf2::backtrack::BacktrackData> temp_bt_tick = std::nullopt;
if (shouldBacktrack(ent)) if (shouldBacktrack(ent))
{ {
auto good_ticks = tf2::backtrack::getGoodTicks(ent); auto good_ticks_tmp = tf2::backtrack::getGoodTicks(ent);
if (good_ticks) if (good_ticks_tmp)
for (auto &bt_tick : *good_ticks) {
auto good_ticks = *good_ticks_tmp;
if (backtrackLastTickOnly)
{ {
good_ticks.clear();
good_ticks.push_back(good_ticks_tmp->back());
}
for (auto &bt_tick : good_ticks)
{
if (!validateTickFOV(bt_tick))
continue;
hacks::tf2::backtrack::MoveToTick(bt_tick); hacks::tf2::backtrack::MoveToTick(bt_tick);
if (IsTargetStateGood(ent)) if (IsTargetStateGood(ent))
{ {
@ -564,6 +605,7 @@ CachedEntity *RetrieveBestTarget(bool aimkey_state)
} }
hacks::tf2::backtrack::RestoreEntity(ent->m_IDX); hacks::tf2::backtrack::RestoreEntity(ent->m_IDX);
} }
}
} }
else else
isTargetGood = IsTargetStateGood(ent); isTargetGood = IsTargetStateGood(ent);