// // // This is the default entity base. // You can add to this is completely replace it if you know what you're doing. // // ENT.Type = "anim" ENT.Base = "base_anim" ENT.PrintName = "Realistic Timed Bomb" ENT.Author = "Henoik" function ENT:Initialize() if ( SERVER ) then self.Entity:SetModel( "models/props_c17/TrapPropeller_Engine.mdl" ) self.Entity:PhysicsInit( SOLID_VPHYSICS ) self.Entity:SetMoveType( MOVETYPE_VPHYSICS) self.Entity:SetSolid( SOLID_VPHYSICS) self.Entity:SetUseType( SIMPLE_USE ) self.Entity:SetNWBool("IsSet", false ) local phys = self.Entity:GetPhysicsObject() if(phys:IsValid()) then phys:Wake() end end end // // Note - the classname isn't always going to be the same // So use ClassName instead of a static string. // // This function puts the entity in the map.. and must be defined. // function ENT:SpawnFunction( ply, tr ) if ( !tr.Hit ) then return end local SpawnPos = tr.HitPos + tr.HitNormal * 16 local ent = ents.Create( ClassName ) ent:SetPos( SpawnPos ) ent:Spawn() ent:Activate() return ent end function ENT:Use( activator, caller ) if self:GetNWBool("IsSet") == false then activator:PrintMessage(3, "The bomb has been set! You have 10 secondes to leave!"); timer.Simple( 10, function() local explode = ents.Create( "env_explosion" ); explode:SetPos( self:GetPos() ); explode:Spawn(); explode:SetKeyValue( "iMagnitude", 250); explode:Fire( "Explode", 0, 0 ); explode:EmitSound( "ambient\explosions\explode_4.wav" ) local shake = ents.Create( "env_shake" ) shake:SetPos( self:GetPos() ) shake:SetKeyValue( "amplitude", "800" ) shake:SetKeyValue( "radius", "800" ) shake:SetKeyValue( "duration", "3" ) shake:SetKeyValue( "frequency", "255" ) shake:SetKeyValue( "spawnflags", "4" ) shake:Spawn() shake:Activate() shake:Fire( "StartShake", "", 0 ) -- Fire start local fire01 = ents.Create("env_fire"); fire01:SetKeyValue("firesize", math.random(100, 128)); fire01:SetKeyValue( "health", math.random( 10, 18 ) ) fire01:SetKeyValue("spawnflags", "128"); fire01:SetKeyValue("damagescale", "10"); fire01:SetPos(self:GetPos()+ Vector( math.random( -300, 300 ), math.random( -300, 300 ), 0 )); fire01:Spawn() fire01:Fire("StartFire", math.random( 1.0, 1.5)) local fire02 = ents.Create("env_fire"); fire02:SetKeyValue("firesize", math.random(100, 128)); fire02:SetKeyValue( "health", math.random( 10, 18 ) ) fire02:SetKeyValue("spawnflags", "128"); fire02:SetKeyValue("damagescale", "10"); fire02:SetPos(self:GetPos()+ Vector( math.random( -300, 300 ), math.random( -300, 300 ), 0 )); fire02:Spawn() fire02:Fire("StartFire", math.random( 1.0, 1.5)) local fire03 = ents.Create("env_fire"); fire03:SetKeyValue("firesize", math.random(100, 128)); fire03:SetKeyValue( "health", math.random( 10, 18 ) ) fire03:SetKeyValue("spawnflags", "128"); fire03:SetKeyValue("damagescale", "10"); fire03:SetPos(self:GetPos()+ Vector( math.random( -300, 300 ), math.random( -300, 300 ), 0 )); fire03:Spawn() fire03:Fire("StartFire", math.random( 1.0, 1.5)) local fire04 = ents.Create("env_fire"); fire04:SetKeyValue("firesize", math.random(100, 128)); fire04:SetKeyValue( "health", math.random( 10, 18 ) ) fire04:SetKeyValue("spawnflags", "128"); fire04:SetKeyValue("damagescale", "10"); fire04:SetPos(self:GetPos()+ Vector( math.random( -300, 300 ), math.random( -300, 300 ), 0 )); fire04:Spawn() fire04:Fire("StartFire", math.random( 1.0, 1.5)) local fire05 = ents.Create("env_fire"); fire05:SetKeyValue("firesize", math.random(100, 128)); fire05:SetKeyValue( "health", math.random( 10, 18 ) ) fire05:SetKeyValue("spawnflags", "128"); fire05:SetKeyValue("damagescale", "10"); fire05:SetPos(self:GetPos()+ Vector( math.random( -300, 300 ), math.random( -300, 300 ), 0 )); fire05:Spawn() fire05:Fire("StartFire", math.random( 1.0, 1.5)) -- Fire end -- Sparks start local spark01 = ents.Create( "env_spark" ) spark01:SetPos( self:GetPos() + Vector( math.random( -150, 150 ), math.random( -150, 150 ), math.random( -150, 200 ) ) ) spark01:SetKeyValue( "MaxDelay", "0" ) spark01:SetKeyValue( "Magnitude", math.random( 2, 3) ) spark01:SetKeyValue( "TrailLength", "3" ) spark01:SetKeyValue( "spawnflags", "0" ) spark01:Spawn() spark01:Fire( "SparkOnce", "", 0 ) local spark02 = ents.Create( "env_spark" ) spark02:SetPos( self:GetPos() + Vector( math.random( -150, 150 ), math.random( -150, 150 ), math.random( -150, 200 ) ) ) spark02:SetKeyValue( "MaxDelay", "0" ) spark02:SetKeyValue( "Magnitude", math.random( 2, 3) ) spark02:SetKeyValue( "TrailLength", "3" ) spark02:SetKeyValue( "spawnflags", "0" ) spark02:Spawn() spark02:Fire( "SparkOnce", "", 0 ) local spark03 = ents.Create( "env_spark" ) spark03:SetPos( self:GetPos() + Vector( math.random( -150, 150 ), math.random( -150, 150 ), math.random( -150, 200 ) ) ) spark03:SetKeyValue( "MaxDelay", "0" ) spark03:SetKeyValue( "Magnitude", math.random( 2, 3) ) spark03:SetKeyValue( "TrailLength", "3" ) spark03:SetKeyValue( "spawnflags", "0" ) spark03:Spawn() spark03:Fire( "SparkOnce", "", 0 ) local spark04 = ents.Create( "env_spark" ) spark04:SetPos( self:GetPos() + Vector( math.random( -150, 150 ), math.random( -150, 150 ), math.random( -150, 200 ) ) ) spark04:SetKeyValue( "MaxDelay", "0" ) spark04:SetKeyValue( "Magnitude", math.random( 2, 3) ) spark04:SetKeyValue( "TrailLength", "3" ) spark04:SetKeyValue( "spawnflags", "0" ) spark04:Spawn() spark04:Fire( "SparkOnce", "", 0 ) local spark05 = ents.Create( "env_spark" ) spark05:SetPos( self:GetPos() + Vector( math.random( -150, 150 ), math.random( -150, 150 ), math.random( -150, 200 ) ) ) spark05:SetKeyValue( "MaxDelay", "0" ) spark05:SetKeyValue( "Magnitude", math.random( 2, 3) ) spark05:SetKeyValue( "TrailLength", "3" ) spark05:SetKeyValue( "spawnflags", "0" ) spark05:Spawn() spark05:Fire( "SparkOnce", "", 0 ) -- Sparks end self:Remove() end) end self:SetNWBool("IsSet", true) end