if(time==100 && stagephase==1){ CreateEnemyFromFile("script\Functions\stagebars.txt",0,0,0,0,7); }

if(time==500 && stagephase==1){ phase+=1; frame=0; enemyx=0; enemyy=0; enemiescalled=0; }

if(nextphase==1 && stagephase==1){ phase+=1; frame=0; enemyx=0; enemyy=0; enemiescalled=0; nextphase=0; SetCommonData("IncreasePhase",0); }


if(phase==1 && stagephase==1){
	if(frame%40==0){
		if(enemiescalled<6 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Extra\704.txt",cx+rand(30,70),miny-32,0,0,[1,1]); }
		if(enemiescalled<6 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Extra\704.txt",cx-rand(30,70),miny-32,0,0,[2,1]); }
	enemiescalled++; }
	if(enemiescalled>=9){ nextphase=1; }
}
if(phase==2 && stagephase==1){
	if(enemiescalled==0){ newviewx=0; newviewy=0; viewmovetimexy=60; }
	if(frame%30==0){
		if(enemiescalled<10){ CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx-100*cos((time*4)+(rand(-60,60))),miny-32,0,0,rand(4.5,6)); }
	enemiescalled++; }
	if(enemiescalled>=14){ nextphase=1; }
}
if(phase==3 && stagephase==1){
	if(enemiescalled==0){ newviewx=0; newviewy=0; viewmovetimexy=60; }
	if(frame%15==0){
		if(enemiescalled<10){ CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx-100*cos((time*4)+(rand(-60,60))),miny-32,0,0,rand(4.5,6)); }
	enemiescalled++; }
	if(enemiescalled>=20){ nextphase=1; }
}
if(phase==4 && stagephase==1){
	if(frame%40==0){
if(enemiescalled<8 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Extra\704.txt",cx-rand(30,70),miny-32,0,0,[3,1]); }
if(enemiescalled<8 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Extra\704.txt",cx+rand(30,70),miny-32,0,0,[4,1]); }
if(enemiescalled>=2 && enemiescalled<8){ CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx+rand(-100,100),miny-32,0,0,rand(4.5,6)); }
	enemiescalled++; }
	if(enemiescalled>=13){ nextphase=1; }
}
if(phase==5 && stagephase==1){
	if(frame%150==0){
		if(enemiescalled<4 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Extra\703.txt",minx-32,miny+100+enemyy,0,0,[5,1]); }
		if(enemiescalled<4 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Extra\703.txt",maxx+32,miny+100+enemyy,0,0,[5,3]); }
	enemiescalled++; enemyy+=15; }
	if(enemiescalled>=5){ nextphase=1; }
}


if(phase==6 && stagephase==1){
	if(enemiescalled==0){ newviewx=60; newviewy=-10; viewmovetimexy=1200; }
	if(frame%25==0){
		if(enemiescalled<12){ CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx+120*cos((time*4)+(rand(-60,60))),miny-32,0,0,[4,1]); }
	enemiescalled++; }
	if(enemiescalled>=16){ nextphase=1; }
}
if(phase==7 && stagephase==1){
	if(enemiescalled==0){ newviewx=60; newviewy=-10; viewmovetimexy=1200; }
	if(frame%25==0){
		if(enemiescalled<12){ CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx+120*cos((time*4)+(rand(-60,60))),miny-32,0,0,[4,2]); }
	enemiescalled++; }
	if(enemiescalled>=16){ nextphase=1; }
}
if(phase==8 && stagephase==1){
	if(enemiescalled==0){ newviewx=60; newviewy=-10; viewmovetimexy=1200; }
	if(frame%25==0){
		if(enemiescalled<12 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx+180*cos((time*4)+(rand(-60,60))),miny-32,0,0,[4,2]); }
		if(enemiescalled<12 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx+100*cos((time*4)+(rand(-60,60))),miny-32,0,0,[4,1]); }
	enemiescalled++; }
	if(enemiescalled>=16){ nextphase=1; }
}
if(phase==9 && stagephase==1){
	if(frame%40==0){
if(enemiescalled<8 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Extra\704.txt",cx+rand(30,70),miny-32,0,0,[5,1]); }
if(enemiescalled<8 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Extra\704.txt",cx-rand(30,70),miny-32,0,0,[6,1]); }
if(enemiescalled>=2 && enemiescalled<8){ CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx+rand(-100,100),miny-32,0,0,[4,1]); }
	enemiescalled++; }
	if(enemiescalled>=13){ nextphase=1; }
}
if(phase==10 && stagephase==1){
	if(frame%75==0){
		if(enemiescalled<4 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Extra\703.txt",minx-32,miny+100+enemyy,0,0,[5,1]); }
		if(enemiescalled<4 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Extra\703.txt",maxx+32,miny+100+enemyy,0,0,[5,3]); }
	enemiescalled++; enemyy+=15; }
	if(enemiescalled>=6){ nextphase=1; }
}

if(phase==11 && stagephase==1){
	if(frame==60-enemyx){
		if(enemiescalled%2==0 && enemiescalled<22){
			CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx+rand(30,100),miny-32,0,0,[4,1]);
			CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx-rand(30,100),miny-32,0,0,5.5);
		}
		if(enemiescalled%2!=0 && enemiescalled<22){
			CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx-rand(30,100),miny-32,0,0,[4,1]);
			CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx+rand(30,100),miny-32,0,0,5.5);
		}
	enemiescalled++; if(enemyx<50){ enemyx+=4; } frame=0; }
	if(enemiescalled>=70){ nextphase=1; }
}

if(phase==12 && stagephase==1){
	if(frame%20==0){
		if(enemiescalled<16 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Extra\704.txt",cx-rand(30,70),miny-32,0,0,[12,3]); }
		if(enemiescalled<16 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Extra\704.txt",cx+rand(30,70),miny-32,0,0,[12,3]); }
	enemiescalled++; }
	if(enemiescalled>=24){ nextphase=1; }
}

if(phase==13 && stagephase==1){
	if(enemiescalled==0){ newviewx=0; newviewy=0; viewmovetimexy=1200; }
	if(frame%60==0){
		if(enemiescalled==0){ CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx,miny+100,0,0,[15,3,45,1]); }
		if(enemiescalled==1){
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx-120,miny-32,0,0,5);
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx-60,miny-32,0,0,6);
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx+60,miny-32,0,0,6);
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx+120,miny-32,0,0,5);

		CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx-80,miny-32,0,0,[3,1]);
		CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx,miny-32,0,0,[4,1]);
		CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx+80,miny-32,0,0,[3,1]);
		}
		if(enemiescalled==3){
		CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx-60,miny+130,0,0,[15,3,0,1]);
		CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx+60,miny+130,0,0,[15,3,0,1]);
		}
		if(enemiescalled==4){
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx-120,miny-32,0,0,6);
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx,miny-32,0,0,5);
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx+120,miny-32,0,0,6);

		CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx-80,miny-32,0,0,[3,2]);
		CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx+80,miny-32,0,0,[3,2]);
		}
		if(enemiescalled==6){
		CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx-90,miny+130,0,0,[15,3,0,1]);
		CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx,miny+100,0,0,[15,3,45,1]);
		CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx+90,miny+130,0,0,[15,3,0,1]);
		}
		if(enemiescalled==7){
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx-45,miny-32,0,0,6);
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx+45,miny-32,0,0,6);

		CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx-140,miny-32,0,0,[3,2]);
		CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx-60,miny-32,0,0,[4,1]);
		CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx+60,miny-32,0,0,[4,1]);
		CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx+140,miny-32,0,0,[3,2]);
		}
		if(enemiescalled==9){
		CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx-120,miny+130,0,0,[15,3,10,1]);
		CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx-40,miny+100,0,0,[15,2,30,1]);
		CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx+40,miny+100,0,0,[15,2,-30,1]);
		CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx+120,miny+130,0,0,[15,3,-10,1]);
		}
		if(enemiescalled==10){
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx-140,miny-32,0,0,6);
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx-80,miny-32,0,0,5);
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx,miny-32,0,0,4);
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx+80,miny-32,0,0,5);
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx+140,miny-32,0,0,6);

		CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx-80,miny-32,0,0,[4,1]);
		CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx,miny-32,0,0,[5,1]);
		CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx+80,miny-32,0,0,[4,1]);
		}
		if(enemiescalled==12){
		CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx-140,miny+130,0,0,[15,3,0,1]);
		CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx-70,miny+100,0,0,[15,2.5,22.5,1]);
		CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx,miny+100,0,0,[15,2,45,1]);
		CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx+70,miny+100,0,0,[15,2.5,-22.5,1]);
		CreateEnemyFromFile("script\Enemies\Extra\706.txt",cx+140,miny+130,0,0,[15,3,0,1]);
		}
		if(enemiescalled==13){
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx-110,miny-32,0,0,5);
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx-30,miny-32,0,0,6);
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx+30,miny-32,0,0,6);
		CreateEnemyFromFile("script\Enemies\Extra\701.txt",cx+110,miny-32,0,0,5);

		CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx-80,miny-32,0,0,[4,2]);
		CreateEnemyFromFile("script\Enemies\Extra\702.txt",cx+80,miny-32,0,0,[4,2]);
		}
		enemiescalled++; }
	if(enemiescalled>=22){ nextphase=1; }
}