Separate weapon holster & deploy from con.commands
This commit is contained in:
parent
fa7b5259d6
commit
221462ae02
|
@ -0,0 +1,66 @@
|
||||||
|
|
||||||
|
-- Weapon ID
|
||||||
|
function SWEP:DGetWep( hand )
|
||||||
|
return hand and self:GetWep2() or self:GetWep1()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:DSetWep( hand, value )
|
||||||
|
return hand and self:SetWep2( value ) or self:SetWep1( value )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Internal SWEP Clip
|
||||||
|
function SWEP:DGetClip( hand )
|
||||||
|
return hand and self:Clip2() or self:Clip1()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:DSetClip( hand, value )
|
||||||
|
return hand and self:SetClip2( value ) or self:SetClip1( value )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Wep. Clip ID
|
||||||
|
function SWEP:DGetWepClip( hand )
|
||||||
|
return hand and self:GetWep1Clip() or self:GetWep1Clip()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:DSetWepClip( hand, value )
|
||||||
|
return hand and self:SetWep1Clip( value ) or self:SetWep1Clip( value )
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:BDeploy( hand, id )
|
||||||
|
local p = self:GetOwner()
|
||||||
|
local inv = p:INV_Get()
|
||||||
|
|
||||||
|
local item = inv[id]
|
||||||
|
local class = WEAPONS[item.Class]
|
||||||
|
|
||||||
|
assert( item, "That item doesn't exist. " .. tostring(item) )
|
||||||
|
|
||||||
|
self:DSetWep( hand, id )
|
||||||
|
self:DSetWepClip( hand, item.Loaded )
|
||||||
|
|
||||||
|
-- PROTO: Make grenade/melee/firearm logic way way better.
|
||||||
|
if class.Features == "firearm" then
|
||||||
|
if item.Loaded != 0 then
|
||||||
|
assert( item[ "Ammo" .. item.Loaded ], "That magazine doesn't exist." )
|
||||||
|
end
|
||||||
|
|
||||||
|
self:DSetClip( hand, item.Loaded == 0 and 0 or item[ "Ammo" .. item.Loaded ] )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:BHolster( hand )
|
||||||
|
local p = self:GetOwner()
|
||||||
|
local inv = p:INV_Get()
|
||||||
|
|
||||||
|
local item = inv[hand and self:GetWep2() or self:GetWep1()]
|
||||||
|
local class = WEAPONS[item.Class]
|
||||||
|
|
||||||
|
if class.Holster then class.Holster( self ) end
|
||||||
|
|
||||||
|
self:DSetWep( hand, "" )
|
||||||
|
|
||||||
|
-- PROTO: Make grenade/melee/firearm logic way way better.
|
||||||
|
if class.Features == "firearm" then
|
||||||
|
self:DSetClip( hand, 0 )
|
||||||
|
end
|
||||||
|
end
|
|
@ -22,7 +22,9 @@ SWEP.Secondary.Ammo = "none"
|
||||||
AddCSLuaFile( "sh_statregen.lua" )
|
AddCSLuaFile( "sh_statregen.lua" )
|
||||||
include ( "sh_statregen.lua" )
|
include ( "sh_statregen.lua" )
|
||||||
AddCSLuaFile( "sh_firing.lua" )
|
AddCSLuaFile( "sh_firing.lua" )
|
||||||
include ( "sh_firing.lua" )
|
AddCSLuaFile( "sh_firing.lua" )
|
||||||
|
include ( "sh_inv.lua" )
|
||||||
|
include ( "sh_inv.lua" )
|
||||||
|
|
||||||
function SWEP:SetupDataTables()
|
function SWEP:SetupDataTables()
|
||||||
self:NetworkVar( "Float", 0, "Aim" )
|
self:NetworkVar( "Float", 0, "Aim" )
|
||||||
|
|
|
@ -728,7 +728,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local arena = true
|
local arena = false
|
||||||
if arena then
|
if arena then
|
||||||
surface.SetDrawColor( scheme["bg"] )
|
surface.SetDrawColor( scheme["bg"] )
|
||||||
|
|
||||||
|
@ -810,6 +810,16 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if true then
|
||||||
|
local bx, by = sw/2, sh*(0.75)
|
||||||
|
local mx = 50
|
||||||
|
draw.SimpleText( "Clip1: " .. wep:Clip1(), "Trebuchet24", bx-mx, by+24*0, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||||
|
draw.SimpleText( "ID1: " .. wep:GetWep1(), "Trebuchet24", bx-mx, by+24*1, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||||
|
|
||||||
|
draw.SimpleText( "Clip2: " .. wep:Clip2(), "Trebuchet24", bx+mx, by+24*0, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||||
|
draw.SimpleText( "ID2: " .. wep:GetWep2(), "Trebuchet24", bx+mx, by+24*1, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||||
|
end
|
||||||
end )
|
end )
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
|
@ -68,23 +68,12 @@ end)
|
||||||
|
|
||||||
-- PROTO: Move this all into weapon code.
|
-- PROTO: Move this all into weapon code.
|
||||||
concommand.Add("benny_inv_equip", function( ply, cmd, args )
|
concommand.Add("benny_inv_equip", function( ply, cmd, args )
|
||||||
local inv = ply:INV_Get()
|
if ply:BennyCheck() then ply:GetActiveWeapon():BDeploy( false, args[1] ) end
|
||||||
local wep = ply:GetActiveWeapon()
|
end)
|
||||||
local item = inv[args[1]]
|
|
||||||
local class = WEAPONS[item.Class]
|
|
||||||
-- PROTO: Check that this is the correct 'benny' weapon.
|
|
||||||
assert( item, "That item doesn't exist. " .. tostring(item) )
|
|
||||||
|
|
||||||
wep:SetWep1( args[1] )
|
-- PROTO: Move this all into weapon code.
|
||||||
wep:SetWep1Clip( item.Loaded )
|
concommand.Add("benny_inv_holster", function( ply, cmd, args )
|
||||||
|
if ply:BennyCheck() then ply:GetActiveWeapon():BHolster( false ) end
|
||||||
-- PROTO: Make grenade/melee/firearm logic way way better.
|
|
||||||
if class.Features == "firearm" then
|
|
||||||
if item.Loaded != 0 then
|
|
||||||
assert( item[ "Ammo" .. item.Loaded ], "That magazine doesn't exist." )
|
|
||||||
end
|
|
||||||
wep:SetClip1( item.Loaded == 0 and 0 or item[ "Ammo" .. item.Loaded ] )
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
concommand.Add("benny_inv_sync", function( ply, cmd, args )
|
concommand.Add("benny_inv_sync", function( ply, cmd, args )
|
||||||
|
@ -161,6 +150,12 @@ function GM:ShowTeam( ply )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function GM:ShowSpare1( ply )
|
||||||
|
if SERVER then
|
||||||
|
ply:ConCommand( "benny_inv_holster" )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Debug inv
|
-- Debug inv
|
||||||
if CLIENT then
|
if CLIENT then
|
||||||
function GM:OnSpawnMenuOpen()
|
function GM:OnSpawnMenuOpen()
|
||||||
|
|
Loading…
Reference in New Issue