From 012a8472fe18caa1f1f5123c98e2a82594c5e48d Mon Sep 17 00:00:00 2001 From: Fesiug Date: Tue, 14 Nov 2023 22:34:58 -0500 Subject: [PATCH] Something for thin ledges (but I don't like them) --- .../modules/player/sh_movement_advanced.lua | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua b/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua index 212f9e0..98f61b1 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua @@ -22,20 +22,27 @@ function VaultReady( ply, pos, ang, forw, side ) if ply:NoclippingAndNotVaulting() then return false end local wantdir = Vector( forw, -side, 0 ):GetNormalized() wantdir:Rotate( Angle( 0, ang.y, 0 ) ) - local cum = pos + wantdir*16 - local ts, te = cum + Vector( 0, 0, 22 ), cum + Vector( 0, 0, 65 ) - local bottom, top = ply:GetHull() - if ply:Crouching() then bottom, top = ply:GetHullDuck() end - local tr = util.TraceHull( { - start = ts, - endpos = te, - mins = bottom, - maxs = top, - filter = ply, - } ) + for i=1, 2 do + local cum = pos + wantdir*(((2-i)/2)*14) - return (ply:GetVaultDebuff() == 0 and tr.Hit and tr.StartSolid and !tr.AllSolid and tr.FractionLeftSolid>0) and tr, ts, te or false + local ts, te = cum + Vector( 0, 0, 22 ), cum + Vector( 0, 0, 65 ) + local bottom, top = ply:GetHull() + if ply:Crouching() then bottom, top = ply:GetHullDuck() end + local tr = util.TraceHull( { + start = ts, + endpos = te, + mins = bottom, + maxs = top, + filter = ply, + } ) + local accept = (ply:GetVaultDebuff() == 0 and tr.Hit and tr.StartSolid and !tr.AllSolid and tr.FractionLeftSolid>0) + if accept then + return tr, ts, te + end + end + + return false end hook.Add( "SetupMove", "Benny_SetupMove", function( ply, mv, cmd )