Move vaulting into func for HUD, but buggy on Raid

This commit is contained in:
Fesiug 2023-11-12 06:52:30 -05:00
parent 120d6e3550
commit a6bcd70c86
3 changed files with 62 additions and 32 deletions

View File

@ -224,6 +224,10 @@ local mat_long_s = Material("benny/hud/xhair/long_s.png", "mips smooth")
local spacer_long = 2 -- screenscaled local spacer_long = 2 -- screenscaled
local gap = 24 local gap = 24
local trash_vec, trash_ang = Vector(), Angle()
local vaultsave = false
local nextvaultrecheck = 0
bucket_selected = bucket_selected or 1 bucket_selected = bucket_selected or 1
item_selected = item_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 render.SetScissorRect( 0, 0, 0, 0, false ) -- Disable after you are done
end 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 do -- Weapon
if !(IsValid(wep) and wep:GetClass() == "benny") then if !(IsValid(wep) and wep:GetClass() == "benny") then
print( "Failed to retrieve 'benny' weapon!" ) 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 ) surface.DrawTexturedRectRotated( poosx, poosy + gap, s(24), s(24), 0 )
end end
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
end end

View File

@ -13,6 +13,7 @@ function GM:PlayerSpawn( ply )
ply:SetSlowWalkSpeed( 100 ) ply:SetSlowWalkSpeed( 100 )
ply:SetWalkSpeed( 160 ) ply:SetWalkSpeed( 160 )
ply:SetRunSpeed( 220 ) ply:SetRunSpeed( 220 )
ply:SetStepSize( 8 )
end end
if SERVER then if SERVER then

View File

@ -16,17 +16,11 @@ hook.Add( "PlayerTick", "Benny_PlayerTick", function( ply, mv )
ply:SetVaultDebuff( math.Clamp( ply:GetVaultDebuff() - FrameTime()/0.4 , 0, 1 ) ) ply:SetVaultDebuff( math.Clamp( ply:GetVaultDebuff() - FrameTime()/0.4 , 0, 1 ) )
end) end)
hook.Add( "Move", "Benny_Move", function( ply, mv ) function VaultReady( ply, pos, ang, forw, side )
local ang = mv:GetMoveAngles() local wantdir = Vector( forw, -side, 0 ):GetNormalized()
local pos = mv:GetOrigin()
local vel = mv:GetVelocity()
local wantdir = Vector( mv:GetForwardSpeed(), -mv:GetSideSpeed(), 0 ):GetNormalized()
wantdir:Rotate( Angle( 0, ang.y, 0 ) ) wantdir:Rotate( Angle( 0, ang.y, 0 ) )
local cum = pos + wantdir*8 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 ts, te = cum + Vector( 0, 0, 24 ), cum + Vector( 0, 0, 65 )
local tr = util.TraceHull( { local tr = util.TraceHull( {
start = ts, start = ts,
@ -36,21 +30,30 @@ hook.Add( "Move", "Benny_Move", function( ply, mv )
filter = ply filter = ply
} ) } )
for i=1, 2 do return (ply:GetVaultDebuff() == 0 and tr.Hit and tr.StartSolid and !tr.AllSolid and tr.FractionLeftSolid>0) and tr, ts, te or false
debugoverlay.Box( ts, smale, small, 0, tB ) end
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 hook.Add( "SetupMove", "Benny_SetupMove", function( ply, mv, cmd )
print( CurTime(), "Moved!" ) if !ply:OnGround() and mv:KeyDown( IN_DUCK ) then
local epic = LerpVector( tr.FractionLeftSolid, ts, te ) local newbuttons = bit.band(mv:GetButtons(), bit.bnot(IN_DUCK))
debugoverlay.Box( epic, smale, small, 0, SERVER and dS or dC ) mv:SetButtons(newbuttons)
mv:SetOrigin( epic + Vector(0, 0, 1/16) )
mv:SetVelocity( vector_origin )
ply:SetVaultDebuff( 1 )
end 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()) local speed = mv:GetMaxSpeed() * (1-ply:GetVaultDebuff())
mv:SetMaxSpeed( speed ) mv:SetMaxSpeed( speed )
mv:SetMaxClientSpeed( 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) end)