Fix projectile aimbot with backtrack enabled
This commit is contained in:
parent
910544a947
commit
da1a901187
@ -121,7 +121,7 @@ float cur_proj_grav{ 0.0f };
|
|||||||
|
|
||||||
bool shouldBacktrack()
|
bool shouldBacktrack()
|
||||||
{
|
{
|
||||||
return *enable && !projectile_mode && (*backtrackAimbot || force_backtrack_aimbot) && hacks::tf2::backtrack::isBacktrackEnabled;
|
return !projectile_mode && (*backtrackAimbot || force_backtrack_aimbot) && hacks::tf2::backtrack::isBacktrackEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsBacktracking()
|
bool IsBacktracking()
|
||||||
@ -937,7 +937,7 @@ void Aim(CachedEntity *entity)
|
|||||||
|
|
||||||
if (silent && !slow_aim)
|
if (silent && !slow_aim)
|
||||||
g_pLocalPlayer->bUseSilentAngles = true;
|
g_pLocalPlayer->bUseSilentAngles = true;
|
||||||
// Set tick count to target's (backtrack messes with this)
|
// Set tick count to targets (backtrack messes with this)
|
||||||
if (!shouldBacktrack() && nolerp && entity->m_IDX <= g_IEngine->GetMaxClients())
|
if (!shouldBacktrack() && nolerp && entity->m_IDX <= g_IEngine->GetMaxClients())
|
||||||
current_user_cmd->tick_count = TIME_TO_TICKS(CE_FLOAT(entity, netvar.m_flSimulationTime));
|
current_user_cmd->tick_count = TIME_TO_TICKS(CE_FLOAT(entity, netvar.m_flSimulationTime));
|
||||||
// Set Backtrack data
|
// Set Backtrack data
|
||||||
@ -1258,7 +1258,7 @@ int BestHitbox(CachedEntity *target)
|
|||||||
}
|
}
|
||||||
else if (target->hitboxes.VisibilityCheck(preferred))
|
else if (target->hitboxes.VisibilityCheck(preferred))
|
||||||
return preferred;
|
return preferred;
|
||||||
// Else attempt to find a hitbox at all
|
// Else attempt to find any hitbox at all
|
||||||
if (IsBacktracking())
|
if (IsBacktracking())
|
||||||
{
|
{
|
||||||
// We already vischecked
|
// We already vischecked
|
||||||
|
@ -177,7 +177,7 @@ void CreateMove()
|
|||||||
std::optional<BacktrackData> best_data;
|
std::optional<BacktrackData> best_data;
|
||||||
CachedEntity *best_ent = nullptr;
|
CachedEntity *best_ent = nullptr;
|
||||||
|
|
||||||
for (int i = 0; i <= g_IEngine->GetMaxClients(); i++)
|
for (int i = 1; i <= g_IEngine->GetMaxClients(); i++)
|
||||||
{
|
{
|
||||||
if (i == g_pLocalPlayer->entity_idx)
|
if (i == g_pLocalPlayer->entity_idx)
|
||||||
{
|
{
|
||||||
@ -195,7 +195,7 @@ void CreateMove()
|
|||||||
resetData(i);
|
resetData(i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto &backtrack_ent = backtrack_data.at(i);
|
auto &backtrack_ent = backtrack_data.at(i - 1);
|
||||||
|
|
||||||
// Have no data, create it
|
// Have no data, create it
|
||||||
if (!backtrack_ent)
|
if (!backtrack_ent)
|
||||||
@ -235,11 +235,23 @@ void CreateMove()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy bones (for chams/glow)
|
// Copy bones (for chams/glow)
|
||||||
int numbones = CE_INT(ent, 0x844);
|
auto model = (const model_t *) RAW_ENT(ent)->GetModel();
|
||||||
if (numbones != current_tick.bones.size())
|
if (model)
|
||||||
current_tick.bones.resize(numbones);
|
{
|
||||||
|
auto shdr = g_IModelInfo->GetStudiomodel(model);
|
||||||
|
if (shdr)
|
||||||
|
{
|
||||||
|
int numbones = shdr->numbones;
|
||||||
|
if (numbones != current_tick.bones.size())
|
||||||
|
current_tick.bones.resize(numbones);
|
||||||
|
|
||||||
memcpy((void *) ¤t_tick.bones[0], (void *) &ent->hitboxes.bones[0], sizeof(matrix3x4_t) * numbones);
|
memcpy((void *) ¤t_tick.bones[0], (void *) &ent->hitboxes.bones[0], sizeof(matrix3x4_t) * numbones);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
current_tick.bones.resize(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
current_tick.bones.resize(0);
|
||||||
|
|
||||||
// Check if tick updated or not (fakelag)
|
// Check if tick updated or not (fakelag)
|
||||||
current_tick.has_updated = !previous_tick.m_flSimulationTime || previous_tick.m_flSimulationTime != current_tick.m_flSimulationTime;
|
current_tick.has_updated = !previous_tick.m_flSimulationTime || previous_tick.m_flSimulationTime != current_tick.m_flSimulationTime;
|
||||||
@ -409,7 +421,7 @@ std::vector<BacktrackData> getGoodTicks(int entidx)
|
|||||||
{
|
{
|
||||||
std::vector<BacktrackData> to_return;
|
std::vector<BacktrackData> to_return;
|
||||||
// Invalid
|
// Invalid
|
||||||
if (!backtrack_data.at(entidx - 1))
|
if (entidx <= 1 || (int) backtrack_data.size() < entidx || !backtrack_data.at(entidx - 1))
|
||||||
return to_return;
|
return to_return;
|
||||||
|
|
||||||
// Check all ticks
|
// Check all ticks
|
||||||
@ -429,7 +441,7 @@ std::optional<BacktrackData> getBestTick(CachedEntity *ent, std::function<bool(C
|
|||||||
std::optional<BacktrackData> best_tick;
|
std::optional<BacktrackData> best_tick;
|
||||||
|
|
||||||
// No data recorded
|
// No data recorded
|
||||||
if (!backtrack_data.at(ent->m_IDX - 1))
|
if (backtrack_data.size() < ent->m_IDX || !backtrack_data.at(ent->m_IDX - 1))
|
||||||
return best_tick;
|
return best_tick;
|
||||||
|
|
||||||
// Let the callback do the lifting
|
// Let the callback do the lifting
|
||||||
@ -468,7 +480,7 @@ std::optional<BacktrackData> getClosestEntTick(CachedEntity *ent, Vector vec, st
|
|||||||
{
|
{
|
||||||
std::optional<BacktrackData> return_value;
|
std::optional<BacktrackData> return_value;
|
||||||
// No entry
|
// No entry
|
||||||
if (!backtrack_data.at(ent->m_IDX - 1))
|
if (backtrack_data.size() < ent->m_IDX || !backtrack_data.at(ent->m_IDX - 1))
|
||||||
return return_value;
|
return return_value;
|
||||||
|
|
||||||
float distance = FLT_MAX;
|
float distance = FLT_MAX;
|
||||||
|
@ -19,7 +19,9 @@ Vector SimpleLatencyPrediction(CachedEntity *ent, int hb)
|
|||||||
Vector result;
|
Vector result;
|
||||||
GetHitbox(ent, hb, result);
|
GetHitbox(ent, hb, result);
|
||||||
float latency = g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING) + g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_INCOMING);
|
float latency = g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING) + g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_INCOMING);
|
||||||
result += CE_VECTOR(ent, netvar.vVelocity) * latency;
|
Vector velocity;
|
||||||
|
velocity::EstimateAbsVelocity(RAW_ENT(ent), velocity);
|
||||||
|
result += velocity * latency;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +142,9 @@ void Prediction_PaintTraverse()
|
|||||||
auto ent = ENTITY(i);
|
auto ent = ENTITY(i);
|
||||||
if (CE_BAD(ent) || !ent->m_bAlivePlayer())
|
if (CE_BAD(ent) || !ent->m_bAlivePlayer())
|
||||||
continue;
|
continue;
|
||||||
auto data = Predict(ent->m_vecOrigin(), 0.0f, CE_VECTOR(ent, netvar.vVelocity), Vector(0, 0, -sv_gravity->GetFloat()), std::make_pair(RAW_ENT(ent)->GetCollideable()->OBBMins(), RAW_ENT(ent)->GetCollideable()->OBBMaxs()), 0.0f, 32);
|
Vector velocity;
|
||||||
|
velocity::EstimateAbsVelocity(RAW_ENT(ent), velocity);
|
||||||
|
auto data = Predict(ent->m_vecOrigin(), 0.0f, velocity, Vector(0, 0, -sv_gravity->GetFloat()), std::make_pair(RAW_ENT(ent)->GetCollideable()->OBBMins(), RAW_ENT(ent)->GetCollideable()->OBBMaxs()), 0.0f, 32);
|
||||||
Vector previous_screen;
|
Vector previous_screen;
|
||||||
if (!draw::WorldToScreen(ent->m_vecOrigin(), previous_screen))
|
if (!draw::WorldToScreen(ent->m_vecOrigin(), previous_screen))
|
||||||
continue;
|
continue;
|
||||||
@ -185,7 +189,8 @@ Vector EnginePrediction(CachedEntity *entity, float time)
|
|||||||
CUserCmd fakecmd{};
|
CUserCmd fakecmd{};
|
||||||
memset(&fakecmd, 0, sizeof(CUserCmd));
|
memset(&fakecmd, 0, sizeof(CUserCmd));
|
||||||
|
|
||||||
Vector vel = CE_VECTOR(entity, netvar.vVelocity);
|
Vector vel;
|
||||||
|
velocity::EstimateAbsVelocity(RAW_ENT(entity), vel);
|
||||||
fakecmd.command_number = last_cmd_number;
|
fakecmd.command_number = last_cmd_number;
|
||||||
fakecmd.forwardmove = vel.x;
|
fakecmd.forwardmove = vel.x;
|
||||||
fakecmd.sidemove = -vel.y;
|
fakecmd.sidemove = -vel.y;
|
||||||
@ -364,7 +369,8 @@ Vector ProjectilePrediction(CachedEntity *ent, int hb, float speed, float gravit
|
|||||||
onground = true;
|
onground = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector velocity = CE_VECTOR(ent, netvar.vVelocity);
|
Vector velocity;
|
||||||
|
velocity::EstimateAbsVelocity(RAW_ENT(ent), velocity);
|
||||||
static ConVar *sv_gravity = g_ICvar->FindVar("sv_gravity");
|
static ConVar *sv_gravity = g_ICvar->FindVar("sv_gravity");
|
||||||
Vector acceleration = { 0.0f, 0.0f, -(sv_gravity->GetFloat() * entgmod) };
|
Vector acceleration = { 0.0f, 0.0f, -(sv_gravity->GetFloat() * entgmod) };
|
||||||
float steplength = ((float) (2 * range) / (float) maxsteps);
|
float steplength = ((float) (2 * range) / (float) maxsteps);
|
||||||
|
Reference in New Issue
Block a user