AddCSLuaFile()

ENT.Base = "base_gmodentity"
ENT.Type = "anim"
ENT.PrintName = "MI24 Rocket"
ENT.AutomaticFrameAdvance = true
ENT.Spawnable = true

if SERVER then
    function ENT:Initialize()
        self:SetModel("models/props_phx/amraam.mdl")
        self:SetSolid(SOLID_VPHYSICS)
        self:PhysicsInit(SOLID_VPHYSICS)
        self:SetModelScale(0.5, 0)
    end
    
    function ENT:PhysicsCollide(data, col)
        self:Explode()
    end

    function ENT:Explode()
        if self.Exploded then return end
        self.Exploded = true
        if IsValid(self.Heli) then
            util.BlastDamage(self.Heli, self.Heli, self:GetPos(), 200, 200)
        else
            util.BlastDamage(self, self, self:GetPos(), 200, 100)
        end
        self:EmitSound(")ambient/explosions/explode_4.wav", 100, math.random(60,90))
        local eff = EffectData()
        eff:SetFlags(4)
        eff:SetOrigin(self:GetPos())
        util.Effect("Explosion", eff)
        self:Remove()
    end 

    function ENT:Think()
        local phys = self:GetPhysicsObject()
        phys:SetVelocity(-phys:GetVelocity()+self:GetForward()*4000)

        self:NextThink(CurTime())
        return true
    end
end
