Advertisement
Ragerek

Untitled

Aug 29th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.20 KB | None | 0 0
  1. AddCSLuaFile( "cl_init.lua" )
  2. AddCSLuaFile( "shared.lua" )
  3. include("shared.lua")
  4.  
  5. FIRE_CurrentFires = 0
  6.  
  7. function ENT:Initialize()
  8. self:SetMoveType( MOVETYPE_NONE )
  9. self:SetSolid( SOLID_NONE )
  10. self:SetAngles( Angle(0, 0, 0) )
  11. self:SetPos( self:GetPos() + Vector(0, 0, 10) )
  12.  
  13. FIRE_CurrentFires = FIRE_CurrentFires + 1
  14.  
  15. self.ExtinguisherLeft = 100
  16. self.LastDamage = CurTime()
  17. self.FireHealth = CurTime()
  18. self.LastSpread = CurTime()
  19.  
  20. self:DrawShadow( false )
  21.  
  22. if FIRE_AutoTurnOff > 0 then
  23. timer.Simple( FIRE_AutoTurnOff, function()
  24. if self:IsValid() then
  25. self:KillFire()
  26. end
  27. end)
  28. end
  29. end
  30.  
  31. function ENT:KillFire()
  32. FIRE_CurrentFires = FIRE_CurrentFires - 1
  33. self:Remove()
  34. end
  35.  
  36. function ENT:SpreadFire()
  37. for i = 1, 20 do
  38. local trace = {}
  39. trace.start = self:GetPos() + Vector( 0, 0, 10 )
  40. trace.endpos = self:GetPos() + Vector( math.Rand( -1, 1 ) * math.Rand( 50, 100 ), math.Rand( -1, 1 ) * math.Rand( 50, 100 ), 50 )
  41. trace.filter = self.Entity
  42. trace.mask = MASK_OPAQUE
  43.  
  44. local traceline1 = util.TraceLine( trace )
  45.  
  46. local trace2 = {}
  47. trace2.start = self:GetPos() + Vector( math.Rand( -1, 1 ) * math.Rand( 50, 100 ), math.Rand( -1, 1 ) * math.Rand( 50, 100 ), 50 )
  48. trace2.endpos = self:GetPos() + Vector( 0, 0, 10 )
  49. trace2.filter = self.Entity
  50. trace2.mask = MASK_OPAQUE
  51.  
  52. local traceline2 = util.TraceLine( trace2 )
  53.  
  54. if ( traceline1.Hit and traceline2.Hit ) or ( not traceline1.Hit and not traceline2.Hit ) then
  55.  
  56. local trstart = self:GetPos() + Vector( math.Rand( -1, 1 ) * math.Rand( 50, 100 ), math.Rand( -1, 1 ) * math.Rand( 50, 100 ), 50)
  57. local trend = trstart - Vector( 0, 0, 100 )
  58.  
  59. local trace = {}
  60. trace.start = trstart
  61. trace.endpos = trend
  62. trace.filter = self.Entity
  63.  
  64. local TraceResults = util.TraceLine( trace )
  65.  
  66. if TraceResults.HitWorld then
  67. if util.IsInWorld( TraceResults.HitPos ) then
  68. if table.HasValue( FIRE_MaterialTypes, TraceResults.MatType ) then
  69.  
  70. local NearOtherFire = false
  71.  
  72. for k, v in pairs( ents.FindInSphere( TraceResults.HitPos, 50) ) do
  73. if v:GetClass() == "fire" then
  74. NearOtherFire = true
  75. end
  76. end
  77.  
  78. if !NearOtherFire then
  79. if FIRE_CurrentFires >= FIRE_MaxFires then return false end
  80. local NewFire = ents.Create( "fire" )
  81. NewFire:SetPos( TraceResults.HitPos )
  82. NewFire:Spawn()
  83. return
  84. end
  85. end
  86. end
  87. end
  88. end
  89. end
  90. end
  91.  
  92. function ENT:ExtinguishAttack( ply, hose )
  93. if hose then
  94. self.ExtinguisherLeft = self.ExtinguisherLeft - math.random(3, 5)
  95. else
  96. self.ExtinguisherLeft = self.ExtinguisherLeft - math.random(1, 3)
  97. end
  98.  
  99. if self.ExtinguisherLeft <= 0 then
  100. if ply:IsValid() then
  101. if table.HasValue( FIRE_AllowedTeams, team.GetName(ply:Team()) ) then
  102. ply:addMoney( FIRE_ExtinguishPay )
  103. if FIRE_NotifyOnExtinguish then
  104. DarkRP.notify(ply, 2, 5, "You've been given $".. FIRE_ExtinguishPay .." for extinguishing fire.")
  105. end
  106. else
  107. ply:addMoney( FIREEXTCITZ_ExtinguishPay )
  108. if FIRE_NotifyOnExtinguish then
  109. DarkRP.notify(ply, 2, 5, "You've been given $".. FIREEXTCITZ_ExtinguishPay .." for extinguishing fire as a non-firefighter.")
  110. end
  111. end
  112. end
  113.  
  114. self:KillFire()
  115. end
  116. end
  117.  
  118. function ENT:Think()
  119. if self:WaterLevel() > 0 then
  120. self:KillFire()
  121. return
  122. end
  123.  
  124. local trace = {}
  125. trace.start = self:GetPos()
  126. trace.endpos = self:GetPos() + Vector(0, 0, 500)
  127. trace.mask = MASK_VISIBLE
  128. trace.filter = self
  129.  
  130. local tr = util.TraceLine(trace)
  131.  
  132. if self.FireHealth + 10 < CurTime() then
  133. self.FireHealth = CurTime()
  134. self.ExtinguisherLeft = math.Clamp(self.ExtinguisherLeft + 1, 0, 120)
  135. end
  136.  
  137. if self.LastSpread + FIRE_SpreadInterval < CurTime() then
  138. self:SpreadFire()
  139.  
  140. self.LastSpread = CurTime()
  141. end
  142.  
  143. if self.LastDamage + FIRE_DamageInterval < CurTime() then
  144. self.LastDamage = CurTime()
  145.  
  146. for k , v in pairs(ents.FindInSphere(self:GetPos(), math.random(35, 100))) do
  147. if v:GetClass() == "prop_physics" then
  148. if not v:IsOnFire() then
  149. v:Ignite(60, 100)
  150. timer.Simple(FIRE_RemovePropTimer, function()
  151. if IsValid(v) then
  152. if v:IsOnFire() then
  153. local effectdata = EffectData()
  154. effectdata:SetOrigin( v:GetPos() )
  155. effectdata:SetMagnitude( 2 )
  156. effectdata:SetScale( 2 )
  157. effectdata:SetRadius( 3 )
  158. util.Effect( "Sparks", effectdata )
  159. v:Remove()
  160. end
  161. end
  162. end)
  163. end
  164.  
  165. v:SetColor( FIRE_BurntPropColor )
  166. elseif v:IsPlayer() and v:Alive() and v:GetPos():Distance(self:GetPos()) < 70 then
  167. if table.HasValue( FIRE_AllowedTeams, team.GetName(v:Team()) ) then
  168. v:TakeDamage( FIRE_FireFighterDamage, v )
  169. else
  170. v:TakeDamage( FIRE_FireDamage, v )
  171. end
  172. elseif v:IsVehicle() and v:GetPos():Distance(self:GetPos()) < 70 then
  173. v:TakeDamage( FIRE_VehicleDamage )
  174. end
  175. end
  176. end
  177. end
  178.  
  179. ==================================
  180.  
  181. --[[
  182. Name: init.lua
  183.  
  184.  
  185. ]]--
  186.  
  187. AddCSLuaFile "cl_init.lua"
  188. AddCSLuaFile "shared.lua"
  189. include "shared.lua"
  190.  
  191. function ENT:Initialize()
  192. local fireSize = Vector( 1, 1, 1 ) *52
  193.  
  194. self:SetModel( "models/props_wasteland/kitchen_counter001c.mdl" )
  195. self:PhysicsInitBox( -fireSize, fireSize )
  196.  
  197. self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
  198. self:SetCollisionBounds( -fireSize, fireSize )
  199. self:SetMoveType( MOVETYPE_NONE )
  200. self:SetSolid( SOLID_BBOX )
  201. self:DrawShadow( false )
  202. self:SetTrigger( true )
  203. --self:SetCustomCollisionCheck( true )
  204.  
  205. self.m_intSpawnTime = CurTime()
  206. self.m_intLastBurn = 0
  207. self.m_intBurnInterval = 2
  208. self.m_intBurnDamage = 0
  209. --self.m_intLifeTime = math.random( 45, 80 )
  210. self.m_intWaterHit = 0
  211. self.m_intHitsToRemove = 9
  212.  
  213. self.m_tblBurning = {}
  214.  
  215. self.m_pSound = CreateSound( self, "interior_fire01_stereo.wav" )
  216. if self.m_pSound then
  217. self.m_pSound:Play()
  218. self.m_pSound:ChangeVolume( 0.15, 0 )
  219. end
  220.  
  221. self.AdminPhysGun = true
  222. end
  223.  
  224. function ENT:StartTouch( eEnt )
  225. if not IsValid( eEnt ) or eEnt:IsVehicle() then return end
  226. if eEnt:IsPlayer() and eEnt:InVehicle() then return end
  227. self.m_tblBurning[eEnt] = true
  228. self:Burn( eEnt )
  229. end
  230.  
  231. function ENT:EndTouch( eEnt )
  232. if not IsValid( eEnt ) then return end
  233. self.m_tblBurning[eEnt] = nil
  234. end
  235.  
  236. function ENT:Think()
  237. --if CurTime() > self.m_intSpawnTime +self.m_intLifeTime then
  238. -- self:Remove()
  239. -- return
  240. --end
  241.  
  242. if CurTime() < self.m_intLastBurn then return end
  243. for k, v in pairs( self.m_tblBurning ) do
  244. if not IsValid( k ) then self.m_tblBurning[k] = nil continue end
  245. self:Burn( k )
  246. end
  247.  
  248. self.m_intLastBurn = CurTime() +self.m_intBurnInterval
  249. end
  250.  
  251. function ENT:Burn( eEnt )
  252. --eEnt:Ignite( eEnt:IsPlayer() and self.m_intBurnInterval or 60 )
  253. eEnt.m_bIsOnFire = true
  254.  
  255. local dmgInfo = DamageInfo()
  256. dmgInfo:SetAttacker( self )
  257. dmgInfo:SetInflictor( self )
  258. dmgInfo:SetDamage( 2 )
  259. dmgInfo:SetDamageType( DMG_BURN )
  260. eEnt:TakeDamageInfo( dmgInfo )
  261.  
  262. --eEnt:StopParticles()
  263. --ParticleEffectAttach( "fire_medium_01", PATTACH_ABSORIGIN_FOLLOW, eEnt, 0 )
  264. end
  265.  
  266. function ENT:WaterHit( pPlayer )
  267. self.m_intWaterHit = self.m_intWaterHit +1
  268.  
  269. if self.m_intWaterHit >= self.m_intHitsToRemove then
  270. if self.m_bRemoved then return end
  271. self:Remove()
  272. self.m_bRemoved = true
  273.  
  274. if not IsValid( pPlayer ) then return end
  275. if not pPlayer.m_intFireExtinguishCount then
  276. pPlayer.m_intFireExtinguishCount = 0
  277. end
  278. pPlayer.m_intFireExtinguishCount = pPlayer.m_intFireExtinguishCount +1
  279.  
  280. if pPlayer.m_intFireExtinguishCount >= GAMEMODE.Config.FireExtinguishBonusCount then
  281. pPlayer:AddBankMoney( GAMEMODE.Config.FireBonus )
  282. pPlayer:AddNote( "You earned a $".. GAMEMODE.Config.FireBonus.. " bonus for fighting a fire!" )
  283. pPlayer:AddNote( "This bonus has been sent to your bank account." )
  284. pPlayer.m_intFireExtinguishCount = 0
  285. end
  286. end
  287. end
  288.  
  289. function ENT:OnRemove()
  290. --self:StopParticles()
  291. if self.m_pSound then
  292. self.m_pSound:Stop()
  293. end
  294. end
  295.  
  296. --timer.Create( "UpdateBurningEnts", 1, 0, function()
  297. -- for k, v in pairs( ents.GetAll() ) do
  298. -- if not v:IsOnFire() and v.m_bIsOnFire then
  299. -- v:StopParticles()
  300. -- v.m_bIsOnFire = false
  301. -- end
  302. -- end
  303. --end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement