2014-10-02 08:49:54 +08:00
|
|
|
function EFFECT:Think()
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
function EFFECT:Render()
|
|
|
|
end
|
|
|
|
|
|
|
|
local function CollideCallback(particle, hitpos, hitnormal)
|
|
|
|
if particle:GetDieTime() == 0 then return end
|
|
|
|
particle:SetDieTime(0)
|
|
|
|
|
|
|
|
if math.random(3) == 3 then
|
2018-05-02 06:32:59 +08:00
|
|
|
sound.Play("physics/glass/glass_impact_bullet"..math.random(4)..".wav", hitpos, 50, math.Rand(135, 155))
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
if math.random(3) == 3 then
|
2018-05-02 06:32:59 +08:00
|
|
|
util.Decal("Impact.Glass", hitpos + hitnormal, hitpos - hitnormal)
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function EFFECT:Init(data)
|
|
|
|
local pos = data:GetOrigin()
|
|
|
|
|
|
|
|
local emitter = ParticleEmitter(pos)
|
|
|
|
emitter:SetNearClip(28, 32)
|
2018-05-02 06:32:59 +08:00
|
|
|
local grav = Vector(0, 0, -200)
|
2014-10-02 08:49:54 +08:00
|
|
|
for i=1, math.random(4, 7) do
|
2018-05-02 06:32:59 +08:00
|
|
|
local particle = emitter:Add("particle/sparkles", pos)
|
2014-10-02 08:49:54 +08:00
|
|
|
particle:SetVelocity(VectorRand():GetNormalized() * math.Rand(16, 64))
|
2018-05-02 06:32:59 +08:00
|
|
|
particle:SetDieTime(math.Rand(1.1, 1.5))
|
|
|
|
particle:SetStartAlpha(150)
|
|
|
|
particle:SetEndAlpha(0)
|
|
|
|
particle:SetStartSize(math.Rand(2, 3))
|
2014-10-02 08:49:54 +08:00
|
|
|
particle:SetEndSize(0)
|
|
|
|
particle:SetRoll(math.Rand(0, 360))
|
|
|
|
particle:SetRollDelta(math.Rand(-1, 1))
|
|
|
|
particle:SetCollide(true)
|
|
|
|
particle:SetGravity(grav)
|
|
|
|
particle:SetCollideCallback(CollideCallback)
|
2018-05-02 06:32:59 +08:00
|
|
|
particle:SetColor(140, 175, 205)
|
|
|
|
particle:SetLighting(false)
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
2018-05-02 06:32:59 +08:00
|
|
|
emitter:Finish() emitter = nil collectgarbage("step", 64)
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
sound.Play("physics/glass/glass_impact_bullet"..math.random(4)..".wav", pos, 80, math.Rand(165, 170))
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|