Touch up weapon class code pt.1
This commit is contained in:
parent
c0b0157797
commit
fd5ebda7be
|
@ -29,36 +29,36 @@ function SWEP:BFire( hand )
|
||||||
if wep_class.Custom_Fire then
|
if wep_class.Custom_Fire then
|
||||||
if wep_class.Custom_Fire( self, wep_table, wep_class, hand ) then return end
|
if wep_class.Custom_Fire( self, wep_table, wep_class, hand ) then return end
|
||||||
end
|
end
|
||||||
if self:D_GetDelay( hand ) > CurTime() then
|
if self:bGetIntDelay( hand ) > CurTime() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if self:D_GetHolstering( hand ) > 0 then
|
if self:bGetHolsterTime( hand ) > 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if self:D_GetClip( hand ) == 0 then
|
if self:bGetIntClip( hand ) == 0 then
|
||||||
if self:D_GetBurst( hand ) >= 1 then
|
if self:bGetBurst( hand ) >= 1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
B_Sound( self, wep_class.Sound_DryFire )
|
B_Sound( self, wep_class.Sound_DryFire )
|
||||||
self:D_SetBurst( hand, self:D_GetBurst( hand ) + 1 )
|
self:bSetBurst( hand, self:bGetBurst( hand ) + 1 )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if self:D_GetBurst( hand ) >= self:B_Firemode( hand ).Mode then
|
if self:bGetBurst( hand ) >= self:B_Firemode( hand ).Mode then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if !ConVarSV_Bool("cheat_infiniteammo") then
|
if !ConVarSV_Bool("cheat_infiniteammo") then
|
||||||
self:B_Ammo( hand, self:D_GetClip( hand ) - 1 )
|
self:B_Ammo( hand, self:bGetIntClip( hand ) - 1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
B_Sound( self, wep_class.Sound_Fire )
|
B_Sound( self, wep_class.Sound_Fire )
|
||||||
self:TPFire( hand )
|
self:TPFire( hand )
|
||||||
self:CallFire( hand )
|
self:CallFire( hand )
|
||||||
|
|
||||||
self:D_SetDelay( hand, CurTime() + wep_class.Delay )
|
self:bSetIntDelay( hand, CurTime() + wep_class.Delay )
|
||||||
self:D_SetBurst( hand, self:D_GetBurst( hand ) + 1 )
|
self:bSetBurst( hand, self:bGetBurst( hand ) + 1 )
|
||||||
self:D_SetSpread( hand, math.Clamp( self:D_GetSpread( hand ) + wep_class.SpreadAdd, 0, wep_class.SpreadAddMax ) )
|
self:bSetSpread( hand, math.Clamp( self:bGetSpread( hand ) + wep_class.SpreadAdd, 0, wep_class.SpreadAddMax ) )
|
||||||
self:D_SetShotTime( hand, CurTime() )
|
self:bSetShotTime( hand, CurTime() )
|
||||||
|
|
||||||
|
|
||||||
if CLIENT and IsFirstTimePredicted() then
|
if CLIENT and IsFirstTimePredicted() then
|
||||||
|
@ -80,7 +80,7 @@ function SWEP:CallFire( hand )
|
||||||
local p = self:GetOwner()
|
local p = self:GetOwner()
|
||||||
local class = self:BClass( hand )
|
local class = self:BClass( hand )
|
||||||
local spread = self:BSpread( hand )
|
local spread = self:BSpread( hand )
|
||||||
for i=1, class.Pellets or 1 do
|
for i=1, self:GetStat( hand, "Pellets" ) do
|
||||||
local dir = self:GetOwner():EyeAngles()
|
local dir = self:GetOwner():EyeAngles()
|
||||||
|
|
||||||
local radius = util.SharedRandom("benny_distance_"..tostring(hand), 0, 1, i )
|
local radius = util.SharedRandom("benny_distance_"..tostring(hand), 0, 1, i )
|
||||||
|
@ -98,7 +98,7 @@ function SWEP:CallFire( hand )
|
||||||
self:FireBullets( {
|
self:FireBullets( {
|
||||||
Attacker = p,
|
Attacker = p,
|
||||||
Damage = class.Damage,
|
Damage = class.Damage,
|
||||||
Force = class.Damage/10,
|
Force = ( class.Damage / 10 ) * self:GetStat( hand, "Pellets" ),
|
||||||
Src = p:EyePos(),
|
Src = p:EyePos(),
|
||||||
Dir = dir:Forward(),
|
Dir = dir:Forward(),
|
||||||
Tracer = 0,
|
Tracer = 0,
|
||||||
|
|
|
@ -1,131 +1,4 @@
|
||||||
|
|
||||||
-- Weapon ID
|
|
||||||
function SWEP:D_GetID( hand )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:GetWep2() or (hand == false) and self:GetWep1()
|
|
||||||
end
|
|
||||||
|
|
||||||
function SWEP:D_SetID( hand, value )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:SetWep2( value ) or (hand == false) and self:SetWep1( value )
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Wep. Clip ID
|
|
||||||
function SWEP:D_GetMagID( hand )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:GetWep2_Clip() or (hand == false) and self:GetWep1_Clip()
|
|
||||||
end
|
|
||||||
|
|
||||||
function SWEP:D_SetMagID( hand, value )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:SetWep2_Clip( value ) or (hand == false) and self:SetWep1_Clip( value )
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Weapon Firemode
|
|
||||||
function SWEP:D_GetFiremode( hand )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:GetWep2_Firemode() or (hand == false) and self:GetWep1_Firemode()
|
|
||||||
end
|
|
||||||
|
|
||||||
function SWEP:D_SetFiremode( hand, value )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:SetWep2_Firemode( value ) or (hand == false) and self:SetWep1_Firemode( value )
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Weapon Burst
|
|
||||||
function SWEP:D_GetBurst( hand )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:GetWep2_Burst() or (hand == false) and self:GetWep1_Burst()
|
|
||||||
end
|
|
||||||
|
|
||||||
function SWEP:D_SetBurst( hand, value )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:SetWep2_Burst( value ) or (hand == false) and self:SetWep1_Burst( value )
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Weapon Spread
|
|
||||||
function SWEP:D_GetSpread( hand )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:GetWep2_Spread() or (hand == false) and self:GetWep1_Spread()
|
|
||||||
end
|
|
||||||
|
|
||||||
function SWEP:D_SetSpread( hand, value )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:SetWep2_Spread( value ) or (hand == false) and self:SetWep1_Spread( value )
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Weapon Spread
|
|
||||||
function SWEP:D_GetShotTime( hand )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:GetWep2_ShotTime() or (hand == false) and self:GetWep1_ShotTime()
|
|
||||||
end
|
|
||||||
|
|
||||||
function SWEP:D_SetShotTime( hand, value )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:SetWep2_ShotTime( value ) or (hand == false) and self:SetWep1_ShotTime( value )
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Weapon Holstering Time
|
|
||||||
function SWEP:D_GetHolstering( hand )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:GetWep2_Holstering() or (hand == false) and self:GetWep1_Holstering()
|
|
||||||
end
|
|
||||||
|
|
||||||
function SWEP:D_SetHolstering( hand, value )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:SetWep2_Holstering( value ) or (hand == false) and self:SetWep1_Holstering( value )
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Weapon Reloading Time
|
|
||||||
function SWEP:D_GetReloading( hand )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:GetWep2_Reloading() or (hand == false) and self:GetWep1_Reloading()
|
|
||||||
end
|
|
||||||
|
|
||||||
function SWEP:D_SetReloading( hand, value )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:SetWep2_Reloading( value ) or (hand == false) and self:SetWep1_Reloading( value )
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Weapon Reload Type
|
|
||||||
function SWEP:D_GetReloadType( hand )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:GetWep2_ReloadType() or (hand == false) and self:GetWep1_ReloadType()
|
|
||||||
end
|
|
||||||
|
|
||||||
function SWEP:D_SetReloadType( hand, value )
|
|
||||||
assert( hand!=nil, "Missing hand argument" )
|
|
||||||
return (hand == true) and self:SetWep2_ReloadType( value ) or (hand == false) and self:SetWep1_ReloadType( value )
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Weapon Player Requesting ID
|
|
||||||
function SWEP:D_GetReqID( hand )
|
|
||||||
local p = self:GetOwner()
|
|
||||||
return (hand == true) and p:GetReqID2() or (hand == false) and p:GetReqID1()
|
|
||||||
end
|
|
||||||
|
|
||||||
function SWEP:D_SetReqID( hand, value )
|
|
||||||
local p = self:GetOwner()
|
|
||||||
return (hand == true) and p:SetReqID2( value ) or (hand == false) and p:SetReqID1( value )
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Internal SWEP Delay
|
|
||||||
function SWEP:D_GetDelay( hand )
|
|
||||||
return (hand == true) and self:GetDelay2() or (hand == false) and self:GetDelay1()
|
|
||||||
end
|
|
||||||
|
|
||||||
function SWEP:D_SetDelay( hand, value )
|
|
||||||
return (hand == true) and self:SetDelay2( value ) or (hand == false) and self:SetDelay1( value )
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Internal SWEP Clip
|
|
||||||
function SWEP:D_GetClip( hand )
|
|
||||||
return (hand == true) and self:Clip2() or (hand == false) and self:Clip1()
|
|
||||||
end
|
|
||||||
|
|
||||||
function SWEP:D_SetClip( hand, value )
|
|
||||||
return (hand == true) and self:SetClip2( value ) or (hand == false) and self:SetClip1( value )
|
|
||||||
end
|
|
||||||
|
|
||||||
local fallbackstat = {
|
local fallbackstat = {
|
||||||
["Reload_MagOut"] = 0.2,
|
["Reload_MagOut"] = 0.2,
|
||||||
|
@ -188,10 +61,10 @@ end
|
||||||
function SWEP:BDeploy( hand, id )
|
function SWEP:BDeploy( hand, id )
|
||||||
assert( isbool(hand), "You forgot the hand." )
|
assert( isbool(hand), "You forgot the hand." )
|
||||||
assert( isstring(id), "You forgot the ID." )
|
assert( isstring(id), "You forgot the ID." )
|
||||||
if self:D_GetID( hand ) == id then
|
if self:bGetInvID( hand ) == id then
|
||||||
-- This breaks prediction somewhat!!
|
-- This breaks prediction somewhat!!
|
||||||
-- return -- PROTO: If you're in the middle of holstering, cancel it
|
-- return -- PROTO: If you're in the middle of holstering, cancel it
|
||||||
elseif self:D_GetID( hand ) != "" then
|
elseif self:bGetInvID( hand ) != "" then
|
||||||
return--self:BHolster( hand )
|
return--self:BHolster( hand )
|
||||||
end
|
end
|
||||||
local p = self:GetOwner()
|
local p = self:GetOwner()
|
||||||
|
@ -202,11 +75,11 @@ function SWEP:BDeploy( hand, id )
|
||||||
|
|
||||||
assert( item, "That item doesn't exist. " .. tostring(item) )
|
assert( item, "That item doesn't exist. " .. tostring(item) )
|
||||||
|
|
||||||
self:D_SetID( hand, id )
|
self:bSetInvID( hand, id )
|
||||||
self:D_SetMagID( hand, "" )
|
self:bSetMagInvID( hand, "" )
|
||||||
self:D_SetClip( hand, 0 )
|
self:bSetIntClip( hand, 0 )
|
||||||
self:D_SetSpread( hand, 0 )
|
self:bSetSpread( hand, 0 )
|
||||||
self:D_SetDelay( hand, CurTime() + 0.35 )
|
self:bSetIntDelay( hand, CurTime() + 0.35 )
|
||||||
B_Sound( self, "Common.Deploy" )
|
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
|
||||||
|
@ -215,13 +88,13 @@ function SWEP:BDeploy( hand, id )
|
||||||
item.Loaded = ""
|
item.Loaded = ""
|
||||||
error( "Deploy: Magazine doesn't exist in the inventory!! " .. tostring(mid) .. " item.Loaded removed." )
|
error( "Deploy: Magazine doesn't exist in the inventory!! " .. tostring(mid) .. " item.Loaded removed." )
|
||||||
end
|
end
|
||||||
self:D_SetMagID( hand, mid )
|
self:bSetMagInvID( hand, mid )
|
||||||
self:D_SetClip( hand, midi.Ammo )
|
self:bSetIntClip( hand, midi.Ammo )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function SWEP:BHolster( hand )
|
function SWEP:BHolster( hand )
|
||||||
if self:D_GetID( hand ) == "" then
|
if self:bGetInvID( hand ) == "" then
|
||||||
return -- What the hell are you holstering..?
|
return -- What the hell are you holstering..?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -233,12 +106,12 @@ function SWEP:BHolster( hand )
|
||||||
if class.Custom_Holster then class.Custom_Holster( self, item, class, hand ) end
|
if class.Custom_Holster then class.Custom_Holster( self, item, class, hand ) end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:D_SetID( hand, "" )
|
self:bSetInvID( hand, "" )
|
||||||
self:D_SetMagID( hand, "" )
|
self:bSetMagInvID( hand, "" )
|
||||||
self:D_SetClip( hand, 0 )
|
self:bSetIntClip( hand, 0 )
|
||||||
end
|
end
|
||||||
|
|
||||||
function SWEP:BSpread( hand )
|
function SWEP:BSpread( hand )
|
||||||
return self:BClass( hand ).Spread + self:D_GetSpread( hand )
|
return self:BClass( hand ).Spread + self:bGetSpread( hand )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,20 +11,20 @@ function SWEP:Reload( hand )
|
||||||
if wep_class.Custom_Reload then
|
if wep_class.Custom_Reload then
|
||||||
if wep_class.Custom_Reload( self, wep_table ) then return end
|
if wep_class.Custom_Reload( self, wep_table ) then return end
|
||||||
end
|
end
|
||||||
if self:D_GetDelay( hand ) > CurTime() then
|
if self:bGetIntDelay( hand ) > CurTime() then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local rt = self:D_GetReloading( hand )
|
local rt = self:bGetReloadTime( hand )
|
||||||
if rt > 0 then
|
if rt > 0 then
|
||||||
local rtt = self:D_GetReloadType( hand )
|
local rtt = self:bGetReloadType( hand )
|
||||||
-- TODO: Unshitify this.
|
-- TODO: Unshitify this.
|
||||||
if rtt == 1 then
|
if rtt == 1 then
|
||||||
if (rt+self:GetStat( hand, "Reload_MagIn_Bonus1" )) <= RealTime() and RealTime() <= (rt+self:GetStat( hand, "Reload_MagIn_Bonus2" )) then
|
if (rt+self:GetStat( hand, "Reload_MagIn_Bonus1" )) <= RealTime() and RealTime() <= (rt+self:GetStat( hand, "Reload_MagIn_Bonus2" )) then
|
||||||
self:D_SetReloading( hand, 0 )
|
self:bSetReloadTime( hand, 0 )
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
B_Sound( self, "Common.ReloadFail" )
|
B_Sound( self, "Common.ReloadFail" )
|
||||||
self:D_SetReloading( hand, RealTime() )
|
self:bSetReloadTime( hand, RealTime() )
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -32,15 +32,15 @@ function SWEP:Reload( hand )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local curmag = self:D_GetMagID( hand )
|
local curmag = self:bGetMagInvID( hand )
|
||||||
if curmag != "" then
|
if curmag != "" then
|
||||||
self:D_SetReloading( hand, RealTime() )
|
self:bSetReloadTime( hand, RealTime() )
|
||||||
self:D_SetReloadType( hand, 2 )
|
self:bSetReloadType( hand, 2 )
|
||||||
B_Sound( self, wep_class.Sound_MagOut )
|
B_Sound( self, wep_class.Sound_MagOut )
|
||||||
self:Reload_MagOut( hand, self:D_GetMagID( hand ), inv )
|
self:Reload_MagOut( hand, self:bGetMagInvID( hand ), inv )
|
||||||
elseif self:GetBestLoadableMagazine( hand, wep_table.Class, inv, wep_table ) then
|
elseif self:GetBestLoadableMagazine( hand, wep_table.Class, inv, wep_table ) then
|
||||||
self:D_SetReloading( hand, RealTime() )
|
self:bSetReloadTime( hand, RealTime() )
|
||||||
self:D_SetReloadType( hand, 1 )
|
self:bSetReloadType( hand, 1 )
|
||||||
B_Sound( self, wep_class.Sound_MagIn )
|
B_Sound( self, wep_class.Sound_MagIn )
|
||||||
else
|
else
|
||||||
B_Sound( self, "Common.NoAmmo" )
|
B_Sound( self, "Common.NoAmmo" )
|
||||||
|
@ -59,7 +59,7 @@ function SWEP:Reload_MagOut( hand, curmag, optinv, optwep_table, optwep_class )
|
||||||
if !inv[curmag] then
|
if !inv[curmag] then
|
||||||
-- PROTO: This happens sometimes. I'm commenting it so it doesn't look like anything broke, because it didn't.
|
-- PROTO: This happens sometimes. I'm commenting it so it doesn't look like anything broke, because it didn't.
|
||||||
-- ErrorNoHalt( "Mag isn't a valid item" )
|
-- ErrorNoHalt( "Mag isn't a valid item" )
|
||||||
self:D_SetMagID( hand, "" )
|
self:bSetMagInvID( hand, "" )
|
||||||
wep_table.Loaded = ""
|
wep_table.Loaded = ""
|
||||||
elseif inv[curmag].Ammo == 0 then
|
elseif inv[curmag].Ammo == 0 then
|
||||||
if SERVER or (CLIENT and IsFirstTimePredicted()) then
|
if SERVER or (CLIENT and IsFirstTimePredicted()) then
|
||||||
|
@ -67,8 +67,8 @@ function SWEP:Reload_MagOut( hand, curmag, optinv, optwep_table, optwep_class )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:D_SetMagID( hand, "" )
|
self:bSetMagInvID( hand, "" )
|
||||||
self:D_SetClip( hand, 0 )
|
self:bSetIntClip( hand, 0 )
|
||||||
--B_Sound( self, wep_class.Sound_MagOut )
|
--B_Sound( self, wep_class.Sound_MagOut )
|
||||||
wep_table.Loaded = ""
|
wep_table.Loaded = ""
|
||||||
end
|
end
|
||||||
|
@ -122,8 +122,8 @@ function SWEP:Reload_MagIn( hand, curmag, optinv, optwep_table, optwep_class )
|
||||||
local mag = self:GetBestLoadableMagazine( hand, wep_table.Class )
|
local mag = self:GetBestLoadableMagazine( hand, wep_table.Class )
|
||||||
|
|
||||||
if mag then
|
if mag then
|
||||||
self:D_SetMagID( hand, mag )
|
self:bSetMagInvID( hand, mag )
|
||||||
self:D_SetClip( hand, inv[mag].Ammo )
|
self:bSetIntClip( hand, inv[mag].Ammo )
|
||||||
wep_table.Loaded = mag
|
wep_table.Loaded = mag
|
||||||
B_Sound( self, wep_class.Sound_Cock )
|
B_Sound( self, wep_class.Sound_Cock )
|
||||||
else
|
else
|
||||||
|
|
|
@ -0,0 +1,130 @@
|
||||||
|
|
||||||
|
-- Stat2
|
||||||
|
|
||||||
|
-- Weapon ID
|
||||||
|
function SWEP:bGetInvID( hand )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:GetWep2() or (hand == false) and self:GetWep1()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:bSetInvID( hand, value )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:SetWep2( value ) or (hand == false) and self:SetWep1( value )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Wep. Clip ID
|
||||||
|
function SWEP:bGetMagInvID( hand )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:GetWep2_Clip() or (hand == false) and self:GetWep1_Clip()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:bSetMagInvID( hand, value )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:SetWep2_Clip( value ) or (hand == false) and self:SetWep1_Clip( value )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Weapon Firemode
|
||||||
|
function SWEP:bGetFiremode( hand )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:GetWep2_Firemode() or (hand == false) and self:GetWep1_Firemode()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:bSetFiremode( hand, value )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:SetWep2_Firemode( value ) or (hand == false) and self:SetWep1_Firemode( value )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Weapon Burst
|
||||||
|
function SWEP:bGetBurst( hand )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:GetWep2_Burst() or (hand == false) and self:GetWep1_Burst()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:bSetBurst( hand, value )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:SetWep2_Burst( value ) or (hand == false) and self:SetWep1_Burst( value )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Weapon Spread
|
||||||
|
function SWEP:bGetSpread( hand )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:GetWep2_Spread() or (hand == false) and self:GetWep1_Spread()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:bSetSpread( hand, value )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:SetWep2_Spread( value ) or (hand == false) and self:SetWep1_Spread( value )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Weapon Spread
|
||||||
|
function SWEP:bGetShotTime( hand )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:GetWep2_ShotTime() or (hand == false) and self:GetWep1_ShotTime()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:bSetShotTime( hand, value )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:SetWep2_ShotTime( value ) or (hand == false) and self:SetWep1_ShotTime( value )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Weapon Holstering Time
|
||||||
|
function SWEP:bGetHolsterTime( hand )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:GetWep2_Holstering() or (hand == false) and self:GetWep1_Holstering()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:bSetHolsterTime( hand, value )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:SetWep2_Holstering( value ) or (hand == false) and self:SetWep1_Holstering( value )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Weapon Reloading Time
|
||||||
|
function SWEP:bGetReloadTime( hand )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:GetWep2_Reloading() or (hand == false) and self:GetWep1_Reloading()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:bSetReloadTime( hand, value )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:SetWep2_Reloading( value ) or (hand == false) and self:SetWep1_Reloading( value )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Weapon Reload Type
|
||||||
|
function SWEP:bGetReloadType( hand )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:GetWep2_ReloadType() or (hand == false) and self:GetWep1_ReloadType()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:bSetReloadType( hand, value )
|
||||||
|
assert( hand!=nil, "Missing hand argument" )
|
||||||
|
return (hand == true) and self:SetWep2_ReloadType( value ) or (hand == false) and self:SetWep1_ReloadType( value )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Weapon Player Requesting ID
|
||||||
|
function SWEP:bGetReqInvID( hand )
|
||||||
|
local p = self:GetOwner()
|
||||||
|
return (hand == true) and p:GetReqID2() or (hand == false) and p:GetReqID1()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:bSetReqInvID( hand, value )
|
||||||
|
local p = self:GetOwner()
|
||||||
|
return (hand == true) and p:SetReqID2( value ) or (hand == false) and p:SetReqID1( value )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Internal SWEP Delay
|
||||||
|
function SWEP:bGetIntDelay( hand )
|
||||||
|
return (hand == true) and self:GetDelay2() or (hand == false) and self:GetDelay1()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:bSetIntDelay( hand, value )
|
||||||
|
return (hand == true) and self:SetDelay2( value ) or (hand == false) and self:SetDelay1( value )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Internal SWEP Clip
|
||||||
|
function SWEP:bGetIntClip( hand )
|
||||||
|
return (hand == true) and self:Clip2() or (hand == false) and self:Clip1()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:bSetIntClip( hand, value )
|
||||||
|
return (hand == true) and self:SetClip2( value ) or (hand == false) and self:SetClip1( value )
|
||||||
|
end
|
|
@ -25,6 +25,8 @@ AddCSLuaFile( "sh_firing.lua" )
|
||||||
include ( "sh_firing.lua" )
|
include ( "sh_firing.lua" )
|
||||||
AddCSLuaFile( "sh_inv.lua" )
|
AddCSLuaFile( "sh_inv.lua" )
|
||||||
include ( "sh_inv.lua" )
|
include ( "sh_inv.lua" )
|
||||||
|
AddCSLuaFile( "sh_stat2.lua" )
|
||||||
|
include ( "sh_stat2.lua" )
|
||||||
AddCSLuaFile( "sh_holdtypes.lua" )
|
AddCSLuaFile( "sh_holdtypes.lua" )
|
||||||
include ( "sh_holdtypes.lua" )
|
include ( "sh_holdtypes.lua" )
|
||||||
AddCSLuaFile( "sh_reload.lua" )
|
AddCSLuaFile( "sh_reload.lua" )
|
||||||
|
@ -79,7 +81,7 @@ end
|
||||||
function SWEP:BClass( alt )
|
function SWEP:BClass( alt )
|
||||||
local ta = self:BTable( alt )
|
local ta = self:BTable( alt )
|
||||||
if ta then
|
if ta then
|
||||||
return WEAPONS[ ta.Class ]
|
return WeaponGet( ta.Class )
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -88,13 +90,13 @@ end
|
||||||
function SWEP:B_Ammo( hand, value )
|
function SWEP:B_Ammo( hand, value )
|
||||||
local p = self:GetOwner()
|
local p = self:GetOwner()
|
||||||
local inv = p:INV_Get()
|
local inv = p:INV_Get()
|
||||||
self:D_SetClip( hand, value )
|
self:bSetIntClip( hand, value )
|
||||||
assert( self:D_GetMagID( hand ) != "", "There is no magazine loaded!" )
|
assert( self:bGetMagInvID( hand ) != "", "There is no magazine loaded!" )
|
||||||
inv[ self:D_GetMagID( hand ) ].Ammo = value
|
inv[ self:bGetMagInvID( hand ) ].Ammo = value
|
||||||
end
|
end
|
||||||
|
|
||||||
function SWEP:B_Firemode( alt )
|
function SWEP:B_Firemode( alt )
|
||||||
return self:BClass( alt ).Firemodes[ self:D_GetFiremode( alt ) ]
|
return self:BClass( alt ).Firemodes[ self:bGetFiremode( alt ) ]
|
||||||
end
|
end
|
||||||
|
|
||||||
function SWEP:B_FiremodeName( alt )
|
function SWEP:B_FiremodeName( alt )
|
||||||
|
@ -142,26 +144,26 @@ hook.Add( "PlayerButtonUp", "Benny_PlayerButtonUp_TempForAim", function( ply, bu
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function SWEP:BStartHolster( hand )
|
function SWEP:BStartHolster( hand )
|
||||||
if self:D_GetHolstering( hand ) == -1 then
|
if self:bGetHolsterTime( hand ) == -1 then
|
||||||
B_Sound( self, "Common.Holster" )
|
B_Sound( self, "Common.Holster" )
|
||||||
-- print( "Holstering the " .. (hand and "LEFT" or "RIGHT") )
|
-- print( "Holstering the " .. (hand and "LEFT" or "RIGHT") )
|
||||||
self:D_SetHolstering( hand, 0 )
|
self:bSetHolsterTime( hand, 0 )
|
||||||
self:D_SetReloading( hand, -1 )
|
self:bSetReloadTime( hand, -1 )
|
||||||
self:D_SetReloadType( hand, 0 )
|
self:bSetReloadType( hand, 0 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function SWEP:BThinkHolster( hand )
|
function SWEP:BThinkHolster( hand )
|
||||||
if self:D_GetHolstering( hand ) >= 0 then
|
if self:bGetHolsterTime( hand ) >= 0 then
|
||||||
self:D_SetHolstering( hand, math.Approach( self:D_GetHolstering( hand ), 1, FrameTime() / 0.35 ) )
|
self:bSetHolsterTime( hand, math.Approach( self:bGetHolsterTime( hand ), 1, FrameTime() / 0.35 ) )
|
||||||
end
|
end
|
||||||
if self:D_GetHolstering( hand ) == 1 then
|
if self:bGetHolsterTime( hand ) == 1 then
|
||||||
self:D_SetHolstering( hand, -1 )
|
self:bSetHolsterTime( hand, -1 )
|
||||||
self:D_SetReloading( hand, -1 )
|
self:bSetReloadTime( hand, -1 )
|
||||||
self:D_SetReloadType( hand, 0 )
|
self:bSetReloadType( hand, 0 )
|
||||||
self:BHolster( hand )
|
self:BHolster( hand )
|
||||||
local p = self:GetOwner()
|
local p = self:GetOwner()
|
||||||
local req = self:D_GetReqID( hand )
|
local req = self:bGetReqInvID( hand )
|
||||||
local inv = p:INV_Get()
|
local inv = p:INV_Get()
|
||||||
if req != "" and inv[req] then
|
if req != "" and inv[req] then
|
||||||
self:BDeploy( hand, req )
|
self:BDeploy( hand, req )
|
||||||
|
@ -178,25 +180,25 @@ function SWEP:Think()
|
||||||
local wep2 = self:BTable( true )
|
local wep2 = self:BTable( true )
|
||||||
local wep2c = self:BClass( true )
|
local wep2c = self:BClass( true )
|
||||||
|
|
||||||
if self:D_GetReqID( false ) != "" and self:D_GetReqID( true ) != "" and self:D_GetReqID( false ) == self:D_GetReqID( true ) then
|
if self:bGetReqInvID( false ) != "" and self:bGetReqInvID( true ) != "" and self:bGetReqInvID( false ) == self:bGetReqInvID( true ) then
|
||||||
self:D_SetReqID( false, "" )
|
self:bSetReqInvID( false, "" )
|
||||||
self:D_SetReqID( true, "" )
|
self:bSetReqInvID( true, "" )
|
||||||
if CLIENT then chat.AddText( "Same weapons on ReqID, both holstered" ) end
|
if CLIENT then chat.AddText( "Same weapons on ReqID, both holstered" ) end
|
||||||
end
|
end
|
||||||
for i=1, 2 do
|
for i=1, 2 do
|
||||||
local hand = i==2
|
local hand = i==2
|
||||||
if self:D_GetReqID( hand ) != "" and !inv[self:D_GetReqID( hand )] then
|
if self:bGetReqInvID( hand ) != "" and !inv[self:bGetReqInvID( hand )] then
|
||||||
self:D_SetReqID( hand, "" )
|
self:bSetReqInvID( hand, "" )
|
||||||
end
|
end
|
||||||
local req = self:D_GetReqID( hand )
|
local req = self:bGetReqInvID( hand )
|
||||||
local req_o = self:D_GetReqID( !hand )
|
local req_o = self:bGetReqInvID( !hand )
|
||||||
local curr = self:D_GetID( hand )
|
local curr = self:bGetInvID( hand )
|
||||||
local curr_o = self:D_GetID( !hand )
|
local curr_o = self:bGetInvID( !hand )
|
||||||
if req != curr then
|
if req != curr then
|
||||||
-- Don't allow holstering from this weapon if...
|
-- Don't allow holstering from this weapon if...
|
||||||
-- Just know, this feels bad.
|
-- Just know, this feels bad.
|
||||||
if self:D_GetReloading( hand ) > 0 then
|
if self:bGetReloadTime( hand ) > 0 then
|
||||||
elseif self:D_GetShotTime( hand ) + self:GetStat( hand, "ShootHolsterTime" ) > CurTime() then
|
elseif self:bGetShotTime( hand ) + self:GetStat( hand, "ShootHolsterTime" ) > CurTime() then
|
||||||
|
|
||||||
else
|
else
|
||||||
if curr != "" then
|
if curr != "" then
|
||||||
|
@ -220,18 +222,18 @@ function SWEP:Think()
|
||||||
self:BThinkHolster( hand )
|
self:BThinkHolster( hand )
|
||||||
|
|
||||||
do -- Reload logic
|
do -- Reload logic
|
||||||
if self:D_GetReloading( hand ) != -1 then
|
if self:bGetReloadTime( hand ) != -1 then
|
||||||
local rlt = self:D_GetReloadType( hand )
|
local rlt = self:bGetReloadType( hand )
|
||||||
-- TODO: Unshitify this.
|
-- TODO: Unshitify this.
|
||||||
if RealTime() >= self:D_GetReloading( hand ) + (rlt == 1 and self:GetStat( hand, "Reload_MagIn" ) or rlt == 2 and self:GetStat( hand, "Reload_MagOut" )) then
|
if RealTime() >= self:bGetReloadTime( hand ) + (rlt == 1 and self:GetStat( hand, "Reload_MagIn" ) or rlt == 2 and self:GetStat( hand, "Reload_MagOut" )) then
|
||||||
if rlt == 1 then
|
if rlt == 1 then
|
||||||
if SERVER or (CLIENT and IsFirstTimePredicted() ) then
|
if SERVER or (CLIENT and IsFirstTimePredicted() ) then
|
||||||
self:Reload_MagIn( hand, self:D_GetMagID( hand ), inv )
|
self:Reload_MagIn( hand, self:bGetMagInvID( hand ), inv )
|
||||||
end
|
end
|
||||||
elseif rlt == 2 then
|
elseif rlt == 2 then
|
||||||
end
|
end
|
||||||
self:D_SetReloading( hand, -1 )
|
self:bSetReloadTime( hand, -1 )
|
||||||
self:D_SetReloadType( hand, 0 )
|
self:bSetReloadType( hand, 0 )
|
||||||
-- Do reload stuff.
|
-- Do reload stuff.
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -243,23 +245,23 @@ function SWEP:Think()
|
||||||
for i=1, 2 do
|
for i=1, 2 do
|
||||||
local hand = i==2
|
local hand = i==2
|
||||||
if !self:C_AttackDown( hand ) then
|
if !self:C_AttackDown( hand ) then
|
||||||
self:D_SetBurst( hand, 0 )
|
self:bSetBurst( hand, 0 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1, 2 do
|
for i=1, 2 do
|
||||||
local hand = i==2
|
local hand = i==2
|
||||||
local wep, wepc = self:BTable( hand ), self:BClass( hand )
|
local wep, wepc = self:BTable( hand ), self:BClass( hand )
|
||||||
if wepc and wepc.Features == "firearm" and self:D_GetDelay( hand ) < CurTime()-0.01 then
|
if wepc and wepc.Features == "firearm" and self:bGetIntDelay( hand ) < CurTime()-0.01 then
|
||||||
local mweh = math.Remap( CurTime(), self:D_GetShotTime( hand ), self:D_GetShotTime( hand ) + self:GetStat( hand, "SpreadDecay_RampTime" ), 0, 1 )
|
local mweh = math.Remap( CurTime(), self:bGetShotTime( hand ), self:bGetShotTime( hand ) + self:GetStat( hand, "SpreadDecay_RampTime" ), 0, 1 )
|
||||||
mweh = math.Clamp( mweh, 0, 1 )
|
mweh = math.Clamp( mweh, 0, 1 )
|
||||||
local decayfinal = Lerp( math.ease.InExpo( mweh ), self:GetStat( hand, "SpreadDecay_Start" ), self:GetStat( hand, "SpreadDecay_End" ) )
|
local decayfinal = Lerp( math.ease.InExpo( mweh ), self:GetStat( hand, "SpreadDecay_Start" ), self:GetStat( hand, "SpreadDecay_End" ) )
|
||||||
self:D_SetSpread( hand, math.Approach( self:D_GetSpread( hand ), 0, decayfinal * FrameTime() ) )
|
self:bSetSpread( hand, math.Approach( self:bGetSpread( hand ), 0, decayfinal * FrameTime() ) )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ht = "normal"
|
local ht = "normal"
|
||||||
if self:BClass( false ) and self:D_GetHolstering( false ) < 0 then
|
if self:BClass( false ) and self:bGetHolsterTime( false ) < 0 then
|
||||||
ht = "passive"
|
ht = "passive"
|
||||||
if self:GetUserAim() then
|
if self:GetUserAim() then
|
||||||
if self:BClass( true ) then
|
if self:BClass( true ) then
|
||||||
|
|
|
@ -130,8 +130,8 @@ local function regen_items( itemlist )
|
||||||
|
|
||||||
local wep = ply:BennyCheck()
|
local wep = ply:BennyCheck()
|
||||||
if wep then
|
if wep then
|
||||||
local handed_r = wep:D_GetID( false ) == v
|
local handed_r = wep:bGetInvID( false ) == v
|
||||||
local handed_l = wep:D_GetID( true ) == v
|
local handed_l = wep:bGetInvID( true ) == v
|
||||||
if handed_r or handed_l then
|
if handed_r or handed_l then
|
||||||
draw.SimpleText( handed_l and "LEFT" or "RIGHT", "Benny_18", w/2, h/2 + ss(1), schema_c("bg"), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
draw.SimpleText( handed_l and "LEFT" or "RIGHT", "Benny_18", w/2, h/2 + ss(1), schema_c("bg"), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Your Name Is Benny
|
||||||
|
Item definition
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- Not 100% sure how metastuff works yet.
|
||||||
|
|
||||||
|
-- Global weapons table
|
||||||
|
WEAPONS = {}
|
||||||
|
|
||||||
|
function WeaponGet(class)
|
||||||
|
return ItemDef(class)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ItemDef metatable
|
||||||
|
ItemDef = {}
|
||||||
|
|
||||||
|
function ItemDef.__index( self, key )
|
||||||
|
if rawget(self, "BaseClass") then
|
||||||
|
return rawget( rawget(self, "BaseClass"), key )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ItemDef:new( classname, classtable )
|
||||||
|
if classtable then
|
||||||
|
local newdef = classtable
|
||||||
|
newdef.ClassName = classname
|
||||||
|
newdef.BaseClass = WEAPONS[newdef.Base]
|
||||||
|
|
||||||
|
WEAPONS[classname] = newdef
|
||||||
|
|
||||||
|
setmetatable( newdef, ItemDef )
|
||||||
|
return newdef
|
||||||
|
else
|
||||||
|
return WEAPONS[classname]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ItemDef:__tostring()
|
||||||
|
return "ItemDef [" .. self.ClassName .. "]"
|
||||||
|
end
|
||||||
|
|
||||||
|
setmetatable( ItemDef, { __call = ItemDef.new } )
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Your Name Is Benny
|
||||||
|
Item existance
|
||||||
|
]]
|
|
@ -516,8 +516,8 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
|
|
||||||
local identicallist = p:INV_Find( wep:BTable( hand ).Class )
|
local identicallist = p:INV_Find( wep:BTable( hand ).Class )
|
||||||
identicallist = table.Flip( identicallist )
|
identicallist = table.Flip( identicallist )
|
||||||
local numba = identicallist[ wep:D_GetID( hand ) ]
|
local numba = identicallist[ wep:bGetInvID( hand ) ]
|
||||||
draw.SimpleText( "#" .. tostring(numba) .. ", " .. wep:D_GetID( hand ), "Benny_10", p_x+p_w-pb2, p_y+ss(7), scheme["bg"], TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
draw.SimpleText( "#" .. tostring(numba) .. ", " .. wep:bGetInvID( hand ), "Benny_10", p_x+p_w-pb2, p_y+ss(7), scheme["bg"], TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||||
|
|
||||||
if wep_class.Firemodes then -- Firemode
|
if wep_class.Firemodes then -- Firemode
|
||||||
surface.SetDrawColor( scheme["fg"] )
|
surface.SetDrawColor( scheme["fg"] )
|
||||||
|
@ -526,19 +526,19 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
draw.SimpleText( wep:B_FiremodeName( hand ), "Benny_12", p_x + pb + ss(14.5), p_y + pb + t_h + ss(8), scheme["bg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
draw.SimpleText( wep:B_FiremodeName( hand ), "Benny_12", p_x + pb + ss(14.5), p_y + pb + t_h + ss(8), scheme["bg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
||||||
-- draw.SimpleText( "[AMMO TYPE]", "Benny_10", p_x + pb + ss(30+4), p_y + pb + t_h + ss(8), scheme["fg"], TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
|
-- draw.SimpleText( "[AMMO TYPE]", "Benny_10", p_x + pb + ss(30+4), p_y + pb + t_h + ss(8), scheme["fg"], TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
|
||||||
end
|
end
|
||||||
if wep_class.Ammo then -- Ammo
|
if wep_table.Loaded and wep_table.Loaded != "" then -- Ammo
|
||||||
local b_w, b_h = ss(3), ss(10)
|
local b_w, b_h = ss(3), ss(10)
|
||||||
local lw, lh = ss(2), ss(2)
|
local lw, lh = ss(2), ss(2)
|
||||||
surface.SetDrawColor( scheme["fg"] )
|
surface.SetDrawColor( scheme["fg"] )
|
||||||
|
|
||||||
local ammo = math.max( wep:D_GetClip( hand ), wep_class.Ammo )
|
local ammo = math.max( wep:bGetIntClip( hand ), ItemDef(inv[wep_table.Loaded].Class).Ammo )
|
||||||
if ammo>30 then b_w, b_h = ss(3), ss(4) end
|
if ammo>30 then b_w, b_h = ss(3), ss(4) end
|
||||||
|
|
||||||
local offset = b_h
|
local offset = b_h
|
||||||
local count = 1
|
local count = 1
|
||||||
for i=1, ammo do
|
for i=1, ammo do
|
||||||
local thefunk = surface.DrawRect
|
local thefunk = surface.DrawRect
|
||||||
if i > wep:D_GetClip( hand ) then
|
if i > wep:bGetIntClip( hand ) then
|
||||||
thefunk = surface.DrawOutlinedRect
|
thefunk = surface.DrawOutlinedRect
|
||||||
end
|
end
|
||||||
if i!=1 and i%30 == 1 then
|
if i!=1 and i%30 == 1 then
|
||||||
|
@ -548,9 +548,9 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
thefunk( p_x + p_w - b_w - pb - ((count-1)*(b_w+lw)), p_y + p_h - offset - pb, b_w, b_h, ss(0.5) )
|
thefunk( p_x + p_w - b_w - pb - ((count-1)*(b_w+lw)), p_y + p_h - offset - pb, b_w, b_h, ss(0.5) )
|
||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
draw.SimpleText( wep:D_GetClip( hand ), "Benny_12", p_x + p_w - pb - ss(1), p_y + p_h - offset - ss(12+3), scheme["fg"], TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
draw.SimpleText( wep:bGetIntClip( hand ), "Benny_12", p_x + p_w - pb - ss(1), p_y + p_h - offset - ss(12+3), scheme["fg"], TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||||
|
|
||||||
if wep:D_GetMagID( hand ) != wep_table.Loaded then
|
if wep:bGetMagInvID( hand ) != wep_table.Loaded then
|
||||||
surface.SetDrawColor( scheme["bg"] )
|
surface.SetDrawColor( scheme["bg"] )
|
||||||
surface.DrawRect( p_x, p_y - ss( 12+3 ), ss( 66 ), ss( 12 ) )
|
surface.DrawRect( p_x, p_y - ss( 12+3 ), ss( 66 ), ss( 12 ) )
|
||||||
draw.SimpleText( "!! Mag desync.", "Benny_12", p_x + ss( 2 ), p_y - ss( 12+2 ), scheme["fg"], TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
draw.SimpleText( "!! Mag desync.", "Benny_12", p_x + ss( 2 ), p_y - ss( 12+2 ), scheme["fg"], TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||||
|
@ -563,7 +563,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
local b2 = ss( 2 )
|
local b2 = ss( 2 )
|
||||||
local b3 = ss( 3 )
|
local b3 = ss( 3 )
|
||||||
local b4 = ss( 4 )
|
local b4 = ss( 4 )
|
||||||
local maglist = p:INV_FindMagSmart( wep_table.Class, wep:D_GetID( hand ) )
|
local maglist = p:INV_FindMagSmart( wep_class.ClassName, wep:bGetInvID( hand ) )
|
||||||
for id, tag in ipairs( maglist ) do
|
for id, tag in ipairs( maglist ) do
|
||||||
--assert( inv[tag], "That magazine doesn't exist. " .. tag )
|
--assert( inv[tag], "That magazine doesn't exist. " .. tag )
|
||||||
local chunk = ((ss(1)+m_w)*(id-1))
|
local chunk = ((ss(1)+m_w)*(id-1))
|
||||||
|
@ -578,8 +578,8 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
local s3 = math.floor( s2 - s1 )
|
local s3 = math.floor( s2 - s1 )
|
||||||
|
|
||||||
local m1, m2, m3, m4 = m_x + bb + bb - chunk, m_y + bb + bb - s3, m_w - b2 - b2, s2
|
local m1, m2, m3, m4 = m_x + bb + bb - chunk, m_y + bb + bb - s3, m_w - b2 - b2, s2
|
||||||
local active = tag == wep:D_GetMagID( hand )
|
local active = tag == wep:bGetMagInvID( hand )
|
||||||
local active2 = tag == wep:D_GetMagID( !hand )
|
local active2 = tag == wep:bGetMagInvID( !hand )
|
||||||
if active or active2 then
|
if active or active2 then
|
||||||
draw.SimpleText( active2 and "|" or "x", "Benny_10", m_x + (m_w/2) - chunk, m_y + (m_h/2), scheme["fg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
draw.SimpleText( active2 and "|" or "x", "Benny_10", m_x + (m_w/2) - chunk, m_y + (m_h/2), scheme["fg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
||||||
end
|
end
|
||||||
|
@ -735,9 +735,9 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
local invid = 0
|
local invid = 0
|
||||||
for _, item in pairs( weighted ) do
|
for _, item in pairs( weighted ) do
|
||||||
local id = iflip[item]
|
local id = iflip[item]
|
||||||
local active = wep:D_GetReqID( false ) == id or wep:D_GetReqID( true ) == id
|
local active = wep:bGetReqInvID( false ) == id or wep:bGetReqInvID( true ) == id
|
||||||
local active_r = wep:D_GetReqID( false ) == id
|
local active_r = wep:bGetReqInvID( false ) == id
|
||||||
local active_l = wep:D_GetReqID( true ) == id
|
local active_l = wep:bGetReqInvID( true ) == id
|
||||||
local class = WeaponGet(item.Class)
|
local class = WeaponGet(item.Class)
|
||||||
local boxsize = ss(b_w)
|
local boxsize = ss(b_w)
|
||||||
surface.SetDrawColor( scheme[active and "fg" or "bg"] )
|
surface.SetDrawColor( scheme[active and "fg" or "bg"] )
|
||||||
|
@ -911,7 +911,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
draw.SimpleText( wep1_class.Name, "Benny_14", bx-mx, by+ss(8)*-1, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
draw.SimpleText( wep1_class.Name, "Benny_14", bx-mx, by+ss(8)*-1, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||||
draw.SimpleText( "Clip1: " .. wep:Clip1(), "Benny_14", bx-mx, by+ss(8)*0, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
draw.SimpleText( "Clip1: " .. wep:Clip1(), "Benny_14", bx-mx, by+ss(8)*0, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||||
draw.SimpleText( "ID1: " .. wep:GetWep1(), "Benny_14", bx-mx, by+ss(8)*1, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
draw.SimpleText( "ID1: " .. wep:GetWep1(), "Benny_14", bx-mx, by+ss(8)*1, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||||
draw.SimpleText( "MagID1: " .. wep:D_GetMagID( false ), "Benny_14", bx-mx, by+ss(8)*2, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
draw.SimpleText( "MagID1: " .. wep:bGetMagInvID( false ), "Benny_14", bx-mx, by+ss(8)*2, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||||
if wep1_table.Loaded then
|
if wep1_table.Loaded then
|
||||||
draw.SimpleText( "T_MagID1: " .. wep1_table.Loaded, "Benny_14", bx-mx, by+ss(8)*3, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
draw.SimpleText( "T_MagID1: " .. wep1_table.Loaded, "Benny_14", bx-mx, by+ss(8)*3, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||||
end
|
end
|
||||||
|
@ -922,7 +922,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
draw.SimpleText( wep2_class.Name, "Benny_14", bx+mx, by+ss(8)*-1, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
draw.SimpleText( wep2_class.Name, "Benny_14", bx+mx, by+ss(8)*-1, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||||
draw.SimpleText( "Clip2: " .. wep:Clip2(), "Benny_14", bx+mx, by+ss(8)*0, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
draw.SimpleText( "Clip2: " .. wep:Clip2(), "Benny_14", bx+mx, by+ss(8)*0, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||||
draw.SimpleText( "ID2: " .. wep:GetWep2(), "Benny_14", bx+mx, by+ss(8)*1, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
draw.SimpleText( "ID2: " .. wep:GetWep2(), "Benny_14", bx+mx, by+ss(8)*1, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||||
draw.SimpleText( "MagID2: " .. wep:D_GetMagID( true ), "Benny_14", bx+mx, by+ss(8)*2, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
draw.SimpleText( "MagID2: " .. wep:bGetMagInvID( true ), "Benny_14", bx+mx, by+ss(8)*2, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||||
if wep2_table.Loaded then
|
if wep2_table.Loaded then
|
||||||
draw.SimpleText( "T_MagID2: " .. wep2_table.Loaded, "Benny_12", bx+mx, by+24*3, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
draw.SimpleText( "T_MagID2: " .. wep2_table.Loaded, "Benny_12", bx+mx, by+24*3, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||||
end
|
end
|
||||||
|
@ -939,8 +939,8 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
local hand = i==2
|
local hand = i==2
|
||||||
if hand then boost = -boost end
|
if hand then boost = -boost end
|
||||||
|
|
||||||
local wr = wep:D_GetReloading( hand )
|
local wr = wep:bGetReloadTime( hand )
|
||||||
local wrt = wep:D_GetReloadType( hand )
|
local wrt = wep:bGetReloadType( hand )
|
||||||
if wr > 0 then
|
if wr > 0 then
|
||||||
local b1 = math.TimeFraction( wr, wr + wep:GetStat( hand, "Reload_MagIn" ), wr + wep:GetStat( hand, "Reload_MagIn_Bonus1" ) )
|
local b1 = math.TimeFraction( wr, wr + wep:GetStat( hand, "Reload_MagIn" ), wr + wep:GetStat( hand, "Reload_MagIn_Bonus1" ) )
|
||||||
local b2 = math.TimeFraction( wr, wr + wep:GetStat( hand, "Reload_MagIn" ), wr + wep:GetStat( hand, "Reload_MagIn_Bonus2" ) )
|
local b2 = math.TimeFraction( wr, wr + wep:GetStat( hand, "Reload_MagIn" ), wr + wep:GetStat( hand, "Reload_MagIn_Bonus2" ) )
|
||||||
|
|
|
@ -69,25 +69,25 @@ concommand.Add("benny_inv_discard", function( ply, cmd, args )
|
||||||
net.WriteString( args[1] )
|
net.WriteString( args[1] )
|
||||||
net.Send( ply )
|
net.Send( ply )
|
||||||
|
|
||||||
if wep:D_GetID( false ) == args[1] then
|
if wep:bGetInvID( false ) == args[1] then
|
||||||
print( "Disequipped " .. args[1] .. " for " .. tostring(wep) )
|
print( "Disequipped " .. args[1] .. " for " .. tostring(wep) )
|
||||||
wep:SetWep1( "" )
|
wep:SetWep1( "" )
|
||||||
wep:SetWep1_Clip( "" )
|
wep:SetWep1_Clip( "" )
|
||||||
wep:SetClip1( 0 )
|
wep:SetClip1( 0 )
|
||||||
end
|
end
|
||||||
if wep:D_GetID( true ) == args[1] then
|
if wep:bGetInvID( true ) == args[1] then
|
||||||
print( "Disequipped " .. args[1] .. " for " .. tostring(wep) )
|
print( "Disequipped " .. args[1] .. " for " .. tostring(wep) )
|
||||||
wep:SetWep2( "" )
|
wep:SetWep2( "" )
|
||||||
wep:SetWep2_Clip( "" )
|
wep:SetWep2_Clip( "" )
|
||||||
wep:SetClip2( 0 )
|
wep:SetClip2( 0 )
|
||||||
end
|
end
|
||||||
if wep:D_GetMagID( false ) == args[1] then
|
if wep:bGetMagInvID( false ) == args[1] then
|
||||||
inv[wep:D_GetID( false )].Loaded = ""
|
inv[wep:bGetInvID( false )].Loaded = ""
|
||||||
wep:SetWep1_Clip( "" )
|
wep:SetWep1_Clip( "" )
|
||||||
wep:SetClip1( 0 )
|
wep:SetClip1( 0 )
|
||||||
end
|
end
|
||||||
if wep:D_GetMagID( true ) == args[1] then
|
if wep:bGetMagInvID( true ) == args[1] then
|
||||||
inv[wep:D_GetID( true )].Loaded = ""
|
inv[wep:bGetInvID( true )].Loaded = ""
|
||||||
wep:SetWep2_Clip( "" )
|
wep:SetWep2_Clip( "" )
|
||||||
wep:SetClip2( 0 )
|
wep:SetClip2( 0 )
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,39 +30,39 @@ local function beatup( ply, num )
|
||||||
invid = invid + 1
|
invid = invid + 1
|
||||||
if num == 0 then num = 10 end
|
if num == 0 then num = 10 end
|
||||||
if num == invid then
|
if num == invid then
|
||||||
if id == wep:D_GetReqID( hand ) then
|
if id == wep:bGetReqInvID( hand ) then
|
||||||
-- If we are selected our currently equipped weapon, holster it.
|
-- If we are selected our currently equipped weapon, holster it.
|
||||||
return wep:D_SetReqID( hand, "" )
|
return wep:bSetReqInvID( hand, "" )
|
||||||
else
|
else
|
||||||
if wep:D_GetReqID( hand ) != "" then
|
if wep:bGetReqInvID( hand ) != "" then
|
||||||
-- Something is in this hand
|
-- Something is in this hand
|
||||||
|
|
||||||
if wep:D_GetReqID( !hand ) != "" then
|
if wep:bGetReqInvID( !hand ) != "" then
|
||||||
-- Something in the other hand
|
-- Something in the other hand
|
||||||
wep:D_SetReqID( !hand, wep:D_GetReqID( hand ) )
|
wep:bSetReqInvID( !hand, wep:bGetReqInvID( hand ) )
|
||||||
wep:D_SetReqID( hand, id )
|
wep:bSetReqInvID( hand, id )
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
-- Nothing in the other hand
|
-- Nothing in the other hand
|
||||||
wep:D_SetReqID( !hand, "" )
|
wep:bSetReqInvID( !hand, "" )
|
||||||
wep:D_SetReqID( hand, id )
|
wep:bSetReqInvID( hand, id )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- Nothing in this hand.
|
-- Nothing in this hand.
|
||||||
if wep:D_GetReqID( !hand ) == id then
|
if wep:bGetReqInvID( !hand ) == id then
|
||||||
-- Weapon we want is in the other hand.
|
-- Weapon we want is in the other hand.
|
||||||
wep:D_SetReqID( !hand, "" )
|
wep:bSetReqInvID( !hand, "" )
|
||||||
wep:D_SetReqID( hand, id )
|
wep:bSetReqInvID( hand, id )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return wep:D_SetReqID( hand, id )
|
return wep:bSetReqInvID( hand, id )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return wep:D_SetReqID( hand, "" )
|
return wep:bSetReqInvID( hand, "" )
|
||||||
end
|
end
|
||||||
|
|
||||||
hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_Inv", function( ply, button )
|
hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_Inv", function( ply, button )
|
||||||
|
|
|
@ -157,10 +157,10 @@ hook.Add( "Move", "Benny_Move", function( ply, mv )
|
||||||
|
|
||||||
targetspeed = targetspeed * Lerp( w:GetAim(), 1, w:GetStat( false, "Speed_Aiming" ) )
|
targetspeed = targetspeed * Lerp( w:GetAim(), 1, w:GetStat( false, "Speed_Aiming" ) )
|
||||||
|
|
||||||
local st = w:D_GetShotTime( false )
|
local st = w:bGetShotTime( false )
|
||||||
targetspeed = targetspeed * (st+w:GetStat( hand, "Speed_FiringTime" ) > CurTime() and w:GetStat( false, "Speed_Firing" ) or 1)
|
targetspeed = targetspeed * (st+w:GetStat( hand, "Speed_FiringTime" ) > CurTime() and w:GetStat( false, "Speed_Firing" ) or 1)
|
||||||
|
|
||||||
targetspeed = targetspeed * (w:D_GetReloading( false ) > 0 and w:GetStat( false, "Speed_Reloading" ) or 1)
|
targetspeed = targetspeed * (w:bGetReloadTime( false ) > 0 and w:GetStat( false, "Speed_Reloading" ) or 1)
|
||||||
|
|
||||||
mv:SetMaxSpeed( targetspeed )
|
mv:SetMaxSpeed( targetspeed )
|
||||||
mv:SetMaxClientSpeed( targetspeed )
|
mv:SetMaxClientSpeed( targetspeed )
|
||||||
|
|
|
@ -182,6 +182,7 @@ local T_WEIGHT = {
|
||||||
["equipment"] = 00,
|
["equipment"] = 00,
|
||||||
["grenade"] = -10,
|
["grenade"] = -10,
|
||||||
["magazine"] = -100,
|
["magazine"] = -100,
|
||||||
|
["base"] = -1000,
|
||||||
}
|
}
|
||||||
|
|
||||||
function PT:INV_Weight()
|
function PT:INV_Weight()
|
||||||
|
@ -253,6 +254,7 @@ do
|
||||||
["utility"] = { 6, 2 },
|
["utility"] = { 6, 2 },
|
||||||
["equipment"] = { 7, 1 },
|
["equipment"] = { 7, 1 },
|
||||||
["magazine"] = { 8, 1 },
|
["magazine"] = { 8, 1 },
|
||||||
|
["base"] = { 8, 2 },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- PROTO: Cache this!
|
-- PROTO: Cache this!
|
||||||
|
@ -289,16 +291,6 @@ do
|
||||||
end
|
end
|
||||||
return inventorylist
|
return inventorylist
|
||||||
end
|
end
|
||||||
-- PROTO: I am on an outdated version of GMod.
|
|
||||||
function table.Flip( tab )
|
|
||||||
local res = {}
|
|
||||||
|
|
||||||
for k, v in pairs( tab ) do
|
|
||||||
res[ v ] = k
|
|
||||||
end
|
|
||||||
|
|
||||||
return res
|
|
||||||
end
|
|
||||||
function PT:INV_ListFromBuckets()
|
function PT:INV_ListFromBuckets()
|
||||||
local buckets = self:INV_Buckets()
|
local buckets = self:INV_Buckets()
|
||||||
|
|
||||||
|
@ -325,7 +317,7 @@ hook.Add("StartCommand", "Benny_INV_StartCommand", function( ply, cmd )
|
||||||
-- if CLIENT and ply.CLIENTDESIRE and inv[ply.CLIENTDESIRE ] and inv_bucketlist_flipped[ ply.CLIENTDESIRE ] then
|
-- if CLIENT and ply.CLIENTDESIRE and inv[ply.CLIENTDESIRE ] and inv_bucketlist_flipped[ ply.CLIENTDESIRE ] then
|
||||||
-- cmd:SetUpMove( inv_bucketlist_flipped[ ply.CLIENTDESIRE ] )
|
-- cmd:SetUpMove( inv_bucketlist_flipped[ ply.CLIENTDESIRE ] )
|
||||||
-- end
|
-- end
|
||||||
-- if CLIENT and (wep:D_GetID( hand ) == ply.CLIENTDESIRE) then
|
-- if CLIENT and (wep:bGetInvID( hand ) == ply.CLIENTDESIRE) then
|
||||||
-- ply.CLIENTDESIRE = 0
|
-- ply.CLIENTDESIRE = 0
|
||||||
-- print("Fixed")
|
-- print("Fixed")
|
||||||
-- end
|
-- end
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue