5 Commits
Author SHA1 Message Date
Legonzaur 125296a37e Merge pull request #7 from DBmaoha/rewind-stuck-fix
Fix player stuck in places they can't stand up
2023-02-27 17:03:37 +01:00
DBmaoha a8941335f9 Update mp_ability_holopilot.nut 2022-12-16 21:37:59 +08:00
Legonzaur 552078bb29 Update mod.json 2022-08-01 14:55:59 +02:00
Legonzaur 33be9bf439 Merge pull request #5 from fvnkhead/main
Attempt negative charge count fix
2022-08-01 14:53:56 +02:00
fvnkhead f0ebe74408 Attempt negative charge count fix 2022-07-27 06:53:53 +00:00
3 changed files with 42 additions and 12 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"Name": "Legonzaur.HoloShift", "Name": "Legonzaur.HoloShift",
"Description": "Swap positions with your beloved decoy", "Description": "Swap positions with your beloved decoy",
"Version": "1.0.7", "Version": "1.0.8",
"LoadPriority": 2, "LoadPriority": 2,
"Scripts": [ "Scripts": [
{ {
@@ -33,6 +33,7 @@ bool IsLaunched = false
if(!player.IsPhaseShifted()){ if(!player.IsPhaseShifted()){
if(player in playerDecoyActiveFrom){ if(player in playerDecoyActiveFrom){
float chargeCount = float(player.GetOffhandWeapon(1).GetWeaponPrimaryClipCountMax()) - ((Time() - playerDecoyActiveFrom[player])*rechargeMultiplier) float chargeCount = float(player.GetOffhandWeapon(1).GetWeaponPrimaryClipCountMax()) - ((Time() - playerDecoyActiveFrom[player])*rechargeMultiplier)
chargeCount = max(chargeCount, 0.0) // can be negative in weird cases
player.GetOffhandWeapon(1).SetWeaponPrimaryClipCount(int(chargeCount)) player.GetOffhandWeapon(1).SetWeaponPrimaryClipCount(int(chargeCount))
} }
} }
@@ -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