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

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){ newviewh=20; newviewy=100; viewmovetimehv=90; }
	if(frame%20==0){
		if(enemiescalled<10){ CreateEnemyFromFile("script\Enemies\Stage 1\101.txt",cx-rand(80,150),miny-32,0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=12){ nextphase=1; }
}
if(phase==2 && stagephase==1){
	if(enemiescalled==0){ newviewh=-20; viewmovetimehv=90; }
	if(frame%20==0){
		if(enemiescalled<10){ CreateEnemyFromFile("script\Enemies\Stage 1\101.txt",cx+rand(80,150),miny-32,0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=16){ nextphase=1; }
}
if(phase==3 && stagephase==1){
	if(enemiescalled==0){ newviewx=-30; newviewy=-10; viewmovetimexy=90; }
	if(enemiescalled==0){ newviewh=-0; viewmovetimehv=60; }
	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>=9){ nextphase=1; }
}
if(phase==4 && stagephase==1){
	if(enemiescalled==0){ newviewx=0; newviewy=0; viewmovetimexy=90; }
	if(frame%15==0){
		if(enemiescalled<20){ CreateEnemyFromFile("script\Enemies\Stage 1\101.txt",cx+rand(-60,60),miny-32,0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=25){ nextphase=1; }
}
if(phase==5 && stagephase==1){
	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>=11){ nextphase=1; }
}
if(phase==6 && stagephase==1){
	if(enemiescalled==0){ newviewx=0; newviewy=0; viewmovetimexy=90; }
	if(frame%15==0){
		if(enemiescalled<10){ CreateEnemyFromFile("script\Enemies\Stage 1\103.txt",minx-rand(32,64),miny+rand(-30,0),0,0,0); }
		if(enemiescalled<10){ CreateEnemyFromFile("script\Enemies\Stage 1\103.txt",maxx+rand(32,64),miny+rand(-30,0),0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=20){ nextphase=1; }
}
if(phase==7 && stagephase==1){
	if(enemiescalled==0){ newviewh=-20; viewmovetimehv=90; }
	if(frame%15==0){
		if(enemiescalled<7){ CreateEnemyFromFile("script\Enemies\Stage 1\101.txt",cx+rand(80,150),miny-32,0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=10){ nextphase=1; }
}
if(phase==8 && stagephase==1){
	if(enemiescalled==0){ newviewh=20; viewmovetimehv=90; }
	if(frame%15==0){
		if(enemiescalled<7){ CreateEnemyFromFile("script\Enemies\Stage 1\101.txt",cx-rand(80,150),miny-32,0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=10){ nextphase=1; }
}
if(phase==9 && stagephase==1){
	if(enemiescalled==0){ newviewh=0; viewmovetimehv=90; }
	if(frame%15==0){
		if(enemiescalled<10){ CreateEnemyFromFile("script\Enemies\Stage 1\101.txt",cx+rand(80,150),miny-32,0,0,0); }
		if(enemiescalled>=5 && enemiescalled<15){ CreateEnemyFromFile("script\Enemies\Stage 1\101.txt",cx-rand(80,180),miny-32,0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=18){ nextphase=1; }
}
if(phase==10 && stagephase==1){
	if(enemiescalled==6){ newviewx=40; viewmovetimexy=120; }
	if(enemiescalled==6){ newviewh=30; viewmovetimehv=120; }
	if(frame%60==0){
		if(enemiescalled<1){ CreateEnemyFromFile("script\Enemies\Stage 1\104.txt",cx,miny-32,0,0,0); }
	enemiescalled++; }
	if(enemiescalled>=9){ nextphase=1; }
}