Merge pull request #7 from DBmaoha/rewind-stuck-fix

Fix player stuck in places they can't stand up
This commit is contained in:
Legonzaur
2023-02-27 17:03:37 +01:00
committed by GitHub
@@ -428,18 +428,36 @@ void function PlayerUsesHoloRewindThreaded( entity player, entity decoy )
entity mover = CreateScriptMover( player.GetOrigin(), player.GetAngles() ) entity mover = CreateScriptMover( player.GetOrigin(), player.GetAngles() )
player.SetParent( mover, "REF" ) player.SetParent( mover, "REF" )
OnThreadEnd( function() : ( player, mover, decoy ) table decoyData = {}
decoyData.forceCrouch <- TraceLine
( decoy.GetOrigin(),
decoy.GetOrigin() + < 0,0,80 >, // 40 is crouched pilot height! add additional 40 for better check
[ decoy ],
TRACE_MASK_SHOT,
TRACE_COLLISION_GROUP_NONE
).hitEnt != null // decoy will stuck, need to forceCrouch player
OnThreadEnd( function() : ( player, mover, decoy, decoyData )
{ {
player.SetOrigin(decoy.GetOrigin()) if ( IsValid( player ) )
player.SetAngles(decoy.GetAngles()) {
player.SetVelocity(decoy.GetVelocity()) player.SetOrigin(decoy.GetOrigin())
CancelPhaseShift( player ) player.SetAngles(decoy.GetAngles())
player.DeployWeapon() player.SetVelocity(decoy.GetVelocity())
player.SetPredictionEnabled( true ) CancelPhaseShift( player )
player.ClearParent() player.DeployWeapon()
ViewConeFree( player ) player.SetPredictionEnabled( true )
mover.Destroy() player.ClearParent()
CleanupExistingDecoy(decoy) ViewConeFree( player )
if( decoyData.forceCrouch )
thread HoloRewindForceCrouch( player ) // this will handle "UnforceCrouch()"
}
if ( IsValid( mover ) )
mover.Destroy()
if ( IsValid( decoy ) )
CleanupExistingDecoy(decoy)
}) })
vector initial_origin = player.GetOrigin() vector initial_origin = player.GetOrigin()
@@ -449,6 +467,8 @@ void function PlayerUsesHoloRewindThreaded( entity player, entity decoy )
ViewConeZero( player ) ViewConeZero( player )
player.HolsterWeapon() player.HolsterWeapon()
player.SetPredictionEnabled( false ) player.SetPredictionEnabled( false )
if( decoyData.forceCrouch )
player.ForceCrouch() // avoid stucking!
PhaseShift( player, 0.0, 7 * PHASE_REWIND_PATH_SNAPSHOT_INTERVAL * 1.5 ) PhaseShift( player, 0.0, 7 * PHASE_REWIND_PATH_SNAPSHOT_INTERVAL * 1.5 )
for ( float i = 7; i > 0; i-- ) for ( float i = 7; i > 0; i-- )
@@ -464,4 +484,13 @@ void function PlayerUsesHoloRewindThreaded( entity player, entity decoy )
mover.NonPhysicsRotateTo( decoy.GetAngles(), PHASE_REWIND_PATH_SNAPSHOT_INTERVAL, 0, 0 ) mover.NonPhysicsRotateTo( decoy.GetAngles(), PHASE_REWIND_PATH_SNAPSHOT_INTERVAL, 0, 0 )
player.SetVelocity( decoy.GetVelocity() ) player.SetVelocity( decoy.GetVelocity() )
} }
void function HoloRewindForceCrouch( entity player )
{
// make player crouch
player.ForceCrouch()
wait 0.2 // magic number, player must be completely crouched to avoid auto-stand
if( IsValid( player ) )
player.UnforceCrouch()
}
#endif #endif