Replace unpredicted refill timer, fix empty firing

This commit is contained in:
Fesiug 2024-03-20 00:15:48 -04:00
parent c97527ce51
commit c41f359cb4
No known key found for this signature in database
GPG Key ID: 374BFF45E1EEF243
7 changed files with 28 additions and 20 deletions

View File

@ -1,3 +1,4 @@
{
"git-blame.gitWebUrl": ""
"editor.detectIndentation": true,
"editor.insertSpaces": true
}

View File

@ -1,3 +0,0 @@
{
"git-blame.gitWebUrl": ""
}

View File

@ -107,7 +107,7 @@ function SWEP:PlayAnimation(anim, mult, lock, delayidle, noproxy, notranslate, n
if animation.EjectAt then
self:SetTimer(animation.EjectAt * mult, function()
self:DoEject()
end)
end, "ejectat")
end
if animation.DropMagAt then

View File

@ -217,6 +217,7 @@ function SWEP:Holster(wep)
return true
else
-- Prepare the holster and set up the timer
self:KillTimer("ejectat")
if self:HasAnimation("holster") then
local animation = self:PlayAnimation("holster", self:GetProcessedValue("DeployTime", true, 1), true, false, nil, nil, true) or 0
local aentry = self:GetAnimationEntry(self:TranslateAnimation("holster"))

View File

@ -1,3 +1,14 @@
function SWEP:SetReloadTimer( time, amount )
self:SetReloadTime( time )
self:SetReloadAmount( amount )
end
function SWEP:KillReloadTimer()
self:SetReloadTime( 0 )
self:SetReloadAmount( 0 )
end
function SWEP:Reload()
if self:GetOwner():IsNPC() then
self:NPC_Reload()
@ -106,15 +117,7 @@ function SWEP:Reload()
minprogress = math.min(minprogress, 0.95)
if !self:GetAnimationEntry(self:TranslateAnimation(anim)).RestoreAmmo then
if getUBGL then
self:SetTimer(t * minprogress, function()
self:RestoreClip(self:GetValue("UBGLClipSize"))
end, "reloadtimer")
else
self:SetTimer(t * minprogress, function()
self:RestoreClip(self:GetValue("ClipSize"))
end, "reloadtimer")
end
self:SetReloadTimer( CurTime() + (t * minprogress), self:GetValue(getUBGL and "UBGLClipSize" or "ClipSize") )
end
local newcliptime = self:GetAnimationEntry(self:TranslateAnimation(anim)).MagSwapTime or 0.5
@ -211,7 +214,7 @@ function SWEP:CancelReload()
self:PlayAnimation("idle")
self:DoPlayerAnimationEvent(ACT_HL2MP_GESTURE_RELOAD_MAGIC)
self:CancelSoundTable()
self:KillTimer("reloadtimer")
self:KillReloadTimer()
self:SetIKTimeLineStart(0)
self:SetIKTime(0)
self:SetEmptyReload(false)
@ -496,6 +499,11 @@ function SWEP:EndReload()
end
function SWEP:ThinkReload()
if self:GetReloadTime() != 0 and self:GetReloadTime() <= CurTime() then
self:RestoreClip( self:GetReloadAmount() )
self:SetReloadTime( 0 )
self:SetReloadAmount( 0 )
end
if self:GetReloading() and self:GetReloadFinishTime() <= CurTime() then
self:EndReload()
end

View File

@ -366,6 +366,7 @@ function SWEP:DoPrimaryAttack()
self:RunHook("Hook_PrimaryAttack")
self:SetEmptyReload(false)
self:TakeAmmo()
local triggerStartFireAnim = processedValue(self,"TriggerStartFireAnim", true)

View File

@ -1496,7 +1496,7 @@ function SWEP:SetupDataTables()
self:NetworkVar("Float", 6, "SprintAmount")
self:NetworkVar("Float", 7, "LastMeleeTime")
self:NetworkVar("Float", 8, "TriggerDelay")
-- 9
self:NetworkVar("Float", 9, "ReloadTime")
self:NetworkVar("Float", 10, "ReloadFinishTime")
self:NetworkVar("Float", 11, "SightAmount")
self:NetworkVar("Float", 12, "HeatAmount")
@ -1524,12 +1524,12 @@ function SWEP:SetupDataTables()
self:NetworkVar("Int", 4, "NthReload")
self:NetworkVar("Int", 5, "MultiSight")
self:NetworkVar("Int", 6, "SequenceProxy")
-- self:NetworkVar("Int", 6, "BlindFireDirection")
self:NetworkVar("Int", 7, "HideBoneIndex")
self:NetworkVar("Int", 8, "SequenceIndex")
self:NetworkVar("Int", 9, "LeanState")
self:NetworkVar("Int", 10, "LastLoadedRounds")
self:NetworkVar("Int", 11, "PoseParameterIndex")
self:NetworkVar("Int", 12, "ReloadAmount")
self:NetworkVar("Bool", 0, "Customize")
self:NetworkVar("Bool", 1, "Reloading")