#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Spellcard 3 Hard"]
#Text[" Last Words - Goodbye World "]

let bossObj;
let BossX = 0;
let BossY = 0;
let imgBoss = GetCurrentScriptDirectory ~ "IMG/ghost.png";

#include "script/default_system/Default_ShotConst.txt"
#include "./Render.txt"

@Initialize{
	// Initialize: Works when starting up Danmakufu PH3
	
	DeleteShotAll(TYPE_ALL, TYPE_ITEM);

	//  Defines a Boss and Registers it.
	bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(bossObj);
	
	
	//Textures the Boss and Indicates the Boss's True Center.
	ObjPrim_SetTexture(bossObj,imgBoss);
	renderBoss;
	ObjSprite2D_SetDestCenter(bossObj);
	
    //Starts a Spellcard.
	LoadSound(GetCurrentScriptDirectory ~ "SE/spell.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/spell.wav");
	let sceneObj = GetEnemyBossSceneObjectID;
	ObjEnemyBossScene_StartSpell(sceneObj);
	
	// Moves Boss to XY Location at wanted Speed (Parameters:Obj,X,Y,V)
	ObjMove_SetDestAtSpeed(bossObj,GetStgFrameWidth/2,GetStgFrameHeight/2,5);
	
	mainTask; //Runs Maintask
	
}

@Event{
	// Event: Sets the Boss's Specs
	
		// Sets Boss's Life and Timer
		alternative(GetEventType() )
		case(EV_REQUEST_LIFE) {
			SetScriptResult(25000);
		}
		case(EV_REQUEST_TIMER) {
			SetScriptResult(1000);
		}
		
		case(EV_REQUEST_SPELL_SCORE) {
			SetScriptResult(100000);
		}

}

@MainLoop{
	// MainLoop: Runs throughout the script.
	
	// Indicates that BossX = GetEnemyX and BossY = GetEnemyY
	BossX = ObjMove_GetX(bossObj);
	BossY = ObjMove_GetY(bossObj);
	
	// Sets the Boss's Collision Circle(Hitbox) For the Shots and Player.
	ObjEnemy_SetIntersectionCircleToShot(bossObj,BossX,BossY,24);
	ObjEnemy_SetIntersectionCircleToPlayer(bossObj,BossX,BossY,24);
	
	yield;

}

@Finalize{


}

// Your best friend. FOREVER!!! The Wait Function
function wait(w) { loop(w){ yield;} }

task mainTask{
	end;
	CutIn("Last Words \"Goodbye World\"");
	MagicCircle;
	wait(210);
	all;
	alls;
	
}

task alls{
	loop{
					wait(440);
		while(ObjEnemy_GetInfo(bossObj,INFO_LIFE) <= 25000 && ObjEnemy_GetInfo(bossObj,INFO_LIFE) >= 21000){

	LoadSound(GetCurrentScriptDirectory ~ "SE/wave.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/wave.wav");
				wait(200);
	LoadSound(GetCurrentScriptDirectory ~ "SE/wave.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/wave.wav");
				wait(200);
	LoadSound(GetCurrentScriptDirectory ~ "SE/wave.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/wave.wav");
				wait(200);
		}
		wait(331);
		while(ObjEnemy_GetInfo(bossObj,INFO_LIFE) <= 21001 && ObjEnemy_GetInfo(bossObj,INFO_LIFE) >= 16000){

	LoadSound(GetCurrentScriptDirectory ~ "SE/wave.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/wave.wav");
				wait(260);
	LoadSound(GetCurrentScriptDirectory ~ "SE/wave.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/wave.wav");
				wait(260);
	LoadSound(GetCurrentScriptDirectory ~ "SE/wave.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/wave.wav");
				wait(260);
		}
		wait(331);
		while(ObjEnemy_GetInfo(bossObj,INFO_LIFE) <= 16001 && ObjEnemy_GetInfo(bossObj,INFO_LIFE) >= 12000){

		loop(11){
			LoadSound(GetCurrentScriptDirectory ~ "SE/wave.wav");
			PlaySE(GetCurrentScriptDirectory ~ "SE/wave.wav");
			wait(5);
		}
				wait(320);
		loop(11){
			LoadSound(GetCurrentScriptDirectory ~ "SE/wave.wav");
			PlaySE(GetCurrentScriptDirectory ~ "SE/wave.wav");
			wait(5);
		}
				wait(320);
		loop(11){
			LoadSound(GetCurrentScriptDirectory ~ "SE/wave.wav");
			PlaySE(GetCurrentScriptDirectory ~ "SE/wave.wav");
			wait(5);
		}
		}
		wait(331);
		while(ObjEnemy_GetInfo(bossObj,INFO_LIFE) <= 12001 && ObjEnemy_GetInfo(bossObj,INFO_LIFE) >= 8000){

		loop(11){
			LoadSound(GetCurrentScriptDirectory ~ "SE/wave.wav");
			PlaySE(GetCurrentScriptDirectory ~ "SE/wave.wav");
			wait(10);
		}
				wait(360);
		loop(11){
			LoadSound(GetCurrentScriptDirectory ~ "SE/wave.wav");
			PlaySE(GetCurrentScriptDirectory ~ "SE/wave.wav");
			wait(10);
		}
				wait(360);
		loop(11){
			LoadSound(GetCurrentScriptDirectory ~ "SE/wave.wav");
			PlaySE(GetCurrentScriptDirectory ~ "SE/wave.wav");
			wait(10);
		}
				wait(360);
		}
		wait(331);
		if(ObjEnemy_GetInfo(bossObj,INFO_LIFE) <= 8001 && ObjEnemy_GetInfo(bossObj,INFO_LIFE) >= 0){

	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
				loop{		
		loop(11){
			LoadSound(GetCurrentScriptDirectory ~ "SE/wave.wav");
			PlaySE(GetCurrentScriptDirectory ~ "SE/wave.wav");
			wait(20);
		}
				wait(360);		
		loop(11){
			LoadSound(GetCurrentScriptDirectory ~ "SE/wave.wav");
			PlaySE(GetCurrentScriptDirectory ~ "SE/wave.wav");
			wait(20);
		}
				wait(360);
				}
		}
		yield;
	}
}
task all{
	ConcentrationQ;
	wait(110);
	loop{
		while(ObjEnemy_GetInfo(bossObj,INFO_LIFE) <= 25000 && ObjEnemy_GetInfo(bossObj,INFO_LIFE) >= 21000){
				fire;
				wait(200);
				fire2;
				wait(200);
				fire3;
				wait(200);
		}
		loop(1){
	ConcentrationQ;
			DeleteShotAll(TYPE_ALL, TYPE_ITEM);
			yield;
		}
		while(ObjEnemy_GetInfo(bossObj,INFO_LIFE) <= 21001 && ObjEnemy_GetInfo(bossObj,INFO_LIFE) >= 16000){
				fire4;
				wait(260);
				fire5;
				wait(260);
				fire6;
				wait(260);
		}
		loop(1){
	ConcentrationQ;
			DeleteShotAll(TYPE_ALL, TYPE_ITEM);
			yield;
		}
		while(ObjEnemy_GetInfo(bossObj,INFO_LIFE) <= 16001 && ObjEnemy_GetInfo(bossObj,INFO_LIFE) >= 12000){
				fire7;
				wait(320);
				fire8;
				wait(320);
				fire9;
				wait(320);
		}
		loop(1){
	ConcentrationQ;
			DeleteShotAll(TYPE_ALL, TYPE_ITEM);
			yield;
		}
		while(ObjEnemy_GetInfo(bossObj,INFO_LIFE) <= 12001 && ObjEnemy_GetInfo(bossObj,INFO_LIFE) >= 8000){
				fire10;
				wait(360);
				fire11;
				wait(360);
				fire12;
				wait(360);
		}
		loop(1){
	ConcentrationQ;
			DeleteShotAll(TYPE_ALL, TYPE_ITEM);
			yield;
		}
		if(ObjEnemy_GetInfo(bossObj,INFO_LIFE) <= 8001 && ObjEnemy_GetInfo(bossObj,INFO_LIFE) >= 0){
				fire15;
				loop{
				fire13;;
				wait(360);
				fire14;
				wait(360);
				}
		}
		yield;
	}
}

task fire{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	ascent(i in 0..7){
		while(x<26){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
		let obj = CreateShotA1(BossX+30*cos(dir),BossY+30*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj,0,3,dir,-0.01,2,0,9);
			ObjMove_AddPatternA3(obj,300,i/20+1,dir+i,0,0,2,174);
			
		let obj1 = CreateShotA1(BossX+30*cos(dir),BossY+30*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj1,0,3,dir,-0.01,-2,0,9);
			ObjMove_AddPatternA3(obj1,300,i/20+1,dir-i,0,0,2,174);
			
			
			
			dir+=360/26;
			x++;
			spin++;
		}
		x = 0;
		dir = 0;
		yield;
	}
	if(spin == 359){
		spin = 0;
	}
	
}

task fire2{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	ascent(i in 0..7){
		while(x<20){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
		let obj = CreateShotA1(BossX+10*cos(dir),BossY+10*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj,0,3,dir,-0.01,2,0,14);
			ObjMove_AddPatternA3(obj,300,i/20+1,dir+i*2,0,0,2,176);
			
		let obj1 = CreateShotA1(BossX+10*cos(dir),BossY+10*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj1,0,3,dir,-0.01,-2,0,14);
			ObjMove_AddPatternA3(obj1,300,i/20+1,dir-i*2,0,0,2,176);
			
			
			
			dir+=360/20;
			x++;
			spin++;
		}
		x = 0;
		dir = 0;
		yield;
	}
	if(spin == 359){
		spin = 0;
	}
	
}

task fire3{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	ascent(i in 0..7){
		while(x<14){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
		let obj = CreateShotA1(BossX+10*cos(dir),BossY+10*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj,0,3,dir,-0.01,2,0,15);
			ObjMove_AddPatternA3(obj,300,i/20+1,dir+i*3,0,0,2,175);
			
		let obj1 = CreateShotA1(BossX+10*cos(dir),BossY+10*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj1,0,3,dir,-0.01,-2,0,15);
			ObjMove_AddPatternA3(obj1,300,i/20+1,dir-i*3,0,0,2,175);
			
			
			
			dir+=360/14;
			x++;
			spin++;
		}
		x = 0;
		dir = 0;
		yield;
	}
	if(spin == 359){
		spin = 0;
	}
	
}

task fire4{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	ascent(i in 0..7){
		while(x<28){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
		let obj = CreateShotA1(BossX-100*cos(dir),BossY-100*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj,0,3,dir,-0.01,2,0,9);
			ObjMove_AddPatternA3(obj,300,i/20+1,dir+i,0,0,2,174);
			
		let obj1 = CreateShotA1(BossX-100*cos(dir),BossY-100*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj1,0,3,dir,-0.01,-2,0,9);
			ObjMove_AddPatternA3(obj1,300,i/20+1,dir-i,0,0,2,174);
			
			
			
			dir+=360/28;
			x++;
			spin++;
		}
		x = 0;
		dir = 0;
		yield;
	}
	if(spin == 359){
		spin = 0;
	}
	
}

task fire5{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	ascent(i in 0..7){
		while(x<14){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
		let obj = CreateShotA1(BossX-50*cos(dir),BossY-50*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj,0,3,dir,-0.01,2,0,14);
			ObjMove_AddPatternA3(obj,300,i/20+1,dir+i*2,0,0,2,176);
			
		let obj1 = CreateShotA1(BossX-50*cos(dir),BossY-50*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj1,0,3,dir,-0.01,-2,0,14);
			ObjMove_AddPatternA3(obj1,300,i/20+1,dir-i*2,0,0,2,176);
			
			
			
			dir+=360/14;
			x++;
			spin++;
		}
		x = 0;
		dir = 0;
		yield;
	}
	if(spin == 359){
		spin = 0;
	}
	
}

task fire6{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	ascent(i in 0..7){
		while(x<14){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
		let obj = CreateShotA1(BossX-0*cos(dir),BossY-0*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj,0,3,dir,-0.01,2,0,15);
			ObjMove_AddPatternA3(obj,300,i/20+1,dir+i*3,0,0,2,175);
			
		let obj1 = CreateShotA1(BossX-0*cos(dir),BossY-0*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj1,0,3,dir,-0.01,-2,0,15);
			ObjMove_AddPatternA3(obj1,300,i/20+1,dir-i*3,0,0,2,175);
			
			
			
			dir+=360/14;
			x++;
			spin++;
		}
		x = 0;
		dir = 0;
		yield;
	}
	if(spin == 359){
		spin = 0;
	}
	
}

task fire7{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	ascent(i in 0..11){
		while(x<12){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
		let obj = CreateShotA1(BossX+10*cos(dir),BossY+10*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj,0,3,dir,-0.01,3,0,9);
			ObjMove_AddPatternA3(obj,300,i/10+1,dir+i,0,-0.1,2,174);
			
		let obj1 = CreateShotA1(BossX+10*cos(dir),BossY+10*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj1,0,3,dir,-0.01,-3,0,9);
			ObjMove_AddPatternA3(obj1,300,i/10+1,dir-i,0,0.1,2,174);
			
			
			
			dir+=360/12;
			x++;
			spin++;
		}
		x = 0;
		dir = 0;
		wait(5);
	}
	if(spin == 359){
		spin = 0;
	}
	
}

task fire8{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	ascent(i in 0..11){
		while(x<16){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
		let obj = CreateShotA1(BossX+20*cos(dir),BossY+20*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj,0,3,dir,-0.01,3,0,14);
			ObjMove_AddPatternA3(obj,300,i/10+1,dir+i,0,0.1,2,176);
			
		let obj1 = CreateShotA1(BossX+20*cos(dir),BossY+20*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj1,0,3,dir,-0.01,-3,0,14);
			ObjMove_AddPatternA3(obj1,300,i/10+1,dir-i,0,-0.1,2,176);
			
			
			
			dir+=360/16;
			x++;
			spin++;
		}
		x = 0;
		dir = 0;
		wait(5);
	}
	if(spin == 359){
		spin = 0;
	}
	
}

task fire9{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	ascent(i in 0..11){
		while(x<16){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
		let obj = CreateShotA1(BossX+10*cos(dir),BossY+10*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj,0,3,dir,-0.01,3,0,15);
			ObjMove_AddPatternA3(obj,300,i/10+1,dir+i,0,-0.1,2,175);
			
		let obj1 = CreateShotA1(BossX+10*cos(dir),BossY+10*sin(dir),i,dir,17,30);
		
			ObjMove_AddPatternA3(obj1,0,3,dir,-0.01,-3,0,15);
			ObjMove_AddPatternA3(obj1,300,i/10+1,dir-i,0,0.1,2,175);
			
			
			
			dir+=360/16;
			x++;
			spin++;
		}
		x = 0;
		dir = 0;
		wait(5);
	}
	if(spin == 359){
		spin = 0;
	}
	
}

task fire10{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	ascent(i in 0..11){
		while(x<10){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
		let obj = CreateShotA1(BossX+30*cos(dir),BossY+30*sin(dir),i,dir,9,30);
		
			ObjMove_AddPatternA3(obj,5,3,dir,-0.01,3,0,9);
			ObjMove_AddPatternA3(obj,300,i/10+1,dir+i*41,0,-0.1,2,174);
			
		let obj1 = CreateShotA1(BossX+30*cos(dir),BossY+30*sin(dir),i,dir,9,30);
		
			ObjMove_AddPatternA3(obj1,5,3,dir,-0.01,-3,0,9);
			ObjMove_AddPatternA3(obj1,300,i/10+1,dir-i*41,0,0.1,2,174);
			
			
			
			dir+=360/10;
			x++;
			spin++;
		}
		x = 0;
		dir = 0;
		wait(10);
	}
	if(spin == 359){
		spin = 0;
	}
	
}

task fire11{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	ascent(i in 0..11){
		while(x<10){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
		let obj = CreateShotA1(BossX+20*cos(dir),BossY+20*sin(dir),i,dir,14,30);
		
			ObjMove_AddPatternA3(obj,5,3,dir,-0.01,3,0,14);
			ObjMove_AddPatternA3(obj,300,i/10+1,dir+i*41,0,0.1,2,176);
			
		let obj1 = CreateShotA1(BossX+20*cos(dir),BossY+20*sin(dir),i,dir,14,30);
		
			ObjMove_AddPatternA3(obj1,5,3,dir,-0.01,-3,0,14);
			ObjMove_AddPatternA3(obj1,300,i/10+1,dir-i*41,0,-0.1,2,176);
			
			
			
			dir+=360/10;
			x++;
			spin++;
		}
		x = 0;
		dir = 0;
		wait(10);
	}
	if(spin == 359){
		spin = 0;
	}
	
}

task fire12{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	ascent(i in 0..11){
		while(x<10){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
		let obj = CreateShotA1(BossX+10*cos(dir),BossY+10*sin(dir),i,dir,15,30);
		
			ObjMove_AddPatternA3(obj,5,3,dir,-0.01,3,0,15);
			ObjMove_AddPatternA3(obj,300,i/10+1,dir+i*41,0,-0.1,2,175);
			
		let obj1 = CreateShotA1(BossX+10*cos(dir),BossY+10*sin(dir),i,dir,15,30);
		
			ObjMove_AddPatternA3(obj1,5,3,dir,-0.01,-3,0,15);
			ObjMove_AddPatternA3(obj1,300,i/10+1,dir-i*41,0,0.1,2,175);
			
			
			
			dir+=360/10;
			x++;
			spin++;
		}
		x = 0;
		dir = 0;
		wait(10);
	}
	if(spin == 359){
		spin = 0;
	}
	
}

task fire13{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	ascent(i in 5..20){
		while(x<12 && !Obj_IsDeleted(bossObj)){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
		let obj = CreateShotA1(BossX+20*cos(dir+i*31),BossY+20*sin(dir+i*31),i,dir,14,30);
		
			ObjMove_AddPatternA3(obj,0,i/15+2,dir,-0.05,0,0,14);
			ObjMove_AddPatternA3(obj,100,0,dir+180,0,i/10,0,14);
			ObjMove_AddPatternA3(obj,200,i/5,NO_CHANGE,0.05,0,i/10+1,176);
			
			dir+=360/12;
			x++;
			spin++;
		}
		x = 0;
		dir = 0;
		wait(20);
	}
	if(spin == 359){
		spin = 0;
	}
	
}

task fire14{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	ascent(i in 5..20){
		while(x<12 && !Obj_IsDeleted(bossObj)){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot2.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot2.wav");
		let obj = CreateShotA1(BossX+20*cos(dir-i*31),BossY+20*sin(dir-i*31),i,dir,14,30);
		
			ObjMove_AddPatternA3(obj,0,i/15+2,dir,-0.05,0,0,9);
			ObjMove_AddPatternA3(obj,100,0,dir+180,0,-i/10,0,9);
			ObjMove_AddPatternA3(obj,200,i/5,NO_CHANGE,0.05,0,i/10+1,174);
			
			dir+=360/12;
			x++;
			spin++;
		}
		x = 0;
		dir = 0;
		wait(20);
	}
	if(spin == 359){
		spin = 0;
	}
	
}

task fire15{
	let spin = 0;
	let dir = 0;
	let x = 0;
	let i = 0;
	
	wait(500);
	loop{
		while(x<10 && !Obj_IsDeleted(bossObj)){
	LoadSound(GetCurrentScriptDirectory ~ "SE/shot3.wav");
	PlaySE(GetCurrentScriptDirectory ~ "SE/shot3.wav");
		let obj = CreateShotA1(BossX+0*cos(dir),BossY+0*sin(dir),i,dir,14,10);
		
			ObjMove_AddPatternA3(obj,0,2,dir,-0.005,3,2,197);
			ObjMove_AddPatternA3(obj,60,2,dir-spin,-0.005,0,1,197);
			ObjMove_AddPatternA3(obj,90,NO_CHANGE,dir-spin,-0.005,0.3,1,197);
			
		let obj1 = CreateShotA1(BossX+0*cos(dir),BossY+0*sin(dir),i,dir,14,10);
		
			ObjMove_AddPatternA3(obj1,0,2,dir,-0.005,3,2,197);
			ObjMove_AddPatternA3(obj1,60,2,dir-spin,-0.005,0,1,197);
			ObjMove_AddPatternA3(obj1,90,NO_CHANGE,dir-spin,-0.005,-0.3,1,197);
			
			dir+=360/10;
			x++;
			spin+=1;
		}
		x = 0;
		dir = 0;
		wait(90);
	}
	if(spin == 360){
		spin = 0;
	}
	
}

task end{
	while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){ yield;}
	
	Death;
	Obj_SetVisible(bossObj,false);
	DeleteShotAll(TYPE_ALL, TYPE_ITEM);
	wait(110);
	Obj_Delete(bossObj);
	
	break;
	loop(120){
	yield;
	DeleteShotAll(TYPE_ALL, TYPE_ITEM);
	}

	DeleteShotAll(TYPE_ALL, TYPE_ITEM);
	CloseScript(GetOwnScriptID());
}