diff --git a/gamemodes/benny/entities/weapons/benny/sh_firing.lua b/gamemodes/benny/entities/weapons/benny/sh_firing.lua index 3032ed3..2344295 100644 --- a/gamemodes/benny/entities/weapons/benny/sh_firing.lua +++ b/gamemodes/benny/entities/weapons/benny/sh_firing.lua @@ -44,7 +44,9 @@ function SWEP:BFire( hand ) return end - self:B_Ammo( hand, self:D_GetClip( hand ) - 1 ) + if !ConVarSV_Bool("cheat_infiniteammo") then + self:B_Ammo( hand, self:D_GetClip( hand ) - 1 ) + end B_Sound( self, wep_class.Sound_Fire ) self:TPFire( hand ) @@ -52,6 +54,8 @@ function SWEP:BFire( hand ) self:D_SetDelay( hand, CurTime() + wep_class.Delay ) self:D_SetBurst( hand, self:D_GetBurst( hand ) + 1 ) + self:D_SetSpread( hand, math.Clamp( self:D_GetSpread( hand ) + wep_class.SpreadAdd, 0, wep_class.SpreadAddMax ) ) + self:D_SetShotTime( hand, CurTime() ) if CLIENT and IsFirstTimePredicted() then @@ -76,7 +80,7 @@ end function SWEP:CallFire( hand ) local p = self:GetOwner() local class = self:BClass( hand ) - local spread = class.Spread or 0 + local spread = self:BSpread( hand ) for i=1, class.Pellets or 1 do local dir = self:GetOwner():EyeAngles() diff --git a/gamemodes/benny/entities/weapons/benny/sh_inv.lua b/gamemodes/benny/entities/weapons/benny/sh_inv.lua index 1f8eaed..8925232 100644 --- a/gamemodes/benny/entities/weapons/benny/sh_inv.lua +++ b/gamemodes/benny/entities/weapons/benny/sh_inv.lua @@ -35,6 +35,24 @@ function SWEP:D_SetBurst( hand, value ) return (hand == true) and self:SetWep2_Burst( value ) or (hand == false) and self:SetWep1_Burst( value ) end +-- Weapon Spread +function SWEP:D_GetSpread( hand ) + return (hand == true) and self:GetWep2_Spread() or (hand == false) and self:GetWep1_Spread() +end + +function SWEP:D_SetSpread( hand, value ) + return (hand == true) and self:SetWep2_Spread( value ) or (hand == false) and self:SetWep1_Spread( value ) +end + +-- Weapon Spread +function SWEP:D_GetShotTime( hand ) + return (hand == true) and self:GetWep2_ShotTime() or (hand == false) and self:GetWep1_ShotTime() +end + +function SWEP:D_SetShotTime( hand, value ) + return (hand == true) and self:SetWep2_ShotTime( value ) or (hand == false) and self:SetWep1_ShotTime( value ) +end + -- Internal SWEP Delay function SWEP:D_GetDelay( hand ) return (hand == true) and self:GetDelay2() or (hand == false) and self:GetDelay1() @@ -94,6 +112,8 @@ function SWEP:BDeploy( hand, id ) self:D_SetID( hand, id ) self:D_SetMagID( hand, "" ) self:D_SetClip( hand, 0 ) + self:D_SetSpread( hand, 0 ) + B_Sound( self, "Common.Deploy" ) if item.Loaded and item.Loaded != "" then local mid = item.Loaded local midi = inv[ mid ] @@ -112,6 +132,7 @@ function SWEP:BHolster( hand ) end local p = self:GetOwner() + B_Sound( self, "Common.Holster" ) local item = self:BTable( hand ) if item then local class = WeaponGet(item.Class) @@ -121,4 +142,9 @@ function SWEP:BHolster( hand ) self:D_SetID( hand, "" ) self:D_SetMagID( hand, "" ) self:D_SetClip( hand, 0 ) -end \ No newline at end of file +end + +function SWEP:BSpread( hand ) + return self:BClass( hand ).Spread + self:D_GetSpread( hand ) +end + diff --git a/gamemodes/benny/entities/weapons/benny/shared.lua b/gamemodes/benny/entities/weapons/benny/shared.lua index 9263a9b..0a69ba0 100644 --- a/gamemodes/benny/entities/weapons/benny/shared.lua +++ b/gamemodes/benny/entities/weapons/benny/shared.lua @@ -38,6 +38,10 @@ function SWEP:SetupDataTables() self:NetworkVar( "Float", 1, "Delay1" ) self:NetworkVar( "Float", 2, "Delay2" ) self:NetworkVar( "Float", 3, "GrenadeDownStart" ) + self:NetworkVar( "Float", 4, "Wep1_Spread" ) + self:NetworkVar( "Float", 5, "Wep2_Spread" ) + self:NetworkVar( "Float", 6, "Wep1_ShotTime" ) + self:NetworkVar( "Float", 7, "Wep2_ShotTime" ) self:NetworkVar( "String", 0, "Wep1" ) self:NetworkVar( "String", 1, "Wep2" ) self:NetworkVar( "String", 2, "Wep1_Clip" ) @@ -159,31 +163,33 @@ end hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_TempForAim", function( ply, button ) local wep = ply:BennyCheck() - - if button == KEY_F then - if tobool(ply:GetInfoNum("benny_wep_toggleaim", 1)) then - wep:SetUserAim( !wep:GetUserAim() ) - else - wep:SetUserAim( true ) + if wep then + if button == KEY_F then + if tobool(ply:GetInfoNum("benny_wep_toggleaim", 1)) then + wep:SetUserAim( !wep:GetUserAim() ) + else + wep:SetUserAim( true ) + end end - end - local dual = wep:C_DualCheck() - if button == KEY_R then - if dual then wep:Reload( true ) else wep:Reload( false ) end - end + local dual = wep:C_DualCheck() + if button == KEY_R then + if dual then wep:Reload( true ) else wep:Reload( false ) end + end - if button == KEY_T then - if dual then wep:Reload( false ) else wep:Reload( true ) end + if button == KEY_T then + if dual then wep:Reload( false ) else wep:Reload( true ) end + end end end) hook.Add( "PlayerButtonUp", "Benny_PlayerButtonUp_TempForAim", function( ply, button ) local wep = ply:BennyCheck() - - if button == KEY_F then - if !tobool(ply:GetInfoNum("benny_wep_toggleaim", 0)) then - wep:SetUserAim( false ) + if wep then + if button == KEY_F then + if !tobool(ply:GetInfoNum("benny_wep_toggleaim", 0)) then + wep:SetUserAim( false ) + end end end end) @@ -191,6 +197,11 @@ end) function SWEP:Think() local p = self:GetOwner() + local wep1 = self:BTable( false ) + local wep1c = self:BClass( false ) + local wep2 = self:BTable( true ) + local wep2c = self:BClass( true ) + self:SetAim( math.Approach( self:GetAim(), self:GetUserAim() and 1 or 0, FrameTime()/0.2 ) ) if !self:C_AttackDown( false ) then @@ -200,6 +211,13 @@ function SWEP:Think() self:SetWep2_Burst( 0 ) end + if wep1 and self:D_GetDelay( false ) < CurTime()-0.01 then + local mweh = math.Remap( CurTime(), self:D_GetShotTime( false ), self:D_GetShotTime( false )+wep1c.SpreadDecay_RampTime, 0, 1 ) + mweh = math.Clamp( mweh, 0, 1 ) + local decayfinal = Lerp( math.ease.InExpo( mweh ), wep1c.SpreadDecay_Start, wep1c.SpreadDecay_End ) + self:D_SetSpread( false, math.Approach( self:D_GetSpread( false ), 0, decayfinal * FrameTime() ) ) + end + local ht = "normal" if self:GetUserAim() then if self:BClass( false ) then diff --git a/gamemodes/benny/gamemode/modules/audio/sh_audio.lua b/gamemodes/benny/gamemode/modules/audio/sh_audio.lua index f1b8b7d..8fac4ae 100644 --- a/gamemodes/benny/gamemode/modules/audio/sh_audio.lua +++ b/gamemodes/benny/gamemode/modules/audio/sh_audio.lua @@ -38,8 +38,6 @@ RegisterCaption("Anaconda.Reload", "Anaconda", color_white, "[reload]", 0.1, 0.5 RegisterCaption("Nambu.Fire", "Nambu", color_white, "[fire]", 0.1, 0.5, false, true ) RegisterCaption("Nambu.Reload", "Nambu", color_white, "[reload]", 0.1, 0.5, false, true ) -CAPTIONS = CAPTIONS["en-us"] - SOUNDS = {} function AddSound( name, path, sndlevel, pitch, volume, channel ) @@ -71,4 +69,11 @@ function B_Sound( ent, tag ) MsgC( screwup, "No caption defined for " .. tag .. "\n" ) end end -end \ No newline at end of file +end + +AddSound( "Common.Deploy", "benny/weapons/common/06-07.ogg", 70, 100, 0.2, CHAN_STATIC ) +AddSound( "Common.Holster", "benny/weapons/common/06-09.ogg", 70, 100, 0.2, CHAN_STATIC ) +RegisterCaption("Common.Deploy", "DEBUG", color_white, "[deploy]", 0.1, 0.5, false, true ) +RegisterCaption("Common.Holster", "DEBUG", color_white, "[holster]", 0.1, 0.5, false, true ) + +CAPTIONS = CAPTIONS["en-us"] \ No newline at end of file diff --git a/gamemodes/benny/gamemode/modules/commons/sh_convars.lua b/gamemodes/benny/gamemode/modules/commons/sh_convars.lua index a63630d..5c3adaf 100644 --- a/gamemodes/benny/gamemode/modules/commons/sh_convars.lua +++ b/gamemodes/benny/gamemode/modules/commons/sh_convars.lua @@ -1,5 +1,5 @@ --- Meanings: Default, Min, Max, Replicated, Archived, Hint +-- Meanings: Default, Min, Max, Replicated, Archived, Hint -- Replicated is Userinfo in Client. CONVARS_SV = {} @@ -9,6 +9,8 @@ CONVARS_SV["cam_unlock"] = { 0, 0, 1, true, false, "First person (sort CONVARS_SV["net_easyway"] = { 0, 0, 1, true, false, "Use a disgusting way of networking inventories for minimal desync." } +CONVARS_SV["cheat_infiniteammo"] = { 0, 0, 1, true, false, "Cheat: Don't expend ammo." } + CONVARS_SV_GEN = {} for i, v in pairs( CONVARS_SV ) do