Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local fakeparticles = {{}, {}}
- local nxtparticle = CurTime()
- local function AddSmokeChunk(whichone)
- local ply = LocalPlayer()
- local vm = ply:GetViewModel()
- if !vm:IsValid() then return end
- local p = {}
- local att1 = vm:GetAttachment(1)
- local att2 = vm:GetAttachment(2)
- p.position = (whichone == 1) and att1.Pos or att2.Pos
- if (whichone == 1) and ply:GetActiveWeapon():GetClass() == "dmod_cigarettes" then
- p.position = att1.Pos + att1.Ang:Right()*-5.3 + att1.Ang:Up()*-2.3
- if ply:GetActiveWeapon().CigHotFix then p.position = p.position + att1.Ang:Up()*2.1 + att1.Ang:Right() end
- end
- p.normal = (whichone == 1) and att1.Ang:Right() or att2.Ang:Forward()
- p.velocity = (whichone == 1) and p.normal * 2 or p.normal*1.5
- p.startlife = CurTime()
- p.lifetime = (whichone == 1) and 1 or 0.2
- p.radius = (whichone == 1) and 2 or 3
- if fakeparticles[whichone] then
- table.insert(fakeparticles[whichone],#fakeparticles[whichone]+1, p)
- end
- end
- local function ProcessSmoke(whichone)
- if fakeparticles[whichone] then
- if CurTime() > nxtparticle then
- AddSmokeChunk(whichone)
- nxtparticle = CurTime() + 0.1
- end
- for k,v in ipairs(fakeparticles[whichone]) do
- v.position = v.position + v.velocity * FrameTime()
- v.velocity = v.velocity + Vector(math.Rand(-4, 4),math.Rand(-4, 4),10) * 0.005
- if CurTime() > v.startlife + v.lifetime then
- table.remove(fakeparticles[whichone],k)
- end
- end
- end
- end
- local smokecol = Color(225,225,225,100)
- local smokemat = Material("trails/smoke")
- smokemat:SetInt("$nocull",1)
- local firemat = Material("particles/flamelet"..math.random(1,5))
- firemat:SetInt("$nocull",1)
- hook.Add("PostDrawOpaqueRenderables", "smokesystem_weaponeffects", function()
- local whichone = nil
- local ply = LocalPlayer()
- local wep = LocalPlayer():GetActiveWeapon()
- if !ply:Alive() or ply:InVehicle() or ply:WaterLevel() > 2 or ply:GetViewEntity() != ply or !wep or !IsValid(wep) or wep.Category != "Smoke System" then return end
- if wep:GetLit() then whichone = 1 end
- if wep:GetLighterActive() then whichone = 2 end
- if whichone == nil or (wep.PrintName == "Meth Pipe" and whichone == 1) then return end
- local whichmat = (whichone == 1) and smokemat or firemat
- local whichcol = (whichone == 1) and Color(255, 255, 255, 100) or Color(255, 255, 255)
- ProcessSmoke(whichone)
- render.SetMaterial(whichmat)
- render.StartBeam(#fakeparticles[whichone])
- for k,v in ipairs(fakeparticles[whichone]) do
- local alphac = (whichone == 1) and ColorAlpha(whichcol, (1-(CurTime()-v.startlife)/v.lifetime) * 64) or whichcol
- render.AddBeam(v.position,v.radius*(1-k/#fakeparticles[whichone]),(k/#fakeparticles[whichone]),alphac)
- end
- render.EndBeam()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement