@name Flare System
@persist [Flare Temp]:entity  Lock
@model models/hunter/blocks/cube075x075x025.mdl
if(first())
{
    runOnTick(1)
    holoCreate(1)
    holoModel(1,"hq_tube_thin")
    holoPos(1,entity():toWorld(vec(0,0,15)))
    holoScale(1,vec(1,1,1.5))
    holoColor(1,vec(100))
    holoMaterial(1,"models/shiny")
    holoParent(1,entity())
    entity():setColor(0,0,0,0)
    holoCreate(2)
    holoModel(2,"hq_cylinder")
    holoScale(2,vec(3.5,3.5,1))
    holoMaterial(2,"models/shiny")
    holoColor(2,vec(100))
    holoParent(2,entity())
}

if(!Lock)
{
    findByClass("player")
    findSortByDistance(entity():pos())
    T = find()
    if(T:team()==owner():team()&T:pos():distance(entity():pos())<300)
    {
        if(T:keyUse()&T:aimEntity()==entity())
        {
            soundPlay("fire",5,"/weapons/flaregun/fire.wav")
            Flare = propSpawn("models/props_phx/amraam.mdl",entity():toWorld(vec(0,0,300)),ang(-90,0,0),0)
            Flare:setTrails(500,5,3,"trails/smoke",vec(200,0,0),255)
            Flare:setColor(0,0,0,0)
            holoCreate(3)
            holoModel(3,"hq_rcylinder_thick")
            holoColor(3,vec(150,0,0))
            holoMaterial(3,"models/shiny")
            holoParent(3,Flare)
            Flare:applyForce(entity():up()*700000+vec(random(-3000,3000),random(-3000,3000),0))
            Flare:applyAngForce(ang(random(-60,60),random(-60,60),random(-60,60)))
            Lock = 1
        }
    }
}

if(Lock)
{
    if(Flare:vel():length()<150|!Flare:isValid())
    {
        Flare:propBreak()
        Lock = 0
    }
}
    
