Fucking infinitely better rewrite of vaulting
This commit is contained in:
parent
6d2fdf2191
commit
d741067f44
|
@ -273,6 +273,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
do -- Vaulting
|
do -- Vaulting
|
||||||
if vaultsave then
|
if vaultsave then
|
||||||
local tex = "[SPACE] VAULT OVER"
|
local tex = "[SPACE] VAULT OVER"
|
||||||
|
if vaultsave == 2 then tex = "[SPACE] MANTLE OVER" end
|
||||||
|
|
||||||
surface.SetFont( "Benny_16" )
|
surface.SetFont( "Benny_16" )
|
||||||
local tox, toy = surface.GetTextSize( tex )
|
local tox, toy = surface.GetTextSize( tex )
|
||||||
|
@ -440,8 +441,11 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
local item_gap_sel = ss(36+2)
|
local item_gap_sel = ss(36+2)
|
||||||
|
|
||||||
local inventorylist = p:INV_Buckets()
|
local inventorylist = p:INV_Buckets()
|
||||||
|
|
||||||
local bump = 0
|
local bump = 0
|
||||||
|
|
||||||
|
-- PROTO: Maybe check this every 10hz instead
|
||||||
|
|
||||||
|
|
||||||
for i, bucket in ipairs( inventorylist ) do
|
for i, bucket in ipairs( inventorylist ) do
|
||||||
surface.SetDrawColor( scheme["bg"] )
|
surface.SetDrawColor( scheme["bg"] )
|
||||||
surface.DrawRect( bump + b, b, size_num, size_num )
|
surface.DrawRect( bump + b, b, size_num, size_num )
|
||||||
|
|
|
@ -4,8 +4,9 @@ local smale = -small
|
||||||
|
|
||||||
local moe = Vector( 0, 0, 1/16 )
|
local moe = Vector( 0, 0, 1/16 )
|
||||||
|
|
||||||
local dmaxs = Vector( 16, 16, 48 )
|
local dmaxs = Vector( 1, 1, 1 )
|
||||||
local dmins = Vector( -16, -16, 0 )
|
local dmins = -dmaxs
|
||||||
|
local dcol = Color( 255, 0, 255, 0 )
|
||||||
|
|
||||||
local dW = Color( 255, 255, 255, 0 )
|
local dW = Color( 255, 255, 255, 0 )
|
||||||
local dB = Color( 0, 0, 0, 0 )
|
local dB = Color( 0, 0, 0, 0 )
|
||||||
|
@ -18,33 +19,6 @@ hook.Add( "PlayerTick", "Benny_PlayerTick", function( ply, mv )
|
||||||
end
|
end
|
||||||
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 )
|
hook.Add( "SetupMove", "Benny_SetupMove", function( ply, mv, cmd )
|
||||||
if !ply:OnGround() and mv:KeyDown( IN_DUCK ) then
|
if !ply:OnGround() and mv:KeyDown( IN_DUCK ) then
|
||||||
local newbuttons = bit.band(mv:GetButtons(), bit.bnot(IN_DUCK))
|
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
|
||||||
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 )
|
hook.Add( "Move", "Benny_Move", function( ply, mv )
|
||||||
local ang = mv:GetMoveAngles()
|
local ang = mv:GetMoveAngles()
|
||||||
local pos = mv:GetOrigin()
|
local pos = mv:GetOrigin()
|
||||||
local vel = mv:GetVelocity()
|
local vel = mv:GetVelocity()
|
||||||
|
|
||||||
local speed = mv:GetMaxSpeed() * (1-ply:GetVaultDebuff())
|
local forw, side = mv:GetForwardSpeed(), mv:GetSideSpeed()
|
||||||
mv:SetMaxSpeed( speed )
|
local ba, bb = ply:GetHull()
|
||||||
mv:SetMaxClientSpeed( speed )
|
if ply:Crouching() then ba, bb = ply:GetHullDuck() end
|
||||||
|
|
||||||
local vault, v2, v3 = VaultReady( ply, pos, ang, mv:GetForwardSpeed(), mv:GetSideSpeed() )
|
local WishDir = Vector( forw, -side, 0 ):GetNormalized()
|
||||||
if CLIENT then vaultsave = false end
|
WishDir:Rotate( Angle( 0, ang.y, 0 ) )
|
||||||
if vault then
|
|
||||||
local epic = LerpVector( vault.FractionLeftSolid, v2, v3 )
|
|
||||||
epic:Add( moe )
|
|
||||||
|
|
||||||
local bottom, top = ply:GetHull()
|
local Target = Vector( pos )
|
||||||
if ply:Crouching() then bottom, top = ply:GetHullDuck() end
|
local TargetNor = Vector()
|
||||||
local tr = util.TraceHull( {
|
|
||||||
start = epic,
|
if !WishDir:IsZero() then
|
||||||
endpos = epic,
|
TargetNor:Set( WishDir )
|
||||||
mins = bottom,
|
elseif vel:Length2D() > 100 then
|
||||||
maxs = top,
|
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,
|
filter = ply,
|
||||||
} )
|
} )
|
||||||
if !tr.AllSolid then
|
debugoverlay.Line( T1.StartPos, T1.HitPos, 0, T1.Hit and CR or color_white )
|
||||||
|
|
||||||
|
if CLIENT then vaultsave = false end
|
||||||
|
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,
|
||||||
|
} )
|
||||||
|
-- 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 CLIENT then vaultsave = true end
|
||||||
|
|
||||||
if mv:KeyDown( IN_JUMP ) then
|
if mv:KeyDown( IN_JUMP ) then
|
||||||
ply:SetVaultPos1( pos )
|
mv:SetOrigin( T4.HitPos )
|
||||||
ply:SetVaultPos2( epic )
|
|
||||||
ply:SetVaultTransition( 1 )
|
|
||||||
-- mv:SetOrigin( epic )
|
|
||||||
-- mv:SetVelocity( Vector( 0, 0, 0 ) )
|
|
||||||
ply:SetVaultDebuff( 1 )
|
|
||||||
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
|
return true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--debugoverlay.Box( Target+(TargetNor*16), ba, bb, 0, CR )
|
||||||
end)
|
end)
|
Loading…
Reference in New Issue