Skip to content

Commit

Permalink
Use effects library
Browse files Browse the repository at this point in the history
  • Loading branch information
thecraftianman committed Aug 30, 2024
1 parent ced8176 commit 162ecf0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
50 changes: 24 additions & 26 deletions lua/acf/entities/ammo_types/glatgm.lua
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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")
Expand Down
18 changes: 10 additions & 8 deletions lua/entities/acf_rack/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 162ecf0

Please sign in to comment.