@name Antlion Guard Spawner
@inputs D
@outputs Count Feelings:string P1ID Spawn:vector Z
@persist Count P1:entity 

findInSphere(entity():pos(),10000)
NPC="npc_antlionguard"
findIncludeClass(NPC)
Total=findToArray()
Max = 15
if(Max>=Total:count()){Stop=1}
if(clk("wave")){Stop=0}

if(!Stop){
    for(C=1,Max){
        D = random(0,360)
        R = random(20,500)
        Spawn = entity():pos()-vec(R*cos(D),R*sin(D),Z*2)
        
        
        if (Count<=Max & !Stop & Spawn:isInWorld()) { 
        P1 = npcSpawn(NPC,Spawn)
        timer("wave",20000)
        P1ID=P1:id()
        #entity(P1ID):npcRelationship("player","fear",99)
        #Feelings = entity(P1ID):npcDisp(entity():owner())
        }
    }
}
Stop=1

if(lastSaid():find("no zombies")){selfDestruct()}





