Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 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(100) 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, 50 do
  29. local prpos = VectorRand() * r
  30. prpos.z = prpos.z + 32
  31. local p = em:Add(table.Random(smokeparticles), center + prpos)
  32. if p then
  33. local gray = math.random(150, 255)
  34. local gray1 = math.random(207, 227)
  35. local gray2 = math.random(118, 138)
  36. local gray3 = math.random(250, 255)
  37. p:SetColor(gray1, gray2, gray3)
  38. p:SetStartAlpha(255)
  39. p:SetEndAlpha(0)
  40. p:SetVelocity(VectorRand() * math.Rand(1, 2))
  41. p:SetLifeTime(0)
  42.  
  43. p:SetDieTime(math.Rand(40, 50))
  44.  
  45. p:SetStartSize(math.random(140, 150))
  46. p:SetEndSize(math.random(200, 350))
  47. p:SetRoll(math.random(-180, 180))
  48. p:SetRollDelta(math.Rand(-0.1, 0.1))
  49. p:SetAirResistance(600)
  50.  
  51. p:SetCollide(true)
  52. p:SetBounce(0.4)
  53.  
  54. p:SetLighting(false)
  55. end
  56. end
  57.  
  58. em:Finish()
  59. end
  60. end
  61.  
  62. function ENT:Explode(tr)
  63. if SERVER then
  64. self:SetNoDraw(true)
  65. self:SetSolid(SOLID_NONE)
  66.  
  67. -- pull out of the surface
  68. if tr.Fraction != 1.0 then
  69. self:SetPos(tr.HitPos + tr.HitNormal * 0.6)
  70. end
  71.  
  72. local pos = self:GetPos()
  73.  
  74. self:Remove()
  75. else
  76. local spos = self:GetPos()
  77. local trs = util.TraceLine({start=spos + Vector(0,0,64), endpos=spos + Vector(0,0,-128), filter=self})
  78. util.Decal("SmallScorch", trs.HitPos + trs.HitNormal, trs.HitPos - trs.HitNormal)
  79.  
  80. self:SetDetonateExact(0)
  81.  
  82. if tr.Fraction != 1.0 then
  83. spos = tr.HitPos + tr.HitNormal * 0.6
  84. end
  85.  
  86. -- Smoke particles can't get cleaned up when a round restarts, so prevent
  87. -- them from existing post-round.
  88. if GetRoundState() == ROUND_POST then return end
  89.  
  90. self:CreateSmoke(spos)
  91. end
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement