diff --git a/gamemodes/benny/gamemode/modules/player/cl_hud.lua b/gamemodes/benny/gamemode/modules/player/cl_hud.lua index c9768bc..81576a9 100644 --- a/gamemodes/benny/gamemode/modules/player/cl_hud.lua +++ b/gamemodes/benny/gamemode/modules/player/cl_hud.lua @@ -273,6 +273,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() do -- Vaulting if vaultsave then local tex = "[SPACE] VAULT OVER" + if vaultsave == 2 then tex = "[SPACE] MANTLE OVER" end surface.SetFont( "Benny_16" ) local tox, toy = surface.GetTextSize( tex ) @@ -440,8 +441,11 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() local item_gap_sel = ss(36+2) local inventorylist = p:INV_Buckets() - local bump = 0 + + -- PROTO: Maybe check this every 10hz instead + + for i, bucket in ipairs( inventorylist ) do surface.SetDrawColor( scheme["bg"] ) surface.DrawRect( bump + b, b, size_num, size_num ) diff --git a/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua b/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua index 98f61b1..b5dce43 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua @@ -4,8 +4,9 @@ local smale = -small local moe = Vector( 0, 0, 1/16 ) -local dmaxs = Vector( 16, 16, 48 ) -local dmins = Vector( -16, -16, 0 ) +local dmaxs = Vector( 1, 1, 1 ) +local dmins = -dmaxs +local dcol = Color( 255, 0, 255, 0 ) local dW = Color( 255, 255, 255, 0 ) local dB = Color( 0, 0, 0, 0 ) @@ -18,33 +19,6 @@ hook.Add( "PlayerTick", "Benny_PlayerTick", function( ply, mv ) end end) -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 ) ) - - for i=1, 2 do - local cum = pos + wantdir*(((2-i)/2)*14) - - 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 ) if !ply:OnGround() and mv:KeyDown( IN_DUCK ) then local newbuttons = bit.band(mv:GetButtons(), bit.bnot(IN_DUCK)) @@ -52,48 +26,105 @@ hook.Add( "SetupMove", "Benny_SetupMove", function( ply, mv, cmd ) end end) +local function Vault_GetAngle( ply, pos, ang, vel ) + return true +end + +local VAULTCHECKDIST = 16 +local VAULTMOVEDIST = 16 +local MAXVAULTHEIGHT = 66 +local MAXVAULTHEIGHT_V = Vector( 0, 0, MAXVAULTHEIGHT ) + 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 forw, side = mv:GetForwardSpeed(), mv:GetSideSpeed() + local ba, bb = ply:GetHull() + if ply:Crouching() then ba, bb = ply:GetHullDuck() end + + local WishDir = Vector( forw, -side, 0 ):GetNormalized() + WishDir:Rotate( Angle( 0, ang.y, 0 ) ) + + local Target = Vector( pos ) + local TargetNor = Vector() + + if !WishDir:IsZero() then + TargetNor:Set( WishDir ) + elseif vel:Length2D() > 100 then + local NoZ = Vector( vel ) + NoZ.z = 0 + NoZ:Normalize() + TargetNor:Set( NoZ ) + else + local NoUp = Angle( ang ) + NoUp.p = 0 + TargetNor = NoUp:Forward() + end + + local CR = HSVToColor( math.Rand( 0, 360 ), 1, 1 ) + CR.a = 8 + --debugoverlay.Box( Target, ba, bb, 0, CR ) + + local Checker = Target + TargetNor*VAULTCHECKDIST + local Desire = Target + TargetNor*VAULTMOVEDIST + local T1 = util.TraceHull( { + start = Target, + endpos = Checker, + mins = ba, + maxs = bb, + filter = ply, + } ) + debugoverlay.Line( T1.StartPos, T1.HitPos, 0, T1.Hit and CR or color_white ) - local vault, v2, v3 = VaultReady( ply, pos, ang, mv:GetForwardSpeed(), mv:GetSideSpeed() ) if CLIENT then vaultsave = false end - if vault then - local epic = LerpVector( vault.FractionLeftSolid, v2, v3 ) - epic:Add( moe ) - - local bottom, top = ply:GetHull() - if ply:Crouching() then bottom, top = ply:GetHullDuck() end - local tr = util.TraceHull( { - start = epic, - endpos = epic, - mins = bottom, - maxs = top, + if T1.Hit then -- A challenger approaches + + -- How tall is it, basically? We still need to do a ledge check + local T2 = util.TraceHull( { + start = Desire + MAXVAULTHEIGHT_V, + endpos = Desire, + mins = ba, + maxs = bb, filter = ply, } ) - if !tr.AllSolid then - if CLIENT then vaultsave = true end - if mv:KeyDown( IN_JUMP ) then - ply:SetVaultPos1( pos ) - ply:SetVaultPos2( epic ) - ply:SetVaultTransition( 1 ) - -- mv:SetOrigin( epic ) - -- mv:SetVelocity( Vector( 0, 0, 0 ) ) - ply:SetVaultDebuff( 1 ) + -- debugoverlay.Box( T2.HitPos, ba, bb, 0, CR ) + + -- Let's check our vertical clearance + local Clearance = Vector( Target.x, Target.y, T2.HitPos.z ) + local T3 = util.TraceHull( { + start = Target, + endpos = Clearance, + mins = ba, + maxs = bb, + filter = ply, + } ) + -- debugoverlay.SweptBox( T3.StartPos, T3.HitPos, ba, bb, angle_zero, 0, CR ) + local VertClearance = T3.HitPos.z - T3.StartPos.z + + -- If we try to go so high and it's TOO high then give up + if VertClearance != MAXVAULTHEIGHT then + -- Trace from clearance to final + local T4 = util.TraceHull( { + start = T3.HitPos, + endpos = T2.HitPos, + mins = ba, + maxs = bb, + filter = ply, + } ) + -- debugoverlay.SweptBox( T4.StartPos, T4.HitPos, ba, bb, angle_zero, 0, CR ) + + local Compare1, Compare2 = Vector( Target.x, Target.y, 0 ), Vector( T4.HitPos.x, T4.HitPos.y, 0 ) + if !Compare1:IsEqualTol( Compare2, 1/16 ) then + if CLIENT then vaultsave = true end + + if mv:KeyDown( IN_JUMP ) then + mv:SetOrigin( T4.HitPos ) + return true + 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 + --debugoverlay.Box( Target+(TargetNor*16), ba, bb, 0, CR ) end) \ No newline at end of file