mirror of
https://github.com/jason-e/rngfix.git
synced 2025-12-06 18:08:33 +00:00
Avoid a side-effect of TeleportEntity (fixes #2)
This commit is contained in:
parent
0e06cb0c81
commit
1c85683a7e
@ -6,7 +6,7 @@
|
||||
#pragma semicolon 1
|
||||
#pragma newdecls required
|
||||
|
||||
#define PLUGIN_VERSION "1.1.1"
|
||||
#define PLUGIN_VERSION "1.1.2"
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
@ -589,12 +589,19 @@ void ClipVelocity(const float velocity[3], const float nrm[3], float out[3])
|
||||
// The adjust step only matters with overbounce which doesnt apply to walkable surfaces.
|
||||
}
|
||||
|
||||
void SetVelocity(int client, float velocity[3])
|
||||
void SetVelocity(int client, float velocity[3], bool dontUseTeleportEntity = false)
|
||||
{
|
||||
// Pull out basevelocity from desired true velocity
|
||||
// Use the pre-tick basevelocity because that is what influenced this tick's movement and the desired new velocity.
|
||||
SubtractVectors(velocity, g_vLastBaseVelocity[client], velocity);
|
||||
|
||||
if (dontUseTeleportEntity && GetEntPropEnt(client, Prop_Data, "m_hMoveParent") == -1)
|
||||
{
|
||||
SetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", velocity);
|
||||
SetEntPropVector(client, Prop_Data, "m_vecVelocity", velocity);
|
||||
}
|
||||
else
|
||||
{
|
||||
float baseVelocity[3];
|
||||
GetEntPropVector(client, Prop_Data, "m_vecBaseVelocity", baseVelocity);
|
||||
|
||||
@ -604,6 +611,7 @@ void SetVelocity(int client, float velocity[3])
|
||||
// Since we didn't change position, nothing should change regarding influences on basevelocity.
|
||||
SetEntPropVector(client, Prop_Data, "m_vecBaseVelocity", baseVelocity);
|
||||
}
|
||||
}
|
||||
|
||||
public MRESReturn DHook_ProcessMovementPre(Handle hParams)
|
||||
{
|
||||
@ -1096,9 +1104,24 @@ bool DoTelehopFix(int client)
|
||||
// Don't forget to add the second half-tick of gravity ourselves.
|
||||
FinishGravity(client, newVelocity);
|
||||
|
||||
DebugMsg(client, "DO FIX: Telehop");
|
||||
float origin[3];
|
||||
GetEntPropVector(client, Prop_Data, "m_vecAbsOrigin", origin);
|
||||
|
||||
SetVelocity(client, newVelocity);
|
||||
float mins[3], maxs[3];
|
||||
GetEntPropVector(client, Prop_Data, "m_vecMins", mins);
|
||||
GetEntPropVector(client, Prop_Data, "m_vecMaxs", maxs);
|
||||
|
||||
TR_TraceHullFilter(origin, origin, mins, maxs, MASK_PLAYERSOLID, PlayerFilter);
|
||||
|
||||
// If we appear to be "stuck" after teleporting (likely because the teleport destination
|
||||
// was exactly on the ground), set velocity directly to avoid side-effects of
|
||||
// TeleportEntity that can cause the player to really get stuck in the ground.
|
||||
// This might only be an issue in CSS, but do it on CSGO too just to be safe.
|
||||
bool dontUseTeleportEntity = TR_DidHit();
|
||||
|
||||
DebugMsg(client, "DO FIX: Telehop%s", dontUseTeleportEntity ? " (no TeleportEntity)" : "");
|
||||
|
||||
SetVelocity(client, newVelocity, dontUseTeleportEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user