diff --git a/gamemodes/benny/gamemode/modules/player/cl_hud.lua b/gamemodes/benny/gamemode/modules/player/cl_hud.lua index 3d7ba29..74d46e3 100644 --- a/gamemodes/benny/gamemode/modules/player/cl_hud.lua +++ b/gamemodes/benny/gamemode/modules/player/cl_hud.lua @@ -254,97 +254,100 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() surface.SetDrawColor( scheme["fg"] ) 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-19) - (tw/2), sh - b + ss(16) - ss(BOXHEIGHT-4) ) - surface.DrawText( str ) + -- PROTO: Make grenade/melee/firearm logic way way better. + if wep1c.Features != "grenade" then + 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-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() - local tw = surface.GetTextSize( text ) - surface.SetTextColor( scheme["fg"] ) - surface.SetTextPos( sw - b - ss(4) - tw, sh - b - ss(24) ) - surface.DrawText( text ) + surface.SetFont( "Benny_12" ) + local text = wep:GetWep1Clip() == 0 and "---" or wep:Clip1()-- .. " - MAG " .. wep:GetWep1Clip() + local tw = surface.GetTextSize( text ) + surface.SetTextColor( scheme["fg"] ) + surface.SetTextPos( sw - b - ss(4) - tw, sh - b - ss(24) ) + surface.DrawText( text ) - 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(9-3) - elseif count>60 then - size = ss(3) - 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) * (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) * (bx-1) ), sh - b - ss(8+4) - by, ss(3), size ) + 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(9-3) + elseif count>60 then + size = ss(3) + by = by - ss(7) + elseif count>30 then + size = ss(3) + by = by - ss(5) end - if i%30 == 0 then - if count>90 then - by = by + ss(3) - elseif count>60 then - by = by + ss(3) - else - by = by + ss(5) + for i=1, count do + surface.SetDrawColor( scheme["fg"] ) + 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) * (bx-1) ), sh - b - ss(8+4) - by, ss(3), size ) 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] } - local ind = 1 - local bubby = ss(1) - local blen, bhei = 25, 10 - for _, v in ipairs( amlist ) do - local active = wep:GetWep1Clip() == _ - if v == 0 and !active then continue end - local perc = v / wep:BClass( false ).Ammo - - 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(fmpw) + ( ss(blen+2) * (ind-1) ), - sh - b + ss(16) - ss(BOXHEIGHT-4), - ss(blen), - ss(bhei), - ss(0.5) ) - - if active then - surface.SetTextColor( scheme["fg"] ) - 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" ) + if i%30 == 0 then + if count>90 then + by = by + ss(3) + elseif count>60 then + by = by + ss(3) + else + by = by + ss(5) + end + bx = 0 + end + bx = bx + 1 end - surface.SetDrawColor( scheme["fg"] ) - 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 ) + local amlist = { wep:BTable( false )["Ammo" .. 1], wep:BTable( false )["Ammo" .. 2], wep:BTable( false )["Ammo" .. 3] } + local ind = 1 + local bubby = ss(1) + local blen, bhei = 25, 10 + for _, v in ipairs( amlist ) do + local active = wep:GetWep1Clip() == _ + if v == 0 and !active then continue end + local perc = v / wep:BClass( false ).Ammo - if active then - render.SetScissorRect( sw - b - ss(w-4-2) + ss(fmpw) + ( ss(blen+2) * (ind-1) ) + bubby, + 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(fmpw) + ( ss(blen+2) * (ind-1) ), + sh - b + ss(16) - ss(BOXHEIGHT-4), + ss(blen), + ss(bhei), + ss(0.5) ) + + if active then + surface.SetTextColor( scheme["fg"] ) + 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(fmpw) + ( ss(blen+2) * (ind-1) ) + bubby, sh - b + ss(16) - ss(BOXHEIGHT-4) + bubby, - 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(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 ) - end + suuze, + ss(bhei) - bubby*2 ) - ind = ind + 1 + if active then + 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(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(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 ) + end + + ind = ind + 1 + end end -- local prog = { @@ -663,6 +666,19 @@ do RunConsoleCommand( "benny_inv_equip", buckets[bucket_selected][item_selected] ) end end + local function Wrap( ply, num ) + local buckets = ply:INV_Buckets() + if bucket_selected == num then + item_selected = item_selected + 1 + if item_selected > #buckets[bucket_selected] then + item_selected = 1 + end + else + bucket_selected = num + item_selected = 1 + end + Equip() + end local qt = { ["invnext"] = function( ply ) local buckets = ply:INV_Buckets() @@ -696,56 +712,34 @@ do Equip() end, ["slot1"] = function( ply ) - local buckets = ply:INV_Buckets() - if bucket_selected == 1 then - item_selected = item_selected + 1 - if item_selected > #buckets[bucket_selected] then - item_selected = 1 - end - else - bucket_selected = 1 - item_selected = 1 - end - Equip() + Wrap( ply, 1 ) end, ["slot2"] = function( ply ) - local buckets = ply:INV_Buckets() - if bucket_selected == 2 then - item_selected = item_selected + 1 - if item_selected > #buckets[bucket_selected] then - item_selected = 1 - end - else - bucket_selected = 2 - item_selected = 1 - end - Equip() + Wrap( ply, 2 ) end, ["slot3"] = function( ply ) - local buckets = ply:INV_Buckets() - if bucket_selected == 3 then - item_selected = item_selected + 1 - if item_selected > #buckets[bucket_selected] then - item_selected = 1 - end - else - bucket_selected = 3 - item_selected = 1 - end - Equip() + Wrap( ply, 3 ) end, ["slot4"] = function( ply ) - local buckets = ply:INV_Buckets() - if bucket_selected == 4 then - item_selected = item_selected + 1 - if item_selected > #buckets[bucket_selected] then - item_selected = 1 - end - else - bucket_selected = 4 - item_selected = 1 - end - Equip() + Wrap( ply, 4 ) + end, + ["slot5"] = function( ply ) + Wrap( ply, 5 ) + end, + ["slot6"] = function( ply ) + -- Wrap( ply, 6 ) + end, + ["slot7"] = function( ply ) + -- Wrap( ply, 7 ) + end, + ["slot8"] = function( ply ) + -- Wrap( ply, 8 ) + end, + ["slot9"] = function( ply ) + -- Wrap( ply, 9 ) + end, + ["slot0"] = function( ply ) + -- Wrap( ply, 0 ) end, } hook.Add( "PlayerBindPress", "inv", function( ply, bind, pressed, code ) diff --git a/gamemodes/benny/gamemode/modules/player/sh_basic.lua b/gamemodes/benny/gamemode/modules/player/sh_basic.lua index 2206ab1..f285013 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_basic.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_basic.lua @@ -69,16 +69,20 @@ concommand.Add("benny_inv_equip", function( ply, cmd, args ) local inv = ply:INV_Get() local wep = ply:GetActiveWeapon() local item = inv[args[1]] + local class = WEAPONS[item.Class] -- PROTO: Check that this is the correct 'benny' weapon. assert( item, "That item doesn't exist. " .. tostring(item) ) wep:SetWep1( args[1] ) wep:SetWep1Clip( item.Loaded ) - if item.Loaded != 0 then - assert( item[ "Ammo" .. item.Loaded ], "That magazine doesn't exist." ) + -- PROTO: Make grenade/melee/firearm logic way way better. + if class.Features != "grenade" then + if item.Loaded != 0 then + assert( item[ "Ammo" .. item.Loaded ], "That magazine doesn't exist." ) + end + wep:SetClip1( item.Loaded == 0 and 0 or item[ "Ammo" .. item.Loaded ] ) end - wep:SetClip1( item.Loaded == 0 and 0 or item[ "Ammo" .. item.Loaded ] ) end) concommand.Add("benny_inv_sync", function( ply, cmd, args ) @@ -177,45 +181,67 @@ if CLIENT then local itemlist = smenu:Add("DScrollPanel") itemlist:Dock( FILL ) - local List = vgui.Create( "DIconLayout", itemlist ) - List:Dock( FILL ) - List:SetSpaceX( 5 ) - List:SetSpaceY( 5 ) + -- local List = vgui.Create( "DIconLayout", itemlist ) + -- List:Dock( FILL ) + -- List:SetSpaceX( 5 ) + -- List:SetSpaceY( 5 ) + + + local createlist = {} for ClassName, Class in SortedPairsByMemberValue( WEAPONS, "Name" ) do - local button = vgui.Create( "DButton" ) - List:Add( button ) - button:SetSize( ss(96), ss(22) ) - --button:Dock( TOP ) - button:DockMargin( 0, 0, 0, ss(4) ) - - button.Text_Name = Class.Name - button.Text_Desc = Class.Description - - -- PROTO: These functions don't need to be remade over and over like this. - function button:DoClick() - RunConsoleCommand( "benny_debug_give", LocalPlayer():EntIndex(), 0, ClassName ) + if !createlist[Class.Type] then + createlist[Class.Type] = {} end - function button:DoRightClick() - end + table.insert( createlist[Class.Type], { ClassName = ClassName, Class = Class } ) + end - function button:Paint( w, h ) - surface.SetDrawColor( schemes["benny"]["fg"] ) - surface.DrawRect( 0, 0, w, h ) - - surface.SetTextColor( schemes["benny"]["bg"] ) - surface.SetFont( "Benny_16" ) - surface.SetTextPos( ss(4), ss(4) ) - surface.DrawText( self.Text_Name ) + for i, v in pairs( createlist ) do + local Collapse = itemlist:Add( "DCollapsibleCategory" ) + Collapse:Dock( TOP ) + Collapse:SetLabel( i ) + local Lays = itemlist:Add( "DIconLayout" ) + Collapse:SetContents( Lays ) + Lays:Dock( FILL ) + Lays:SetSpaceX( 2 ) + Lays:SetSpaceY( 2 ) + for Mew, New in ipairs( v ) do + local button = Lays:Add( "DButton" ) + button:SetSize( ss(96), ss(22) ) + --button:Dock( TOP ) + button:DockMargin( 0, 0, 0, ss(4) ) - -- surface.SetFont( "Benny_10" ) - -- surface.SetTextPos( ss(4), ss(4 + 12) ) - -- surface.DrawText( self.Text_Desc ) - return true + button.Text_Name = New.Class.Name + button.Text_Desc = New.Class.Description + + -- PROTO: These functions don't need to be remade over and over like this. + function button:DoClick() + RunConsoleCommand( "benny_debug_give", LocalPlayer():EntIndex(), 0, New.ClassName ) + end + + function button:DoRightClick() + end + + function button:Paint( w, h ) + surface.SetDrawColor( schemes["benny"]["fg"] ) + surface.DrawRect( 0, 0, w, h ) + + surface.SetTextColor( schemes["benny"]["bg"] ) + + surface.SetFont( "Benny_16" ) + surface.SetTextPos( ss(4), ss(4) ) + surface.DrawText( self.Text_Name ) + + -- surface.SetFont( "Benny_10" ) + -- surface.SetTextPos( ss(4), ss(4 + 12) ) + -- surface.DrawText( self.Text_Desc ) + return true + end end end + end local function regen_items( itemlist ) local ply = LocalPlayer() diff --git a/gamemodes/benny/gamemode/modules/player/sh_player.lua b/gamemodes/benny/gamemode/modules/player/sh_player.lua index d5f162b..b0b0097 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_player.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_player.lua @@ -44,9 +44,11 @@ do ["special"] = { 1, 2 }, ["pistol"] = { 2, 1 }, ["smg"] = { 3, 1 }, - ["shotgun"] = { 3, 2 }, - ["rifle"] = { 4, 1 }, - ["machinegun"] = { 4, 2 }, + ["shotgun"] = { 4, 1 }, + ["rifle"] = { 5, 1 }, + ["machinegun"] = { 5, 2 }, + ["grenade"] = { 6, 1 }, + ["utility"] = { 6, 2 }, } -- PROTO: Cache this! @@ -56,6 +58,8 @@ do [2] = {}, [3] = {}, [4] = {}, + [5] = {}, + [6] = {}, } for i, bucket in ipairs( inventorylist ) do local temp = {} diff --git a/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua b/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua index adbd0c9..3a96412 100644 --- a/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua +++ b/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua @@ -551,6 +551,28 @@ WEAPONS["bizon"] = { Spread = 40/60, } +WEAPONS["chicom"] = { + Name = "QCW-CQB", + Description = "Subsonic bullpup SMG.", + Type = "smg", + + WModel = "models/weapons/w_rif_famas.mdl", + HoldType = "rpg", + GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_REVOLVER, 0.34 }, + + Sound_Fire = "M92.Fire", + Sound_DryFire = "Common.Dryfire.Rifle", + Sound_Reload = "Bizon.Reload", + Sound_MagOut = "Bizon.MagOut", + Sound_MagIn = "Bizon.MagIn", + + Delay = (60/525), + Firemodes = FIREMODE_AUTOSEMI, + Ammo = 36, + Damage = 12, + Spread = 40/60, +} + -- Shotguns WEAPONS["spas12"] = { @@ -620,6 +642,27 @@ WEAPONS["fnc"] = { Damage = 10, } +WEAPONS["qbz"] = { + Name = "QBZ-95", + Description = "Bullpup assault rifle.", + Type = "rifle", + + Icon = Material( "benny/weapons/fnc.png", "smooth" ), + WModel = "models/weapons/w_rif_bakm.mdl", + HoldType = "rpg", + GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL, 0.3 }, + + Sound_Fire = "FNC.Fire", + Sound_DryFire = "Common.Dryfire.Rifle", + Sound_MagOut = "FNC.MagOut", + Sound_MagIn = "FNC.MagIn", + + Delay = (60/600), + Firemodes = FIREMODE_AUTOSEMI, + Ammo = 30, + Damage = 10, +} + WEAPONS["m16a2"] = { Name = "M16A2", Description = "meow", @@ -664,4 +707,86 @@ WEAPONS["stoner63"] = { Firemodes = FIREMODE_AUTOSEMI, Ammo = 100, Damage = 10, +} + +WEAPONS["qbblsw"] = { + Name = "QBB-LSW", + Description = "Bullpup light machine gun.", + Type = "machinegun", + + WModel = "models/weapons/w_mach_mg36.mdl", + HoldType = "rpg", + GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_REVOLVER, 0.3 }, + + Sound_Fire = "FNC.Fire", + Sound_DryFire = "Common.Dryfire.Rifle", + Sound_MagOut = "M16A2.MagOut", + Sound_MagIn = "M16A2.MagIn", + + Delay = (60/550), + Firemodes = FIREMODE_AUTOSEMI, + Ammo = 100, + Damage = 10, +} + +-- Grenades + +WEAPONS["g_frag"] = { + Name = "FRAG GRENADE", + Description = "Pull the pin and throw it the hell away!", + Type = "grenade", + + WModel = "models/weapons/w_eq_flashbang.mdl", + + Features = "grenade", -- All weapons should have this? +} + +WEAPONS["g_semtex"] = { + Name = "SEMTEX GRENADE", + Description = "Long, audible fuse, but sticks to whatever it touches.", + Type = "grenade", + + WModel = "models/weapons/w_eq_flashbang.mdl", + + Features = "grenade", -- All weapons should have this? +} + +WEAPONS["g_molotov"] = { + Name = "MOLOTOV COCKTAIL", + Description = "Alcoholic bottle of flame!", + Type = "grenade", + + WModel = "models/weapons/w_eq_flashbang.mdl", + + Features = "grenade", -- All weapons should have this? +} + +WEAPONS["g_tknife"] = { + Name = "THROWING KNIFE", + Description = "Lightweight knife weighted perfectly.", + Type = "grenade", + + WModel = "models/weapons/w_eq_flashbang.mdl", + + Features = "grenade", -- All weapons should have this? +} + +WEAPONS["g_smoke"] = { + Name = "SMOKE GRENADE", + Description = "Smoke bomb used to conceal your position.", + Type = "grenade", + + WModel = "models/weapons/w_eq_flashbang.mdl", + + Features = "grenade", -- All weapons should have this? +} + +WEAPONS["g_flashbang"] = { + Name = "FLASHBANG", + Description = "Stun grenade that gives off a bright flash and a loud 'bang'.", + Type = "grenade", + + WModel = "models/weapons/w_eq_flashbang.mdl", + + Features = "grenade", -- All weapons should have this? } \ No newline at end of file