Compensate for ping, and fix speed/gravity issues on some projectiles
This commit is contained in:
parent
771e342db2
commit
2a7787e49e
@ -1171,11 +1171,18 @@ int BestHitbox(CachedEntity *target)
|
||||
headonly = false;
|
||||
// Rocket launcher
|
||||
}
|
||||
else if (ci == CL_CLASS(CTFRocketLauncher) || ci == CL_CLASS(CTFRocketLauncher_AirStrike) || ci == CL_CLASS(CTFRocketLauncher_DirectHit) || ci == CL_CLASS(CTFRocketLauncher_Mortar) || ci == CL_CLASS(CTFPipebombLauncher))
|
||||
// These weapons should aim at the foot if the target is grounded
|
||||
else if (ci == CL_CLASS(CTFRocketLauncher) || ci == CL_CLASS(CTFRocketLauncher_AirStrike) || ci == CL_CLASS(CTFRocketLauncher_Mortar))
|
||||
{
|
||||
preferred = hitbox_t::hip_L;
|
||||
preferred = hitbox_t::foot_L;
|
||||
}
|
||||
// Airborn projectile
|
||||
// These weapons should aim at the center of mass due to little/no splash
|
||||
else if (ci == CL_CLASS(CTFPipebombLauncher) || ci == CL_CLASS(CTFRocketLauncher_DirectHit) || ci == CL_CLASS(CTFGrenadeLauncher))
|
||||
{
|
||||
preferred = hitbox_t::spine_3;
|
||||
}
|
||||
|
||||
// Airborn targets should always get hit in center
|
||||
if (GetWeaponMode() == weaponmode::weapon_projectile)
|
||||
{
|
||||
if (g_pLocalPlayer->weapon()->m_iClassID() != CL_CLASS(CTFCompoundBow))
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "Ragdolls.hpp"
|
||||
|
||||
static settings::Boolean tcm{ "debug.tcm", "true" };
|
||||
static settings::Boolean should_correct_punch{ "debug.correct-punch", "true" };
|
||||
|
||||
std::vector<ConVar *> &RegisteredVarsList()
|
||||
{
|
||||
@ -1248,6 +1249,9 @@ bool GetProjectileData(CachedEntity *weapon, float &speed, float &gravity)
|
||||
case CL_CLASS(CTFRocketLauncher):
|
||||
{
|
||||
rspeed = 1100.0f;
|
||||
// Libery Launcher
|
||||
if (CE_INT(weapon, netvar.iItemDefinitionIndex) == 414)
|
||||
rspeed *= 1.4f;
|
||||
break;
|
||||
}
|
||||
case CL_CLASS(CTFCannon):
|
||||
@ -1257,31 +1261,32 @@ bool GetProjectileData(CachedEntity *weapon, float &speed, float &gravity)
|
||||
}
|
||||
case CL_CLASS(CTFGrenadeLauncher):
|
||||
{
|
||||
rspeed = 1200.0f;
|
||||
rgrav = 0.4f;
|
||||
IF_GAME(IsTF2())
|
||||
{
|
||||
rspeed = 1200.0f;
|
||||
rgrav = 0.4f;
|
||||
// Loch'n Load
|
||||
if (CE_INT(weapon, netvar.iItemDefinitionIndex) == 308)
|
||||
rspeed *= 1.25f;
|
||||
}
|
||||
else IF_GAME(IsTF2C())
|
||||
IF_GAME(IsTF2C())
|
||||
{
|
||||
rspeed = 1100.0f;
|
||||
rgrav = 0.5f;
|
||||
rgrav = 0.5f;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CL_CLASS(CTFPipebombLauncher):
|
||||
{
|
||||
float chargebegin = *((float *) ((uint64_t) RAW_ENT(LOCAL_W) + 3152));
|
||||
float chargetime = g_GlobalVars->curtime - chargebegin;
|
||||
rspeed = (fminf(fmaxf(chargetime / 4.0f, 0.0f), 1.0f) * 1500.0f) + 900.0f;
|
||||
rgrav = (fminf(fmaxf(chargetime / 4.0f, 0.0f), 1.0f) * -0.70000001f) + 0.5f;
|
||||
float chargetime = g_GlobalVars->curtime - CE_FLOAT(weapon, netvar.flChargeBeginTime);
|
||||
rspeed = RemapValClamped(chargetime, 0.0f, 4.0f, 900, 2400);
|
||||
rgrav = 0.4f;
|
||||
break;
|
||||
}
|
||||
case CL_CLASS(CTFCompoundBow):
|
||||
{
|
||||
float chargetime = g_GlobalVars->curtime - CE_FLOAT(weapon, netvar.flChargeBeginTime);
|
||||
rspeed = (float) ((float) (fminf(fmaxf(chargetime, 0.0), 1.0) * 800.0) + 1800.0);
|
||||
rgrav = (float) ((float) (fminf(fmaxf(chargetime, 0.0), 1.0) * -0.40000001) + 0.5);
|
||||
rspeed = RemapValClamped(chargetime, 0.0f, 1.f, 1800, 2600);
|
||||
rgrav = RemapValClamped(chargetime, 0.0f, 1.f, 0.5, 0.1);
|
||||
break;
|
||||
}
|
||||
case CL_CLASS(CTFBat_Giftwrap):
|
||||
@ -1449,7 +1454,7 @@ Vector GetForwardVector(Vector origin, Vector viewangles, float distance, Cached
|
||||
float sp, sy, cp, cy;
|
||||
QAngle angle = VectorToQAngle(viewangles);
|
||||
// Compensate for punch angle
|
||||
if (punch_entity)
|
||||
if (punch_entity && should_correct_punch)
|
||||
angle += VectorToQAngle(CE_VECTOR(punch_entity, netvar.vecPunchAngle));
|
||||
trace_t trace;
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <settings/Bool.hpp>
|
||||
|
||||
static settings::Boolean debug_pp_extrapolate{ "debug.pp-extrapolate", "false" };
|
||||
static settings::Boolean debug_pp_rockettimeping{ "debug.pp-rocket-time-ping", "false" };
|
||||
static settings::Boolean debug_pp_draw{ "debug.pp-draw", "false" };
|
||||
// TODO there is a Vector() object created each call.
|
||||
|
||||
@ -271,8 +270,8 @@ Vector ProjectilePrediction_Engine(CachedEntity *ent, int hb, float speed, float
|
||||
}
|
||||
|
||||
float rockettime = g_pLocalPlayer->v_Eye.DistTo(current) / speed;
|
||||
if (debug_pp_rockettimeping)
|
||||
rockettime += g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING);
|
||||
// Compensate for ping
|
||||
rockettime += g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING) + cl_interp->GetFloat();
|
||||
if (fabs(rockettime - currenttime) < mindelta)
|
||||
{
|
||||
besttime = currenttime;
|
||||
@ -282,8 +281,8 @@ Vector ProjectilePrediction_Engine(CachedEntity *ent, int hb, float speed, float
|
||||
}
|
||||
const_cast<Vector &>(RAW_ENT(ent)->GetAbsOrigin()) = origin;
|
||||
CE_VECTOR(ent, 0x354) = origin;
|
||||
if (debug_pp_rockettimeping)
|
||||
besttime += g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING);
|
||||
// Compensate for ping
|
||||
besttime += g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING) + cl_interp->GetFloat();
|
||||
bestpos.z += (400 * besttime * besttime * gravitymod);
|
||||
// S = at^2/2 ; t = sqrt(2S/a)*/
|
||||
Vector result = bestpos + hitbox_offset;
|
||||
@ -325,8 +324,8 @@ Vector BuildingPrediction(CachedEntity *building, Vector vec, float speed, float
|
||||
curpos.z = result.z - dtg;
|
||||
}
|
||||
float rockettime = g_pLocalPlayer->v_Eye.DistTo(curpos) / speed;
|
||||
if (debug_pp_rockettimeping)
|
||||
rockettime += g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING);
|
||||
// Compensate for ping
|
||||
rockettime += g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING) + cl_interp->GetFloat();
|
||||
if (fabs(rockettime - currenttime) < mindelta)
|
||||
{
|
||||
besttime = currenttime;
|
||||
@ -334,8 +333,8 @@ Vector BuildingPrediction(CachedEntity *building, Vector vec, float speed, float
|
||||
mindelta = fabs(rockettime - currenttime);
|
||||
}
|
||||
}
|
||||
if (debug_pp_rockettimeping)
|
||||
besttime += g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING);
|
||||
// Compensate for ping
|
||||
besttime += g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING) + cl_interp->GetFloat();
|
||||
bestpos.z += (400 * besttime * besttime * gravity);
|
||||
// S = at^2/2 ; t = sqrt(2S/a)*/
|
||||
return bestpos;
|
||||
@ -395,8 +394,8 @@ Vector ProjectilePrediction(CachedEntity *ent, int hb, float speed, float gravit
|
||||
}
|
||||
|
||||
float rockettime = g_pLocalPlayer->v_Eye.DistTo(current) / speed;
|
||||
if (debug_pp_rockettimeping)
|
||||
rockettime += g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING);
|
||||
// Compensate for ping
|
||||
rockettime += g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING) + cl_interp->GetFloat();
|
||||
if (fabs(rockettime - currenttime) < mindelta)
|
||||
{
|
||||
besttime = currenttime;
|
||||
@ -404,8 +403,8 @@ Vector ProjectilePrediction(CachedEntity *ent, int hb, float speed, float gravit
|
||||
mindelta = fabs(rockettime - currenttime);
|
||||
}
|
||||
}
|
||||
if (debug_pp_rockettimeping)
|
||||
besttime += g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING);
|
||||
// Compensate for ping
|
||||
besttime += g_IEngine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING) + cl_interp->GetFloat();
|
||||
bestpos.z += (sv_gravity->GetFloat() / 2.0f * besttime * besttime * gravitymod);
|
||||
// S = at^2/2 ; t = sqrt(2S/a)*/
|
||||
Vector result = bestpos + hitbox_offset;
|
||||
|
Reference in New Issue
Block a user