Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local pos = here
- local emitter = ParticleEmitter(vector_origin)
- local particles = {}
- local sounds =
- {
- "npc/headcrab_poison/ph_step2.wav",
- "npc/headcrab_poison/ph_step3.wav",
- "npc/headcrab_poison/ph_step4.wav",
- }
- local WorldSound = WorldSound
- local math_random = math.random
- local function collide(self, pos, normal)
- WorldSound(sounds[math_random(#sounds)], pos, 60, math_random(25, 70))
- end
- local gravity = physenv.GetGravity() * 0.5
- local vel = Vector()
- local sdir = Vector()
- local function Think()
- local delta = FrameTime()
- local c = HSVToColor(CurTime() * 30%360, 0.5, 1)
- sdir = sdir + ((VectorRand() - sdir) * delta)
- for i = 1, 2 do
- local particle = emitter:Add("sprites/light_glow02_add", pos)
- vel.x = math.Rand(-1, 1) * 25
- vel.y = math.Rand(-1, 1) * 25
- vel.z = math.Rand(2.5, 5) * 50
- vel.x = vel.x + sdir.x * 100
- vel.y = vel.y + sdir.y * 100
- vel.z = vel.z + sdir.z * 100
- -- movement
- particle:SetVelocity(vel)
- particle:SetAirResistance(0)
- particle:SetGravity(gravity)
- particle:SetCollide(true)
- particle:SetBounce(0.25)
- -- appearance
- particle:SetColor(c.r, c.g, c.b)
- particle.clr = c
- particle:SetStartAlpha(255)
- particle:SetEndAlpha(0)
- particle:SetStartSize(10)
- particle:SetEndSize(0)
- particle:SetDieTime(math.Rand(1.5, 2.5))
- particle:SetStartLength(0)
- particle:SetEndLength(0)
- particle:SetCollideCallback(collide)
- table.insert(particles, particle)
- end
- end
- local mat = Material("particle/Particle_Glow_04_Additive")
- local render_DrawBeam = render.DrawBeam
- local render_SetMaterial = render.SetMaterial
- hook.Add("PostDrawTranslucentRenderables", 1, function()
- for key, particle in pairs(particles) do
- local delta = particle:GetDieTime() - particle:GetLifeTime()
- if delta > 0 then
- local pos = particle:GetPos()
- local vel = particle:GetVelocity()
- render_SetMaterial(mat)
- render_DrawBeam(pos + vel * 0.05, pos - vel * 0.25, 1 * delta, 0, 1, particle.clr)
- else
- particles[key] = nil
- end
- end
- end)
- hook.Add("Think", "particle_test", Think)
Advertisement
Add Comment
Please, Sign In to add comment