From ac374ae803197708800a50d26157b4a52e777d74 Mon Sep 17 00:00:00 2001 From: Fesiug Date: Sun, 24 Sep 2023 18:38:00 -0400 Subject: [PATCH] Bizon, weapon switching (sorta), wip! --- gamemodes/benny/entities/weapons/benny.lua | 2 +- .../benny/gamemode/modules/audio/sh_audio.lua | 20 +++++++++ .../gamemode/modules/player/sh_basic.lua | 36 ++++++++++++++-- .../gamemode/modules/weapons/sh_weapons.lua | 41 +++++++++++++++++++ 4 files changed, 95 insertions(+), 4 deletions(-) diff --git a/gamemodes/benny/entities/weapons/benny.lua b/gamemodes/benny/entities/weapons/benny.lua index 10e5da3..332c8bd 100644 --- a/gamemodes/benny/entities/weapons/benny.lua +++ b/gamemodes/benny/entities/weapons/benny.lua @@ -76,7 +76,7 @@ function SWEP:PrimaryAttack() -- self:EmitSound( "benny/weapons/1911/0".. math.random(1,3) ..".ogg", 110, 100, 1, CHAN_STATIC ) self:B_Ammo1( self:Clip1() - 1 ) - self:SetDelay1( CurTime() + 0.2 ) + self:SetDelay1( CurTime() + self.B_ClassT1.Delay ) return true end diff --git a/gamemodes/benny/gamemode/modules/audio/sh_audio.lua b/gamemodes/benny/gamemode/modules/audio/sh_audio.lua index 31a4cb5..b5bfd25 100644 --- a/gamemodes/benny/gamemode/modules/audio/sh_audio.lua +++ b/gamemodes/benny/gamemode/modules/audio/sh_audio.lua @@ -23,6 +23,25 @@ CAPTIONS["en-us"]["1911.Reload"] = { LifeTime = 0.5, } +CAPTIONS["en-us"]["Bizon.Fire"] = { + Name = "Bizon", + Color = color_white, + Text = "[fire]", + Bold = false, + Italic = true, + TypeTime = 0.1, + LifeTime = 0.5, +} +CAPTIONS["en-us"]["Bizon.Reload"] = { + Name = "Bizon", + Color = color_white, + Text = "[reload]", + Bold = false, + Italic = true, + TypeTime = 0.1, + LifeTime = 0.5, +} + CAPTIONS = CAPTIONS["en-us"] SOUNDS = {} @@ -40,6 +59,7 @@ end local screwup = SERVER and Color(150, 255, 255) or Color(255, 200, 150) function B_Sound( ent, tag ) + if !tag then return end local tagt = SOUNDS[tag] if !tagt then MsgC( screwup, "Invalid sound " .. tag .. "\n" ) return end local path, sndlevel, pitch, volume, channel = tagt.path, tagt.sndlevel, tagt.pitch, tagt.volume, tagt.channel diff --git a/gamemodes/benny/gamemode/modules/player/sh_basic.lua b/gamemodes/benny/gamemode/modules/player/sh_basic.lua index 2ddb5ed..364efd2 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_basic.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_basic.lua @@ -57,6 +57,20 @@ if CLIENT then end) end +-- PROTO: Move this all into weapon code. +concommand.Add("benny_inv_equip", function( ply, cmd, args ) + local inv = ply:INV_Get() + local wep = ply:GetActiveWeapon() + local item = inv[args[1]] + -- PROTO: Check that this is the correct 'benny' weapon. + assert( item, "That item doesn't exist." ) + + wep:SetWep1( args[1] ) + wep:SetClip1( item.Ammo ) + wep:OnReloaded() +end) + +-- Debug inv if CLIENT then local function regen_items( itemlist ) local ply = LocalPlayer() @@ -69,12 +83,28 @@ if CLIENT then button:Dock( TOP ) button:DockMargin( 0, 0, 0, ss(4) ) - button.Text_ID = i + button.ID = i local Class = WEAPONS[v.Class] button.Text_Name = Class.Name button.Text_Desc = Class.Description - -- PROTO: This paint function doesn't need to be remade over and over like this. + -- PROTO: These functions don't need to be remade over and over like this. + function button:DoClick() + local Menu = DermaMenu() + Menu:AddOption( "Equip", function() + RunConsoleCommand("benny_inv_equip", button.ID) + end ) + Menu:AddOption( "Discard", function() + RunConsoleCommand("benny_inv_discard", button.ID) + end ) + + Menu:Open() + end + + function button:DoRightClick() + + end + function button:Paint( w, h ) surface.SetDrawColor( schemes["benny"]["fg"] ) surface.DrawRect( 0, 0, w, h ) @@ -91,7 +121,7 @@ if CLIENT then surface.SetFont( "Benny_10" ) surface.SetTextPos( ss(4), ss(4 + 20) ) - surface.DrawText( self.Text_ID ) + surface.DrawText( self.ID ) return true end end diff --git a/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua b/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua index d36df60..797d777 100644 --- a/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua +++ b/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua @@ -7,8 +7,16 @@ AddSound( "1911.Fire", { "benny/weapons/1911/03.ogg", }, 140, 100, 0.5, CHAN_STATIC ) +AddSound( "Bizon.Fire", { + "benny/weapons/bizon/01.ogg", + "benny/weapons/bizon/02.ogg", + "benny/weapons/bizon/03.ogg", +}, 140, 100, 0.5, CHAN_STATIC ) + AddSound( "1911.Reload", "benny/weapons/1911/slidedrop.ogg", 140, 100, 0.5, CHAN_STATIC ) +AddSound( "Bizon.Reload", "benny/weapons/bizon/boltdrop.ogg", 140, 100, 0.5, CHAN_STATIC ) + local wep = {} WEAPONS["1911"] = wep wep.Name = "COBRA .45" @@ -28,6 +36,8 @@ wep.Name = "USP .45" wep.Description = "It works for hardasses around the world, it works for you. Higher capacity." wep.WModel = "models/weapons/w_pist_usp.mdl" +wep.Sound_Fire = "1911.Fire" +wep.Sound_Reload = "1911.Reload" -- placeholder wep.Delay = (60/300) wep.Ammo = 12 @@ -39,6 +49,8 @@ wep.Name = "GLOCK-18" wep.Description = "Superb precision but poor capacity." wep.WModel = "models/weapons/w_pist_glock18.mdl" +wep.Sound_Fire = "1911.Fire" +wep.Sound_Reload = "1911.Reload" -- placeholder wep.Delay = (60/800) wep.Ammo = 17 @@ -49,6 +61,10 @@ WEAPONS["nambu"] = wep wep.Name = "NAMBU .38" wep.Description = "Eastern revolver that hits as much as it costs. Low capacity." +wep.WModel = "models/weapons/w_pist_glock18.mdl" +wep.Sound_Fire = "1911.Fire" +wep.Sound_Reload = "1911.Reload" -- placeholder + wep.Delay = (60/180) wep.Ammo = 6 wep.Damage = 26 @@ -58,6 +74,10 @@ WEAPONS["anaconda"] = wep wep.Name = "ANACONDA" wep.Description = "Precise and kicks like a mule, but low capacity." +wep.WModel = "models/weapons/w_pist_glock18.mdl" +wep.Sound_Fire = "1911.Fire" +wep.Sound_Reload = "1911.Reload" -- placeholder + wep.Delay = (60/180) wep.Ammo = 6 wep.Damage = 40 @@ -66,6 +86,11 @@ local wep = {} WEAPONS["tmp"] = wep wep.Name = "TMP" wep.Description = "Precise." + +wep.WModel = "models/weapons/w_pist_glock18.mdl" +wep.Sound_Fire = "1911.Fire" +wep.Sound_Reload = "1911.Reload" -- placeholder + wep.Delay = (60/800) wep.Ammo = 15 wep.Damage = 18 @@ -75,6 +100,10 @@ WEAPONS["mp7"] = wep wep.Name = "MP7" wep.Description = "Small, pistol-sized, and simple." +wep.WModel = "models/weapons/w_pist_glock18.mdl" +wep.Sound_Fire = "1911.Fire" +wep.Sound_Reload = "1911.Reload" -- placeholder + wep.Delay = (60/700) wep.Ammo = 15 wep.Damage = 16 @@ -84,6 +113,10 @@ WEAPONS["mp5k"] = wep wep.Name = "MP5K" wep.Description = "Quality manufacturing, but cumbersome." +wep.WModel = "models/weapons/w_pist_glock18.mdl" +wep.Sound_Fire = "1911.Fire" +wep.Sound_Reload = "1911.Reload" -- placeholder + wep.Delay = (60/700) wep.Ammo = 15 wep.Damage = 18 @@ -93,6 +126,10 @@ WEAPONS["mac11"] = wep wep.Name = "MAC-11" wep.Description = "More fit for combat in a phone booth." +wep.WModel = "models/weapons/w_pist_glock18.mdl" +wep.Sound_Fire = "1911.Fire" +wep.Sound_Reload = "1911.Reload" -- placeholder + wep.Delay = (60/800) wep.Ammo = 16 wep.Damage = 16 @@ -102,6 +139,10 @@ WEAPONS["bizon"] = wep wep.Name = "BIZON" wep.Description = "Unwieldy bullet storm." +wep.WModel = "models/weapons/w_pist_glock18.mdl" +wep.Sound_Fire = "Bizon.Fire" +wep.Sound_Reload = "Bizon.Reload" -- placeholder + wep.Delay = (60/600) wep.Ammo = 40 wep.Damage = 16 \ No newline at end of file