Inf ammo, spread, wip Dep/Hol sounds, fixes

This commit is contained in:
Fesiug 2023-12-06 20:56:36 -05:00
parent 8f95c022d6
commit 69d9e0afb5
5 changed files with 79 additions and 24 deletions

View File

@ -44,7 +44,9 @@ function SWEP:BFire( hand )
return return
end 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 ) B_Sound( self, wep_class.Sound_Fire )
self:TPFire( hand ) self:TPFire( hand )
@ -52,6 +54,8 @@ function SWEP:BFire( hand )
self:D_SetDelay( hand, CurTime() + wep_class.Delay ) self:D_SetDelay( hand, CurTime() + wep_class.Delay )
self:D_SetBurst( hand, self:D_GetBurst( hand ) + 1 ) 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 if CLIENT and IsFirstTimePredicted() then
@ -76,7 +80,7 @@ end
function SWEP:CallFire( hand ) function SWEP:CallFire( hand )
local p = self:GetOwner() local p = self:GetOwner()
local class = self:BClass( hand ) local class = self:BClass( hand )
local spread = class.Spread or 0 local spread = self:BSpread( hand )
for i=1, class.Pellets or 1 do for i=1, class.Pellets or 1 do
local dir = self:GetOwner():EyeAngles() local dir = self:GetOwner():EyeAngles()

View File

@ -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 ) return (hand == true) and self:SetWep2_Burst( value ) or (hand == false) and self:SetWep1_Burst( value )
end 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 -- Internal SWEP Delay
function SWEP:D_GetDelay( hand ) function SWEP:D_GetDelay( hand )
return (hand == true) and self:GetDelay2() or (hand == false) and self:GetDelay1() 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_SetID( hand, id )
self:D_SetMagID( hand, "" ) self:D_SetMagID( hand, "" )
self:D_SetClip( hand, 0 ) self:D_SetClip( hand, 0 )
self:D_SetSpread( hand, 0 )
B_Sound( self, "Common.Deploy" )
if item.Loaded and item.Loaded != "" then if item.Loaded and item.Loaded != "" then
local mid = item.Loaded local mid = item.Loaded
local midi = inv[ mid ] local midi = inv[ mid ]
@ -112,6 +132,7 @@ function SWEP:BHolster( hand )
end end
local p = self:GetOwner() local p = self:GetOwner()
B_Sound( self, "Common.Holster" )
local item = self:BTable( hand ) local item = self:BTable( hand )
if item then if item then
local class = WeaponGet(item.Class) local class = WeaponGet(item.Class)
@ -122,3 +143,8 @@ function SWEP:BHolster( hand )
self:D_SetMagID( hand, "" ) self:D_SetMagID( hand, "" )
self:D_SetClip( hand, 0 ) self:D_SetClip( hand, 0 )
end end
function SWEP:BSpread( hand )
return self:BClass( hand ).Spread + self:D_GetSpread( hand )
end

View File

@ -38,6 +38,10 @@ function SWEP:SetupDataTables()
self:NetworkVar( "Float", 1, "Delay1" ) self:NetworkVar( "Float", 1, "Delay1" )
self:NetworkVar( "Float", 2, "Delay2" ) self:NetworkVar( "Float", 2, "Delay2" )
self:NetworkVar( "Float", 3, "GrenadeDownStart" ) 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", 0, "Wep1" )
self:NetworkVar( "String", 1, "Wep2" ) self:NetworkVar( "String", 1, "Wep2" )
self:NetworkVar( "String", 2, "Wep1_Clip" ) self:NetworkVar( "String", 2, "Wep1_Clip" )
@ -159,31 +163,33 @@ end
hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_TempForAim", function( ply, button ) hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_TempForAim", function( ply, button )
local wep = ply:BennyCheck() local wep = ply:BennyCheck()
if wep then
if button == KEY_F then if button == KEY_F then
if tobool(ply:GetInfoNum("benny_wep_toggleaim", 1)) then if tobool(ply:GetInfoNum("benny_wep_toggleaim", 1)) then
wep:SetUserAim( !wep:GetUserAim() ) wep:SetUserAim( !wep:GetUserAim() )
else else
wep:SetUserAim( true ) wep:SetUserAim( true )
end
end end
end
local dual = wep:C_DualCheck() local dual = wep:C_DualCheck()
if button == KEY_R then if button == KEY_R then
if dual then wep:Reload( true ) else wep:Reload( false ) end if dual then wep:Reload( true ) else wep:Reload( false ) end
end end
if button == KEY_T then if button == KEY_T then
if dual then wep:Reload( false ) else wep:Reload( true ) end if dual then wep:Reload( false ) else wep:Reload( true ) end
end
end end
end) end)
hook.Add( "PlayerButtonUp", "Benny_PlayerButtonUp_TempForAim", function( ply, button ) hook.Add( "PlayerButtonUp", "Benny_PlayerButtonUp_TempForAim", function( ply, button )
local wep = ply:BennyCheck() local wep = ply:BennyCheck()
if wep then
if button == KEY_F then if button == KEY_F then
if !tobool(ply:GetInfoNum("benny_wep_toggleaim", 0)) then if !tobool(ply:GetInfoNum("benny_wep_toggleaim", 0)) then
wep:SetUserAim( false ) wep:SetUserAim( false )
end
end end
end end
end) end)
@ -191,6 +197,11 @@ end)
function SWEP:Think() function SWEP:Think()
local p = self:GetOwner() 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 ) ) self:SetAim( math.Approach( self:GetAim(), self:GetUserAim() and 1 or 0, FrameTime()/0.2 ) )
if !self:C_AttackDown( false ) then if !self:C_AttackDown( false ) then
@ -200,6 +211,13 @@ function SWEP:Think()
self:SetWep2_Burst( 0 ) self:SetWep2_Burst( 0 )
end 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" local ht = "normal"
if self:GetUserAim() then if self:GetUserAim() then
if self:BClass( false ) then if self:BClass( false ) then

View File

@ -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.Fire", "Nambu", color_white, "[fire]", 0.1, 0.5, false, true )
RegisterCaption("Nambu.Reload", "Nambu", color_white, "[reload]", 0.1, 0.5, false, true ) RegisterCaption("Nambu.Reload", "Nambu", color_white, "[reload]", 0.1, 0.5, false, true )
CAPTIONS = CAPTIONS["en-us"]
SOUNDS = {} SOUNDS = {}
function AddSound( name, path, sndlevel, pitch, volume, channel ) function AddSound( name, path, sndlevel, pitch, volume, channel )
@ -72,3 +70,10 @@ function B_Sound( ent, tag )
end end
end end
end 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"]

View File

@ -1,5 +1,5 @@
-- Meanings: Default, Min, Max, Replicated, Archived, Hint -- Meanings: Default, Min, Max, Replicated, Archived, Hint
-- Replicated is Userinfo in Client. -- Replicated is Userinfo in Client.
CONVARS_SV = {} 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["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 = {} CONVARS_SV_GEN = {}
for i, v in pairs( CONVARS_SV ) do for i, v in pairs( CONVARS_SV ) do