forked from HaodongMo/ArcCW
I have clutched... something... from the jaws of source spaghetti
This commit is contained in:
parent
efaa247d42
commit
e0850b34e8
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,3 @@
|
|||||||
arccw.code-workspace
|
|
||||||
upload.cmd
|
upload.cmd
|
||||||
workshop_id.cmd
|
workshop_id.cmd
|
||||||
.VSCodeCounter/2021-01-30_17-43-13/details.md
|
.VSCodeCounter/2021-01-30_17-43-13/details.md
|
||||||
@ -9,3 +8,4 @@ workshop_id.cmd
|
|||||||
.VSCodeCounter/2021-02-19_16-55-12/results.csv
|
.VSCodeCounter/2021-02-19_16-55-12/results.csv
|
||||||
.VSCodeCounter/2021-02-19_16-55-12/results.md
|
.VSCodeCounter/2021-02-19_16-55-12/results.md
|
||||||
.VSCodeCounter/2021-02-19_16-55-12/results.txt
|
.VSCodeCounter/2021-02-19_16-55-12/results.txt
|
||||||
|
*.code-workspace
|
||||||
|
@ -42,6 +42,8 @@ function SWEP:PlayAnimation(key, mult, pred, startfrom, tt, skipholster, ignorer
|
|||||||
ignorereload = ignorereload or false
|
ignorereload = ignorereload or false
|
||||||
absolute = absolute or false
|
absolute = absolute or false
|
||||||
|
|
||||||
|
local ct = CurTime() --pred and CurTime() or UnPredictedCurTime()
|
||||||
|
|
||||||
if !self.Animations[key] then return end
|
if !self.Animations[key] then return end
|
||||||
|
|
||||||
if self:GetReloading() and !ignorereload then return end
|
if self:GetReloading() and !ignorereload then return end
|
||||||
@ -131,12 +133,12 @@ function SWEP:PlayAnimation(key, mult, pred, startfrom, tt, skipholster, ignorer
|
|||||||
if startfrom > (time * mult) then return end
|
if startfrom > (time * mult) then return end
|
||||||
|
|
||||||
if tt then
|
if tt then
|
||||||
self:SetNextPrimaryFire(CurTime() + ((anim.MinProgress or time) * mult) - startfrom)
|
self:SetNextPrimaryFire(ct + ((anim.MinProgress or time) * mult) - startfrom)
|
||||||
end
|
end
|
||||||
|
|
||||||
if CLIENT then
|
--if CLIENT then
|
||||||
vm:SetAnimTime(CurTime() - startfrom)
|
-- vm:SetAnimTime(ct - startfrom)
|
||||||
end
|
--end
|
||||||
|
|
||||||
if anim.LHIK then
|
if anim.LHIK then
|
||||||
-- self.LHIKTimeline = {
|
-- self.LHIKTimeline = {
|
||||||
@ -155,8 +157,8 @@ function SWEP:PlayAnimation(key, mult, pred, startfrom, tt, skipholster, ignorer
|
|||||||
-- self.LHIKTimeline[3] = math.huge
|
-- self.LHIKTimeline[3] = math.huge
|
||||||
-- self.LHIKTimeline[4] = math.huge
|
-- self.LHIKTimeline[4] = math.huge
|
||||||
-- end
|
-- end
|
||||||
self.LHIKStartTime = CurTime()
|
self.LHIKStartTime = ct
|
||||||
self.LHIKEndTime = CurTime() + ttime
|
self.LHIKEndTime = ct + ttime
|
||||||
|
|
||||||
if anim.LHIKTimeline then
|
if anim.LHIKTimeline then
|
||||||
self.LHIKTimeline = {}
|
self.LHIKTimeline = {}
|
||||||
@ -189,7 +191,7 @@ function SWEP:PlayAnimation(key, mult, pred, startfrom, tt, skipholster, ignorer
|
|||||||
end
|
end
|
||||||
|
|
||||||
if anim.LastClip1OutTime then
|
if anim.LastClip1OutTime then
|
||||||
self.LastClipOutTime = CurTime() + ((anim.LastClip1OutTime * mult) - startfrom)
|
self.LastClipOutTime = ct + ((anim.LastClip1OutTime * mult) - startfrom)
|
||||||
end
|
end
|
||||||
|
|
||||||
local seq = anim.Source
|
local seq = anim.Source
|
||||||
@ -212,7 +214,14 @@ function SWEP:PlayAnimation(key, mult, pred, startfrom, tt, skipholster, ignorer
|
|||||||
seq = vm:LookupSequence(seq)
|
seq = vm:LookupSequence(seq)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if seq then --!game.SinglePlayer() and CLIENT
|
if seq then --!game.SinglePlayer() and CLIENT
|
||||||
|
|
||||||
|
--local lastseq = self:GetLastSequence()
|
||||||
|
--self:SetLastSequence(seq)
|
||||||
|
local lastanim = self:GetLastAnim()
|
||||||
|
self:SetLastAnim(key)
|
||||||
|
|
||||||
-- Hack to fix an issue with playing one anim multiple times in a row
|
-- Hack to fix an issue with playing one anim multiple times in a row
|
||||||
-- Provided by Jackarunda
|
-- Provided by Jackarunda
|
||||||
local resetSeq = anim.HardResetAnim and vm:LookupSequence(anim.HardResetAnim)
|
local resetSeq = anim.HardResetAnim and vm:LookupSequence(anim.HardResetAnim)
|
||||||
@ -225,45 +234,62 @@ function SWEP:PlayAnimation(key, mult, pred, startfrom, tt, skipholster, ignorer
|
|||||||
vm:SetPlaybackRate(math.Clamp(dur / (ttime + startfrom), -4, 12))
|
vm:SetPlaybackRate(math.Clamp(dur / (ttime + startfrom), -4, 12))
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
|
|
||||||
|
--[[]
|
||||||
|
if seq > 0 and IsFirstTimePredicted() then
|
||||||
|
print(self:GetOwner(), seq, self:GetLastSequence(), CurTime(), UnPredictedCurTime())
|
||||||
|
if SERVER then
|
||||||
|
PrintMessage(HUD_PRINTTALK, "SERVER: " .. tostring(self:GetOwner()) .. " " .. tostring(seq) .. " " .. CurTime())
|
||||||
|
end
|
||||||
|
end
|
||||||
|
]]
|
||||||
|
|
||||||
|
--[[]
|
||||||
|
print(seq, lastseq, CurTime())
|
||||||
vm:SendViewModelMatchingSequence(seq)
|
vm:SendViewModelMatchingSequence(seq)
|
||||||
local dur = vm:SequenceDuration()
|
local dur = vm:SequenceDuration()
|
||||||
vm:SetPlaybackRate(math.Clamp(dur / (ttime + startfrom), -4, 12))
|
vm:SetPlaybackRate(math.Clamp(dur / (ttime + startfrom), -4, 12))
|
||||||
self.LastAnimStartTime = CurTime()
|
self.LastAnimStartTime = ct
|
||||||
self.LastAnimFinishTime = CurTime() + (dur * mult)
|
self.LastAnimFinishTime = ct + (dur * mult)
|
||||||
|
]]
|
||||||
|
|
||||||
|
if anim == lastanim then
|
||||||
|
|
||||||
|
vm:SendViewModelMatchingSequence(seq)
|
||||||
|
vm:SetPlaybackRate(0)
|
||||||
|
vm:SetCycle(0)
|
||||||
|
|
||||||
|
--if seq ~= lastseq then self:PlayIdleAnimation(pred) end
|
||||||
|
--print("identical", seq, CurTime())
|
||||||
|
if pred and IsFirstTimePredicted() then
|
||||||
|
timer.Simple(0, function()
|
||||||
|
vm:SendViewModelMatchingSequence(seq)
|
||||||
|
local dur = vm:SequenceDuration()
|
||||||
|
vm:SetPlaybackRate(math.Clamp(dur / (ttime + startfrom), -4, 12))
|
||||||
|
self.LastAnimStartTime = ct
|
||||||
|
self.LastAnimFinishTime = ct + (dur * mult)
|
||||||
|
|
||||||
|
self:SetTimer(ttime, function()
|
||||||
|
self:NextAnimation()
|
||||||
|
end, key)
|
||||||
|
|
||||||
|
self:SetTimer(ttime, function()
|
||||||
|
self:PlayIdleAnimation(pred)
|
||||||
|
end, "idlereset")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
--print("new", seq, lastseq, CurTime())
|
||||||
|
vm:SendViewModelMatchingSequence(seq)
|
||||||
|
local dur = vm:SequenceDuration()
|
||||||
|
vm:SetPlaybackRate(math.Clamp(dur / (ttime + startfrom), -4, 12))
|
||||||
|
self.LastAnimStartTime = ct
|
||||||
|
self.LastAnimFinishTime = ct + (dur * mult)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- :(
|
|
||||||
-- unfortunately, gmod seems to have broken the features required for this to work.
|
|
||||||
-- as such, I'm reverting to a more traditional reload system.
|
|
||||||
|
|
||||||
-- local framestorealtime = 1
|
|
||||||
|
|
||||||
-- if anim.FrameRate then
|
|
||||||
-- framestorealtime = 1 / anim.FrameRate
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- local dur = vm:SequenceDuration()
|
|
||||||
-- vm:SetPlaybackRate(dur / (ttime + startfrom))
|
|
||||||
|
|
||||||
-- if anim.Checkpoints then
|
|
||||||
-- self.CheckpointAnimation = key
|
|
||||||
-- self.CheckpointTime = startfrom
|
|
||||||
|
|
||||||
-- for i, k in pairs(anim.Checkpoints) do
|
|
||||||
-- if !k then continue end
|
|
||||||
-- if istable(k) then continue end
|
|
||||||
-- local realtime = k * framestorealtime
|
|
||||||
|
|
||||||
-- if realtime > startfrom then
|
|
||||||
-- self:SetTimer((realtime * mult) - startfrom, function()
|
|
||||||
-- self.CheckpointAnimation = key
|
|
||||||
-- self.CheckpointTime = realtime
|
|
||||||
-- end)
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
|
|
||||||
if anim.TPAnim then
|
if anim.TPAnim then
|
||||||
local aseq = self:GetOwner():SelectWeightedSequence(anim.TPAnim)
|
local aseq = self:GetOwner():SelectWeightedSequence(anim.TPAnim)
|
||||||
if aseq then
|
if aseq then
|
||||||
@ -292,8 +318,6 @@ function SWEP:PlayAnimation(key, mult, pred, startfrom, tt, skipholster, ignorer
|
|||||||
|
|
||||||
self:SetTimer(ttime, function()
|
self:SetTimer(ttime, function()
|
||||||
self:NextAnimation()
|
self:NextAnimation()
|
||||||
|
|
||||||
-- self:ResetCheckpoints()
|
|
||||||
end, key)
|
end, key)
|
||||||
|
|
||||||
self:SetTimer(ttime, function()
|
self:SetTimer(ttime, function()
|
||||||
|
@ -506,7 +506,7 @@ function SWEP:DoPrimaryAnim()
|
|||||||
|
|
||||||
local time = self:GetBuff_Mult("Mult_FireAnimTime", anim) or 1
|
local time = self:GetBuff_Mult("Mult_FireAnimTime", anim) or 1
|
||||||
|
|
||||||
if anim and (CLIENT or game.SinglePlayer()) then self:PlayAnimation(anim, time, true, 0, false) end
|
if anim then self:PlayAnimation(anim, time, false, 0, false) end
|
||||||
end
|
end
|
||||||
|
|
||||||
function SWEP:DoPenetration(tr, penleft, alreadypenned)
|
function SWEP:DoPenetration(tr, penleft, alreadypenned)
|
||||||
|
@ -20,6 +20,7 @@ function SWEP:SetClipInfo(load)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SWEP:Reload()
|
function SWEP:Reload()
|
||||||
|
|
||||||
if self:GetOwner():IsNPC() then
|
if self:GetOwner():IsNPC() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -37,6 +38,17 @@ function SWEP:Reload()
|
|||||||
|
|
||||||
-- if !game.SinglePlayer() and !IsFirstTimePredicted() then return end
|
-- if !game.SinglePlayer() and !IsFirstTimePredicted() then return end
|
||||||
|
|
||||||
|
-- DEBUG
|
||||||
|
--[[]
|
||||||
|
local vm = self.Owner:GetViewModel()
|
||||||
|
vm:SendViewModelMatchingSequence(vm:LookupSequence("reload"))
|
||||||
|
print("reload", CurTime())
|
||||||
|
if SERVER then
|
||||||
|
PrintMessage(HUD_PRINTTALK, "SERVER: " .. tostring(self:GetOwner()) .. " " .. CurTime())
|
||||||
|
end
|
||||||
|
if true then self:SetNextPrimaryFire(CurTime() + 2) return end
|
||||||
|
]]
|
||||||
|
|
||||||
if self.Throwing then return end
|
if self.Throwing then return end
|
||||||
if self.PrimaryBash then return end
|
if self.PrimaryBash then return end
|
||||||
|
|
||||||
@ -335,15 +347,15 @@ function SWEP:ReloadInsert(empty)
|
|||||||
|
|
||||||
ret = self:GetBuff_Hook("Hook_SelectReloadAnimation", ret) or ret
|
ret = self:GetBuff_Hook("Hook_SelectReloadAnimation", ret) or ret
|
||||||
|
|
||||||
self:PlayAnimation(ret, mult, true, 0, true, nil, true)
|
self:PlayAnimation(ret, mult, false, 0, true, nil, true)
|
||||||
self:SetReloading(CurTime() + (self:GetAnimKeyTime(ret, true) * mult))
|
self:SetReloading(CurTime() + (self:GetAnimKeyTime(ret, true) * mult))
|
||||||
self:SetTimer(self:GetAnimKeyTime(ret, true) * mult,
|
self:SetTimer(self:GetAnimKeyTime(ret, true) * mult,
|
||||||
function()
|
function()
|
||||||
self:SetNthReload(self:GetNthReload() + 1)
|
self:SetNthReload(self:GetNthReload() + 1)
|
||||||
if self:GetOwner():KeyDown(IN_ATTACK2) then
|
if self:GetOwner():KeyDown(IN_ATTACK2) then
|
||||||
self:EnterSights()
|
self:EnterSights()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
self:SetReqEnd(false)
|
self:SetReqEnd(false)
|
||||||
else
|
else
|
||||||
@ -370,7 +382,7 @@ function SWEP:ReloadInsert(empty)
|
|||||||
|
|
||||||
self:SetReloading(CurTime() + time * mult)
|
self:SetReloading(CurTime() + time * mult)
|
||||||
|
|
||||||
self:PlayAnimation(insertanim, mult, true, 0, true, nil, true)
|
self:PlayAnimation(insertanim, mult, false, 0, true, nil, true)
|
||||||
self:SetTimer(time * mult,
|
self:SetTimer(time * mult,
|
||||||
function()
|
function()
|
||||||
self:ReloadInsert(empty)
|
self:ReloadInsert(empty)
|
||||||
|
@ -717,6 +717,7 @@ function SWEP:SetupDataTables()
|
|||||||
self:NetworkVar("Int", 3, "LastLoad")
|
self:NetworkVar("Int", 3, "LastLoad")
|
||||||
self:NetworkVar("Int", 4, "NthReload")
|
self:NetworkVar("Int", 4, "NthReload")
|
||||||
self:NetworkVar("Int", 5, "NthShot")
|
self:NetworkVar("Int", 5, "NthShot")
|
||||||
|
--self:NetworkVar("Int", 6, "LastSequence")
|
||||||
|
|
||||||
self:NetworkVar("Bool", 0, "HeatLocked")
|
self:NetworkVar("Bool", 0, "HeatLocked")
|
||||||
self:NetworkVar("Bool", 1, "NeedCycle")
|
self:NetworkVar("Bool", 1, "NeedCycle")
|
||||||
@ -731,6 +732,8 @@ function SWEP:SetupDataTables()
|
|||||||
self:NetworkVar("Float", 2, "ReloadingREAL")
|
self:NetworkVar("Float", 2, "ReloadingREAL")
|
||||||
self:NetworkVar("Float", 3, "MagUpIn")
|
self:NetworkVar("Float", 3, "MagUpIn")
|
||||||
self:NetworkVar("Float", 4, "NextPrimaryFireSlowdown")
|
self:NetworkVar("Float", 4, "NextPrimaryFireSlowdown")
|
||||||
|
|
||||||
|
self:NetworkVar("String", 0, "LastAnim")
|
||||||
end
|
end
|
||||||
|
|
||||||
function SWEP:OnRestore()
|
function SWEP:OnRestore()
|
||||||
|
Loading…
Reference in New Issue
Block a user