@name Were's Turret
@inputs 
@outputs T Potato
@persist E:entity Ang:angle Variable HH Distance AFound:entity Distance2
@trigger 
@model models/hunter/blocks/cube1x1x1.mdl
interval(1)
if(first()){
    E = entity()
    E:setAlpha(0)
holoCreate(1)
holoModel(1,"models/npcs/turret/turret.mdl")
holoPos(1,E:pos() + vec(0,0,-25))
holoAnim(1,1)
soundPlay(3,4000,"npc/turret_floor/deploy.wav")
soundPlay(2,4000,"npc/turret_floor/turret_autosearch_4.wav")
holoParent(1,entity())
Potato= 1
Variable =1
Distance2 = 200
HH = 0
Distance = 200
T = 0
timer("ask",5000)

}
#print(_HUD_PRINTCENTER,T)
if(T<30){
    if(Potato==1){
T = T + 0.3
}
}
if(T>28){  
    Potato=0
}
if(Potato==0){
    T = T - 0.3}
if(T<-28){
Potato = 1}
if(Variable ==1){Ang = ang(0,T,0)}

#    holoSetPose(1,"aim_pitch", Ang:pitch()) 
    holoSetPose(1,"aim_yaw", Ang:yaw())    
if(clk("ask")){soundPlay(3,4000,"npc/turret_floor/turret_autosearch_"+ randint(1,5) + ".wav")
    timer("stop",3000)}
if(clk("stop")){soundPlay(3,4000,"npc/turret_floor/retract.wav")
    holoAnim(1,5)
   Variable = 0
Distance = 200
Ang = ang(0,0,0)}



    findByClass("player")
    AFound = findClosest(entity():pos())
    if(AFound:pos():distance(entity():pos())<Distance){
       
        stoptimer("ask")
        stoptimer("stop")
        timer("alert",1000)
        timer("check",2000)
        HH = HH + 1
            soundPlay(3,4000,"npc/turret_floor/deploy.wav")
soundPlay(2,4000,"npc/turret_floor/turret_autosearch_4.wav")
Distance = 1
}
if(clk("alert")){
    Variable = 1
     holoAnim(1,1)}


if(clk("check")){

  if(AFound:pos():distance(entity():pos())>Distance2){
    timer("ask",500)

}
}
      #[  if(AFound:pos():distance(entity():pos())<Distance2){
Variable = 0
Ang = AFound:angles():yaw() + ang(0,-180,0)
    
     }

}

