@name Cenn's FrankenTurret
@inputs 
@outputs Mode
@persist E:entity AFound:entity Distance Mode GG Chitter:string
@trigger 
@model models/hunter/blocks/cube075x075x075.mdl

Distance = 200
#interval(1)
if(first()){
    timer("sound",randint(1000,3000))
    E = entity()
    E:soundPlay(1,300,"music/aperture_logo_bells_01_01.wav")
    E:setAlpha(0)
    Mode = 0

holoCreate(1)
holoModel(1,"models/npcs/monsters/monster_a.mdl")
holoAnim(1,7)
  E:setAng(E:angles() + ang(-20,0,0))
timer("parent",500)
  timer("timer",2000)
}
if(clk("parent")){holoParent(1,E)
    E:propFreeze(0)}


if(clk("timer")){
    
 timer("timer",100)
    findByClass("player")
    AFound = findClosest(entity():pos())
    if(AFound:pos():distance(entity():pos())<Distance){
       
        if(Mode==1){
holoAnim(1,7)
E:setAng(AFound:angles() + ang(0,180,0))
}}

if(AFound:pos():distance(entity():pos())>Distance){Mode=0
    timer("timer",500)}
if(AFound:pos():distance(entity():pos())<Distance){Mode=1
    timer("timer",500)}
   timer("timer2",100)
}


if(clk("timer")){
if(Mode==0){

        holoAnim(1,4)
        
       E:applyAngForce(ang(0,randint(1,360),0) * 50)
     E:applyForce(E:forward()*E:mass()*200)
    E:applyForce(E:up()*E:mass()*60)
timer("timer",4000)


}
}



if(clk("sound")){
    GG = randint(1,15)
    if(GG==1){Chitter="npc/box_monster/box_monster_chitter_01.wav"}
    if(GG==2){Chitter="npc/box_monster/box_monster_chitter_02.wav"}
    if(GG==3){Chitter="npc/box_monster/box_monster_chitter_03.wav"}
    if(GG==4){Chitter="npc/box_monster/box_monster_chitter_04.wav"}
    if(GG==5){Chitter="npc/box_monster/box_monster_chitter_05.wav"}
    if(GG==6){Chitter="npc/box_monster/box_monster_chitter_06.wav"}
    if(GG==7){Chitter="npc/box_monster/box_monster_chitter_07.wav"}
    if(GG==8){Chitter="npc/box_monster/box_monster_chitter_08.wav"}
    if(GG==9){Chitter="npc/box_monster/box_monster_chitter_09.wav"}
    if(GG==10){Chitter="npc/box_monster/box_monster_chitter_10.wav"}
    if(GG==11){Chitter="npc/box_monster/box_monster_chitter_11.wav"}
    if(GG==12){Chitter="npc/box_monster/box_monster_chitter_12.wav"}
    if(GG==13){Chitter="npc/box_monster/box_monster_chitter_13.wav"}
    if(GG==14){Chitter="npc/box_monster/box_monster_chitter_14.wav"}
    if(GG==15){Chitter="npc/box_monster/box_monster_chitter_15.wav"}
    
    
    timer("sound",randint(1000,3000))
    
    
   E:soundPlay(300,9999,Chitter)}
