#TouhouDanmakufu[Stage]
#ScriptVersion[3]
#Title["England Extra Stage"]
#System["./default_system/Default_System.txt"]
#include".\ZUNShot_Const.txt"
#include".\StageFunctions.txt"

let SShot1 = GetCurrentScriptDirectory~"ZUN/se_kira00.wav";
let SShot2 = GetCurrentScriptDirectory~"ZUN/se_tan00.wav";
let SBoon1 = GetCurrentScriptDirectory~"ZUN/se_boon01.wav";
let SExplode1 = GetCurrentScriptDirectory~"ZUN/se_enep02.wav";
let SCharge1 = GetCurrentScriptDirectory~"ZUN/se_ch02.wav";
let SCharge2 = GetCurrentScriptDirectory~"ZUN/se_ch00.wav";
let SSlash1 = GetCurrentScriptDirectory~"ZUN/se_slash.wav";
let music = GetCurrentScriptDirectory ~ "Extra/stage.mp3";

	@Initialize
	{
		SetCameraFocusX(0);
		SetCameraFocusY(0);
		SetCameraFocusZ(-5);
		SetCameraRadius(400);
		SetCameraElevationAngle(0);
		SetCameraAzimuthAngle(90);
		TStage();
		LoadSound(music);
		PlayBGM(music,0,0);
		PoCCheck;
		SetFogEnable(true);
		SetFogParam(0, 00, 50, 0, 50);
		SetPlayerLife(2);
	}

	@MainLoop
	{
		yield;
	}

	@Finalize
	{
	}

	task PoCCheck{
		let frame = 0;
		loop{
			if(GetPlayerY<120){
				if(frame%30==0){
					PIVItem(GetPlayerX,GetPlayerY,rand(0,360),1.5);
				}
			CollectAllItems;
			}
		frame++;
		yield;
		}
	}
	task TBackground{
		let objBack = ObjPrim_Create(OBJ_SPRITE_3D);
		let image = GetCurrentScriptDirectory~"stg3bg.png";
		let c = 0;
		ObjPrim_SetTexture(objBack,image);
		Obj_SetRenderPriorityI(objBack,20);
		ObjSprite3D_SetDestRect(objBack,-100,0,GetStgFrameWidth+100,GetStgFrameHeight);
		ObjRender_SetPosition(objBack,-GetStgFrameWidth/2,-GetStgFrameHeight/2,20);
		ObjRender_SetAlpha(objBack,200);
		ObjSprite3D_SetSourceRect(objBack,0,0,512,512);
		loop{
			SetCameraFocusX(cos(c/2)*35);
			ObjSprite3D_SetSourceRect(objBack,0,0+c,512,512+c);
			c+=1;
			yield;
	}
}
	task TRandom{
		let xpos = rand(-350,350);
		let zpos = rand(-40,40);
		let angles = [rand(0,360),rand(0,360),rand(0,360)];
		let objBack = ObjPrim_Create(OBJ_SPRITE_3D);
		let image = GetCurrentScriptDirectory~"tree.png";
		let c = 0;
		ObjPrim_SetTexture(objBack,image);
		Obj_SetRenderPriorityI(objBack,21);
		ObjSprite3D_SetDestRect(objBack,0,0,27,20);
		ObjRender_SetPosition(objBack,xpos,0,zpos);
		ObjRender_SetAlpha(objBack,255);
		ObjRender_SetZWrite(objBack, true);
		ObjRender_SetZTest(objBack, true);
		loop(480){
			ObjRender_SetPosition(objBack,xpos-(c/6),(250)-(c/3),zpos-(c/6));
	        ObjRender_SetAngleXYZ(objBack,angles[0]+(c/3),angles[1]+(c/3),angles[2]+(c/3));
			ObjSprite3D_SetSourceRect(objBack,0,0,27,20);
			c+=3;
			yield;
	}
			Obj_Delete(objBack);
}

task TRandomCall{
	loop{
		TRandom;
		loop(10){yield;}
		}
	}
task lifeGet(){
	let pivGet = 200000;
	let bombGet = 166000;
	loop{
		if(GetCommonData("PIValue",1)>=pivGet){
			DelaySE(GetCurrentScriptDirectory ~ "ZUN/se_extend.wav",0,0);
			SetPlayerLife(GetPlayerLife+1);
			pivGet+=100000;
		}
		if(GetCommonData("PIValue",1)>=bombGet){
			DelaySE(GetCurrentScriptDirectory ~ "ZUN/se_extend2.wav",0,0);
			SetPlayerSpell(GetPlayerSpell+1);
			bombGet+=66000;
		}
		yield;
	}
}
task THoming(x,y,angle){
	let obj = ObjEnemy_Create(OBJ_ENEMY);
	let frame = 0;
	let dir = -40;
	let familiar = GetCurrentScriptDirectory~"stg3enm.png";
	Obj_SetRenderPriorityI(obj,22);
	ObjEnemy_SetLife(obj,55);
	ObjEnemy_SetDamageRate(obj,100,100);
	ObjPrim_SetTexture(obj,familiar);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjEnemy_Regist(obj);
	ObjRender_SetColor(obj,255,100,255);
	ObjMove_SetPosition(obj,x,y);
	ObjMove_SetAngle(obj,angle);
	ObjMove_SetSpeed(obj,2);
	while(!Obj_IsDeleted(obj)){
		ObjEnemy_SetIntersectionCircleToShot(obj,ObjMove_GetX(obj),ObjMove_GetY(obj),32*(4/5));
		ObjRender_SetAngleXYZ(obj,0,0,frame);
		ObjSprite2D_SetDestCenter(obj);
		ObjSprite2D_SetSourceRect(obj,2,99,63,160); 
		ObjRender_SetScaleXYZ(obj,0.8,0.8,0.8);
		if(ObjMove_GetX(obj)<-64||ObjMove_GetX(obj)>GetStgFrameWidth+64||ObjMove_GetY(obj)<-64||ObjMove_GetY(obj)>GetStgFrameHeight+64){
			Obj_Delete(obj);
			return;
		}
		if(ObjEnemy_GetInfo(obj,INFO_LIFE)<=0){
			loop(5){PIVItem(ObjMove_GetX(obj),ObjMove_GetY(obj),GetAngleToPlayer(obj)+dir,3); dir+=80/5;}
			Obj_Delete(obj);	
			return;	
		}
		if(frame%7==0){DelaySE(SShot2,0,0); CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),5,GetAngleToPlayer(obj),76,10);}
		frame++;
		yield;
	}	
}
task TLaser(x,y,angle,angleacc,speed){
	let obj = ObjEnemy_Create(OBJ_ENEMY);
	let frame = 0;
	let dir = -40;
	let familiar = GetCurrentScriptDirectory~"stg3enm.png";
	Obj_SetRenderPriorityI(obj,22);
	ObjEnemy_SetLife(obj,75);
	ObjEnemy_SetDamageRate(obj,100,100);
	ObjPrim_SetTexture(obj,familiar);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjEnemy_Regist(obj);
	ObjRender_SetColor(obj,100,100,255);
	ObjMove_SetPosition(obj,x,y);
	ObjMove_SetAngle(obj,angle);
	ObjMove_SetSpeed(obj,speed);
	while(!Obj_IsDeleted(obj)){
		ObjEnemy_SetIntersectionCircleToShot(obj,ObjMove_GetX(obj),ObjMove_GetY(obj),32*(4/5));
		ObjRender_SetAngleXYZ(obj,0,0,frame);
		ObjSprite2D_SetDestCenter(obj);
		ObjSprite2D_SetSourceRect(obj,2,99,63,160); 
		ObjRender_SetScaleXYZ(obj,0.8,0.8,0.8);
		if(ObjMove_GetX(obj)<-64||ObjMove_GetX(obj)>GetStgFrameWidth+64||ObjMove_GetY(obj)<-64||ObjMove_GetY(obj)>GetStgFrameHeight+64){
			Obj_Delete(obj);
			return;
		}
		ObjMove_SetAngle(obj,ObjMove_GetAngle(obj)+angleacc);
		if(ObjEnemy_GetInfo(obj,INFO_LIFE)<=0){
			loop(3){CreateItemA1(ITEM_POINT,ObjMove_GetX(obj)+rand(-50,50),ObjMove_GetY(obj)+rand(-50,50),GetCommonData("PIValue",10000));}
			Obj_Delete(obj);	
			return;	
		}
		if(frame%60==0){DelaySE(SShot1,0,0); 
			CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),3,GetAngleToPlayer(obj),175,10);
			CreateLooseLaserA1(ObjMove_GetX(obj),ObjMove_GetY(obj),3,GetAngleToPlayer(obj),50,10,17,10);
			CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),3,GetAngleToPlayer(obj)+45,175,10);
			CreateLooseLaserA1(ObjMove_GetX(obj),ObjMove_GetY(obj),3,GetAngleToPlayer(obj)+45,50,10,17,10);
			CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),3,GetAngleToPlayer(obj)-45,175,10);
			CreateLooseLaserA1(ObjMove_GetX(obj),ObjMove_GetY(obj),3,GetAngleToPlayer(obj)-45,50,10,17,10);

		}
		frame++;
		yield;
	}	
}
task TCircle(x,y,angle){
	let obj = ObjEnemy_Create(OBJ_ENEMY);
	let frame = 0;
	let dir = rand(0,360);
	let familiar = GetCurrentScriptDirectory~"stg3enm.png";
	Obj_SetRenderPriorityI(obj,22);
	ObjEnemy_SetLife(obj,175);
	ObjEnemy_SetDamageRate(obj,100,100);
	ObjPrim_SetTexture(obj,familiar);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjEnemy_Regist(obj);
	ObjRender_SetColor(obj,255,100,100);
	ObjMove_SetPosition(obj,x,y);
	ObjMove_SetAngle(obj,angle);
	ObjMove_SetSpeed(obj,0.5);
	while(!Obj_IsDeleted(obj)){
		ObjEnemy_SetIntersectionCircleToShot(obj,ObjMove_GetX(obj),ObjMove_GetY(obj),32*(4/5));
		ObjRender_SetAngleXYZ(obj,0,0,frame);
		ObjSprite2D_SetDestCenter(obj);
		ObjSprite2D_SetSourceRect(obj,2,99,63,160); 
		ObjRender_SetScaleXYZ(obj,0.8,0.8,0.8);
		if(ObjMove_GetX(obj)<-64||ObjMove_GetX(obj)>GetStgFrameWidth+64||ObjMove_GetY(obj)<-64||ObjMove_GetY(obj)>GetStgFrameHeight+64){
			Obj_Delete(obj);
			return;
		}
		if(ObjEnemy_GetInfo(obj,INFO_LIFE)<=0){
			loop(2){PIVItem(ObjMove_GetX(obj),ObjMove_GetY(obj),dir,2); dir+=360/2;}
			loop(5){CreateItemA1(ITEM_POINT,ObjMove_GetX(obj)+rand(-50,50),ObjMove_GetY(obj)+rand(-50,50),GetCommonData("PIValue",10000));}
			Obj_Delete(obj);	
			return;	
		}
		if(frame%120==60){DelaySE(SShot2,0,0); loop(30){CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),1,dir,267,10); dir+=360/30;}}
		frame++;
		yield;
	}	
}
task TCircle2(x,y,angle){
	let obj = ObjEnemy_Create(OBJ_ENEMY);
	let frame = 0;
	let dir = rand(0,360);
	let familiar = GetCurrentScriptDirectory~"stg3enm.png";
	Obj_SetRenderPriorityI(obj,22);
	ObjEnemy_SetLife(obj,300);
	ObjEnemy_SetDamageRate(obj,100,100);
	ObjPrim_SetTexture(obj,familiar);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjEnemy_Regist(obj);
	ObjRender_SetColor(obj,255,100,100);
	ObjMove_SetPosition(obj,x,y);
	ObjMove_SetAngle(obj,angle);
	ObjMove_SetSpeed(obj,1);
	while(!Obj_IsDeleted(obj)){
		ObjEnemy_SetIntersectionCircleToShot(obj,ObjMove_GetX(obj),ObjMove_GetY(obj),32*(4/5));
		ObjRender_SetAngleXYZ(obj,0,0,frame);
		ObjSprite2D_SetDestCenter(obj);
		ObjSprite2D_SetSourceRect(obj,2,99,63,160); 
		ObjRender_SetScaleXYZ(obj,0.8,0.8,0.8);
		if(ObjMove_GetX(obj)<-64||ObjMove_GetX(obj)>GetStgFrameWidth+64||ObjMove_GetY(obj)<-64||ObjMove_GetY(obj)>GetStgFrameHeight+64){
			Obj_Delete(obj);
			return;
		}
		if(ObjEnemy_GetInfo(obj,INFO_LIFE)<=0){
			loop(2){PIVItem(ObjMove_GetX(obj),ObjMove_GetY(obj),dir,2); dir+=360/2;}
			loop(5){CreateItemA1(ITEM_POINT,ObjMove_GetX(obj)+rand(-50,50),ObjMove_GetY(obj)+rand(-50,50),GetCommonData("PIValue",10000));}
			Obj_Delete(obj);	
			return;	
		}
		if(frame%120==60){DelaySE(SShot2,0,0); loop(10){
			CreateShotA1(ObjMove_GetX(obj)+50*cos(dir),ObjMove_GetY(obj)+50*sin(dir),1,dir,40,10);
			CreateShotA1(ObjMove_GetX(obj)+50*cos(dir),ObjMove_GetY(obj)+50*sin(dir),1,dir+120,35,10);
			CreateShotA1(ObjMove_GetX(obj)+50*cos(dir),ObjMove_GetY(obj)+50*sin(dir),1,dir-120,36,10); 
			dir+=360/10;
		}
		}
		frame++;
		yield;
	}	
}

task TSpiral(x,y,angle,dir1,dir2){
	let obj = ObjEnemy_Create(OBJ_ENEMY);
	let frame = 0;
	let dir = rand(0,360);
	let familiar = GetCurrentScriptDirectory~"stg3enm.png";
	Obj_SetRenderPriorityI(obj,22);
	ObjEnemy_SetLife(obj,120);
	ObjEnemy_SetDamageRate(obj,100,100);
	ObjPrim_SetTexture(obj,familiar);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjEnemy_Regist(obj);
	ObjRender_SetColor(obj,100,255,100);
	ObjMove_SetPosition(obj,x,y);
	ObjMove_SetAngle(obj,angle);
	ObjMove_SetSpeed(obj,1);
	while(!Obj_IsDeleted(obj)){
		ObjEnemy_SetIntersectionCircleToShot(obj,ObjMove_GetX(obj),ObjMove_GetY(obj),32*(4/5));
		ObjRender_SetAngleXYZ(obj,0,0,frame);
		ObjSprite2D_SetDestCenter(obj);
		ObjSprite2D_SetSourceRect(obj,2,99,63,160); 
		ObjRender_SetScaleXYZ(obj,0.8,0.8,0.8);
		if(ObjMove_GetX(obj)<-64||ObjMove_GetX(obj)>GetStgFrameWidth+64||ObjMove_GetY(obj)<-64||ObjMove_GetY(obj)>GetStgFrameHeight+64){
			Obj_Delete(obj);
			return;
		}
		if(frame>60&&frame<300){ObjMove_SetSpeed(obj,0);} else { ObjMove_SetSpeed(obj,1);}
		if(frame<300){	ObjEnemy_SetDamageRate(obj,0,0);} else {	ObjEnemy_SetDamageRate(obj,100,100);}
		if(ObjEnemy_GetInfo(obj,INFO_LIFE)<=0){
			loop(50){PIVItem(ObjMove_GetX(obj),ObjMove_GetY(obj),dir,rand(1,3)); dir+=360/50;}
			loop(20){CreateItemA1(ITEM_POINT,ObjMove_GetX(obj)+rand(-50,50),ObjMove_GetY(obj)+rand(-50,50),GetCommonData("PIValue",10000));}
			Obj_Delete(obj);	
			return;	
		}
		if(frame==90){ spiral(dir1,67);}
		if(frame==120){ spiral(dir2,68);}
		frame++;
		yield;
	}	
	task spiral(ang,graphic){
		let dire = 0;
		loop(20){
			if(!Obj_IsDeleted(obj)){
			DelaySE(SShot2,0,0);
			loop(10){
				CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),2.5,dire,graphic,40); 
				dire+=360/10;
			}
			dire+=ang;
			loop(10){yield;}
			}
		}
	}
}
task TDeath(x,y,angle,dir1,dir2){
	let obj = ObjEnemy_Create(OBJ_ENEMY);
	let frame = 0;
	let dir = rand(0,360);
	let familiar = GetCurrentScriptDirectory~"stg3enm.png";
	Obj_SetRenderPriorityI(obj,22);
	ObjEnemy_SetLife(obj,120);
	ObjEnemy_SetDamageRate(obj,100,100);
	ObjPrim_SetTexture(obj,familiar);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjEnemy_Regist(obj);
	ObjRender_SetColor(obj,100,255,100);
	ObjMove_SetPosition(obj,x,y);
	ObjMove_SetAngle(obj,angle);
	ObjMove_SetSpeed(obj,1);
	while(!Obj_IsDeleted(obj)){
		ObjEnemy_SetIntersectionCircleToShot(obj,ObjMove_GetX(obj),ObjMove_GetY(obj),32*(4/5));
		ObjRender_SetAngleXYZ(obj,0,0,frame);
		ObjSprite2D_SetDestCenter(obj);
		ObjSprite2D_SetSourceRect(obj,2,99,63,160); 
		ObjRender_SetScaleXYZ(obj,0.8,0.8,0.8);
		if(ObjMove_GetX(obj)<-64||ObjMove_GetX(obj)>GetStgFrameWidth+64||ObjMove_GetY(obj)<-64||ObjMove_GetY(obj)>GetStgFrameHeight+64){
			Obj_Delete(obj);
			return;
		}
		if(frame>60&&frame<420){ObjMove_SetSpeed(obj,0);} else { ObjMove_SetSpeed(obj,1);}
		if(frame<420){	ObjEnemy_SetDamageRate(obj,0,0);} else {	ObjEnemy_SetDamageRate(obj,100,100);}
		if(ObjEnemy_GetInfo(obj,INFO_LIFE)<=0){
			LargePIVItem(ObjMove_GetX(obj),ObjMove_GetY(obj),0,0);
			loop(100){CreateItemA1(ITEM_POINT,ObjMove_GetX(obj)+rand(-50,50),ObjMove_GetY(obj)+rand(-50,50),GetCommonData("PIValue",10000));}
			
			Obj_Delete(obj);	
			return;	
		}
		if(frame==90){ spiral(dir1,67);}
		if(frame==60){ spiral(90,69);}
		if(frame==120){ spiral(dir2,68);}
		frame++;
		yield;
	}	
	task spiral(ang,graphic){
		let dire = 0;
		loop(20){
			if(!Obj_IsDeleted(obj)){
			DelaySE(SShot2,0,0);
			loop(10){
				CreateShotA1(ObjMove_GetX(obj)+20*cos(dire),ObjMove_GetY(obj)+20*sin(dire),2.5,dire,graphic,40); 
				CreateShotA1(ObjMove_GetX(obj)+20*cos(dire),ObjMove_GetY(obj)+20*sin(dire),1.5,dire-120,graphic,40); 
				CreateShotA1(ObjMove_GetX(obj)+20*cos(dire),ObjMove_GetY(obj)+20*sin(dire),3.5,dire+120,graphic,40);  
				dire+=360/10;
			}
			dire+=ang;
			loop(10){yield;}
			}
		}
	}
}
task TYoshika(x,y,angle,dir1,dir2){
	let obj = ObjEnemy_Create(OBJ_ENEMY);
	let frame = 0;
	let dir = rand(0,360);
	let familiar = GetCurrentScriptDirectory~"stg3enm.png";
	Obj_SetRenderPriorityI(obj,22);
	ObjEnemy_SetLife(obj,360);
	ObjEnemy_SetDamageRate(obj,100,100);
	ObjPrim_SetTexture(obj,familiar);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjEnemy_Regist(obj);
	ObjRender_SetColor(obj,100,255,100);
	ObjMove_SetPosition(obj,x,y);
	ObjMove_SetAngle(obj,angle);
	ObjMove_SetSpeed(obj,2);
	while(!Obj_IsDeleted(obj)){
		ObjEnemy_SetIntersectionCircleToShot(obj,ObjMove_GetX(obj),ObjMove_GetY(obj),32*(4/5));
		ObjRender_SetAngleXYZ(obj,0,0,frame);
		ObjSprite2D_SetDestCenter(obj);
		ObjSprite2D_SetSourceRect(obj,2,99,63,160); 
		ObjRender_SetScaleXYZ(obj,0.8,0.8,0.8);
		if(ObjMove_GetX(obj)<-64||ObjMove_GetX(obj)>GetStgFrameWidth+64||ObjMove_GetY(obj)<-64||ObjMove_GetY(obj)>GetStgFrameHeight+64){
			Obj_Delete(obj);
			return;
		}
		if(frame>90&&frame<300){ObjMove_SetSpeed(obj,0);} else { ObjMove_SetSpeed(obj,2);}
		if(ObjEnemy_GetInfo(obj,INFO_LIFE)<=0){
			loop(20){PIVItem(ObjMove_GetX(obj),ObjMove_GetY(obj),dir,rand(1,3)); dir+=360/50;}
			loop(20){CreateItemA1(ITEM_POINT,ObjMove_GetX(obj)+rand(-50,50),ObjMove_GetY(obj)+rand(-50,50),GetCommonData("PIValue",10000));}
			Obj_Delete(obj);	
			return;	
		}
		if(frame==90){ spiral(91,-2);}
		if(frame==120){ spiral(92,2);}
		frame++;
		yield;
	}	
	task spiral(graphic,accel){
		let dire = rand(65,115);
		let posx = (ObjMove_GetX(obj));
		let posy = ObjMove_GetY(obj);
		let dist = 5;
		loop(5){
			loop(10){
				if(!Obj_IsDeleted(obj)){
					DelaySE(SShot2,0,0);
					CreateShotA1(posx+dist*cos(dire),posy+dist*sin(dire),1,rand(0,360),graphic,30);
				}
				dire+=accel;
				loop(2){yield;}
			}
			dist = 5;
			loop(3){yield;}
			dire = rand(75,135);

		}
	}
}
	task TStage
	{
		let dir = GetCurrentScriptDirectory();
		lifeGet;
		TBackground;
		//Creates the boss
		let path = dir ~ "Extra/midplural.txt";
		let idScript = LoadScriptInThread(path);
		loop(1){yield;}//Assuming that compiling with finish in about a second.
		let objTxt = ObjText_Create();
		ObjText_SetText(objTxt,"EXTRA");
		Obj_SetRenderPriority(objTxt, 0.1);
		ObjText_SetHorizontalAlignment(objTxt,ALIGNMENT_LEFT);
		ObjText_SetFontSize(objTxt,20);
		ObjText_SetFontColorTop(objTxt,200,255,200);
		ObjText_SetFontColorBottom(objTxt,200,255,200);
		ObjText_SetFontBorderType(objTxt,BORDER_FULL);
		ObjText_SetFontBorderColor(objTxt,100,200,100);
		ObjText_SetFontBorderWidth(objTxt,2);
		ObjRender_SetPosition(objTxt,480,20,0);
		let a = 0;
		let b = 0;
		loop(120){
			SetCameraElevationAngle(a);
			SetFogParam(b/120*100, b/120*500, 50, 0, 50);
			a-=1/4;
			b++;
			yield;
		}
		loop(60){yield;}
		loop(15){
			THoming(100,0,45);
			loop(20){yield;}
		}
		loop(240){yield;}
		loop(15){
			THoming(GetStgFrameWidth-100,0,135);
			loop(20){yield;}
		}
		loop(240){yield;}
		loop(15){
			THoming(100,0,45);
			THoming(GetStgFrameWidth-100,0,135);
			loop(20){yield;}
		}
		loop(240){yield;}
		let n = 200;
		loop(4){
			TCircle(GetStgFrameWidth/2+n,0,90);
			TCircle(GetStgFrameWidth/2-n,0,90);
			n-=35;
			loop(180){yield;}
		}
		loop(420){yield;}
		TSpiral(GetStgFrameWidth/2,0,90,3,-6);
		loop(480){yield;}
		TSpiral(GetStgFrameWidth/3,0,90,2,5);
		TSpiral(GetStgFrameWidth/3*2,0,90,-5,-2);
		loop(480){yield;}
		loop(10){
			TLaser(rand(0,-20),100,10,1,2);
			TLaser(GetStgFrameWidth+rand(0,20),100,170,-1,2);
			loop(40){yield;}
		}
		loop(180){yield;}
		TCircle(0,50,0);
		TCircle(GetStgFrameWidth,50,180);
		loop(10){
			TLaser(rand(0,-20),100,10,1,2);
			TLaser(GetStgFrameWidth+rand(0,20),100,170,-1,2);
			loop(40){yield;}
		}
		loop(420){yield;}//Assuming that compiling with finish in about a second.
		StartScript(idScript);
		//Stands by until the boss scene is finished
		while(!IsCloseScript(idScript))
		{
			yield;
		}
		LargePIVItem(GetStgFrameWidth/2,GetStgFrameHeight/2,0,0);
		path = dir ~ "Extra/plural.txt";
		idScript = LoadScriptInThread(path);
		//〜〜〜Creating the enemy, or looping the creation of an enemy
		DeleteShotAll(TYPE_ALL, TYPE_ITEM);
		loop(240){yield;}
		TYoshika(GetStgFrameWidth/2,-20,90,0,0);
		loop(240){yield;}
		TYoshika(GetStgFrameWidth/2-150,-20,90,0,0);
		loop(60){yield;}
		TYoshika(GetStgFrameWidth/2,-20,90,0,0);
		loop(60){yield;}
		TYoshika(GetStgFrameWidth/2+150,-20,90,0,0);
		loop(60){yield;}
		TYoshika(GetStgFrameWidth/2+100,-20,90,0,0);
		loop(60){yield;}
		TYoshika(GetStgFrameWidth/2-100,-20,90,0,0);
		loop(360){yield;}
		loop(50){
			TLaser(rand(0,-20),100,10,5,5);
			TLaser(GetStgFrameWidth+rand(0,20),100,170,-5,5);
			loop(10){yield;}
		}
		TCircle2(GetStgFrameWidth/2,-20,90);
		loop(120){yield;}
		TCircle2(GetStgFrameWidth/2-50,-20,90);
		TCircle2(GetStgFrameWidth/2+50,-20,90);
		loop(120){yield;}
		TCircle2(GetStgFrameWidth/2-100,-20,90);
		TCircle2(GetStgFrameWidth/2+100,-20,90);
		loop(120){yield;}
		TCircle2(GetStgFrameWidth/2-150,-20,90);
		TCircle2(GetStgFrameWidth/2+150,-20,90);
		loop(120){yield;}
		TCircle2(GetStgFrameWidth/2-100,-20,90);
		TCircle2(GetStgFrameWidth/2+100,-20,90);
		loop(120){yield;}
		TCircle2(GetStgFrameWidth/2-50,-20,90);
		TCircle2(GetStgFrameWidth/2+50,-20,90);
		loop(120){yield;}
		TCircle2(GetStgFrameWidth/2-100,-20,90);
		TCircle2(GetStgFrameWidth/2+100,-20,90);
		loop(120){yield;}
		TCircle2(GetStgFrameWidth/2-150,-20,90);
		TCircle2(GetStgFrameWidth/2+150,-20,90);
		loop(120){yield;}
		TCircle2(GetStgFrameWidth/2-100,-20,90);
		TCircle2(GetStgFrameWidth/2+100,-20,90);
		loop(1000){yield;}
		TDeath(GetStgFrameWidth/2,-20,90,2,-3);
		loop(1000){yield;}
		DeleteShotAll(TYPE_ALL, TYPE_ITEM);
		RemoveSound(music);
		StartScript(idScript);
		//Stands by until the boss scene is finished
		while(!IsCloseScript(idScript))
		{
			yield;
		}
	    //End of the stage
		CloseStgScene();
	}