@name Visual.Image.Systomatic.Overlay.R
@inputs 
@outputs
@persist HPScale Entity:entity Target:vector Eye:vector
@persist EHPScale LST Select Bearing
@trigger all

Eye = owner():eye()

interval(100)
if(first()) {

#Bars
holoCreate(1)

holoCreate(2)

#Health 1.owner
holoCreate(3)
holoCreate(4)

#lock
holoCreate(5)
holoCreate(6)

#Enemy Bars
holoCreate(7)
holoCreate(8)

#Dir Bars
holoCreate(9)
holoCreate(10)

holoParent(1,owner())
holoParent(2,owner())
holoParent(3,owner())
holoParent(4,owner())
holoParent(5,owner())
holoParent(6,owner())
holoParent(7,owner())
holoParent(8,owner())
holoParent(9,owner())
holoParent(10,owner())
}

#Bars
holoModel(1,"torus")
holoModel(2,"torus")

holoPos(1,owner():shootPos()+vec(0,0,2):rotate(Eye:toAngle()))
holoPos(2,owner():shootPos()+vec(0,0,-2):rotate(Eye:toAngle()))

holoAng(1,Eye:toAngle())
holoAng(2,Eye:toAngle())

holoColor(1,vec(0,255,150),150)
holoColor(2,vec(0,255,150),150)

#Health
holoModel(3,"cylinder")
holoScale(3,vec(0.05,0.05,HPScale))
holoPos(3,owner():shootPos()+Eye*4+vec(0,0,1.5))
holoAng(3,Eye:toAngle()+ang(0,0,90))
holoColor(3,vec(255,0,0))
HPScale = (owner():health() / 100)*0.5

#Target
Target = mix(owner():shootPos(),(Entity:pos() + vec(0,0,Entity:height()/2)),0.95)
holoPos(4,Target)
holoAng(4,Eye:toAngle()+ang(90,0,0))
holoModel(4,"torus")
holoScale(4,vec(0.5,0.5,0.1))
holoColor(4,vec(0,0,255),150)

findByClass("player")
Entity = findResult(Select)
if(owner():lastSaid() == "next"&$LST) {Select++, timer("update",500)}
elseif(owner():lastSaid() == "previous"&$LST) {Select--, timer("update",500)}
else{Update = 0}

if(clk("update") & Entity:isPlayer()) {hint("Target Updated: "+Entity:name(),3)}
LST = owner():lastSaidWhen()

#lock
holoModel(5,"cylinder")
holoColor(5,vec(255,255,0),200)
holoScale(5,vec(0.05,0.1,0.5))
holoAng(5,Eye:toAngle()+ang(0,0,90))

holoModel(6,"cylinder")
holoColor(6,vec(255,255,0),200)
holoScale(6,vec(0.05,0.1,0.5))
holoAng(6,Eye:toAngle()+ang(0,0,90))

if(owner():aimEntity() == Entity) {
holoPos(5,Target+vec(0,5,0):rotate(Eye:toAngle()))
holoPos(6,Target-vec(0,5,0):rotate(Eye:toAngle()))
}else{
holoPos(5,owner():shootPos()-Eye*3)
holoPos(6,owner():shootPos()-Eye*3)
}

#enemy Health
holoModel(7,"cylinder")
holoColor(7,vec(255,0,0),200)
holoScale(7,vec(0.05,0.1,EHPScale))
holoAng(7,Eye:toAngle())
holoPos(7,Target+vec(0,0,5):rotate(Eye:toAngle()))

holoModel(8,"cylinder")
holoColor(8,vec(255,0,0),200)
holoScale(8,vec(0.05,0.1,EHPScale))
holoAng(8,Eye:toAngle())
holoPos(8,Target-vec(0,0,5):rotate(Eye:toAngle()))


EHPScale = (Entity:health()/100)*0.5

#Dir Bars
Bearing = owner():bearing(Entity:shootPos())

holoModel(9,"cylinder")
holoScale(9,vec(0.05,0.05,0.1))
holoAng(9,Eye:toAngle())
holoColor(9,vec(255,0,0))
if(Bearing < -35) {
holoPos(9,owner():shootPos()+Eye*4+(vec(0,2.8,0):rotate(Eye:toAngle())))
} else {
holoPos(9,owner():shootPos()-Eye*3)
}

holoModel(10,"cylinder")
holoScale(10,vec(0.05,0.05,0.1))
holoAng(10,Eye:toAngle())
holoColor(10,vec(255,0,0))
if(Bearing > 35) {
holoPos(10,owner():shootPos()+Eye*4+vec(0,-2.8,0):rotate(Eye:toAngle()))
} else {
holoPos(10,owner():shootPos()-Eye*3)
}

