Skip to content

Commit

Permalink
Make projectile particles less dependent on FPS
Browse files Browse the repository at this point in the history
  • Loading branch information
StyledStrike committed Dec 14, 2024
1 parent 3dad9e5 commit d8fab3a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
15 changes: 10 additions & 5 deletions lua/effects/glide_projectile.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
local FrameTime = FrameTime
local RandomVec = VectorRand
local RandomInt = math.random
local RandomFloat = math.Rand
local Max = math.max

local SMOKE_MATERIAL = "particle/smokesprites_000"
local r, g, b = 0, 0, 0
Expand All @@ -16,16 +18,19 @@ function EFFECT:Init( data )

r, g, b = color[1], color[2], color[3]

local step = 1000 * Max( FrameTime(), 0.03 )

for i = 1, 10 do
local p = emitter:Add( SMOKE_MATERIAL .. RandomInt( 9 ), origin + normal * i * 5 )
local p = emitter:Add( SMOKE_MATERIAL .. RandomInt( 9 ), origin - normal * i * step )

if p then
p:SetDieTime( RandomFloat( 0.5, 1.0 ) )
p:SetStartAlpha( 60 )
p:SetDieTime( RandomFloat( 0.5, 1 ) )
p:SetStartAlpha( 100 )
p:SetEndAlpha( 0 )
p:SetStartSize( RandomFloat( 4, 10 ) * scale )
p:SetEndSize( RandomFloat( 20, 50 ) * scale )
p:SetStartSize( RandomFloat( 5, 10 ) * scale )
p:SetEndSize( RandomFloat( 30, 50 ) * scale )
p:SetRoll( RandomFloat( -1, 1 ) )
p:SetRollDelta( RandomFloat( -4, 4 ) )

p:SetAirResistance( 100 )
p:SetVelocity( RandomVec() * RandomFloat( -100, 100 ) * scale )
Expand Down
2 changes: 1 addition & 1 deletion lua/entities/glide_projectile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end
if not SERVER then return end

function ENT:Initialize()
self:SetSmokeColor( Vector( 80, 80, 80 ) )
self:SetSmokeColor( Vector( 60, 60, 60 ) )

self:SetModel( "models/props_phx/misc/flakshell_big.mdl" )
self:SetSolid( SOLID_VPHYSICS )
Expand Down
12 changes: 6 additions & 6 deletions lua/weapons/gmod_tool/stools/glide_projectile_launcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ TOOL.ClientConVar = {
delay = 2,
radius = 350,
damage = 100,
r = 80,
g = 80,
b = 80
r = 60,
g = 60,
b = 60
}

local function IsGlideProjectileLauncher( ent )
Expand All @@ -31,9 +31,9 @@ if SERVER then
local radius = self:GetClientNumber( "radius" )
local damage = self:GetClientNumber( "damage" )

local r = self:GetClientNumber( "r", 80 )
local g = self:GetClientNumber( "g", 80 )
local b = self:GetClientNumber( "b", 80 )
local r = self:GetClientNumber( "r", 60 )
local g = self:GetClientNumber( "g", 60 )
local b = self:GetClientNumber( "b", 60 )

ent:SetProjectileSpeed( speed )
ent:SetProjectileGravity( gravity )
Expand Down

0 comments on commit d8fab3a

Please sign in to comment.