More weapons and more slots.

This commit is contained in:
Fesiug 2023-11-03 13:20:39 -04:00
parent 29d9a61086
commit ed336f6cfd
4 changed files with 311 additions and 162 deletions

View File

@ -254,6 +254,8 @@ 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) )
-- 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 )
@ -346,6 +348,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
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 )

View File

@ -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 )
-- 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
end)
concommand.Add("benny_inv_sync", function( ply, cmd, args )
@ -177,24 +181,44 @@ 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 )
if !createlist[Class.Type] then
createlist[Class.Type] = {}
end
table.insert( createlist[Class.Type], { ClassName = ClassName, Class = Class } )
end
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) )
button.Text_Name = Class.Name
button.Text_Desc = Class.Description
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, ClassName )
RunConsoleCommand( "benny_debug_give", LocalPlayer():EntIndex(), 0, New.ClassName )
end
function button:DoRightClick()
@ -217,6 +241,8 @@ if CLIENT then
end
end
end
end
local function regen_items( itemlist )
local ply = LocalPlayer()
itemlist:Clear()

View File

@ -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 = {}

View File

@ -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",
@ -665,3 +708,85 @@ WEAPONS["stoner63"] = {
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?
}