Merge pull request #7 from DBmaoha/rewind-stuck-fix
Fix player stuck in places they can't stand up
This commit is contained in:
@@ -428,7 +428,18 @@ 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 )
|
||||||
|
{
|
||||||
|
if ( IsValid( player ) )
|
||||||
{
|
{
|
||||||
player.SetOrigin(decoy.GetOrigin())
|
player.SetOrigin(decoy.GetOrigin())
|
||||||
player.SetAngles(decoy.GetAngles())
|
player.SetAngles(decoy.GetAngles())
|
||||||
@@ -438,7 +449,14 @@ void function PlayerUsesHoloRewindThreaded( entity player, entity decoy )
|
|||||||
player.SetPredictionEnabled( true )
|
player.SetPredictionEnabled( true )
|
||||||
player.ClearParent()
|
player.ClearParent()
|
||||||
ViewConeFree( player )
|
ViewConeFree( player )
|
||||||
|
if( decoyData.forceCrouch )
|
||||||
|
thread HoloRewindForceCrouch( player ) // this will handle "UnforceCrouch()"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( IsValid( mover ) )
|
||||||
mover.Destroy()
|
mover.Destroy()
|
||||||
|
|
||||||
|
if ( IsValid( decoy ) )
|
||||||
CleanupExistingDecoy(decoy)
|
CleanupExistingDecoy(decoy)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -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
|
||||||
Reference in New Issue
Block a user