Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7 from DBmaoha/rewind-stuck-fix
Browse files Browse the repository at this point in the history
Fix player stuck in places they can't stand up
  • Loading branch information
Legonzaur authored Feb 27, 2023
2 parents 552078b + a894133 commit 125296a
Showing 1 changed file with 40 additions and 11 deletions.
51 changes: 40 additions & 11 deletions mod/scripts/vscripts/weapons/mp_ability_holopilot.nut
Original file line number Diff line number Diff line change
Expand Up @@ -428,18 +428,36 @@ void function PlayerUsesHoloRewindThreaded( entity player, entity decoy )
entity mover = CreateScriptMover( player.GetOrigin(), player.GetAngles() )
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())
player.SetAngles(decoy.GetAngles())
player.SetVelocity(decoy.GetVelocity())
CancelPhaseShift( player )
player.DeployWeapon()
player.SetPredictionEnabled( true )
player.ClearParent()
ViewConeFree( player )
mover.Destroy()
CleanupExistingDecoy(decoy)
if ( IsValid( player ) )
{
player.SetOrigin(decoy.GetOrigin())
player.SetAngles(decoy.GetAngles())
player.SetVelocity(decoy.GetVelocity())
CancelPhaseShift( player )
player.DeployWeapon()
player.SetPredictionEnabled( true )
player.ClearParent()
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()
Expand All @@ -449,6 +467,8 @@ void function PlayerUsesHoloRewindThreaded( entity player, entity decoy )
ViewConeZero( player )
player.HolsterWeapon()
player.SetPredictionEnabled( false )
if( decoyData.forceCrouch )
player.ForceCrouch() // avoid stucking!
PhaseShift( player, 0.0, 7 * PHASE_REWIND_PATH_SNAPSHOT_INTERVAL * 1.5 )

for ( float i = 7; i > 0; i-- )
Expand All @@ -464,4 +484,13 @@ void function PlayerUsesHoloRewindThreaded( entity player, entity decoy )
mover.NonPhysicsRotateTo( decoy.GetAngles(), PHASE_REWIND_PATH_SNAPSHOT_INTERVAL, 0, 0 )
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

0 comments on commit 125296a

Please sign in to comment.