Smoke properly cleans itself, multi muzzle particle

This commit is contained in:
Haodong Mo 2022-12-24 15:25:18 +10:00
parent f7d28a098f
commit 32a9bf4130
5 changed files with 73 additions and 10 deletions

View File

@ -49,14 +49,20 @@ function EFFECT:Init(data)
// end
if muzzle then
local pcf = CreateParticleSystem(muz or parent, muzzle, PATTACH_POINT_FOLLOW, att)
if !istable(muzzle) then
muzzle = {muzzle}
end
if IsValid(pcf) then
pcf:StartEmission()
for _, muzzleeffect in ipairs(muzzle) do
local pcf = CreateParticleSystem(muz or parent, muzzleeffect, PATTACH_POINT_FOLLOW, att)
if (muz or parent) != vm and !wm then
pcf:SetShouldDraw(false)
table.insert(wpn.PCFs, pcf)
if IsValid(pcf) then
pcf:StartEmission()
if (muz or parent) != vm and !wm then
pcf:SetShouldDraw(false)
table.insert(wpn.PCFs, pcf)
end
end
end
end

View File

@ -66,6 +66,7 @@ function ENT:Initialize()
local alph = 0
if pa.ft < CurTime() then
pa:SetDieTime(0)
return
elseif pa.dt < CurTime() then
local d = (CurTime() - pa.dt) / (pa.ft - pa.dt)

View File

@ -109,7 +109,6 @@ function SWEP:GetCameraControl()
ang = mdl:WorldToLocalAngles(ang)
ang:Sub(atttbl.IKCameraMotionOffsetAngle or angle_zero)
ang:Mul(self:GetProcessedValue("CamQCA_Mult") or 1)
ang:Mul(1 - self:GetSightAmount() * (1 - (self:GetProcessedValue("CamQCA_Mult_ADS") or 0.5)))
return ang
else
@ -138,7 +137,7 @@ function SWEP:GetCameraControl()
target = math.min(target, 1 - math.pow( vm:GetCycle(), 2 ) )
local progress = Lerp(FrameTime() * 15, progress or 0, target)
local mult = 1
local mult = self:GetProcessedValue("CamQCA_Mult") or 1
if self:GetAnimLockTime() < CurTime() then
mult = 0
@ -167,7 +166,6 @@ function SWEP:GetCameraControl()
return self.ProceduralViewOffset
else
ang:Mul(self:GetProcessedValue("CamQCA_Mult") or 1)
ang:Mul(1 - self:GetSightAmount() * (1 - (self:GetProcessedValue("CamQCA_Mult_ADS") or 0.5)))
end
return ang

View File

@ -1,6 +1,7 @@
SWEP.StatCache = {}
SWEP.HookCache = {}
SWEP.AffectorsCache = nil
SWEP.UBGLAffectorsCache = nil
SWEP.HasNoAffectors = {}
SWEP.ExcludeFromRawStats = {
@ -14,6 +15,7 @@ function SWEP:InvalidateCache()
self.StatCache = {}
self.HookCache = {}
self.AffectorsCache = nil
self.UBGLAffectorsCache = nil
self.ElementsCache = nil
self.RecoilPatternCache = {}
self.ScrollLevels = {}
@ -94,6 +96,7 @@ function SWEP:GetAllAffectors()
if self.AffectorsCache then return self.AffectorsCache end
local aff = {}
local ubgl_aff = {}
table.insert(aff, self:GetTable())
@ -112,7 +115,11 @@ function SWEP:GetAllAffectors()
local atttbl = self:GetFinalAttTable(slot)
if atttbl then
table.insert(aff, atttbl)
if slot.UBGLSlot then
table.insert(ubgl_aff, atttbl)
else
table.insert(aff, atttbl)
end
end
end
@ -153,6 +160,7 @@ function SWEP:GetAllAffectors()
end
self.AffectorsCache = aff
self.UBGLAffectorsCache = ubgl_aff
return aff
end
@ -409,6 +417,7 @@ function SWEP:GetValue(val, base, condition, amount)
local priority = 0
local getallaffectors = self:GetAllAffectors()
local ubgl_affectors = self.UBGLAffectorsCache or {}
if !self.ExcludeFromRawStats[val] then
for _, tbl in ipairs(getallaffectors) do
@ -420,6 +429,18 @@ function SWEP:GetValue(val, base, condition, amount)
unaffected = false
end
end
if self:GetUBGL() then
for _, tbl in ipairs(ubgl_affectors) do
local att_priority = tbl[val .. condition .. "_Priority"] or 1
if tbl[val .. condition] != nil and att_priority >= priority then
stat = tbl[val .. condition]
priority = att_priority
unaffected = false
end
end
end
end
for _, tbl in ipairs(getallaffectors) do
@ -432,6 +453,18 @@ function SWEP:GetValue(val, base, condition, amount)
end
end
if self:GetUBGL() then
for _, tbl in ipairs(ubgl_affectors) do
local att_priority = tbl[val .. "Override" .. condition .. "_Priority"] or 1
if tbl[val .. "Override" .. condition] != nil and att_priority >= priority then
stat = tbl[val .. "Override" .. condition]
priority = att_priority
unaffected = false
end
end
end
if isnumber(stat) then
for _, tbl in ipairs(getallaffectors) do
if tbl[val .. "Add" .. condition] != nil then
@ -445,6 +478,15 @@ function SWEP:GetValue(val, base, condition, amount)
end
end
if self:GetUBGL() then
for _, tbl in ipairs(ubgl_affectors) do
if type(tbl[val .. "Add" .. condition]) == type(stat) then
stat = stat + (tbl[val .. "Add" .. condition] * amount)
end
unaffected = false
end
end
for _, tbl in ipairs(getallaffectors) do
if tbl[val .. "Mult" .. condition] != nil then
-- if !pcall(function() stat = stat * math.pow(tbl[val .. "Mult" .. condition], amount) end) then
@ -460,6 +502,21 @@ function SWEP:GetValue(val, base, condition, amount)
unaffected = false
end
end
if self:GetUBGL() then
for _, tbl in ipairs(ubgl_affectors) do
if tbl[val .. "Mult" .. condition] != nil then
if type(tbl[val .. "Mult" .. condition]) == type(stat) then
if amount > 1 then
stat = stat * (math.pow(tbl[val .. "Mult" .. condition], amount))
else
stat = stat * tbl[val .. "Mult" .. condition]
end
end
unaffected = false
end
end
end
end
self.StatCache[tostring(base) .. val .. condition] = stat

View File

@ -137,6 +137,7 @@ function SWEP:BuildSubAttachmentTree(tbl, parenttbl)
subatts[i].ToggleNum = tbl.SubAttachments[i].ToggleNum or 1
subatts[i].CorrectiveAng = parenttbl.CorrectiveAng
subatts[i].LaserCorrectionAngle = parenttbl.LaserCorrectionAngle
subatts[i].UBGLSlot = subatts[i].UBGLSlot or parenttbl.UBGLSlot
if parenttbl.DuplicateModels then
subatts[i].DuplicateModels = table.Copy(parenttbl.DuplicateModels)