From a6bcd70c86b514fbaa4d2e5e96603b23ab9d756b Mon Sep 17 00:00:00 2001 From: Fesiug Date: Sun, 12 Nov 2023 06:52:30 -0500 Subject: [PATCH] Move vaulting into func for HUD, but buggy on Raid --- .../benny/gamemode/modules/player/cl_hud.lua | 52 ++++++++++++++----- .../gamemode/modules/player/sh_basic.lua | 1 + .../modules/player/sh_movement_advanced.lua | 41 ++++++++------- 3 files changed, 62 insertions(+), 32 deletions(-) diff --git a/gamemodes/benny/gamemode/modules/player/cl_hud.lua b/gamemodes/benny/gamemode/modules/player/cl_hud.lua index a274c63..deced2c 100644 --- a/gamemodes/benny/gamemode/modules/player/cl_hud.lua +++ b/gamemodes/benny/gamemode/modules/player/cl_hud.lua @@ -224,6 +224,10 @@ local mat_long_s = Material("benny/hud/xhair/long_s.png", "mips smooth") local spacer_long = 2 -- screenscaled local gap = 24 +local trash_vec, trash_ang = Vector(), Angle() +local vaultsave = false +local nextvaultrecheck = 0 + bucket_selected = bucket_selected or 1 item_selected = item_selected or 1 @@ -270,6 +274,41 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() render.SetScissorRect( 0, 0, 0, 0, false ) -- Disable after you are done end + do -- Vaulting + if nextvaultrecheck <= CurTime() then + local forback, leright = 0, 0 + forback = forback + (p:KeyDown( IN_FORWARD ) and 1 or 0) + forback = forback - (p:KeyDown( IN_BACK ) and 1 or 0) + leright = leright + (p:KeyDown( IN_MOVELEFT ) and 1 or 0) + leright = leright - (p:KeyDown( IN_MOVERIGHT ) and 1 or 0) + trash_vec.x = forback + trash_vec.y = leright + trash_vec.z = 0 + trash_ang.p = 0 + trash_ang.y = TPSOverride.y + trash_ang.z = 0 + trash_vec:Rotate( trash_ang ) + + vaultsave = VaultReady( p, p:GetPos(), p:EyeAngles(), trash_vec.x, trash_vec.y ) + nextvaultrecheck = CurTime() + (0.1) + end + + if vaultsave then + local tex = "[SPACE] VAULT OVER" + + surface.SetFont( "Benny_16" ) + local tox, toy = surface.GetTextSize( tex ) + local box, boy = ss( 8 ) + tox, ss( 18 ) + surface.SetDrawColor( scheme["bg"] ) + surface.DrawRect( sw/2 - box/2, sh/2 + ss( 96 ) - boy/2 - ss( 2 ), box, boy ) + + surface.SetTextColor( scheme["fg"] ) + surface.SetTextPos( sw/2 - tox/2, sh/2 + ss( 96 ) - toy/2 ) + surface.DrawText( tex ) + + end + end + do -- Weapon if !(IsValid(wep) and wep:GetClass() == "benny") then print( "Failed to retrieve 'benny' weapon!" ) @@ -556,19 +595,6 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() surface.DrawTexturedRectRotated( poosx, poosy + gap, s(24), s(24), 0 ) end end - - local mow = math.Round( CurTime() % 2 ) - local tex = mow == 0 and "NO AMMO" or mow == 1 and "LOW AMMO" or mow == 2 and "[R] RELOAD" - - surface.SetFont( "Benny_16" ) - local tox, toy = surface.GetTextSize( tex ) - local box, boy = ss( 8 ) + tox, ss( 18 ) - surface.SetDrawColor( scheme["bg"] ) - -- surface.DrawRect( ps_x - box/2, ps_y + ss( 96 ) - boy/2 - ss( 2 ), box, boy ) - - surface.SetTextColor( scheme["fg"] ) - surface.SetTextPos( ps_x - tox/2, ps_y + ss( 96 ) - toy/2 ) - -- surface.DrawText( tex ) end end diff --git a/gamemodes/benny/gamemode/modules/player/sh_basic.lua b/gamemodes/benny/gamemode/modules/player/sh_basic.lua index e816fb8..7c0c98b 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_basic.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_basic.lua @@ -13,6 +13,7 @@ function GM:PlayerSpawn( ply ) ply:SetSlowWalkSpeed( 100 ) ply:SetWalkSpeed( 160 ) ply:SetRunSpeed( 220 ) + ply:SetStepSize( 8 ) end if SERVER then diff --git a/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua b/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua index a515126..2229dd4 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua @@ -16,17 +16,11 @@ 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() +function VaultReady( ply, pos, ang, forw, side ) + local wantdir = Vector( forw, -side, 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, @@ -36,21 +30,30 @@ hook.Add( "Move", "Benny_Move", function( ply, mv ) filter = ply } ) - for i=1, 2 do - debugoverlay.Box( ts, smale, small, 0, tB ) - debugoverlay.Box( te, smale, small, 0, tB ) - end + return (ply:GetVaultDebuff() == 0 and tr.Hit and tr.StartSolid and !tr.AllSolid and tr.FractionLeftSolid>0) and tr, ts, te or false +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 ) +hook.Add( "SetupMove", "Benny_SetupMove", function( ply, mv, cmd ) + if !ply:OnGround() and mv:KeyDown( IN_DUCK ) then + local newbuttons = bit.band(mv:GetButtons(), bit.bnot(IN_DUCK)) + mv:SetButtons(newbuttons) end +end) + +hook.Add( "Move", "Benny_Move", function( ply, mv ) + local ang = mv:GetMoveAngles() + local pos = mv:GetOrigin() + local vel = mv:GetVelocity() local speed = mv:GetMaxSpeed() * (1-ply:GetVaultDebuff()) mv:SetMaxSpeed( speed ) mv:SetMaxClientSpeed( speed ) + + local vault, v2, v3 = VaultReady( ply, pos, ang, mv:GetForwardSpeed(), mv:GetSideSpeed() ) + if mv:KeyDown( IN_JUMP ) and vault then + local epic = LerpVector( vault.FractionLeftSolid, v2, v3 ) + mv:SetOrigin( epic + Vector(0, 0, 1/16) ) + mv:SetVelocity( Vector( 0, 0, -100 ) ) + ply:SetVaultDebuff( 1 ) + end end) \ No newline at end of file