Vaulting is smoothed

This commit is contained in:
Fesiug 2023-11-14 02:45:34 -05:00
parent 787d9aacbd
commit 8e5eef9f52
5 changed files with 30 additions and 8 deletions

View File

@ -276,7 +276,7 @@ end
hook.Add( "CalcView", "Benny_CalcView", function( ply, pos, ang, fov ) hook.Add( "CalcView", "Benny_CalcView", function( ply, pos, ang, fov )
if c_unlock:GetBool() then return end if c_unlock:GetBool() then return end
if ply:GetMoveType() == MOVETYPE_NOCLIP then return end if ply:NoclippingAndNotVaulting() then return end
decide_active() decide_active()
local camera = BENNY_ACTIVECAMERA local camera = BENNY_ACTIVECAMERA
local view = {} local view = {}

View File

@ -11,7 +11,7 @@ TPSOverride = TPSOverride or Angle()
hook.Add( "PlayerNoClip", "Benny_PlayerNoClip", function( ply, desiredNoClipState ) hook.Add( "PlayerNoClip", "Benny_PlayerNoClip", function( ply, desiredNoClipState )
if CLIENT then if CLIENT then
if desiredNoClipState then if desiredNoClipState then
LocalPlayer():SetEyeAngles( TPSOverride ) ply:SetEyeAngles( TPSOverride )
else else
TPSOverride:Set( LocalPlayer():EyeAngles() ) TPSOverride:Set( LocalPlayer():EyeAngles() )
lastmoveangle = LocalPlayer():EyeAngles().y lastmoveangle = LocalPlayer():EyeAngles().y
@ -21,14 +21,14 @@ hook.Add( "PlayerNoClip", "Benny_PlayerNoClip", function( ply, desiredNoClipStat
end) end)
hook.Add( "InputMouseApply", "Benny_InputMouseApply", function( cmd, x, y, ang ) hook.Add( "InputMouseApply", "Benny_InputMouseApply", function( cmd, x, y, ang )
if LocalPlayer():BennyCheck() and LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then if LocalPlayer():BennyCheck() and !LocalPlayer():NoclippingAndNotVaulting() then
TPSOverride:Add( Angle( y*0.022, -x*0.022, 0 ) ) TPSOverride:Add( Angle( y*0.022, -x*0.022, 0 ) )
return true return true
end end
end) end)
hook.Add( "CreateMove", "Benny_CreateMove", function( cmd ) hook.Add( "CreateMove", "Benny_CreateMove", function( cmd )
if false and BENNY_ACTIVECAMERA and LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then if false and BENNY_ACTIVECAMERA and !LocalPlayer():NoclippingAndNotVaulting() then
local x, y = cmd:GetForwardMove(), cmd:GetSideMove() local x, y = cmd:GetForwardMove(), cmd:GetSideMove()
local lx=input.GetAnalogValue(ANALOG_JOY_X) // Left X Axis: left -, right + local lx=input.GetAnalogValue(ANALOG_JOY_X) // Left X Axis: left -, right +
@ -76,7 +76,7 @@ hook.Add( "CreateMove", "Benny_CreateMove", function( cmd )
local p = LocalPlayer() local p = LocalPlayer()
local w = p:GetActiveWeapon() local w = p:GetActiveWeapon()
if p:BennyCheck() and LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then -- FPS cam if p:BennyCheck() and !LocalPlayer():NoclippingAndNotVaulting() then -- FPS cam
local aimed = w:GetUserAim() local aimed = w:GetUserAim()
local opos, ang = p:CamSpot( TPSOverride ) local opos, ang = p:CamSpot( TPSOverride )

View File

@ -13,10 +13,13 @@ local dS = Color( 255, 0, 0, 0 )
local dC = Color( 0, 0, 255, 0 ) local dC = Color( 0, 0, 255, 0 )
hook.Add( "PlayerTick", "Benny_PlayerTick", function( ply, mv ) hook.Add( "PlayerTick", "Benny_PlayerTick", function( ply, mv )
ply:SetVaultDebuff( math.Clamp( ply:GetVaultDebuff() - FrameTime()/0.4 , 0, 1 ) ) if ply:GetVaultTransition() == 0 then
ply:SetVaultDebuff( math.Approach( ply:GetVaultDebuff(), 0, FrameTime()/0.4 ) )
end
end) end)
function VaultReady( ply, pos, ang, forw, side ) function VaultReady( ply, pos, ang, forw, side )
if ply:NoclippingAndNotVaulting() then return false end
local wantdir = Vector( forw, -side, 0 ):GetNormalized() local wantdir = Vector( forw, -side, 0 ):GetNormalized()
wantdir:Rotate( Angle( 0, ang.y, 0 ) ) wantdir:Rotate( Angle( 0, ang.y, 0 ) )
local cum = pos + wantdir*16 local cum = pos + wantdir*16
@ -69,10 +72,21 @@ hook.Add( "Move", "Benny_Move", function( ply, mv )
if !tr.AllSolid then if !tr.AllSolid then
if CLIENT then vaultsave = true end if CLIENT then vaultsave = true end
if mv:KeyDown( IN_JUMP ) then if mv:KeyDown( IN_JUMP ) then
mv:SetOrigin( epic ) ply:SetVaultPos1( pos )
mv:SetVelocity( Vector( 0, 0, 0 ) ) ply:SetVaultPos2( epic )
ply:SetVaultTransition( 1 )
-- mv:SetOrigin( epic )
-- mv:SetVelocity( Vector( 0, 0, 0 ) )
ply:SetVaultDebuff( 1 ) ply:SetVaultDebuff( 1 )
end end
end end
end end
if ply:GetVaultTransition() != 0 then
ply:SetVaultTransition( math.Approach( ply:GetVaultTransition(), 0, FrameTime()/0.3 ) )
mv:SetOrigin( LerpVector( math.ease.OutCirc( 1-ply:GetVaultTransition() ), ply:GetVaultPos1(), ply:GetVaultPos2() ) )
mv:SetVelocity( Vector( 0, 0, 0 ) )
ply:SetVaultDebuff( 1 )
ply:SetMoveType( (ply:GetVaultTransition() == 0) and MOVETYPE_WALK or MOVETYPE_NOCLIP )
return true
end
end) end)

View File

@ -34,6 +34,10 @@ function PT:CamSpot( ang )
return tr.HitPos, ang, 90 return tr.HitPos, ang, 90
end end
function PT:NoclippingAndNotVaulting()
return (self:GetMoveType() == MOVETYPE_NOCLIP and self:GetVaultTransition() == 0)
end
function PT:INV_Get() function PT:INV_Get()
if !self.INV then if !self.INV then
print( "Inventory created") print( "Inventory created")

View File

@ -25,6 +25,10 @@ PLAYER.UseVMHands = true
function PLAYER:SetupDataTables() function PLAYER:SetupDataTables()
self.Player:NetworkVar( "Bool", 0, "Shoulder" ) self.Player:NetworkVar( "Bool", 0, "Shoulder" )
self.Player:NetworkVar( "Float", 0, "VaultDebuff" ) self.Player:NetworkVar( "Float", 0, "VaultDebuff" )
self.Player:NetworkVar( "Float", 1, "VaultTransition" )
self.Player:NetworkVar( "Vector", 0, "VaultPos1")
self.Player:NetworkVar( "Vector", 1, "VaultPos2")
end end
player_manager.RegisterClass( "player_benny", PLAYER, "player_default" ) player_manager.RegisterClass( "player_benny", PLAYER, "player_default" )