Weapon HUD gets some lvoe

This commit is contained in:
Fesiug 2023-09-25 21:12:22 -04:00
parent 63f7f0b477
commit 09d56cfaf7
3 changed files with 77 additions and 39 deletions

View File

@ -74,6 +74,21 @@ function SWEP:B_Ammo( alt, value )
self:BTable( alt )["Ammo" .. clip] = value
end
function SWEP:B_Firemode( alt )
return self:BClass( alt ).Firemodes[1]
end
function SWEP:B_FiremodeName( alt )
local mode = self:B_Firemode( alt ).Mode
if mode == 1 then
return "SEMI"
elseif mode == math.huge then
return "AUTO"
else
return mode .. "RND"
end
end
function SWEP:SecondaryAttack()
return true
end

View File

@ -202,31 +202,6 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
local wep2 = wep:BTable( true )
local wep2c = wep:BClass( true )
if false then -- Debug
local ox, oy = 170, 24
surface.SetFont( "Benny_12" )
surface.SetTextColor( scheme["fg"] )
surface.SetTextPos( ss(ox), ss(oy) )
surface.DrawText( "Wep1: " .. wep:GetWep1() )
local num = 1
if wep1 then for i, v in pairs( wep1 ) do
surface.SetTextPos( ss(ox+16), ss(oy+10*num) )
surface.DrawText( i .. ": " .. v )
num = num + 1
end end
surface.SetTextPos( ss(ox+128), ss(oy) )
surface.DrawText( "Wep2: " .. wep:GetWep2() )
if wep2 then for i, v in pairs( wep2 ) do
surface.SetTextPos( ss(ox+128+16), ss(oy+10*num) )
surface.DrawText( i .. ": " .. v )
num = num + 1
end end
end
local w, h = 150, 100
local BOXHEIGHT = 44
@ -244,13 +219,16 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
surface.SetTextPos( sw - b - ss(w-6), sh - b - ss(BOXHEIGHT-3) )
surface.DrawText( wep1c.Name or "???" )
local fmpw = 30
surface.SetDrawColor( scheme["fg"] )
surface.DrawRect( sw - b - ss(w-4), sh - b + ss(16) - ss(BOXHEIGHT-4), ss(29), ss(10) )
surface.DrawRect( sw - b - ss(w-4), sh - b + ss(16) - ss(BOXHEIGHT-4), ss(fmpw), ss(10) )
surface.SetFont( "Benny_12" )
local str = wep:B_FiremodeName( false )
local tw = surface.GetTextSize( str )
surface.SetTextColor( scheme["bg"] )
surface.SetTextPos( sw - b - ss(w-7), sh - b + ss(16) - ss(BOXHEIGHT-4) )
surface.DrawText( wep1c.Firemode or "???" )
surface.SetTextPos( sw - b - ss(w-19) - (tw/2), sh - b + ss(16) - ss(BOXHEIGHT-4) )
surface.DrawText( str )
surface.SetFont( "Benny_12" )
local text = wep:GetWep1Clip() == 0 and "---" or wep:Clip1()-- .. " - MAG " .. wep:GetWep1Clip()
@ -259,12 +237,37 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
surface.SetTextPos( sw - b - ss(4) - tw, sh - b - ss(24) )
surface.DrawText( text )
for i=1, math.max( wep:Clip1(), wep:BClass( false ).Ammo ) do
local bx = 1
local by = 0
local count = math.max( wep:Clip1(), wep:BClass( false ).Ammo )
local size = ss(8)
if count>90 then
size = ss(2)
by = by - ss(8)
elseif count>60 then
size = ss(2)
by = by - ss(7)
elseif count>30 then
size = ss(3)
by = by - ss(5)
end
for i=1, count do
surface.SetDrawColor( scheme["fg"] )
surface.DrawOutlinedRect( sw - b - ss(3+4) - ( ss(5) * (i-1) ), sh - b - ss(8+4), ss(3), ss(8), ss(0.5) )
surface.DrawOutlinedRect( sw - b - ss(3+4) - ( ss(5) * (bx-1) ), sh - b - ss(8+4) - by, ss(3), size, ss(0.5) )
if i <= wep:Clip1() then
surface.DrawRect( sw - b - ss(3+4) - ( ss(5) * (i-1) ), sh - b - ss(8+4), ss(3), ss(8) )
surface.DrawRect( sw - b - ss(3+4) - ( ss(5) * (bx-1) ), sh - b - ss(8+4) - by, ss(3), size )
end
if i%30 == 0 then
if count>90 then
by = by + ss(2.5)
elseif count>60 then
by = by + ss(3)
else
by = by + ss(5)
end
bx = 0
end
bx = bx + 1
end
local amlist = { wep:BTable( false )["Ammo" .. 1], wep:BTable( false )["Ammo" .. 2], wep:BTable( false )["Ammo" .. 3] }
@ -279,7 +282,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
local suuze = ss(blen*perc) - bubby*2*perc
if v != 0 then suuze = math.max( suuze, 1 ) end
surface.SetDrawColor( scheme["fg"] )
surface.DrawOutlinedRect( sw - b - ss(w-4-2) + ss(29) + ( ss(blen+2) * (ind-1) ),
surface.DrawOutlinedRect( sw - b - ss(w-4-2) + ss(fmpw) + ( ss(blen+2) * (ind-1) ),
sh - b + ss(16) - ss(BOXHEIGHT-4),
ss(blen),
ss(bhei),
@ -287,24 +290,24 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
if active then
surface.SetTextColor( scheme["fg"] )
surface.SetTextPos( sw - b - ss(w-4-2) + ss(29/2) + ( ss(blen+2) * (ind) ) + bubby - ss(4),
surface.SetTextPos( sw - b - ss(w-4-2) + ss(fmpw/2) + ( ss(blen+2) * (ind) ) + bubby - ss(4),
sh - b + ss(16) - ss(BOXHEIGHT-4) + bubby - ss(2) )
surface.DrawText( "x" )
end
surface.SetDrawColor( scheme["fg"] )
surface.DrawRect( sw - b - ss(w-4-2) + ss(29) + ( ss(blen+2) * (ind-1) ) + bubby,
surface.DrawRect( sw - b - ss(w-4-2) + ss(fmpw) + ( ss(blen+2) * (ind-1) ) + bubby,
sh - b + ss(16) - ss(BOXHEIGHT-4) + bubby,
suuze,
ss(bhei) - bubby*2 )
if active then
render.SetScissorRect( sw - b - ss(w-4-2) + ss(29) + ( ss(blen+2) * (ind-1) ) + bubby,
render.SetScissorRect( sw - b - ss(w-4-2) + ss(fmpw) + ( ss(blen+2) * (ind-1) ) + bubby,
sh - b + ss(16) - ss(BOXHEIGHT-4) + bubby,
sw - b - ss(w-4-2) + ss(29) + ( ss(blen+2) * (ind-1) ) + bubby + suuze,
sw - b - ss(w-4-2) + ss(fmpw) + ( ss(blen+2) * (ind-1) ) + bubby + suuze,
sh - b + ss(16) - ss(BOXHEIGHT-4) + bubby + (ss(bhei) - bubby*2), true )
surface.SetTextColor( scheme["bg"] )
surface.SetTextPos( sw - b - ss(w-4-2) + ss(29/2) + ( ss(blen+2) * (ind) ) + bubby - ss(4),
surface.SetTextPos( sw - b - ss(w-4-2) + ss(fmpw/2) + ( ss(blen+2) * (ind) ) + bubby - ss(4),
sh - b + ss(16) - ss(BOXHEIGHT-4) + bubby - ss(2) )
surface.DrawText( "x" )
render.SetScissorRect( 0, 0, 0, 0, false )
@ -354,7 +357,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
end
end
do -- Inventory
if false then -- Debug Inventory
local gap = 0
for ID, Data in pairs( p:INV_Get() ) do
local active = (wep:GetWep2() == ID) and "Wep2" or (wep:GetWep1() == ID) and "Wep1" or ""

View File

@ -1,4 +1,14 @@
FIREMODE_AUTO = {
{ Mode = math.huge },
}
FIREMODE_AUTOSEMI = {
{ Mode = math.huge },
{ Mode = 1 },
}
FIREMODE_SEMI = {
{ Mode = 1 },
}
WEAPONS = {}
AddSound( "1911.Fire", {
@ -99,6 +109,7 @@ wep.Sound_MagOut = "1911.MagOut" -- placeholder
wep.Sound_MagIn = "1911.MagIn" -- placeholder
wep.Delay = (60/300)
wep.Firemodes = FIREMODE_SEMI
wep.Ammo = 8
wep.Damage = 30
@ -115,6 +126,7 @@ wep.Sound_MagOut = "USP.MagOut" -- placeholder
wep.Sound_MagIn = "USP.MagIn" -- placeholder
wep.Delay = (60/300)
wep.Firemodes = FIREMODE_SEMI
wep.Ammo = 12
wep.Damage = 30
@ -130,6 +142,7 @@ wep.Sound_MagOut = "Glock.MagOut" -- placeholder
wep.Sound_MagIn = "Glock.MagIn" -- placeholder
wep.Delay = (60/800)
wep.Firemodes = FIREMODE_AUTOSEMI
wep.Ammo = 17
wep.Damage = 18
@ -145,6 +158,7 @@ wep.Sound_MagOut = "Nambu.MagOut" -- placeholder
wep.Sound_MagIn = "Nambu.MagIn" -- placeholder
wep.Delay = (60/180)
wep.Firemodes = FIREMODE_SEMI
wep.Ammo = 6
wep.Damage = 26
@ -160,6 +174,7 @@ wep.Sound_MagOut = "Anaconda.MagOut" -- placeholder
wep.Sound_MagIn = "Anaconda.MagIn" -- placeholder
wep.Delay = (60/180)
wep.Firemodes = FIREMODE_SEMI
wep.Ammo = 6
wep.Damage = 40
@ -176,6 +191,7 @@ wep.Sound_MagOut = "TMP.MagOut" -- placeholder
wep.Sound_MagIn = "TMP.MagIn" -- placeholder
wep.Delay = (60/700)
wep.Firemodes = FIREMODE_AUTOSEMI
wep.Ammo = 15
wep.Damage = 18
@ -192,6 +208,7 @@ wep.Sound_MagOut = "MP7.MagOut" -- placeholder
wep.Sound_MagIn = "MP7.MagIn" -- placeholder
wep.Delay = (60/700)
wep.Firemodes = FIREMODE_AUTOSEMI
wep.Ammo = 15
wep.Damage = 16
@ -208,6 +225,7 @@ wep.Sound_MagOut = "MP5K.MagOut" -- placeholder
wep.Sound_MagIn = "MP5K.MagIn" -- placeholder
wep.Delay = (60/700)
wep.Firemodes = FIREMODE_AUTOSEMI
wep.Ammo = 15
wep.Damage = 18
@ -224,6 +242,7 @@ wep.Sound_MagOut = "MAC11.MagOut" -- placeholder
wep.Sound_MagIn = "MAC11.MagIn" -- placeholder
wep.Delay = (60/800)
wep.Firemodes = FIREMODE_AUTOSEMI
wep.Ammo = 16
wep.Damage = 16
@ -240,5 +259,6 @@ wep.Sound_MagOut = "Bizon.MagOut" -- placeholder
wep.Sound_MagIn = "Bizon.MagIn" -- placeholder
wep.Delay = (60/600)
wep.Ammo = 40
wep.Firemodes = FIREMODE_AUTOSEMI
wep.Ammo = 30
wep.Damage = 16