Advertisement
CapsAdmin

Untitled

May 28th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | None | 0 0
  1. local pos = there
  2. local emitter = ParticleEmitter(vector_origin)
  3.  
  4. local particles = {}
  5.  
  6. local function collide(self, pos, normal)
  7.     WorldSound("npc/headcrab_poison/ph_step"..math.random(2,4)..".wav", pos, 60, math.random(25, 70))
  8. end
  9.  
  10. local function Think() 
  11.     local clr2 = HSVToColor(CurTime()*30%360, 0.5, 1)
  12.     local clr = HSVToColor(CurTime()*30%360, 0.5, 1)
  13.     clr.a = 255
  14.     for i =1, 2 do
  15.     local particle = emitter:Add("sprites/light_glow02_add", pos)
  16.  
  17.     -- movement
  18.     particle:SetVelocity(Vector(math.Rand(-1, 1), math.Rand(-1, 1), math.Rand(2.5, 5)) * 100)
  19.     particle:SetAirResistance(0)
  20.     particle:SetGravity(physenv.GetGravity()*0.5)
  21.  
  22.     particle:SetCollide(true)
  23.     particle:SetBounce(0.25)
  24.  
  25.     -- appearance
  26.     particle:SetColor(clr2.r, clr2.g, clr2.b)
  27.     particle.clr = clr
  28.  
  29.     particle:SetStartAlpha(255)
  30.     particle:SetEndAlpha(0)
  31.  
  32.     particle:SetStartSize(10)
  33.     particle:SetEndSize(0)
  34.  
  35.     particle:SetDieTime(math.Rand(1.5, 2.5))
  36.    
  37.     particle:SetStartLength(0)
  38.     particle:SetEndLength(0)
  39.         particle:SetCollideCallback(collide)
  40.    
  41.     table.insert(particles, particle)
  42.     end
  43. end
  44.  
  45. local mat = Material("particle/Particle_Glow_04_Additive")
  46.  
  47. hook.Add("PostDrawTranslucentRenderables", 1, function()
  48.     for key, particle in pairs(particles) do
  49.         local delta = particle:GetDieTime() - particle:GetLifeTime()
  50.         if delta > 0 then
  51.             render.SetMaterial(mat)
  52.             render.DrawBeam(particle:GetPos() + particle:GetVelocity()*0.05, particle:GetPos() - particle:GetVelocity() * 0.25, 1 * delta, 0, 1, particle.clr)
  53.         else
  54.             particles[key] = nil       
  55.         end
  56.     end
  57. end)
  58.  
  59. hook.Add("Think", "particle_test", Think)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement