rendered paste body
local EffectLength = 3
/*---------------------------------------------------------
Initializes the effect. The data is a table of data
which was passed from the server.
---------------------------------------------------------*/
function EFFECT:Init( data )
self.TargetEntity = data:GetEntity()
self.NextParticles = CurTime()
self.EffectDie = CurTime() + EffectLength
self.Color = team.GetColor( data:GetScale() )
local emitter = ParticleEmitter( data:GetOrigin() )
for i=0, 5 do
local particle = emitter:Add( "effects/yellowflare", data:GetOrigin() )
particle:SetVelocity( Vector( 0,0,0 ) )
particle:SetLifeTime( 0 )
particle:SetDieTime( mathx.Rand( 0.1, 0.3) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 255 )
particle:SetStartSize( 255 )
particle:SetEndSize( 0 )
particle:SetRoll( mathx.Rand( 0, 360 ) )
particle:SetRollDelta( 0 )
particle:SetColor( self.Color.r, self.Color.g, self.Color.b )
end
emitter:Finish()
surface.PlaySound( "ambient/levels/citadel/weapon_disintegrate3.wav" )
end
/*---------------------------------------------------------
THINK
---------------------------------------------------------*/
function EFFECT:Think( )
if ( !self.TargetEntity || !self.TargetEntity:IsValid() ) then return false end
if ( self.EffectDie < CurTime() ) then return false end
if ( self.NextParticles > CurTime() ) then return true end
self.NextParticles = CurTime() + 0.05
local TimeLeft = self.EffectDie - CurTime()
TimeLeft = TimeLeft / EffectLength
local vOffset = self.TargetEntity:GetPos()
local Low, High = self.TargetEntity:WorldSpaceAABB()
local NumParticles = self.TargetEntity:BoundingRadius()
NumParticles = 3 * TimeLeft
local emitter = ParticleEmitter( vOffset )
for i=0, NumParticles do
local particle = emitter:Add( "gamemodes/910/good"..math.random(1, 3), Vector( mathx.Rand(Low.x,High.x), mathx.Rand(Low.y,High.y), mathx.Rand(Low.z,High.z) ) )
particle:SetVelocity( Vector( mathx.Rand( -5, 5), mathx.Rand( -5, 5), mathx.Rand( 10, 20) ) )
particle:SetLifeTime( 0 )
particle:SetDieTime( mathx.Rand( 2, 4 ) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( mathx.Rand( 4, 8 ) )
particle:SetEndSize( 8 )
particle:SetRoll( mathx.Rand( 0, 360 ) )
particle:SetRollDelta( mathx.Rand( -1, 1 ) )
particle:SetColor( self.Color.r, self.Color.g, self.Color.b )
end
local particle = emitter:Add( "effects/yellowflare", vOffset )
particle:SetVelocity( Vector( 0,0,0 ) )
particle:SetLifeTime( 0 )
particle:SetDieTime( 0.5 )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 255 )
particle:SetStartSize( 64 )
particle:SetEndSize( 0 )
particle:SetRoll( mathx.Rand( 0, 360 ) )
particle:SetRollDelta( 0 )
particle:SetColor( self.Color.r, self.Color.g, self.Color.b )
emitter:Finish()
return true
end
/*---------------------------------------------------------
Draw the effect
---------------------------------------------------------*/
function EFFECT:Render()
render.UpdateRefractTexture()
end