Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. local fakeparticles = {{}, {}}
  2. local nxtparticle = CurTime()
  3.  
  4. local function AddSmokeChunk(whichone)
  5. local ply = LocalPlayer()
  6. local vm = ply:GetViewModel()
  7. if !vm:IsValid() then return end
  8. local p = {}
  9. local att1 = vm:GetAttachment(1)
  10. local att2 = vm:GetAttachment(2)
  11. p.position = (whichone == 1) and att1.Pos or att2.Pos
  12. if (whichone == 1) and ply:GetActiveWeapon():GetClass() == "dmod_cigarettes" then
  13. p.position = att1.Pos + att1.Ang:Right()*-5.3 + att1.Ang:Up()*-2.3
  14. if ply:GetActiveWeapon().CigHotFix then p.position = p.position + att1.Ang:Up()*2.1 + att1.Ang:Right() end
  15. end
  16. p.normal = (whichone == 1) and att1.Ang:Right() or att2.Ang:Forward()
  17. p.velocity = (whichone == 1) and p.normal * 2 or p.normal*1.5
  18. p.startlife = CurTime()
  19. p.lifetime = (whichone == 1) and 1 or 0.2
  20. p.radius = (whichone == 1) and 2 or 3
  21. if fakeparticles[whichone] then
  22. table.insert(fakeparticles[whichone],#fakeparticles[whichone]+1, p)
  23. end
  24. end
  25.  
  26. local function ProcessSmoke(whichone)
  27. if fakeparticles[whichone] then
  28. if CurTime() > nxtparticle then
  29. AddSmokeChunk(whichone)
  30. nxtparticle = CurTime() + 0.1
  31. end
  32.  
  33. for k,v in ipairs(fakeparticles[whichone]) do
  34. v.position = v.position + v.velocity * FrameTime()
  35. v.velocity = v.velocity + Vector(math.Rand(-4, 4),math.Rand(-4, 4),10) * 0.005
  36. if CurTime() > v.startlife + v.lifetime then
  37. table.remove(fakeparticles[whichone],k)
  38. end
  39. end
  40. end
  41. end
  42. local smokecol = Color(225,225,225,100)
  43. local smokemat = Material("trails/smoke")
  44. smokemat:SetInt("$nocull",1)
  45. local firemat = Material("particles/flamelet"..math.random(1,5))
  46. firemat:SetInt("$nocull",1)
  47. hook.Add("PostDrawOpaqueRenderables", "smokesystem_weaponeffects", function()
  48. local whichone = nil
  49. local ply = LocalPlayer()
  50. local wep = LocalPlayer():GetActiveWeapon()
  51. 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
  52. if wep:GetLit() then whichone = 1 end
  53. if wep:GetLighterActive() then whichone = 2 end
  54. if whichone == nil or (wep.PrintName == "Meth Pipe" and whichone == 1) then return end
  55. local whichmat = (whichone == 1) and smokemat or firemat
  56. local whichcol = (whichone == 1) and Color(255, 255, 255, 100) or Color(255, 255, 255)
  57. ProcessSmoke(whichone)
  58. render.SetMaterial(whichmat)
  59. render.StartBeam(#fakeparticles[whichone])
  60. for k,v in ipairs(fakeparticles[whichone]) do
  61. local alphac = (whichone == 1) and ColorAlpha(whichcol, (1-(CurTime()-v.startlife)/v.lifetime) * 64) or whichcol
  62. render.AddBeam(v.position,v.radius*(1-k/#fakeparticles[whichone]),(k/#fakeparticles[whichone]),alphac)
  63. end
  64. render.EndBeam()
  65. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement