-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
void aim::PlayerMove(adjust_data* record)
{
Vector start, end, normal;
CGameTrace trace;
CTraceFilterWorldOnly filter;
Ray_t Ray;
// define trace start.
start = record->origin;
// move trace end one tick into the future using predicted velocity.
end = start + (record->velocity * m_globals()->m_intervalpertick);
// trace.
Ray.Init(start, end, record->player->m_vecMins(), record->player->m_vecMaxs());
m_trace()->TraceRay(Ray, CONTENTS_SOLID, &filter, &trace);
// we hit shit
// we need to fix hit.
if (trace.fraction != 1.f)
{
// fix sliding on planes.
for (int i{}; i < 2; ++i) {
record->velocity -= trace.plane.normal * record->velocity.Dot(trace.plane.normal);
float adjust = record->velocity.Dot(trace.plane.normal);
if (adjust < 0.f)
record->velocity -= (trace.plane.normal * adjust);
start = trace.endpos;
end = start + (record->velocity * (m_globals()->m_intervalpertick * (1.f - trace.fraction)));
Ray_t two_ray;
two_ray.Init(start, end, record->mins, record->maxs);
m_trace()->TraceRay(two_ray, CONTENTS_SOLID, &filter, &trace);
if (trace.fraction == 1.f)
break;
}
}
// set new final origin.
start = end = record->origin = trace.endpos;
// move endpos 2 units down.
// this way we can check if we are in/on the ground.
end.z -= 2.f;
// trace.
Ray_t ThreeRay;
ThreeRay.Init(start, end, record->mins, record->maxs);
// strip onground flag.
m_trace()->TraceRay(ThreeRay, CONTENTS_SOLID, &filter, &trace);
record->flags &= ~FL_ONGROUND;
// add back onground flag if we are onground.
if (trace.fraction != 1.f && trace.plane.normal.z > 0.7f)
record->flags != FL_ONGROUND;
}
void aim::prepare_targets()
{
for (auto i = 1; i <= m_globals()->m_maxclients; i++)
{
auto e = (player_t*)m_entitylist()->GetClientEntity(i);
if (!e->valid(true, false))
continue;
auto records = &player_records[i]; //-V826
if (!g_cfg.ragebot.anti_exploit)
{
if (e->m_flSimulationTime() < e->m_flOldSimulationTime())
continue;
}
if (records->empty())
continue;
auto record = records->at(0);
record.break_lagcomp = false;
if (records->size() > 1 && ((record.origin - records->at(1).origin).LengthSqr() > 4096.f
|| records->size() > 2 && (records->at(1).origin - records->at(2).origin).LengthSqr() > 4096.f))
{
record.break_lagcomp = true;
}
if (record.break_lagcomp)
{
PlayerMove(&record);
e->m_vecVelocity() = record.velocity;
e->m_vecOrigin() = record.origin;
e->set_abs_origin(record.origin);
e->m_vecMins() = record.mins;
e->m_vecMaxs() = record.maxs;
if (record.flags & FL_ONGROUND)
e->m_fFlags() |= FL_ONGROUND;
else
e->m_fFlags() &= ~FL_ONGROUND;
}
for (auto index = 0; index < records->size(); index++)
{
const auto& cur_record = records->at(index);
if (index == 0) {
if (record.break_lagcomp || (cur_record.origin - record.origin).LengthSqr() > 4096.f)
{
if (record.player) {
PlayerMove(&record);
e->m_vecVelocity() = record.velocity;
e->m_vecOrigin() = record.origin;
e->set_abs_origin(record.origin);
e->m_vecMins() = record.mins;
e->m_vecMaxs() = record.maxs;
if (record.flags & FL_ONGROUND)
e->m_fFlags() |= FL_ONGROUND;
else
e->m_fFlags() &= ~FL_ONGROUND;
}
else {
record.reset();
}
}
}
}
targets.emplace_back(target(e, get_record(records, false), get_record(records, true)));
}
for (auto& target : targets)
backup.emplace_back(adjust_data(target.e));
}