@name Robot Defence! - By Croco
@inputs 
@outputs A T TIME1 TIME2 H  TIMER  
@persist [PROPA PROPB PROPC]:entity GAME Y:entity LEVEL:string TT:string NAME:string Model:array
@trigger 
if(first()){
        NAME = "brony"
    Model = array("models/bots/heavy/bot_heavy.mdl","models/bots/pyro/bot_pyro.mdl","models/bots/medic/bot_medic.mdl","models/bots/scout/bot_scout.mdl","models/bots/soldier/bot_soldier.mdl")
    holoCreate(1)
    holoCreate(2)
    holoCreate(3)
    holoPos(1,vec(999999,99999,9999))
    holoPos(2,vec(999999,99999,9999))
    holoPos(3,vec(999999,99999,9999))
      Head="anim_attachment_RH"
    H = 0
    T = 5000
    TIME1=1000
    TIME2=6000
    LEVEL = "1"
 TIMER = 0
    timer("med",15000)
    timer("hard",25000)
    timer("HARD",45000)
            holoModel(1,Model[randint(6),string])
    holoModel(2,Model[randint(6),string])
    holoModel(3,Model[randint(6),string])
GAME = 1
}

if(GAME ==1){

       Y = findPlayerByName(NAME)
TT = findPlayerByName(NAME):name()
if(TIMER == 1){timer("robot2",randint(TIME1,TIME2))}
if(clk("robot2")){A = randint(4)}
    entity():setText("Robots Killed : " + H + " ------ Level : " + LEVEL)
timer("anim",2000)
if(clk("anim")){
          holoAnim(1,2)
    holoAnim(2,2)
holoAnim(3,2)}
runOnTick(1)
timer("robot",randint(TIME1,TIME2))
if(clk("robot")){A = randint(4)}
if(A ==1){
    holoAnim(1,2)
    holoPos(1,entity():pos() + vec(0,-100,0))
    if(!PROPA){
        holoModel(1,Model[randint(6),string])
    PROPA = propSpawn("models/props_farm/wooden_barrel.mdl",holoEntity(1):pos() + vec(0,0,60),1)
    PROPA:setAng(ang(0,0,181))
    PROPA:setAlpha(0)
    A = 0
    timer("A",T)
    
    
    
    
}}
if(A ==2){    
     holoAnim(1,2)
    holoPos(2,entity():pos() + vec(0,100,0))
       if(!PROPB){
        holoModel(2,Model[randint(6),string])
        PROPB = propSpawn("models/props_farm/wooden_barrel.mdl",holoEntity(2):pos() + vec(0,0,60),1)
        PROPB:setAng(ang(0,0,182))
        PROPB:setAlpha(0)
        A =0
        timer("B",T)
        
        
        
    }}
if(A ==3){
     holoAnim(1,2)
    holoPos(3,entity():pos() + vec(0,0,0))
       if(!PROPC){
            holoModel(3,Model[randint(6),string])
        PROPC = propSpawn("models/props_farm/wooden_barrel.mdl",holoEntity(3):pos() + vec(0,0,60),1)
        PROPC:setAng(ang(0,0,183))
        PROPC:setAlpha(0)
        A = 0
        timer("C",T)
        
        
        
    }}

   if (Y:weapon():type()=="weapon_physcannon"){
         E = Y:aimEntity()
        R = E:angles():roll()
        if(Y:keyAttack1()){
    if(R == -179){
        PROPA:propDelete()
        stoptimer("A")
H++
        holoPos(1,vec(9999999,9999999,9999999))}
    if(R ==-178){
        PROPB:propDelete()
        stoptimer("B")
H++
        holoPos(2,vec(9999999,9999999,9999999))}
    if(R == -177){
        PROPC:propDelete()
        stoptimer("C")
H++
        holoPos(3,vec(9999999,9999999,9999999))}
    
    }
}


       Y = findPlayerByName(NAME)
TT = findPlayerByName(NAME):name()
if(clk("A")){
      particle("cinefx_goldrush")
    PROPA:propDelete()
    PROPB:propDelete()
    PROPC:propDelete()
    holoDelete(1)
    holoDelete(2)
    holoDelete(3)
 
   
           Y = findPlayerByName(NAME)
TT = findPlayerByName(NAME):name()
print(TT)
GAME = 0
    concmd("say Player " + NAME + " Lost!" + " With a Score of : " + H)
}

if(clk("B")){
    particle("cinefx_goldrush")
        PROPA:propDelete()
    PROPB:propDelete()
    PROPC:propDelete()
        holoDelete(1)
    holoDelete(2)
    holoDelete(3)
GAME = 0
  
           Y = findPlayerByName(NAME)
TT = findPlayerByName(NAME):name()
print(TT)

     concmd("say Player " + NAME + " Lost!" + " With a Score of : " + H)
}

if(clk("C")){
    particle("cinefx_goldrush")
        PROPA:propDelete()
    PROPB:propDelete()
    PROPC:propDelete()
        holoDelete(1)
    holoDelete(2)
    holoDelete(3)

    


GAME = 0
     concmd("say Player " + NAME + " Lost! " + " With a Score of : " + H)
}



if(clk("med")){
    LEVEL = "2"
T = 4000
TIME1 = 700 
TIME2 = 4000}
if(clk("hard")){
    LEVEL = "3"
T = 3000
TIME1 = 500
TIME2 = 2000}
if(clk("HARD")){
    LEVEL = "4"
T = 1000
TIME1 = 200
TIME2 = 1000
TIMER = 1}
}
    if(GAME == 0){timer("end",3000)}
if(clk("end")){selfDestructAll()}

