From 988edfda8ada9a8c230d88ef29cd3d4bb23b461b Mon Sep 17 00:00:00 2001 From: Fesiug Date: Sun, 12 Nov 2023 06:10:03 -0500 Subject: [PATCH] Vaulting!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --- .../modules/player/sh_movement_advanced.lua | 56 +++++++++++++++++++ .../modules/player/sh_player_class.lua | 1 + 2 files changed, 57 insertions(+) create mode 100644 gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua diff --git a/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua b/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua new file mode 100644 index 0000000..a515126 --- /dev/null +++ b/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua @@ -0,0 +1,56 @@ + +local small = Vector( 1, 1, 1 ) +local smale = -small + +local moe = Vector( 0, 0, 8 ) + +local dmaxs = Vector( 16, 16, 48 ) +local dmins = Vector( -16, -16, 0 ) + +local dW = Color( 255, 255, 255, 0 ) +local dB = Color( 0, 0, 0, 0 ) +local dS = Color( 255, 0, 0, 0 ) +local dC = Color( 0, 0, 255, 0 ) + +hook.Add( "PlayerTick", "Benny_PlayerTick", function( ply, mv ) + ply:SetVaultDebuff( math.Clamp( ply:GetVaultDebuff() - FrameTime()/0.4 , 0, 1 ) ) +end) + +hook.Add( "Move", "Benny_Move", function( ply, mv ) + local ang = mv:GetMoveAngles() + local pos = mv:GetOrigin() + local vel = mv:GetVelocity() + + local wantdir = Vector( mv:GetForwardSpeed(), -mv:GetSideSpeed(), 0 ):GetNormalized() + wantdir:Rotate( Angle( 0, ang.y, 0 ) ) + local cum = pos + wantdir*8 + + debugoverlay.Box( cum + (SERVER and vector_up*0.1 or vector_origin), dmins, dmaxs, 0, SERVER and dS or dC ) + + local ts, te = cum + Vector( 0, 0, 24 ), cum + Vector( 0, 0, 65 ) + local tr = util.TraceHull( { + start = ts, + endpos = te, + mins = dmins, + maxs = dmaxs, + filter = ply + } ) + + for i=1, 2 do + debugoverlay.Box( ts, smale, small, 0, tB ) + debugoverlay.Box( te, smale, small, 0, tB ) + end + + if mv:KeyPressed( IN_JUMP ) and ply:GetVaultDebuff() == 0 and tr.Hit and tr.StartSolid and !tr.AllSolid and tr.FractionLeftSolid>0 then + print( CurTime(), "Moved!" ) + local epic = LerpVector( tr.FractionLeftSolid, ts, te ) + debugoverlay.Box( epic, smale, small, 0, SERVER and dS or dC ) + mv:SetOrigin( epic + Vector(0, 0, 1/16) ) + mv:SetVelocity( vector_origin ) + ply:SetVaultDebuff( 1 ) + end + + local speed = mv:GetMaxSpeed() * (1-ply:GetVaultDebuff()) + mv:SetMaxSpeed( speed ) + mv:SetMaxClientSpeed( speed ) +end) \ No newline at end of file diff --git a/gamemodes/benny/gamemode/modules/player/sh_player_class.lua b/gamemodes/benny/gamemode/modules/player/sh_player_class.lua index 14d39be..67bb180 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_player_class.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_player_class.lua @@ -24,6 +24,7 @@ PLAYER.UseVMHands = true function PLAYER:SetupDataTables() self.Player:NetworkVar( "Bool", 0, "Shoulder" ) + self.Player:NetworkVar( "Float", 0, "VaultDebuff" ) end player_manager.RegisterClass( "player_benny", PLAYER, "player_default" )