From 162ecf0994601ee85af963bfc59fe5d9b8a10b67 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Fri, 30 Aug 2024 17:52:29 -0400 Subject: [PATCH] Use effects library --- lua/acf/entities/ammo_types/glatgm.lua | 50 +++++++++++++------------- lua/entities/acf_rack/init.lua | 18 +++++----- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/lua/acf/entities/ammo_types/glatgm.lua b/lua/acf/entities/ammo_types/glatgm.lua index 95ecd8a..4f6e9ce 100644 --- a/lua/acf/entities/ammo_types/glatgm.lua +++ b/lua/acf/entities/ammo_types/glatgm.lua @@ -1,5 +1,6 @@ local ACF = ACF local AmmoTypes = ACF.Classes.AmmoTypes +local Effects = ACF.Utilities.Effects local Ammo = AmmoTypes.Register("GLATGM", "HEATFS") function Ammo:OnLoaded() @@ -60,38 +61,35 @@ if SERVER then end function Ammo:HEATExplosionEffect(Bullet, Pos) - local Data = EffectData() - Data:SetOrigin(Pos) - Data:SetNormal(Bullet.Flight:GetNormalized()) - Data:SetRadius(math.max(Bullet.FillerMass ^ 0.33 * 8 * 39.37, 1)) + local EffectTable = { + Origin = Pos, + Normal = Bullet.Flight:GetNormalized(), + Radius = math.max(Bullet.FillerMass ^ 0.33 * 8 * 39.37, 1), + } - util.Effect("ACF_GLATGMExplosion", Data) + Effects.CreateEffect("ACF_GLATGMExplosion", EffectTable) end else ACF.RegisterAmmoDecal("GLATGM", "damage/heat_pen", "damage/heat_rico", function(Caliber) return Caliber * 0.1667 end) function Ammo:PenetrationEffect(Effect, Bullet) - local Data = EffectData() - - if Bullet.Detonated then - Data:SetOrigin(Bullet.SimPos) - Data:SetNormal(Bullet.SimFlight:GetNormalized()) - Data:SetScale(Bullet.SimFlight:Length()) - Data:SetMagnitude(Bullet.RoundMass) - Data:SetRadius(Bullet.Caliber) - Data:SetDamageType(DecalIndex(Bullet.AmmoType)) - - util.Effect("ACF_Penetration", Data) - else - local BoomFillerMass = Bullet.FillerMass * ACF.HEATBoomConvert - - Data:SetOrigin(Bullet.SimPos) - Data:SetNormal(Bullet.SimFlight:GetNormalized()) - Data:SetScale(math.max(BoomFillerMass ^ 0.33 * 3 * 39.37, 1)) - Data:SetRadius(Bullet.Caliber) - - util.Effect("ACF_GLATGMExplosion", Data) - + local Detonated = Bullet.Detonated + local EffectName = Detonated and "ACF_Penetration" or "ACF_GLATGMExplosion" + local BoomFillerMass = Bullet.FillerMass * ACF.HEATBoomConvert + local Scale = Detonated and Bullet.SimFlight:Length() or math.max(BoomFillerMass ^ 0.33 * 3 * 39.37, 1) + + local EffectTable = { + Origin = Bullet.SimPos, + Normal = Bullet.SimFlight:GetNormalized(), + Radius = Bullet.Caliber, + Scale = Scale, + Magnitude = Detonated and Bullet.RoundMass or nil, + DamageType = Detonated and DecalIndex(Bullet.AmmoType) or nil, + } + + Effects.CreateEffect(EffectName, EffectTable) + + if not Detonated then Bullet.Detonated = true Effect:SetModel("models/Gibs/wood_gib01e.mdl") diff --git a/lua/entities/acf_rack/init.lua b/lua/entities/acf_rack/init.lua index 4bb8768..bd12a39 100644 --- a/lua/entities/acf_rack/init.lua +++ b/lua/entities/acf_rack/init.lua @@ -307,20 +307,22 @@ end --------------------------------------------- do -- Custom ACF damage ------------------------ local Damage = ACF.Damage + local Effects = ACF.Utilities.Effects local SparkSound = "ambient/energy/spark%s.wav" local function ShowDamage(Rack, Point) local Position = Rack:LocalToWorld(Point.Position) - local Effect = EffectData() - Effect:SetMagnitude(math.Rand(0.5, 1)) - Effect:SetRadius(1) - Effect:SetScale(1) - Effect:SetStart(Position) - Effect:SetOrigin(Position) - Effect:SetNormal(VectorRand()) + local EffectTable = { + Magnitude = math.Rand(0.5, 1), + Radius = 1, + Scale = 1, + Start = Position, + Origin = Position, + Normal = VectorRand(), + } - util.Effect("Sparks", Effect, true, true) + Effects.CreateEffect("Sparks", EffectTable, true, true) Sounds.SendSound(Rack, SparkSound:format(math.random(6)), math.random(55, 65), math.random(99, 101), 1)