Guest User

ttt_Supersmokegrenade_proj

a guest
May 22nd, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1.  
  2. AddCSLuaFile()
  3.  
  4. ENT.Type = "anim"
  5. ENT.Base = "ttt_basegrenade_proj"
  6. ENT.Model = Model("models/weapons/w_eq_smokegrenade_thrown.mdl")
  7.  
  8.  
  9. AccessorFunc( ENT, "radius", "Radius", FORCE_NUMBER )
  10.  
  11. function ENT:Initialize()
  12. if not self:GetRadius() then self:SetRadius(20) end
  13.  
  14. return self.BaseClass.Initialize(self)
  15. end
  16.  
  17. if CLIENT then
  18.  
  19. local smokeparticles = {
  20. Model("particle/particle_smokegrenade"),
  21. Model("particle/particle_noisesphere")
  22. };
  23.  
  24. function ENT:CreateSmoke(center)
  25. local em = ParticleEmitter(center)
  26.  
  27. local r = self:GetRadius()
  28. for i=1, 80 do
  29. local prpos = VectorRand() * r
  30. prpos.z = prpos.z + 64
  31. local p = em:Add(table.Random(smokeparticles), center + prpos)
  32. if p then
  33. local gray = math.random(100, 200)
  34. p:SetColor(gray, gray, gray)
  35. p:SetStartAlpha(255)
  36. p:SetEndAlpha(220)
  37. p:SetVelocity(VectorRand() * math.Rand(1300, 1700))
  38. p:SetLifeTime(0)
  39.  
  40. p:SetDieTime(math.Rand(70, 120))
  41.  
  42. p:SetStartSize(math.random(450, 470))
  43. p:SetEndSize(math.random(1, 80))
  44. p:SetRoll(math.random(-180, 180))
  45. p:SetRollDelta(math.Rand(-0.1, 0.1))
  46. p:SetAirResistance(600)
  47.  
  48. p:SetCollide(true)
  49. p:SetBounce(0.4)
  50.  
  51. p:SetLighting(false)
  52. end
  53. end
  54.  
  55. em:Finish()
  56. end
  57. end
  58.  
  59. function ENT:Explode(tr)
  60. if SERVER then
  61. self:SetNoDraw(true)
  62. self:SetSolid(SOLID_NONE)
  63.  
  64. -- pull out of the surface
  65. if tr.Fraction != 1.0 then
  66. self:SetPos(tr.HitPos + tr.HitNormal * 0.6)
  67. end
  68.  
  69. local pos = self:GetPos()
  70.  
  71. self:Remove()
  72. else
  73. local spos = self:GetPos()
  74. local trs = util.TraceLine({start=spos + Vector(0,0,64), endpos=spos + Vector(0,0,-128), filter=self})
  75. util.Decal("SmallScorch", trs.HitPos + trs.HitNormal, trs.HitPos - trs.HitNormal)
  76.  
  77. self:SetDetonateExact(0)
  78.  
  79. if tr.Fraction != 1.0 then
  80. spos = tr.HitPos + tr.HitNormal * 0.6
  81. end
  82.  
  83. -- Smoke particles can't get cleaned up when a round restarts, so prevent
  84. -- them from existing post-round.
  85. if GetRoundState() == ROUND_POST then return end
  86.  
  87. self:CreateSmoke(spos)
  88. end
  89. end
Advertisement
Add Comment
Please, Sign In to add comment