AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )
 
 
function ENT:Initialize()
 
        -- Set up the entity
        self.Entity:SetModel( "models/weapons/w_eq_fraggrenade_thrown.mdl" )
 
        self.Entity:PhysicsInit( SOLID_VPHYSICS )
        self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
        self.Entity:SetSolid( SOLID_VPHYSICS )
        self.Entity:SetColor( 255, 255, 255, 255 )
 
        
        self.Index = self.Entity:EntIndex()
        
        local phys = self.Entity:GetPhysicsObject()
        if phys:IsValid() then
                phys:Wake()
        end
		timer.Simple( 3, self.Detonate, self );
		self.Entity:EmitSound("weapons/c4/c4_beep1.wav")
end

function ENT:Detonate()
		self.Entity:EmitSound("weapons/c4/c4_beep1.wav")
		local objtab = ents.FindInSphere( self.Entity:GetPos(), 100 )
		for k, v in pairs( objtab ) do
		v:Ignite( 20, 1 )
		local lawl = self.Entity:GetPos()
		local lulz = self.Entity:GetOwner()
		util.BlastDamage( self.Entity, lulz, lawl, 150, 250 )
		local effectdata = EffectData() 
 		effectdata:SetOrigin( self.Entity:GetPos() ) 
  		util.Effect( "Explosion", effectdata, true, true ) 
    	self.Entity:Remove(); 
		end
end
