From 65b2c701b74f879f585c6e7cad1083a8c5cbaf75 Mon Sep 17 00:00:00 2001 From: Fesiug Date: Fri, 8 Dec 2023 01:22:22 -0500 Subject: [PATCH] More holstering WIP --- .../entities/weapons/benny/sh_firing.lua | 3 +++ .../benny/entities/weapons/benny/sh_inv.lua | 3 ++- .../benny/entities/weapons/benny/shared.lua | 20 ++++++++++++------- .../benny/gamemode/modules/player/cl_hud.lua | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/gamemodes/benny/entities/weapons/benny/sh_firing.lua b/gamemodes/benny/entities/weapons/benny/sh_firing.lua index 7f99a46..07974e0 100644 --- a/gamemodes/benny/entities/weapons/benny/sh_firing.lua +++ b/gamemodes/benny/entities/weapons/benny/sh_firing.lua @@ -32,6 +32,9 @@ function SWEP:BFire( hand ) if self:D_GetDelay( hand ) > CurTime() then return end + if self:D_GetHolstering( hand ) > 0 then + return + end if self:D_GetClip( hand ) == 0 then if self:D_GetBurst( hand ) >= 1 then return diff --git a/gamemodes/benny/entities/weapons/benny/sh_inv.lua b/gamemodes/benny/entities/weapons/benny/sh_inv.lua index 8df62bc..f43281a 100644 --- a/gamemodes/benny/entities/weapons/benny/sh_inv.lua +++ b/gamemodes/benny/entities/weapons/benny/sh_inv.lua @@ -119,7 +119,7 @@ function SWEP:BDeploy( hand, id ) -- This breaks prediction somewhat!! -- return -- PROTO: If you're in the middle of holstering, cancel it elseif self:D_GetID( hand ) != "" then - self:BHolster( hand ) + return--self:BHolster( hand ) end local p = self:GetOwner() local inv = p:INV_Get() @@ -133,6 +133,7 @@ function SWEP:BDeploy( hand, id ) self:D_SetMagID( hand, "" ) self:D_SetClip( hand, 0 ) self:D_SetSpread( hand, 0 ) + self:D_SetDelay( hand, CurTime() + 0.35 ) B_Sound( self, "Common.Deploy" ) if item.Loaded and item.Loaded != "" then local mid = item.Loaded diff --git a/gamemodes/benny/entities/weapons/benny/shared.lua b/gamemodes/benny/entities/weapons/benny/shared.lua index 42757e1..6e2499d 100644 --- a/gamemodes/benny/entities/weapons/benny/shared.lua +++ b/gamemodes/benny/entities/weapons/benny/shared.lua @@ -204,12 +204,11 @@ 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 ) ) + self:D_SetHolstering( hand, math.Approach( self:D_GetHolstering( hand ), 0, FrameTime() / 0.35 ) ) end if self:D_GetHolstering( hand ) == 0 then self:D_SetHolstering( hand, -1 ) self:BHolster( hand ) - self:D_SetReqID( hand, "" ) end end @@ -222,11 +221,18 @@ function SWEP:Think() for i=1, 1 do local hand = i==2 - if self:D_GetReqID( hand ) != self:D_GetID( hand ) then - if inv[self:D_GetReqID( hand )] and self:D_GetReqID( hand ) != "" then - self:BDeploy( hand, p:GetReqID1() ) - else + local req = self:D_GetReqID( hand ) + local curr = self:D_GetID( hand ) + if req != curr then + if curr != "" then + -- require holster first self:BStartHolster( hand ) + else + if req != "" and inv[req] then + self:BDeploy( hand, req ) + else + self:BStartHolster( hand ) + end end end @@ -260,7 +266,7 @@ function SWEP:Think() end local ht = "normal" - if self:GetUserAim() then + if self:GetUserAim() and self:D_GetHolstering( false ) < 0 then if self:BClass( false ) then if self:BClass( true ) then ht = "duel" diff --git a/gamemodes/benny/gamemode/modules/player/cl_hud.lua b/gamemodes/benny/gamemode/modules/player/cl_hud.lua index 3cc741e..b61a86c 100644 --- a/gamemodes/benny/gamemode/modules/player/cl_hud.lua +++ b/gamemodes/benny/gamemode/modules/player/cl_hud.lua @@ -956,7 +956,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() end end - if wep then + if false and 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) )