Crosshair goes blue for offhand, 0 can equip 10

This commit is contained in:
Fesiug 2023-12-08 19:55:04 -05:00
parent 614102eda1
commit 3da949313b
2 changed files with 104 additions and 87 deletions

View File

@ -254,6 +254,7 @@ globang = Angle()
tr1f = Vector() tr1f = Vector()
tr2f = Vector() tr2f = Vector()
local col_1 = Color(255, 255, 255, 200) local col_1 = Color(255, 255, 255, 200)
local col_1a = Color(100, 100, 255, 200)
local col_2 = Color(0, 0, 0, 255) local col_2 = Color(0, 0, 0, 255)
local col_3 = Color(255, 127, 127, 255) local col_3 = Color(255, 127, 127, 255)
local col_4 = Color(255, 222, 222, 255) local col_4 = Color(255, 222, 222, 255)
@ -264,7 +265,7 @@ local mat_dot_s = Material("benny/hud/xhair/dot_s.png", "mips smooth")
local mat_long_s = Material("benny/hud/xhair/long_s.png", "mips smooth") local mat_long_s = Material("benny/hud/xhair/long_s.png", "mips smooth")
local spacer_long = 3 -- screenscaled local spacer_long = 3 -- screenscaled
local spacer = 1 -- screenscaled local spacer = 1 -- screenscaled
local gap = 8 local gap = 0
local trash_vec, trash_ang = Vector(), Angle() local trash_vec, trash_ang = Vector(), Angle()
@ -535,16 +536,21 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
end end
end end
local meow = wep:C_DualCheck() for h=1, 2 do
if wep:GetUserAim() and wep:BClass( meow ) and wep:BClass( meow ).Spread then -- Crosshair local hand = h==2
if wep:GetUserAim() and wep:BClass( hand ) then -- Crosshair
local s, w, h = ss, ScrW(), ScrH() local s, w, h = ss, ScrW(), ScrH()
local pl_x, pl_y = w/2, h/2 local pl_x, pl_y = w/2, h/2
local dispersion = math.rad( wep:BSpread( meow ) ) if wep:BClass( hand ).Spread then
local dispersion = math.rad( wep:BSpread( hand ) )
cam.Start3D() cam.Start3D()
local lool = ( EyePos() + ( EyeAngles():Forward()*8192 ) + ( dispersion * EyeAngles():Up()*8192 ) ) :ToScreen() local lool = ( EyePos() + ( EyeAngles():Forward()*8192 ) + ( dispersion * EyeAngles():Up()*8192 ) ) :ToScreen()
cam.End3D() cam.End3D()
gap = ( (ScrH()/2) - lool.y ) gap = ( (ScrH()/2) - lool.y )
else
gap = 0
end
do do
local tr1 = util.TraceLine({ local tr1 = util.TraceLine({
@ -569,6 +575,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
ps_y = tr2f:ToScreen().y ps_y = tr2f:ToScreen().y
local touse1 = col_1 local touse1 = col_1
local touse1_primary = col_1a
local touse2 = col_2 local touse2 = col_2
if ve then if ve then
pl_x = tr1f:ToScreen().x pl_x = tr1f:ToScreen().x
@ -587,13 +594,15 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
ps_x = math.Round( ps_x ) ps_x = math.Round( ps_x )
ps_y = math.Round( ps_y ) ps_y = math.Round( ps_y )
local meow = wep:C_DualCheck()
for i=1, 2 do for i=1, 2 do
local cooler = i == 1 and touse2 or touse1 local cooler = i == 1 and touse2 or (hand!=meow and touse1_primary or touse1)
local poosx, poosy = i == 1 and ps_x or pl_x, i == 1 and ps_y or pl_y local poosx, poosy = i == 1 and ps_x or pl_x, i == 1 and ps_y or pl_y
local mat1 = i == 1 and mat_long_s or mat_long local mat1 = i == 1 and mat_long_s or mat_long
local mat2 = i == 1 and mat_dot_s or mat_dot local mat2 = i == 1 and mat_dot_s or mat_dot
surface.SetDrawColor( cooler ) surface.SetDrawColor( cooler )
local typ = wep:BClass( meow ).Type local typ = wep:BClass( hand ).Type
if typ == "rifle" then if typ == "rifle" then
surface.SetMaterial( mat1 ) surface.SetMaterial( mat1 )
surface.DrawTexturedRectRotated( poosx - s(spacer_long) - gap, poosy, s(16), s(16), 0 ) surface.DrawTexturedRectRotated( poosx - s(spacer_long) - gap, poosy, s(16), s(16), 0 )
@ -618,7 +627,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
end end
--surface.SetMaterial( mat2 ) --surface.SetMaterial( mat2 )
--surface.DrawTexturedRectRotated( poosx, poosy, s(32), s(32), 0 ) --surface.DrawTexturedRectRotated( poosx, poosy, s(32), s(32), 0 )
else -- pistol elseif typ == "pistol" then -- pistol
surface.SetMaterial( mat2 ) surface.SetMaterial( mat2 )
surface.DrawTexturedRectRotated( poosx - gap - s(spacer), poosy, s(32), s(32), 0 ) surface.DrawTexturedRectRotated( poosx - gap - s(spacer), poosy, s(32), s(32), 0 )
surface.DrawTexturedRectRotated( poosx + gap + s(spacer), poosy, s(32), s(32), 0 ) surface.DrawTexturedRectRotated( poosx + gap + s(spacer), poosy, s(32), s(32), 0 )
@ -626,6 +635,11 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
surface.SetMaterial( mat2 ) surface.SetMaterial( mat2 )
surface.DrawTexturedRectRotated( poosx, poosy - gap - s(spacer), s(32), s(32), 0 ) surface.DrawTexturedRectRotated( poosx, poosy - gap - s(spacer), s(32), s(32), 0 )
surface.DrawTexturedRectRotated( poosx, poosy + gap + s(spacer), s(32), s(32), 0 ) surface.DrawTexturedRectRotated( poosx, poosy + gap + s(spacer), s(32), s(32), 0 )
elseif typ == "grenade" then -- grenade
surface.SetMaterial( mat2 )
surface.DrawTexturedRectRotated( poosx, poosy, s(32), s(32), 0 )
surface.DrawTexturedRectRotated( poosx, poosy, s(32), s(32), 0 )
end
end end
end end
end end
@ -753,7 +767,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
local invid = 0 local invid = 0
for _, item in pairs( weighted ) do for _, item in pairs( weighted ) do
local id = iflip[item] local id = iflip[item]
local active = wep:D_GetID( false ) == id or wep:D_GetID( true ) == id local active = wep:D_GetReqID( false ) == id or wep:D_GetReqID( true ) == id
local class = WeaponGet(item.Class) local class = WeaponGet(item.Class)
local boxsize = ss(b_w) local boxsize = ss(b_w)
surface.SetDrawColor( scheme[active and "fg" or "bg"] ) surface.SetDrawColor( scheme[active and "fg" or "bg"] )
@ -762,12 +776,14 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
draw.SimpleText( class.Name, "Benny_8", b_x + bump + boxsize/2, b_y + ss(6), scheme[active and "bg" or "fg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP ) draw.SimpleText( class.Name, "Benny_8", b_x + bump + boxsize/2, b_y + ss(6), scheme[active and "bg" or "fg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP )
--draw.SimpleText( "", "Benny_8", b_x + bump + boxsize/2, b_y + ss(17), scheme["fg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP ) --draw.SimpleText( "", "Benny_8", b_x + bump + boxsize/2, b_y + ss(17), scheme["fg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP )
if class.Features == "firearm" or class.Features == "grenade" then if class.Features == "firearm" or class.Features == "grenade" then
invid = invid + 1
surface.SetDrawColor( scheme[active and "bg" or "fg"] ) surface.SetDrawColor( scheme[active and "bg" or "fg"] )
surface.DrawOutlinedRect( b_x + bump + ss(1), b_y + ss(1), boxsize-ss(2), ss(b_h-2), ss(0.5) ) surface.DrawOutlinedRect( b_x + bump + ss(1), b_y + ss(1), boxsize-ss(2), ss(b_h-2), ss(0.5) )
invid = invid + 1 if invid < 11 then
surface.SetDrawColor( scheme[active and "fg" or "bg"] ) surface.SetDrawColor( scheme[active and "fg" or "bg"] )
surface.DrawRect( b_x + bump, b_y - ss(2+12), ss(12), ss(12) ) surface.DrawRect( b_x + bump, b_y - ss(2+12), ss(12), ss(12) )
draw.SimpleText( invid, "Benny_10", b_x + bump + ss(6), b_y - ss(2+10), scheme[active and "bg" or "fg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP ) draw.SimpleText( invid==10 and 0 or invid, "Benny_10", b_x + bump + ss(6), b_y - ss(2+10), scheme[active and "bg" or "fg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP )
end
end end
local maginv = p:INV_FindMagSmart( item.Class, id ) local maginv = p:INV_FindMagSmart( item.Class, id )

View File

@ -26,6 +26,7 @@ local function beatup( ply, num )
local id = iflip[item] local id = iflip[item]
if class.Features == "firearm" or class.Features == "grenade" then if class.Features == "firearm" or class.Features == "grenade" then
invid = invid + 1 invid = invid + 1
if num == 0 then num = 10 end
if num == invid then if num == invid then
if ply:KeyDown(IN_ZOOM) then if ply:KeyDown(IN_ZOOM) then
if id == wep:D_GetID( true ) then if id == wep:D_GetID( true ) then