Fix a trace crash and fix some aimbot prediction problems

This commit is contained in:
BenCat07 2021-08-14 18:44:16 +02:00
parent 285e22accb
commit 266f829ee2
3 changed files with 4 additions and 4 deletions

View File

@ -1199,7 +1199,7 @@ Vector PredictEntity(CachedEntity *entity, bool vischeck)
std::pair<Vector, Vector> tmp_result;
// Use prediction engine if user settings allow
if (engine_projpred)
tmp_result = ProjectilePrediction_Engine(entity, cd.hitbox, cur_proj_speed, cur_proj_grav, 0, cur_proj_start_vel);
tmp_result = ProjectilePrediction_Engine(entity, cd.hitbox, cur_proj_speed, cur_proj_grav, PlayerGravityMod(entity), cur_proj_start_vel);
else
tmp_result = ProjectilePrediction(entity, cd.hitbox, cur_proj_speed, cur_proj_grav, PlayerGravityMod(entity), cur_proj_start_vel);

View File

@ -468,7 +468,7 @@ Vector EnginePrediction(CachedEntity *entity, float time)
return result;
}
std::pair<Vector, Vector> ProjectilePrediction_Engine(CachedEntity *ent, int hb, float speed, float gravitymod, float entgmod, float proj_startvelocity)
std::pair<Vector, Vector> ProjectilePrediction_Engine(CachedEntity *ent, int hb, float speed, float gravity, float entgmod, float proj_startvelocity)
{
Vector origin = ent->m_vecOrigin();
Vector velocity = CE_VECTOR(ent, 0x14c);
@ -531,7 +531,7 @@ std::pair<Vector, Vector> ProjectilePrediction_Engine(CachedEntity *ent, int hb,
CE_VECTOR(ent, 0x14c) = velocity;
// Compensate for ping
// besttime += g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING) + cl_interp->GetFloat();
bestpos.z += (sv_gravity->GetFloat() / 2.0f * besttime * besttime * gravitymod);
bestpos.z += (sv_gravity->GetFloat() / 2.0f * besttime * besttime * gravity);
// S = at^2/2 ; t = sqrt(2S/a)*/
Vector result = bestpos + hitbox_offset;
Vector result_initialvel = result;

View File

@ -52,7 +52,7 @@ bool trace::FilterDefault::ShouldHitEntity(IHandleEntity *handle, int mask)
if (m_pSelf)
{
// If what we hit is an enemy it does not matter
if (entity && entity->entindex() != 0 && CE_VALID(ENTITY(entity->entindex())) && ENTITY(entity->entindex())->m_iTeam() == ENTITY(m_pSelf->entindex())->m_iTeam())
if (m_pSelf && entity && entity->entindex() != 0 && IDX_GOOD(entity->entindex()) && CE_VALID(ENTITY(entity->entindex())) && ENTITY(entity->entindex())->m_iTeam() == ENTITY(m_pSelf->entindex())->m_iTeam())
{
auto ent = ENTITY(m_pSelf->entindex());
if (CE_GOOD(ent) && ent->m_bAlivePlayer())