More reload tweaks

This commit is contained in:
Fesiug 2023-12-15 04:15:56 -05:00
parent d1da58d9b7
commit 8d244cd85c
4 changed files with 31 additions and 30 deletions

View File

@ -4,8 +4,8 @@
SWEP.GEN_MagOut = 0
SWEP.GEN_MagIn = 0.8
SWEP.GEN_MagIn_BonusStart = 0.2
SWEP.GEN_MagIn_BonusEnd = 0.25
SWEP.GEN_MagIn_BonusStart = 0.6
SWEP.GEN_MagIn_BonusEnd = 0.7
function SWEP:Reload( hand )
if hand == nil then return end -- Needs to be called from the custom ones
@ -22,12 +22,12 @@ function SWEP:Reload( hand )
end
local rt = self:D_GetReloading( hand )
if rt > 0 then
if self.GEN_MagIn_BonusStart <= rt and rt < self.GEN_MagIn_BonusEnd then
if (rt+self.GEN_MagIn_BonusStart) <= RealTime() and RealTime() <= (rt+self.GEN_MagIn_BonusEnd) then
self:D_SetReloading( hand, 0 )
return true
else
B_Sound( self, "Common.ReloadFail" )
self:D_SetReloading( hand, 1 )
self:D_SetReloading( hand, RealTime() )
return false
end
end
@ -38,8 +38,9 @@ function SWEP:Reload( hand )
-- self:D_SetReloadType( hand, 2 )
self:Reload_MagOut( hand, self:D_GetMagID( hand ), inv )
else
self:D_SetReloading( hand, wep_class.Reload_MagIn or self.GEN_MagIn )
self:D_SetReloading( hand, RealTime() )
self:D_SetReloadType( hand, 1 )
B_Sound( self, "Common.Unload" )
end
self:TPReload( hand )
end

View File

@ -212,8 +212,8 @@ function SWEP:Think()
do -- Reload logic
if self:D_GetReloading( hand ) != -1 then
self:D_SetReloading( hand, math.Approach( self:D_GetReloading( hand ), 0, FrameTime() ) )
if self:D_GetReloading( hand ) == 0 then
--self:D_SetReloading( hand, math.Approach( self:D_GetReloading( hand ), 0, FrameTime() ) )
if RealTime() >= self:D_GetReloading( hand ) + (self:BClass( hand ).Reload_MagIn or self.GEN_MagIn) then
local rlt = self:D_GetReloadType( hand )
if rlt == 1 then
if SERVER or (CLIENT and IsFirstTimePredicted() ) then

View File

@ -896,40 +896,39 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
end
if true and wep then
local bump1 = ss(1)
local bump2 = ss(1)
local bump4 = ss(2)
local boost = ss(44)
local r_w, r_h = ss(8), ss(72)
for i=1, 2 do
local hand = i==2
local boost = ss(44)
if hand then boost = -boost end
local wr = wep:D_GetReloading( hand )
if wr > 0 then
local translate = 1
if wep:D_GetReloadType( hand ) == 2 then
wr = math.TimeFraction( 0, wep.GEN_MagOut, wr )
else
wr = math.TimeFraction( 0, wep.GEN_MagIn, wr )
end
translate = wr/wep:D_GetReloading( hand )
wr = 1-wr
-- PROTO: Get interp values
local interpr = GetConVarNumber( "cl_interp_ratio" )/GetConVarNumber( "cl_cmdrate" )
local interp = GetConVarNumber( "cl_interp" )
wr = wr - math.max( interpr, interp )
local r_w, r_h = ss(8), ss(72)
local b1 = math.TimeFraction( wr, wr + (wep.GEN_MagIn), wr + (wep.GEN_MagIn_BonusStart) )
local b2 = math.TimeFraction( wr, wr + (wep.GEN_MagIn), wr + (wep.GEN_MagIn_BonusEnd) )
wr = math.TimeFraction( wr, wr + (wep:BClass( hand ).Reload_MagIn or wep.GEN_MagIn), RealTime() )
local r_x, r_y = sw/2 - r_w/2 + boost, sh/2 - r_h/2
surface.SetDrawColor( schema("bg") )
surface.DrawRect( r_x, r_y, r_w, r_h )
surface.DrawRect( r_x - bump4, r_y - bump4, r_w + bump4*2, r_h + bump4*2 )
surface.SetDrawColor( schema("fg") )
surface.DrawOutlinedRect( r_x + ss(1), r_y + ss(1), r_w - ss(2), r_h - ss(2), ss(0.5) )
surface.DrawOutlinedRect( r_x - bump2, r_y - bump2, r_w + bump2*2, r_h + bump2*2, ss(0.5) )
surface.DrawRect( r_x + ss(2), r_y + ss(2) + (r_h-ss(4))-math.Round( (r_h-ss(4)) * wr ), r_w - ss(4), math.Round((r_h - ss(4)) * wr) )
local gump = math.Round( r_h*(1-wr) )
surface.SetDrawColor( schema("fg") )
surface.DrawRect( r_x, r_y+gump, r_w, r_h-gump )
local gump1 = math.Round( r_h*(1-b1) )
local gump2 = math.Round( r_h*(1-b2) )
surface.SetDrawColor( 255, 100, 100, 100 )
surface.DrawRect( r_x, r_y+gump2, r_w, gump2 )
surface.SetDrawColor( 255, 100, 100 )
surface.DrawRect( r_x + ss(2), r_y + ss(2) + (r_h+ss(4))*(translate*wep.GEN_MagIn_BonusStart), r_w - ss(4), ss(1) )
surface.DrawRect( r_x + ss(2), r_y + ss(2) + (r_h+ss(4))*(translate*wep.GEN_MagIn_BonusEnd), r_w - ss(4), ss(1) )
surface.DrawRect( r_x, r_y+gump1, r_w, ss(1) )
surface.DrawRect( r_x, r_y+gump2, r_w, ss(1) )
end
end
end

View File

@ -158,10 +158,11 @@ do -- Sound definitions
}, 70, 100, 0.5, CHAN_STATIC )
AddSound( "SPAS12.MagIn", "benny/weapons/spas12/magin.ogg", 70, 100, 0.5, CHAN_STATIC )
AddSound( "Common.Unload", "benny/weapons/unload.ogg", 70, 100, 0.5, CHAN_STATIC )
AddSound( "Common.Dryfire.Pistol", "benny/weapons/common/06-13.ogg", 70, 100, 0.5, CHAN_STATIC )
AddSound( "Common.Dryfire.Rifle", "benny/weapons/common/06-12.ogg", 70, 100, 0.5, CHAN_STATIC )
AddSound( "Common.NoAmmo", "benny/weapons/noammo.ogg", 70, 100, 0.5, CHAN_STATIC )
AddSound( "Common.ReloadFail", "benny/hud/reloadfail.ogg", 70, 100, 0.5, CHAN_STATIC )
AddSound( "Common.ReloadFail", "benny/hud/reloadfail.ogg", 70, 100, 0.1, CHAN_STATIC )
end