From 42be9ec6ab8a442bb4b0bc19ec2272107592ded3 Mon Sep 17 00:00:00 2001 From: Fesiug Date: Mon, 25 Mar 2024 00:48:36 -0400 Subject: [PATCH] Burst rifle and weapon fixes --- .../benny/entities/weapons/itemhandler.lua | 2 + gamemodes/benny/gamemode/camera.lua | 4 +- gamemodes/benny/gamemode/debugmenu.lua | 10 +++ gamemodes/benny/gamemode/hud.lua | 3 +- gamemodes/benny/gamemode/items.lua | 82 +++++++++++++++++-- gamemodes/benny/gamemode/languages/en-us.lua | 8 +- gamemodes/benny/gamemode/shared.lua | 4 + 7 files changed, 102 insertions(+), 11 deletions(-) diff --git a/gamemodes/benny/entities/weapons/itemhandler.lua b/gamemodes/benny/entities/weapons/itemhandler.lua index 839ee4b..d58b3b0 100644 --- a/gamemodes/benny/entities/weapons/itemhandler.lua +++ b/gamemodes/benny/entities/weapons/itemhandler.lua @@ -137,6 +137,7 @@ function SWEP:EquipItem( ent ) ent:AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES ) ent:AddEffects( EF_BONEMERGE ) + ent:PhysicsInit( SOLID_NONE ) ent:SetMoveType( MOVETYPE_NONE ) ent:SetNoDraw( true ) ent:SetParent( p ) @@ -171,6 +172,7 @@ function SWEP:DropItem() ent:RemoveEFlags( EFL_KEEP_ON_RECREATE_ENTITIES ) ent:RemoveEffects( EF_BONEMERGE ) + ent:PhysicsInit( SOLID_VPHYSICS ) ent:SetMoveType( MOVETYPE_VPHYSICS ) ent:SetNoDraw( false ) diff --git a/gamemodes/benny/gamemode/camera.lua b/gamemodes/benny/gamemode/camera.lua index 158872b..a99e3f6 100644 --- a/gamemodes/benny/gamemode/camera.lua +++ b/gamemodes/benny/gamemode/camera.lua @@ -3,8 +3,8 @@ -- Your Name is Benny --------------------- -local cam_f = CreateConVar( "b-cam_f", -40 ) -local cam_r = CreateConVar( "b-cam_r", 12 ) +local cam_f = CreateConVar( "b-cam_f", -50 ) +local cam_r = CreateConVar( "b-cam_r", 14 ) local cam_u = CreateConVar( "b-cam_u", 0 ) local cam_fov = CreateConVar( "b-cam_fov", 75 ) diff --git a/gamemodes/benny/gamemode/debugmenu.lua b/gamemodes/benny/gamemode/debugmenu.lua index 14a9b00..16bea49 100644 --- a/gamemodes/benny/gamemode/debugmenu.lua +++ b/gamemodes/benny/gamemode/debugmenu.lua @@ -27,6 +27,7 @@ local function OpenDebugMenu() DebugMenu:SetSize( 400, 300 ) DebugMenu:Center() DebugMenu:MakePopup() + DebugMenu:SetKeyboardInputEnabled( false ) local opt = DebugMenu:Add("DCollapsibleCategory") opt:Dock( TOP ) @@ -43,6 +44,15 @@ local function OpenDebugMenu() button.iData = idata button.DoClick = dospawn end + + local button = DebugMenu:Add("DButton") + button:Dock( BOTTOM ) + button:DockMargin( 4, 4, 4, 4 ) + button:SetText( "CLOSE" ) + button:SetTall( 36 ) + button.DoClick = function( self ) + DebugMenu:Remove() + end end hook.Add("PlayerButtonDown", "PlayerButtonDown_DebugMenu", function( ply, button ) diff --git a/gamemodes/benny/gamemode/hud.lua b/gamemodes/benny/gamemode/hud.lua index c925f4c..1d14b57 100644 --- a/gamemodes/benny/gamemode/hud.lua +++ b/gamemodes/benny/gamemode/hud.lua @@ -116,7 +116,8 @@ function GM:HUDPaint() hCol( v == handler:GetActiveR() and COLOR_BRIGHT or COLOR_DARK ) hRect( (i-1)*(120+10), 0, 120, 60 ) local x, y = hXY( (i-1)*(120+10), 0 ) - draw.SimpleText( l8( v.Class.PrintName ) .. "(" .. v:GetClip() .. "/" .. v.Class.ClipSize .. ")", "HUD_24", x + 120/2, y + 60/2, COLOR_MAIN, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + draw.SimpleText( l8( v.Class.PrintName ), "HUD_24", x + 120/2, y + 60/2 - (10), COLOR_MAIN, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + draw.SimpleText( "[ " .. v:GetClip() .. "/" .. v.Class.ClipSize .. " ]", "HUD_24", x + 120/2, y + 60/2 + (10), COLOR_MAIN, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) end S_Pop() end diff --git a/gamemodes/benny/gamemode/items.lua b/gamemodes/benny/gamemode/items.lua index 3c694d9..fb3d86b 100644 --- a/gamemodes/benny/gamemode/items.lua +++ b/gamemodes/benny/gamemode/items.lua @@ -94,6 +94,7 @@ AddItem( "base_firearm", { Delay = 0.1, Pellets = 1, + Accuracy = 1, ClipSize = 15, BurstCount = math.huge, BurstRunaway = false, @@ -133,14 +134,23 @@ AddItem( "base_firearm", { ["Attack"] = function( class, ent, handler ) if ent:GetClip() <= 0 then return end if ent:GetDelay() > CurTime() then return end + if ent:GetDelayBurst() > CurTime() then return end if ent:GetBurstCount() >= class.BurstCount then return end + local Runaway = class.BurstRunaway + local BAuto = class.BurstAuto ent:SetBurstCount( ent:GetBurstCount() + 1 ) + if ent:GetBurstCount() >= class.BurstCount then + ent:SetDelayBurst( CurTime() + class.BurstDelay ) + if BAuto then + ent:SetBurstCount( 0 ) + end + end ent:SetClip( ent:GetClip() - 1 ) ent:SetDelay( CurTime() + class.Delay ) - handler:EmitSound( class.FireSound, 140, 100, 0.4, CHAN_STATIC ) + handler:EmitSound( istable(class.FireSound) and TSelShared(class.FireSound, "FireSound") or class.FireSound, 140, 100, 0.4, CHAN_STATIC ) - local acc = 0 + local acc = math.rad( class.Accuracy or 0 ) local p = handler:GetOwner() handler:FireBullets( { Attacker = p, @@ -157,18 +167,18 @@ AddItem( "base_firearm", { if ent:GetClip() >= class.ClipSize then return end if ent:GetDelay() > CurTime() then return end handler:EmitSound( "weapons/m4a1/m4a1_boltpull.wav", 70, 125, 0.4, CHAN_STATIC ) - ent:SetDelay( CurTime() + 0.5 ) + ent:SetDelay( CurTime() + 0.25 ) ent:SetClip( class.ClipSize ) end, ["Deploy"] = function( class, ent, handler ) handler:EmitSound( "weapons/usp/usp_slideback.wav", 70, 125, 0.4, CHAN_STATIC ) - ent:SetDelay( CurTime() + 0.5 ) + ent:SetDelay( CurTime() + 0.25 ) end, ["Holster"] = function( class, ent, handler ) handler:EmitSound( "weapons/m4a1/m4a1_deploy.wav", 70, 125, 0.4, CHAN_STATIC ) - ent:SetDelay( CurTime() + 0.5 ) + ent:SetDelay( CurTime() + 0.25 ) end, }) @@ -183,7 +193,11 @@ AddItem( "mk23", { ClipSize = 12, Delay = (60/350), - FireSound = "weapons/usp/usp_unsil-1.wav", + FireSound = { + "benny/weapons/usp/01.ogg", + "benny/weapons/usp/02.ogg", + "benny/weapons/usp/03.ogg", + }, Accuracy = 5/60, BurstCount = 1, @@ -202,7 +216,11 @@ AddItem( "fnc", { ClipSize = 30, Delay = (60/750), - FireSound = "weapons/m4a1/m4a1_unsil-1.wav", + FireSound = { + "benny/weapons/m16a2/fire-01.ogg", + "benny/weapons/m16a2/fire-02.ogg", + "benny/weapons/m16a2/fire-03.ogg", + }, Accuracy = 1, Accuracy_Add = 0.4, @@ -210,6 +228,56 @@ AddItem( "fnc", { Accuracy_Decay = 12, }) +AddItem( "m16a2", { + PrintName = "#Item.m16a2.Name", + Description = "#Item.m16a2.Description", + Base = "base_firearm", + + Model = "models/weapons/w_rif_ar556.mdl", + HoldType = "rpg", + + ClipSize = 30, + Delay = (60/900), + BurstCount = 3, + BurstRunaway = true, + BurstAuto = true, + BurstDelay = 0.2, + FireSound = { + "benny/weapons/m16a2/fire-01.ogg", + "benny/weapons/m16a2/fire-02.ogg", + "benny/weapons/m16a2/fire-03.ogg", + }, + + Accuracy = 1, + Accuracy_Add = 0.4, + Accuracy_Reset = 0.4, + Accuracy_Decay = 12, +}) + +AddItem( "spas12", { + PrintName = "#Item.spas12.Name", + Description = "#Item.spas12.Description", + Base = "base_firearm", + + Model = "models/weapons/w_shotgun.mdl", + HoldType = "rpg", + + ClipSize = 8, + Pellets = 8, + Delay = 0.4, + BurstCount = 1, + FireSound = { + "benny/weapons/spas12/01.ogg", + "benny/weapons/spas12/02.ogg", + "benny/weapons/spas12/03.ogg", + }, + + Accuracy = 8, + Accuracy_Add = 0.4, + Accuracy_Reset = 0.4, + Accuracy_Decay = 12, +}) + for ID, Data in pairs(ITEMS) do local tent = {} tent.Base = "b-itembase" diff --git a/gamemodes/benny/gamemode/languages/en-us.lua b/gamemodes/benny/gamemode/languages/en-us.lua index e4e3c4c..05c30dd 100644 --- a/gamemodes/benny/gamemode/languages/en-us.lua +++ b/gamemodes/benny/gamemode/languages/en-us.lua @@ -7,4 +7,10 @@ L["#Item.mk23.Name"] = "MK.23" L["#Item.mk23.Description"] = "Special forces sidearm" L["#Item.fnc.Name"] = "FNC Para" -L["#Item.fnc.Description"] = "Imported assault rifle" \ No newline at end of file +L["#Item.fnc.Description"] = "Imported assault rifle" + +L["#Item.m16a2.Name"] = "M16A2" +L["#Item.m16a2.Description"] = "Rugged burst rifle" + +L["#Item.spas12.Name"] = "SPAS-12" +L["#Item.spas12.Description"] = "Chrome-lined autoshotgun" \ No newline at end of file diff --git a/gamemodes/benny/gamemode/shared.lua b/gamemodes/benny/gamemode/shared.lua index db54393..bf51365 100644 --- a/gamemodes/benny/gamemode/shared.lua +++ b/gamemodes/benny/gamemode/shared.lua @@ -10,6 +10,10 @@ local AC, IN = AddCSLuaFile, include local CL = SERVER and AddCSLuaFile or include +function TSelShared( tbl, seed ) + return tbl[math.Round( util.SharedRandom( seed, 1, #tbl ) )] +end + AC("language.lua") IN("language.lua") AC("camera.lua")