Advertisement
Guest User

Untitled

a guest
Jun 24th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. AddCSLuaFile()
  2. DEFINE_BASECLASS( "base_gmodentity" )
  3.  
  4. ENT.PrintName = "FirePlace"
  5. ENT.Author = "buu342"
  6. ENT.Information = "Keeps you warm and tasty."
  7. ENT.Category = "Survival"
  8.  
  9. ENT.Spawnable = true
  10. ENT.On = false
  11.  
  12. function ENT:SpawnFunction( ply, tr, ClassName )
  13. if ( !tr.Hit ) then return end
  14. local SpawnPos = tr.HitPos + tr.HitNormal *7
  15. local ent = ents.Create( ClassName )
  16. ent:SetPos( SpawnPos )
  17. ent:Spawn()
  18. ent:Activate()
  19. return ent
  20. end
  21.  
  22. function ENT:Initialize()
  23. self.Entity:SetModel( "models/props/FarCry3/fireplace.mdl" )
  24. self.Entity:PhysicsInit(SOLID_VPHYSICS)
  25. self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
  26. self.Entity:SetSolid(SOLID_VPHYSICS)
  27. self:DrawShadow( true )
  28.  
  29. local phys = self.Entity:GetPhysicsObject()
  30. if phys and phys:IsValid() then phys:Wake() end
  31. end
  32.  
  33. function ENT:Use( activator, caller )
  34. if !self.On then
  35. self.On = true
  36. self.fireeffect= ents.Create("info_particle_system")
  37. self.fireeffect:SetPos(self.Entity:GetPos()+Vector(0,0,5))
  38. self.fireeffect:SetKeyValue( "effect_name", "env_fire_small")
  39. self.fireeffect:Fire("Start","", 0)
  40. self.fireeffect:Spawn()
  41. self.fireeffect:Activate()
  42. self.fireeffect:SetParent(self.Entity)
  43.  
  44. self.smokeeffect = ents.Create("info_particle_system")
  45. self.smokeeffect:SetPos(self.Entity:GetPos()+Vector(0,0,15))
  46. self.smokeeffect:SetKeyValue( "effect_name", "env_fire_large_smoke")
  47. self.smokeeffect:Fire("Start","", 0)
  48. self.smokeeffect:Spawn()
  49. self.smokeeffect:Activate()
  50. self.smokeeffect:SetParent(self.Entity)
  51. timer.Simple(60, function() if !IsValid(self.Entity) then return end self.On = false print("off") self:StopParticle() end)
  52. end
  53. end
  54.  
  55.  
  56.  
  57. if ( CLIENT ) then
  58. function ENT:BeingLookedAtByPlayer()
  59. if ( LocalPlayer():GetEyeTrace().Entity != self ) then return false end
  60. if ( EyePos():Distance( self:GetPos() ) > 130 ) then return false end
  61. return true
  62. end
  63. end
  64.  
  65. function ENT:StopParticle()
  66. self.fireeffect:Fire("Stop","", 0)
  67. self.fireeffect:Fire("Kill","", 0.1)
  68. end
  69.  
  70. function ENT:Think()
  71. if ( CLIENT && self:BeingLookedAtByPlayer() ) then
  72. //LocalPlayer():PrintMessage(HUD_PRINTCENTER, "Press E to Light on fire.")
  73. halo.Add( { self }, Color( 255, 100, 0, 255 ), 1, 1, 1, true, true )
  74. end
  75.  
  76. if CLIENT && self.On == true then
  77. local firelight = DynamicLight( self:EntIndex() )
  78. if ( firelight ) then
  79. firelight.Pos = self:GetPos()
  80. firelight.r = 255
  81. firelight.g = 100
  82. firelight.b = 0
  83. firelight.Brightness = 6
  84. firelight.Size = 500
  85. firelight.Decay = 500
  86. firelight.DieTime = CurTime() + 0.25
  87. end
  88. end
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement