Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clamp spark effect so ammo powerup doesn't cause issues #66

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lua/weapons/cfc_ion_cannon/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ if SERVER then

local dmgPos = hitPos - traceDir * pullback
local falloffMult = wep:GetDamageFalloff( startPos:Distance( hitPos ) )
local damageFracClamped = math.Clamp( damageFrac, 0, 1 )

damage = damage * falloffMult
radius = radius * falloffMult
Expand All @@ -419,8 +420,8 @@ if SERVER then

local eff = EffectData()
eff:SetOrigin( dmgPos )
eff:SetMagnitude( 2.5 * damageFrac )
eff:SetScale( 1.75 * damageFrac )
eff:SetMagnitude( 2.5 * damageFracClamped ) -- Clamp the effect scale, as high-magntitude sparks can prevent future sparks from rendering
Copy link
Member

@brandonsturgeon brandonsturgeon Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment would be better up by the damageFracClamped definition.

Also, still not a fan of trailing comments that are more than a few words🥲

eff:SetScale( 1.75 * damageFracClamped )
eff:SetRadius( radius * 0.35 )
eff:SetNormal( tr.HitNormal )
util.Effect( "AR2Explosion", eff, true, true )
Expand All @@ -429,6 +430,6 @@ if SERVER then
local rf = RecipientFilter()
rf:AddPAS( dmgPos )

EmitSound( wep.Primary.ExplosionSound, dmgPos, 0, CHAN_AUTO, wep.Primary.ExplosionVolume * damageFrac * falloffMult, 80, 0, wep.Primary.ExplosionPitch, 0, rf )
EmitSound( wep.Primary.ExplosionSound, dmgPos, 0, CHAN_AUTO, wep.Primary.ExplosionVolume * damageFracClamped * falloffMult, 80, 0, wep.Primary.ExplosionPitch, 0, rf )
end
end