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

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(enemiescalled==0){ newviewx=-15; newviewy=0; viewmovetimexy=120; }
	if(frame%24==0){
		if(enemiescalled<7){ CreateEnemyFromFile("script\Enemies\Stage 3\302.txt",minx-32,miny+50,0,0,1); }
	enemiescalled++; }
	if(enemiescalled>=11){ nextphase=1; }
}
if(phase==2 && stagephase==1){
	if(enemiescalled==0){ newviewx=15; newviewy=-10; viewmovetimexy=90; }
	if(frame%15==0){
		if(enemiescalled<12){ CreateEnemyFromFile("script\Enemies\Stage 3\303.txt",maxx-40-enemyx,miny-32,0,0,[1,1]); }
	enemiescalled++; enemyx+=20; }
	if(enemiescalled>=15){ nextphase=1; }
}
if(phase==3 && stagephase==1){
	if(enemiescalled==0){ newviewx=15; newviewy=0; viewmovetimexy=90; }
	if(frame%24==0){
		if(enemiescalled<7){ CreateEnemyFromFile("script\Enemies\Stage 3\302.txt",maxx+32,miny+50,0,0,1); }
	enemiescalled++; }
	if(enemiescalled>=11){ nextphase=1; }
}
if(phase==4 && stagephase==1){
	if(enemiescalled==0){ newviewx=-15; newviewy=-10; viewmovetimexy=120; }
	if(frame%15==0){
		if(enemiescalled<12){ CreateEnemyFromFile("script\Enemies\Stage 3\303.txt",minx+40+enemyx,miny-32,0,0,[1,2]); }
	enemiescalled++; enemyx+=20; }
	if(enemiescalled>=18){ nextphase=1; }
}
if(phase==5 && stagephase==1){
	if(enemiescalled==0){ newviewx=0; newviewy=0; viewmovetimexy=90; }
	if(frame%24==0){
		if(enemiescalled<14 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Stage 3\302.txt",minx-32,miny+50,0,0,2); }
		if(enemiescalled<14 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Stage 3\302.txt",maxx+32,miny+50,0,0,2); }
	enemiescalled++; }
	if(enemiescalled>=16){ nextphase=1; }
}
if(phase==6 && stagephase==1){
	if(enemiescalled==0){ newviewx=0; newviewy=-10; viewmovetimexy=120; }
	if(frame%15==0){
		if(enemiescalled<16 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Stage 3\303.txt",minx+40+enemyx,miny-32,0,0,[1,1]); }
		if(enemiescalled<16 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Stage 3\303.txt",maxx-40-enemyx,miny-32,0,0,[1,2]); }
		if(enemiescalled>=20 && enemiescalled<36 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Stage 3\303.txt",minx-32,miny+150,0,0,[2,1]); }
		if(enemiescalled>=20 && enemiescalled<36 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Stage 3\303.txt",maxx+32,miny+150,0,0,[2,1]); }
	enemiescalled++; enemyx+=20; }
	if(enemiescalled>=42){ nextphase=1; }
}
if(phase==7 && stagephase==1){
	if(enemiescalled==0){ newviewh=300; viewmovetimehv=300; newviewx=-45; viewmovetimexy=120; }
	if(enemiescalled==9){ newviewx=0; newviewy=-10; viewmovetimexy=120; }
	if(frame%24==0){
		if(enemiescalled<10 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Stage 3\302.txt",minx-32,miny,0,0,3); }
		if(enemiescalled<10 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Stage 3\302.txt",maxx+32,miny,0,0,3); }
	enemiescalled++; }
	if(enemiescalled>=14){ nextphase=1; }
}
if(phase==8 && stagephase==1){
	if(frame%60==0){
		if(enemiescalled==0){
		CreateEnemyFromFile("script\Enemies\Stage 3\301.txt",cx-rand(100,140),miny-32,0,0,0);
		CreateEnemyFromFile("script\Enemies\Stage 3\301.txt",cx+rand(100,140),miny-32,0,0,0);
		}
		if(enemiescalled==3){
		CreateEnemyFromFile("script\Enemies\Stage 3\301.txt",cx-rand(50,80),miny-32,0,0,0);
		CreateEnemyFromFile("script\Enemies\Stage 3\301.txt",cx+rand(50,80),miny-32,0,0,0);
		}
	enemiescalled++; }
	if(enemiescalled>=7){ nextphase=1; }
}
if(phase==9 && stagephase==1){
	if(enemiescalled==0){ newviewx=0; newviewy=0; viewmovetimexy=120; }
	if(frame%24==0){
		if(enemiescalled<7 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Stage 3\302.txt",maxx+32,miny+100,0,0,1); }
		if(enemiescalled<7 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Stage 3\302.txt",minx-32,miny+50,0,0,1); }
		if(enemiescalled>=10 && enemiescalled<17 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Stage 3\302.txt",maxx+32,miny+150,0,0,1); }
		if(enemiescalled>=10 && enemiescalled<17 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Stage 3\302.txt",minx-32,miny+200,0,0,1); }
	enemiescalled++; }
	if(enemiescalled>=20){ nextphase=1; }
}
if(phase==10 && stagephase==1){
	if(enemiescalled==0){ newviewx=0; newviewy=-10; viewmovetimexy=90; }
	if(frame%12==0){
		if(enemiescalled<18 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Stage 3\303.txt",minx-32,miny+150,0,0,[2,1]); }
		if(enemiescalled<18 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Stage 3\303.txt",maxx+32,miny+150,0,0,[2,1]); }
	enemiescalled++; }
	if(enemiescalled>=24){ nextphase=1; }
}
if(phase==11 && stagephase==1){
	if(frame%60==0){
		if(enemiescalled==0){
		CreateEnemyFromFile("script\Enemies\Stage 3\301.txt",cx-rand(100,140),miny-32,0,0,0);
		CreateEnemyFromFile("script\Enemies\Stage 3\301.txt",cx+rand(100,140),miny-32,0,0,0);
		}
		if(enemiescalled==2){
		CreateEnemyFromFile("script\Enemies\Stage 3\301.txt",cx-rand(50,80),miny-32,0,0,0);
		CreateEnemyFromFile("script\Enemies\Stage 3\301.txt",cx+rand(50,80),miny-32,0,0,0);
		}
		if(enemiescalled==4){
		CreateEnemyFromFile("script\Enemies\Stage 3\301.txt",cx-rand(100,140),miny-32,0,0,0);
		CreateEnemyFromFile("script\Enemies\Stage 3\301.txt",cx+rand(100,140),miny-32,0,0,0);
		}
	enemiescalled++; }
	if(enemiescalled>=9){ nextphase=1; }
}
if(phase==12 && stagephase==1){
	if(enemiescalled==0){ newviewx=0; newviewy=0; viewmovetimexy=120; }
	if(frame%24==0){
		if(enemiescalled<10 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Stage 3\302.txt",minx-32,miny,0,0,3); }
		if(enemiescalled<10 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Stage 3\302.txt",maxx+32,miny,0,0,3); }
	enemiescalled++; }
	if(enemiescalled>=14){ nextphase=1; }
}
if(phase==13 && stagephase==1){
	if(enemiescalled==0){ newviewx=0; newviewy=-10; viewmovetimexy=90; }
	if(frame%8==0){
		if(enemiescalled<18 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Stage 3\303.txt",minx-32,miny+150,0,0,[2,1]); }
		if(enemiescalled<18 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Stage 3\303.txt",maxx+32,miny+150,0,0,[2,1]); }
	enemiescalled++; }
	if(enemiescalled>=24){ nextphase=1; }
}
if(phase==14 && stagephase==1){
	if((frame+50)%60==0){
		if(enemiescalled<18 && enemiescalled%2==0){ CreateEnemyFromFile("script\Enemies\Stage 3\301.txt",cx-rand(100,150),miny-32,0,0,0); }
		if(enemiescalled<18 && enemiescalled%2!=0){ CreateEnemyFromFile("script\Enemies\Stage 3\301.txt",cx+rand(100,150),miny-32,0,0,0); }
	enemiescalled++; }
	if(enemiescalled==19){ newviewx=90; newviewy=0; viewmovetimexy=180; }
	if(enemiescalled==20){ newviewh=270; newviewv=0; viewmovetimehv=120; }
	if(enemiescalled>=23){ SetCommonData("BackgroundStop",1); nextphase=1; }
}