Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile( "cl_init.lua" )
- AddCSLuaFile( "shared.lua" )
- include("shared.lua")
- FIRE_CurrentFires = 0
- function ENT:Initialize()
- self:SetMoveType( MOVETYPE_NONE )
- self:SetSolid( SOLID_NONE )
- self:SetAngles( Angle(0, 0, 0) )
- self:SetPos( self:GetPos() + Vector(0, 0, 10) )
- FIRE_CurrentFires = FIRE_CurrentFires + 1
- self.ExtinguisherLeft = 100
- self.LastDamage = CurTime()
- self.FireHealth = CurTime()
- self.LastSpread = CurTime()
- self:DrawShadow( false )
- if FIRE_AutoTurnOff > 0 then
- timer.Simple( FIRE_AutoTurnOff, function()
- if self:IsValid() then
- self:KillFire()
- end
- end)
- end
- end
- function ENT:KillFire()
- FIRE_CurrentFires = FIRE_CurrentFires - 1
- self:Remove()
- end
- function ENT:SpreadFire()
- for i = 1, 20 do
- local trace = {}
- trace.start = self:GetPos() + Vector( 0, 0, 10 )
- trace.endpos = self:GetPos() + Vector( math.Rand( -1, 1 ) * math.Rand( 50, 100 ), math.Rand( -1, 1 ) * math.Rand( 50, 100 ), 50 )
- trace.filter = self.Entity
- trace.mask = MASK_OPAQUE
- local traceline1 = util.TraceLine( trace )
- local trace2 = {}
- trace2.start = self:GetPos() + Vector( math.Rand( -1, 1 ) * math.Rand( 50, 100 ), math.Rand( -1, 1 ) * math.Rand( 50, 100 ), 50 )
- trace2.endpos = self:GetPos() + Vector( 0, 0, 10 )
- trace2.filter = self.Entity
- trace2.mask = MASK_OPAQUE
- local traceline2 = util.TraceLine( trace2 )
- if ( traceline1.Hit and traceline2.Hit ) or ( not traceline1.Hit and not traceline2.Hit ) then
- local trstart = self:GetPos() + Vector( math.Rand( -1, 1 ) * math.Rand( 50, 100 ), math.Rand( -1, 1 ) * math.Rand( 50, 100 ), 50)
- local trend = trstart - Vector( 0, 0, 100 )
- local trace = {}
- trace.start = trstart
- trace.endpos = trend
- trace.filter = self.Entity
- local TraceResults = util.TraceLine( trace )
- if TraceResults.HitWorld then
- if util.IsInWorld( TraceResults.HitPos ) then
- if table.HasValue( FIRE_MaterialTypes, TraceResults.MatType ) then
- local NearOtherFire = false
- for k, v in pairs( ents.FindInSphere( TraceResults.HitPos, 50) ) do
- if v:GetClass() == "fire" then
- NearOtherFire = true
- end
- end
- if !NearOtherFire then
- if FIRE_CurrentFires >= FIRE_MaxFires then return false end
- local NewFire = ents.Create( "fire" )
- NewFire:SetPos( TraceResults.HitPos )
- NewFire:Spawn()
- return
- end
- end
- end
- end
- end
- end
- end
- function ENT:ExtinguishAttack( ply, hose )
- if hose then
- self.ExtinguisherLeft = self.ExtinguisherLeft - math.random(3, 5)
- else
- self.ExtinguisherLeft = self.ExtinguisherLeft - math.random(1, 3)
- end
- if self.ExtinguisherLeft <= 0 then
- if ply:IsValid() then
- if table.HasValue( FIRE_AllowedTeams, team.GetName(ply:Team()) ) then
- ply:addMoney( FIRE_ExtinguishPay )
- if FIRE_NotifyOnExtinguish then
- DarkRP.notify(ply, 2, 5, "You've been given $".. FIRE_ExtinguishPay .." for extinguishing fire.")
- end
- else
- ply:addMoney( FIREEXTCITZ_ExtinguishPay )
- if FIRE_NotifyOnExtinguish then
- DarkRP.notify(ply, 2, 5, "You've been given $".. FIREEXTCITZ_ExtinguishPay .." for extinguishing fire as a non-firefighter.")
- end
- end
- end
- self:KillFire()
- end
- end
- function ENT:Think()
- if self:WaterLevel() > 0 then
- self:KillFire()
- return
- end
- local trace = {}
- trace.start = self:GetPos()
- trace.endpos = self:GetPos() + Vector(0, 0, 500)
- trace.mask = MASK_VISIBLE
- trace.filter = self
- local tr = util.TraceLine(trace)
- if self.FireHealth + 10 < CurTime() then
- self.FireHealth = CurTime()
- self.ExtinguisherLeft = math.Clamp(self.ExtinguisherLeft + 1, 0, 120)
- end
- if self.LastSpread + FIRE_SpreadInterval < CurTime() then
- self:SpreadFire()
- self.LastSpread = CurTime()
- end
- if self.LastDamage + FIRE_DamageInterval < CurTime() then
- self.LastDamage = CurTime()
- for k , v in pairs(ents.FindInSphere(self:GetPos(), math.random(35, 100))) do
- if v:GetClass() == "prop_physics" then
- if not v:IsOnFire() then
- v:Ignite(60, 100)
- timer.Simple(FIRE_RemovePropTimer, function()
- if IsValid(v) then
- if v:IsOnFire() then
- local effectdata = EffectData()
- effectdata:SetOrigin( v:GetPos() )
- effectdata:SetMagnitude( 2 )
- effectdata:SetScale( 2 )
- effectdata:SetRadius( 3 )
- util.Effect( "Sparks", effectdata )
- v:Remove()
- end
- end
- end)
- end
- v:SetColor( FIRE_BurntPropColor )
- elseif v:IsPlayer() and v:Alive() and v:GetPos():Distance(self:GetPos()) < 70 then
- if table.HasValue( FIRE_AllowedTeams, team.GetName(v:Team()) ) then
- v:TakeDamage( FIRE_FireFighterDamage, v )
- else
- v:TakeDamage( FIRE_FireDamage, v )
- end
- elseif v:IsVehicle() and v:GetPos():Distance(self:GetPos()) < 70 then
- v:TakeDamage( FIRE_VehicleDamage )
- end
- end
- end
- end
- ==================================
- --[[
- Name: init.lua
- ]]--
- AddCSLuaFile "cl_init.lua"
- AddCSLuaFile "shared.lua"
- include "shared.lua"
- function ENT:Initialize()
- local fireSize = Vector( 1, 1, 1 ) *52
- self:SetModel( "models/props_wasteland/kitchen_counter001c.mdl" )
- self:PhysicsInitBox( -fireSize, fireSize )
- self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
- self:SetCollisionBounds( -fireSize, fireSize )
- self:SetMoveType( MOVETYPE_NONE )
- self:SetSolid( SOLID_BBOX )
- self:DrawShadow( false )
- self:SetTrigger( true )
- --self:SetCustomCollisionCheck( true )
- self.m_intSpawnTime = CurTime()
- self.m_intLastBurn = 0
- self.m_intBurnInterval = 2
- self.m_intBurnDamage = 0
- --self.m_intLifeTime = math.random( 45, 80 )
- self.m_intWaterHit = 0
- self.m_intHitsToRemove = 9
- self.m_tblBurning = {}
- self.m_pSound = CreateSound( self, "interior_fire01_stereo.wav" )
- if self.m_pSound then
- self.m_pSound:Play()
- self.m_pSound:ChangeVolume( 0.15, 0 )
- end
- self.AdminPhysGun = true
- end
- function ENT:StartTouch( eEnt )
- if not IsValid( eEnt ) or eEnt:IsVehicle() then return end
- if eEnt:IsPlayer() and eEnt:InVehicle() then return end
- self.m_tblBurning[eEnt] = true
- self:Burn( eEnt )
- end
- function ENT:EndTouch( eEnt )
- if not IsValid( eEnt ) then return end
- self.m_tblBurning[eEnt] = nil
- end
- function ENT:Think()
- --if CurTime() > self.m_intSpawnTime +self.m_intLifeTime then
- -- self:Remove()
- -- return
- --end
- if CurTime() < self.m_intLastBurn then return end
- for k, v in pairs( self.m_tblBurning ) do
- if not IsValid( k ) then self.m_tblBurning[k] = nil continue end
- self:Burn( k )
- end
- self.m_intLastBurn = CurTime() +self.m_intBurnInterval
- end
- function ENT:Burn( eEnt )
- --eEnt:Ignite( eEnt:IsPlayer() and self.m_intBurnInterval or 60 )
- eEnt.m_bIsOnFire = true
- local dmgInfo = DamageInfo()
- dmgInfo:SetAttacker( self )
- dmgInfo:SetInflictor( self )
- dmgInfo:SetDamage( 2 )
- dmgInfo:SetDamageType( DMG_BURN )
- eEnt:TakeDamageInfo( dmgInfo )
- --eEnt:StopParticles()
- --ParticleEffectAttach( "fire_medium_01", PATTACH_ABSORIGIN_FOLLOW, eEnt, 0 )
- end
- function ENT:WaterHit( pPlayer )
- self.m_intWaterHit = self.m_intWaterHit +1
- if self.m_intWaterHit >= self.m_intHitsToRemove then
- if self.m_bRemoved then return end
- self:Remove()
- self.m_bRemoved = true
- if not IsValid( pPlayer ) then return end
- if not pPlayer.m_intFireExtinguishCount then
- pPlayer.m_intFireExtinguishCount = 0
- end
- pPlayer.m_intFireExtinguishCount = pPlayer.m_intFireExtinguishCount +1
- if pPlayer.m_intFireExtinguishCount >= GAMEMODE.Config.FireExtinguishBonusCount then
- pPlayer:AddBankMoney( GAMEMODE.Config.FireBonus )
- pPlayer:AddNote( "You earned a $".. GAMEMODE.Config.FireBonus.. " bonus for fighting a fire!" )
- pPlayer:AddNote( "This bonus has been sent to your bank account." )
- pPlayer.m_intFireExtinguishCount = 0
- end
- end
- end
- function ENT:OnRemove()
- --self:StopParticles()
- if self.m_pSound then
- self.m_pSound:Stop()
- end
- end
- --timer.Create( "UpdateBurningEnts", 1, 0, function()
- -- for k, v in pairs( ents.GetAll() ) do
- -- if not v:IsOnFire() and v.m_bIsOnFire then
- -- v:StopParticles()
- -- v.m_bIsOnFire = false
- -- end
- -- end
- --end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement