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

if(phase==0 && stagephase==2){
	if(enemiescalled==0){ newviewx=0; viewmovetimexy=120; }
	if(enemiescalled==0){ newviewh=0; viewmovetimehv=120; }
	if(frame%60==0){ enemiescalled++; } //Wait
	if(enemiescalled>=4){ nextphase=1; }
}

if(phase==1 && stagephase==2){
	if(enemiescalled==0){ newviewx=20; newviewy=-15; viewmovetimexy=90; }
	if(frame%50==0){
		if(enemiescalled<5){ CreateEnemyFromFile("script\Enemies\Stage 1\105.txt",maxx+32+rand(0,20),miny+rand(0,50),0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=5){ nextphase=1; }
}
if(phase==2 && stagephase==2){
	if(enemiescalled==0){ newviewh=-20; viewmovetimehv=90; }
	if(frame%10==0){
		if(enemiescalled<10){ CreateEnemyFromFile("script\Enemies\Stage 1\101.txt",cx-rand(80,150),miny-32,0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=20){ nextphase=1; }
}
if(phase==3 && stagephase==2){
	if(enemiescalled==0){ newviewx=-20; newviewy=-15; viewmovetimexy=90; }
	if(frame%40==0){
		if(enemiescalled<5){ CreateEnemyFromFile("script\Enemies\Stage 1\105.txt",minx-32-rand(0,20),miny+rand(0,50),0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=5){ nextphase=1; }
}
if(phase==4 && stagephase==2){
	if(enemiescalled==0){ newviewh=20; viewmovetimehv=90; }
	if(frame%10==0){
		if(enemiescalled<10){ CreateEnemyFromFile("script\Enemies\Stage 1\101.txt",cx+rand(80,150),miny-32,0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=20){ nextphase=1; }
}
if(phase==5 && stagephase==2){
	if(enemiescalled==0){ newviewx=0; newviewy=0; viewmovetimexy=90; }
	if(enemiescalled==0){ newviewh=0; viewmovetimehv=60; }
	if(frame%8==0){
		if(enemiescalled<12){ CreateEnemyFromFile("script\Enemies\Stage 1\103.txt",maxx+rand(32,64),miny+rand(-30,30),0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=12){ nextphase=1; }
}
if(phase==6 && stagephase==2){
	if(frame%8==0){
		if(enemiescalled<12){ CreateEnemyFromFile("script\Enemies\Stage 1\103.txt",minx-rand(32,64),miny+rand(-30,30),0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=18){ nextphase=1; }
}
if(phase==7 && stagephase==2){
	if(enemiescalled==2){ newviewx=-10; newviewy=0; viewmovetimexy=90; }
	if(enemiescalled==4){ newviewx=10; newviewy=0; viewmovetimexy=90; }
	if(frame%60==0){
		if(enemiescalled==2){ CreateEnemyFromFile("script\Enemies\Stage 1\104.txt",cx-100,miny-32,0,0,0); }
		if(enemiescalled==4){ CreateEnemyFromFile("script\Enemies\Stage 1\104.txt",cx+100,miny-32,0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=10){ nextphase=1; }
}
if(phase==8 && stagephase==2){
	if(enemiescalled==0){ newviewx=-20; newviewy=-15; viewmovetimexy=90; }
	if(frame%10==0){
		if(enemiescalled%5==0){ CreateEnemyFromFile("script\Enemies\Stage 1\105.txt",minx-32-rand(0,20),miny+rand(0,50),0,0,0); }
		if(enemiescalled%3==0){ CreateEnemyFromFile("script\Enemies\Stage 1\101.txt",cx+rand(-50,50),miny-32,0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=24){ nextphase=1; }
}
if(phase==9 && stagephase==2){
	if(enemiescalled==0){ newviewx=20; newviewy=-15; viewmovetimexy=90; }
	if(frame%10==0){
		if(enemiescalled%5==0 && enemiescalled<10){ CreateEnemyFromFile("script\Enemies\Stage 1\105.txt",maxx+32+rand(0,20),miny+rand(0,50),0,0,0); }
		if(enemiescalled%3==0 && enemiescalled<10){ CreateEnemyFromFile("script\Enemies\Stage 1\101.txt",cx+rand(-50,50),miny-32,0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=24){ nextphase=1; }
}
if(phase==10 && stagephase==2){
	if(enemiescalled==0){ newviewx=30; newviewy=-10; viewmovetimexy=90; }
	if(frame%30==0){
		if(enemiescalled<5){ CreateEnemyFromFile("script\Enemies\Stage 1\102.txt",maxx+rand(32,64),miny+rand(70,100),0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=7){ nextphase=1; }
}
if(phase==11 && stagephase==2){
	if(enemiescalled==0){ newviewx=-30; newviewy=-10; viewmovetimexy=90; }
	if(frame%30==0){
		if(enemiescalled<5){ CreateEnemyFromFile("script\Enemies\Stage 1\102.txt",minx-rand(32,64),miny+rand(70,100),0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=12){ nextphase=1; }
}
if(phase==12 && stagephase==2){
	if(enemiescalled==0){ newviewx=0; newviewy=-15; viewmovetimexy=90; }
	if(frame%40==0){
		if(enemiescalled<5){ CreateEnemyFromFile("script\Enemies\Stage 1\105.txt",maxx+32+rand(0,20),miny+rand(0,50),0,0,0); }
		if(enemiescalled<5){ CreateEnemyFromFile("script\Enemies\Stage 1\105.txt",minx-32-rand(0,20),miny+rand(0,50),0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=9){ nextphase=1; }
}
if(phase==13 && stagephase==2){
	if(enemiescalled==0){ newviewx=-10; newviewy=0; viewmovetimexy=90; }
	if(enemiescalled==2){ newviewx=0; newviewy=0; viewmovetimexy=90; }
	if(enemiescalled==4){ newviewx=10; newviewy=0; viewmovetimexy=90; }
	if(frame%60==0){
		if(enemiescalled==0){ CreateEnemyFromFile("script\Enemies\Stage 1\104.txt",cx-100,miny-32,0,0,0); }
		if(enemiescalled==2){ CreateEnemyFromFile("script\Enemies\Stage 1\104.txt",cx,miny-80,0,0,0); }
		if(enemiescalled==4){ CreateEnemyFromFile("script\Enemies\Stage 1\104.txt",cx+100,miny-32,0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=10){ nextphase=1; }
}
if(phase==14 && stagephase==2){
	if(enemiescalled==0){ newviewx=0; newviewy=-20; viewmovetimexy=90; }
	if(frame%60==0){
		if(enemiescalled<1){ CreateEnemyFromFile("script\Enemies\Stage 1\106.txt",cx,miny-32,0,0,0); }
	enemiescalled++; }
	if(GetCommonData("IncreasePhase")==1){ nextphase=1; }
}

if(phase==15 && stagephase==2){
	if(enemiescalled==2){ newviewx=0; newviewy=0; viewmovetimexy=120; }
	if(frame%60==0){ enemiescalled++; } //Wait
	if(enemiescalled>=5){ nextphase=1; }
}