Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local fire = {
- "particles/flamelet1",
- "particles/flamelet2",
- "particles/flamelet3",
- "particles/flamelet4",
- "particles/flamelet5",
- }
- local smoke = {
- "particle/smokesprites_0001",
- "particle/smokesprites_0002",
- "particle/smokesprites_0003",
- "particle/smokesprites_0004",
- "particle/smokesprites_0005",
- "particle/smokesprites_0006",
- "particle/smokesprites_0007",
- "particle/smokesprites_0008",
- "particle/smokesprites_0009",
- "particle/smokesprites_0010",
- "particle/smokesprites_0012",
- "particle/smokesprites_0013",
- "particle/smokesprites_0014",
- "particle/smokesprites_0015",
- "particle/smokesprites_0016",
- }
- local sounds = {
- "ambient/explosions/explode_5.wav",
- "ambient/explosions/explode_8.wav",
- }
- local function draw_sunbeams(pos, amount, size)
- local ply = LocalPlayer()
- local eye_pos = EyePos()
- if util.QuickTrace(eye_pos, pos - eye_pos, {ply}).HitWorld then return end
- local screen_pos = pos:ToScreen()
- DrawSunbeams(
- 0,
- amount * math.Clamp(ply:GetAimVector():DotProduct((pos - eye_pos):GetNormalized()) - 0.5, 0, 1) * 2,
- size,
- screen_pos.x / ScrW(),
- screen_pos.y / ScrH()
- )
- end
- local explosions = {}
- hook.Add("Think", "explosion_think", function()
- for key, data in pairs(explosions) do
- for _, think in pairs(data.arms) do
- think()
- end
- if data.think() ~= nil then
- explosions[key] = nil
- end
- end
- end)
- hook.Add("RenderScreenspaceEffects", "explosion_render", function()
- for key, data in pairs(explosions) do
- data.render()
- end
- end)
- local emitter = ParticleEmitter(Vector())
- local function explode(origin, normal, size, arm_size)
- size = size or 1
- arm_size = arm_size or 1
- local explosion = {arms = {}}
- local light = DynamicLight(tostring(origin))
- light.Pos = origin
- light.r = 255
- light.g = 50
- light.b = 0
- light.Brightness = 1 * size
- light.Size = 1000 * size
- light.Decay = 1000
- light.DieTime = CurTime() + 2
- sound.Play(table.Random(sounds), origin, 160, math.random(70, 130))
- local arm_count = math.Round(math.Clamp(50 * size, 10, 70))
- local wind = Vector(math.random(-200, 200), math.random(-200, 200), math.random(-50, 50)) * size
- local lifespan = 0
- for i = 0, arm_count do
- local color = math.random(200,255)
- local lightball = emitter:Add("sprites/light_glow02_add", origin)
- local life = math.Rand(0.5, 1)
- lifespan = lifespan + life
- local vec = VectorRand() + normal
- lightball:SetVelocity((vec * 10 + Vector(0, 0, vec.z)) * math.random(100,200) * size)
- lightball:SetDieTime(life)
- lightball:SetStartAlpha(50)
- lightball:SetEndAlpha(50)
- lightball:SetStartSize(math.random(300,400) * size * arm_size)
- lightball:SetEndSize(0)
- lightball:SetColor(255, color, color/1.5)
- lightball:SetAirResistance(0)
- lightball:SetGravity(physenv.GetGravity())
- lightball:SetCollide(true)
- lightball:SetBounce(0.2)
- local alpha = life * 255
- table.insert(explosion.arms, function()
- alpha = math.max(alpha - FrameTime() * 100, 0)
- local fire = emitter:Add(table.Random(fire), lightball:GetPos() )
- fire:SetDieTime(life)
- fire:SetStartAlpha(alpha)
- fire:SetEndAlpha(0)
- fire:SetAngles(Angle(math.random(360), math.random(360), math.random(360)))
- fire:SetStartSize(0)
- fire:SetEndSize(math.random(50, 300) / 2 * size * arm_size)
- fire:SetColor(255,255,255)
- fire:SetRoll(math.Rand(-0.5, 0.5))
- fire:SetRollDelta(math.Rand(-0.5, 0.5))
- fire:SetAirResistance(30)
- fire:SetGravity(wind)
- local smoke = emitter:Add(table.Random(smoke), lightball:GetPos())
- local color = math.random(20,50)
- smoke:SetDieTime(life*3)
- smoke:SetStartAlpha(alpha)
- smoke:SetEndAlpha(0)
- smoke:SetAngles(Angle(math.random(360), math.random(360), math.random(360)))
- smoke:SetStartSize(0)
- smoke:SetEndSize(math.random(100,400) * size * arm_size)
- smoke:SetColor(color, color, color)
- smoke:SetRoll(math.Rand(-0.5, 0.5))
- smoke:SetRollDelta(math.Rand(-0.5, 0.5))
- smoke:SetAirResistance(30)
- smoke:SetGravity(wind)
- smoke:SetCollide(true)
- end)
- end
- lifespan = lifespan / arm_count
- explosion.render = function()
- draw_sunbeams(origin, lifespan / 10, 0.1)
- end
- explosion.think = function()
- lifespan = lifespan - FrameTime()
- if lifespan < 0 then
- return true
- end
- end
- table.insert(explosions, explosion)
- end
- explode(there, trace.HitNormal)
Advertisement
Add Comment
Please, Sign In to add comment