Holstering
This commit is contained in:
parent
887688a14a
commit
43de9503eb
|
@ -53,6 +53,26 @@ function SWEP:D_SetShotTime( hand, value )
|
||||||
return (hand == true) and self:SetWep2_ShotTime( value ) or (hand == false) and self:SetWep1_ShotTime( value )
|
return (hand == true) and self:SetWep2_ShotTime( value ) or (hand == false) and self:SetWep1_ShotTime( value )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Weapon Holstering Time
|
||||||
|
function SWEP:D_GetHolstering( hand )
|
||||||
|
return (hand == true) and self:GetWep2_Holstering() or (hand == false) and self:GetWep1_Holstering()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:D_SetHolstering( hand, value )
|
||||||
|
return (hand == true) and self:SetWep2_Holstering( value ) or (hand == false) and self:SetWep1_Holstering( 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
|
-- 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()
|
||||||
|
|
|
@ -42,6 +42,8 @@ function SWEP:SetupDataTables()
|
||||||
self:NetworkVar( "Float", 5, "Wep2_Spread" )
|
self:NetworkVar( "Float", 5, "Wep2_Spread" )
|
||||||
self:NetworkVar( "Float", 6, "Wep1_ShotTime" )
|
self:NetworkVar( "Float", 6, "Wep1_ShotTime" )
|
||||||
self:NetworkVar( "Float", 7, "Wep2_ShotTime" )
|
self:NetworkVar( "Float", 7, "Wep2_ShotTime" )
|
||||||
|
self:NetworkVar( "Float", 8, "Wep1_Holstering" )
|
||||||
|
self:NetworkVar( "Float", 9, "Wep2_Holstering" )
|
||||||
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" )
|
||||||
|
@ -194,6 +196,23 @@ hook.Add( "PlayerButtonUp", "Benny_PlayerButtonUp_TempForAim", function( ply, bu
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
function SWEP:BStartHolster( hand )
|
||||||
|
if self:D_GetHolstering( hand ) == -1 then
|
||||||
|
self:D_SetHolstering( hand, 1 )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function SWEP:BThinkHolster( hand )
|
||||||
|
if self:D_GetHolstering( hand ) > 0 then
|
||||||
|
self:D_SetHolstering( hand, math.Approach( self:D_GetHolstering( hand ), 0, FrameTime() / 0.2 ) )
|
||||||
|
end
|
||||||
|
if self:D_GetHolstering( hand ) == 0 then
|
||||||
|
self:D_SetHolstering( hand, -1 )
|
||||||
|
self:BHolster( hand )
|
||||||
|
self:D_SetReqID( hand, "" )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function SWEP:Think()
|
function SWEP:Think()
|
||||||
local p = self:GetOwner()
|
local p = self:GetOwner()
|
||||||
local inv = p:INV_Get()
|
local inv = p:INV_Get()
|
||||||
|
@ -201,30 +220,18 @@ function SWEP:Think()
|
||||||
local L, R = true, false
|
local L, R = true, false
|
||||||
local curr_l, curr_r = self:D_GetID( true ), self:D_GetID( false )
|
local curr_l, curr_r = self:D_GetID( true ), self:D_GetID( false )
|
||||||
|
|
||||||
if p:GetReqID1() != self:D_GetID( R ) then
|
for i=1, 1 do
|
||||||
if inv[p:GetReqID1()] and p:GetReqID1() != "" then
|
local hand = i==2
|
||||||
if curr_r != "" then
|
if self:D_GetReqID( hand ) != self:D_GetID( hand ) then
|
||||||
-- We already have something equipped here, move it to the offhand
|
if inv[self:D_GetReqID( hand )] and self:D_GetReqID( hand ) != "" then
|
||||||
self:BDeploy( L, curr_r )
|
self:BDeploy( hand, p:GetReqID1() )
|
||||||
p:SetReqID2( curr_r )
|
|
||||||
end
|
|
||||||
self:BDeploy( R, p:GetReqID1() )
|
|
||||||
else
|
else
|
||||||
self:BHolster( R )
|
self:BStartHolster( hand )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if p:GetReqID2() != self:D_GetID( L ) then
|
self:BThinkHolster( R )
|
||||||
if inv[p:GetReqID2()] and p:GetReqID2() != "" then
|
-- print( self:D_GetReqID( hand ), self:D_GetID( hand ) )
|
||||||
if curr_l != "" then
|
|
||||||
-- We already have something equipped here, move it to the offhand
|
|
||||||
self:BDeploy( R, curr_l )
|
|
||||||
p:SetReqID1( curr_l )
|
|
||||||
end
|
|
||||||
self:BDeploy( L, p:GetReqID2() )
|
|
||||||
else
|
|
||||||
self:BHolster( L )
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local wep1 = self:BTable( false )
|
local wep1 = self:BTable( false )
|
||||||
|
|
|
@ -929,7 +929,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if false and p:BennyCheck() then
|
if false and wep then
|
||||||
local bx, by = sw/2, sh*(0.75)
|
local bx, by = sw/2, sh*(0.75)
|
||||||
local mx = 50
|
local mx = 50
|
||||||
|
|
||||||
|
@ -955,6 +955,13 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if wep then
|
||||||
|
surface.SetDrawColor( color_white )
|
||||||
|
surface.DrawRect( sw/2 - ss(400)/2, sh/2 - ss(8)/2, ss(400*wep:GetWep1_Holstering()), ss(8) )
|
||||||
|
|
||||||
|
surface.DrawOutlinedRect( sw/2 - ss(400+2)/2, sh/2 - ss(8+2)/2, ss(400+2), ss(8+2), ss(0.5) )
|
||||||
|
end
|
||||||
end )
|
end )
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
|
@ -27,13 +27,14 @@ local function beatup( ply, num )
|
||||||
if num == invid then
|
if num == invid then
|
||||||
--RunConsoleCommand( "benny_inv_equip", iflip[item], "false", "false" )
|
--RunConsoleCommand( "benny_inv_equip", iflip[item], "false", "false" )
|
||||||
if ply:KeyDown(IN_ZOOM) then
|
if ply:KeyDown(IN_ZOOM) then
|
||||||
ply:SetReqID2(iflip[item])
|
return ply:SetReqID2(iflip[item])
|
||||||
else
|
else
|
||||||
ply:SetReqID1(iflip[item])
|
return ply:SetReqID1(iflip[item])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return ply:SetReqID1( "" )
|
||||||
end
|
end
|
||||||
|
|
||||||
hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_Inv", function( ply, button )
|
hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_Inv", function( ply, button )
|
||||||
|
|
Loading…
Reference in New Issue