#“Œ•û’e–‹•—[Single]
#ScriptVersion[3]
#Title["Sanae Sign\"Embodiment of Scarlet Devil\""]
#Text["Embodiment of Scarlet Devil"]
#Player[DEFAULT]

#include"./Functions/Index.txt"
#include"./shot/ZUNShot_Const.txt"
#include"script/Default_system/Default_Effect.Txt"

let objBoss;
let GCSD=GetCurrentScriptDirectory~"";
let enemy;
let mainsnd;
let subsnd;
let bSpell=false;
let bSpell2=false;
let stgx=GetStgFrameWidth()/2;
let stgy=GetStgFrameHeight()/2;
let idle = true;
let s = 1;
let m = 0;
let objScene=GetEnemyBossSceneObjectID();
let bg = GCSD~"img/Sanae1.png";
let bg1 = GCSD~"img/Sanae2.png";
let bg2 = GCSD~"img/BG2.png";
LoadTexture(bg2);

@Initialize
{
	SetPlayerLife(4);
	LoadTexture(GCSD~"shot/ZUNShot.png");
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	ObjEnemy_SetDamageRate(objBoss,0,0);
	ObjMove_SetDestAtWeight(objBoss,stgx,150,10,7);
	mainTask;
	TRender;
	TEnd;
}

@MainLoop
{
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),25);
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),26);
	yield;

}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		SetScriptResult(2750);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(600);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(30000);
	}
}

//----------------------------------------------------
task mainTask{
	wait(90);
	PlaySound("cardcall",100,0);
	Cutin("Medi","Miracle Sign\"Embodiment of Scarlet Devil\"",15);
	ObjEnemyBossScene_StartSpell(objScene);
	TSpell;
	wait(90);
	ObjEnemy_SetDamageRate(objBoss,0,0);
	T01MN1;
	//Opening;
	//T06FS2;
	//T06FS3;
	//T06FS4;
	}
	
function Sound(path){
	let obj = ObjSound_Create;
	ObjSound_Load(obj,path);
	ObjSound_SetSoundDivision(obj, SOUND_BGM);
	ObjSound_SetRestartEnable(obj, true);
	ObjSound_SetLoopEnable(obj, true);
	ObjSound_SetLoopTime(obj, 0,300);
	ObjSound_Play(obj);
	return obj;
	}
	
task SoundStop(obj){
	descent(i in 0..100){
	ObjSound_SetVolumeRate(obj,i);
	wait(6);
	}
	ObjSound_Stop(obj);
	}
//----------------------------------------------------

task T01MN1{
	let acc = 0;
	let spd = 0;
	let color = [185,188,191,192,186];
	mainsnd = Sound(MainSTG~"Faith.mp3");
	wait(120);
	maple(3);
	wait(120);
	ascent(i in 0..20){
	PlaySound("Shot1",95,0);
	ascent(a in 3..8){
	spd = 7+a/3;
	acc = -spd/20;
	ShotA2(GetEnemyX,GetEnemyY,spd,i*18,acc,1+a/8,SMALL_BLUE,20);
	}
	}
	TMovement(35,5,5);
	wait(30);
	ascent(n in 0..5){
	PlaySound("Shot1",95,0);
	ascent(i in 0..24){
	spd = 5-n/5;
	acc = -spd/20;
	let shot = ShotA2(GetEnemyX,GetEnemyY,spd,i*15+n*6,acc,0.5,color[n],10);
	ObjMove_AddPatternA2(shot,30,0.5,i*15+n*4,0.02,0,3);
	}
	wait(7);
	}
	wait(30);
	ascent(n in 0..2){
	ascent(i in 0..15){
	PlaySound("Shot1",95,0);
	ascent(a in 3..8){
	spd = 7+a/3;
	acc = -spd/20;
	if(n==0){ShotA2(GetEnemyX,GetEnemyY,spd,i*24,acc,1+a/8,SMALL_GREEN,20);}
	if(n==1){ShotA2(GetEnemyX,GetEnemyY,spd,i*24+n*12,acc,1+a/8,SMALL_YELLOW,20);}
	}
	}
	wait(30);
	TMovement(35,5,5);
	}
	AccelMove(objBoss,stgx,120,0.1,30);
	ascent(n in 0..7){
	PlaySound("Shot1",95,0);
	ascent(i in 0..12){
	spd = 5-n/7;
	acc = -spd/30;
	ShotA2(GetEnemyX,GetEnemyY,spd,i*30+n*12,acc,spd/2,186+n,8);
	spd = 5.5-n/7;
	ShotA2(GetEnemyX,GetEnemyY,spd,i*30+n*12,acc,spd/2,86+n,16);
	}
	wait(10);
	}
	ascent(n in 0..2){
	ascent(i in 0..15){
	PlaySound("Shot1",95,0);
	ascent(a in 3..8){
	spd = 7+a/3;
	acc = -spd/20;
	if(n==0){ShotA2(GetEnemyX,GetEnemyY,spd,i*24,acc,1+a/8,SMALL_BLUE,20);}
	if(n==1){ShotA2(GetEnemyX,GetEnemyY,spd,i*24+n*12,acc,1+a/8,SMALL_RED,20);}
	}
	}
	wait(30);
	TMovement(35,5,5);
	}
	T01MS1;
	}
	
task T01MS1{
	wait(30);
	AccelMove(objBoss,stgx,120,0.1,30);
	Dot;
	wait(60);
	RumiaLaser;
	task Dot{
	ascent(n in 0..15){
	PlaySound("Shot1",95,0);
	ascent(i in 0..24){
	ShotA1(GetEnemyX,GetEnemyY,2.5,i*15+angleToPlayer,186,15);
	}
	wait(20);
	}
	}
		task RumiaLaser{
		PlaySound("Laser2",95,30);
		let laser = CreateStraightLaserA1(GetEnemyX,GetEnemyY,20,500,30,240,7,30);
		Manage(laser,1);
		laser = CreateStraightLaserA1(GetEnemyX,GetEnemyY,160,500,30,240,7,30);
		Manage(laser,2);
			task Manage(laser,way){
			let c = 0;
			let angle = ObjStLaser_GetAngle(laser);
			wait(30);
			while(c<55){
			if(way==1){ObjStLaser_SetAngle(laser,angle+c);}
			if(way==2){ObjStLaser_SetAngle(laser,angle-c);}
			c+=0.3;
			yield;
			}
			descent(i in 0..30){
			ObjLaser_SetRenderWidth(laser,i);
			yield;
			}
			Obj_Delete(laser);
			}
		}
	wait(180);
	T01FN1;
	}
	
task T01FN1{
	let dir = 0;
	maple(2);
	wait(60);
	TMovement(35,5,3);
	ascent(n in 0..6){
	PlaySound("Shot1",95,0);
	 ascent(i in 0..2+n/2){
	  ascent(a in 0..7){
	  dir = angleToPlayer+i*4;
	  ShotA1(GetEnemyX,GetEnemyY,1.2+a/3,dir,SMALL_RED,18);
	  dir = angleToPlayer-i*4;
	  ShotA1(GetEnemyX,GetEnemyY,1.2+a/3,dir,SMALL_RED,18);
	  }
	 }
	 wait(10);
	}
	wait(45);
	TMovement(35,5,3);
	wait(45);
	PlaySound("Shot1",95,0);
	ascent(i in 0..5){
	dir = angleToPlayer-14+i*7;
	ascent(a in 0..12){
	ShotA1(GetEnemyX,GetEnemyY,1+a/6,dir,PELLET_RED,30);
	}
	}
	ascent(i in 0..30){
	ascent(a in 0..3){
	dir = i*12+a*5;
	ShotA1(GetEnemyX,GetEnemyY,1.5+a/2.5,dir,BL_SMALL_BLUE,40);
	}
	}
	wait(60);
	AccelMove(objBoss,stgx+75,100,1,1);
	wait(30);
	dir = 90;
	ascent(n in 0..30){
	PlaySound("Shot1",95,0);
	ascent(a in 0..3){
	ascent(i in 0..3){
	ShotA1(GetEnemyX,GetEnemyY,1+n/20+a/2+i/6,-10+dir-n*1.5-i*0.7,BL_SMALL_GREEN,35);
	}
	}
	yield;
	}
	ascent(n in 0..30){
	PlaySound("Shot1",95,0);
	ascent(a in 0..3){
	ascent(i in 0..3){
	ShotA1(GetEnemyX,GetEnemyY,0.7+n/20+a/2+i/6,10+dir+n*1.5+i*0.7,BL_SMALL_GREEN,35);
	}
	}
	yield;
	}
	wait(30);
	AccelMove(objBoss,stgx,150,4,1);
	wait(30);
	T01FS1;
	}
	
task T01FS1{
	attack(240);
	wait(30);
	ascent(n in 0..5){
	ascent(i in 0..12){
	PlaySound("Shot1",90,0);
	ascent(a in 0..3){
	ShotA1(GetEnemyX-13,GetEnemyY-40,0.8+a/2.5+i/10+n/5,20+i*14+5*sin(n*77),BL_SMALL_AQUA,10);
	}
	wait(2);
	}
	ascent(i in 0..12){
	PlaySound("Shot1",90,0);
	ascent(a in 0..3){
	ShotA1(GetEnemyX-13,GetEnemyY-40,0.8+a/2.5+i/10+n/5,160-i*14+5*sin(n*77),BL_SMALL_BLUE,10);
	}
	wait(2);
	}
	}
	T01FN2;
	}
	
task T01FN2{
	let dir = 0;
	maple(2);
	wait(60);
	AccelMove(objBoss,stgx-100,210,4,1);
	ascent(n in 0..5){
	PlaySound("Laser2",95,90);
	PlaySound("Shot5",95,0);
	let laser = CreateStraightLaserA1(GetEnemyX,GetEnemyY,angleToPlayer,500,20,90,7,90);
	Manage(laser);
	ascent(i in 0..7){
	dir = angleToPlayer-48+i*12;
	ascent(a in 0..12){
	PlaySound("Shot1",95,0);
	if(n==0){ShotA1(GetEnemyX,GetEnemyY,1+a/4,dir,BL_SMALL_GREEN,30);}
	}
	}
	wait(10);
	}
		task Manage(laser){
			wait(160);
			descent(i in 0..20){
			ObjLaser_SetRenderWidth(laser,i);
			yield;
			}
			}
	wait(90);
	AccelMove(objBoss,stgx+100,120,4,1);
	ascent(i in 0..30){
		PlaySound("Shot1",95,0);
	ascent(a in 0..3){
	ShotA1(GetEnemyX,GetEnemyY,0.5+i/10+a/20,90-i*2-a,BL_SMALL_GREEN,20);
	ShotA1(GetEnemyX,GetEnemyY,0.8+i/10+a/20,90-i*2-a,BL_SMALL_GREEN,20);
	ShotA1(GetEnemyX,GetEnemyY,1.1+i/10+a/20,90-i*2-a,BL_SMALL_GREEN,20);
	}
	wait(2);
	}
	T01FS2;
	}
	
task T01FS2{
	let color = [PELLET_BLUE,PELLET_GREEN,PELLET_RED];
	let spd = 0;
	let acc = 0;
	let shot;
	let dir = 0;
	ascent(m in 0..2){
	ascent(n in 0..3){
	PlaySound("Shot1",95,0);
	ascent(i in 0..20){
	ascent(a in 0..2){
	spd = 3.5+a*1.5;
	acc = -spd/40;
	dir = i*18-a*18;
	shot = ShotA2(GetEnemyX,GetEnemyY,spd,dir,acc,0,color[n],10);
	ObjMove_AddPatternA2(shot,50,0,dir+90,0.5,0,1.5);
	dir = i*18+9-a*18;
	shot = ShotA2(GetEnemyX,GetEnemyY,spd,dir,acc,0,color[n],10);
	ObjMove_AddPatternA2(shot,50,0,dir-90,0.5,0,1.5);
	}
	}
	TMovement(20,2,5);
	wait(60);
	}
	RapidAim;
	task RapidAim{
	ascent(n in 0..3){
	ascent(i in 0..15){
	PlaySound("Shot1",95,0);
	ascent(a in 0..3){
	let shot = ShotA2(GetEnemyX,GetEnemyY,2.5+a/2.5+i/10,90+i*9,-0.1,0,SMALL_BLUE,12);
	Manage(shot);
	}
	yield;
	}
	ascent(i in 0..15){
	PlaySound("Shot1",95,0);
	ascent(a in 0..3){
	let shot = ShotA2(GetEnemyX,GetEnemyY,2+a/3+i/10,90-i*9,-0.1,0,SMALL_BLUE,12);
	Manage(shot)
	}
	yield;
	}
	}
	}
	TMovement(20,4,5);
	}
	AccelMove(objBoss,stgx,150,0.05,60);
	wait(60);
	maple(3);
	wait(120);
	TLaser(0);
		task Manage(shot){
		wait(60);
		let dir = getDotAngle(GetPlayerX,GetPlayerY,ObjMove_GetX(shot),ObjMove_GetY(shot));
		ObjMove_AddPatternA1(shot,0,3.5,dir);
		}
	task TLaser(dir){
	PlaySound("Laser1",100,60);
	PlaySound("Laser5",100,0);
	ascent(i in 0..20){
	let laser = CreateStraightLaserA1(GetEnemyX,GetEnemyY,i*18,0,25,90,7,60);
	Manage2(laser);
	}
	}
		task Manage2(laser){
		ascent(i in 0..60){
		ObjLaser_SetLength(laser,i*10);
		yield;
		}
		wait(60);
		descent(i in 0..30){
		ObjLaser_SetRenderWidth(laser,i);
		yield;
		}
		}
	wait(120);
	SetPlayerLife(GetPlayerLife+1);
	PlaySound("Life",100,0);
	T02MN1;
	}
	
task T02MN1{
	let shot;
	let s =  1;
	let color = [102,95];
	AccelMove(objBoss,stgx-100,120,4,2);
	maple(2);
	wait(60);
	PlaySound("Weird2",100,0);
	AccelMove(objBoss,stgx+150,180,0.2,30);
	ascent(m in 0..2){
	ascent(n in 0..15){
	ascent(i in 0..4){
	ascent(a in 0..4){
	shot = ShotA2(GetEnemyX,GetEnemyY,4,i*90+n*10*s,0,0,color[m],10);
	ObjMove_AddPatternA2(shot,10,2.25+1*sin(a*77+m*45),NO_CHANGE,0,0,5);
	}
	}
	wait(2);
	}
	s = -s;
	}
	wait(60);
	AccelMove(objBoss,stgx+150,60,4,2);
	wait(60);
	AccelMove(objBoss,stgx-100,150,0.1,30);
	PlaySound("Weird2",100,0);
	ascent(n in 0..10){
	ascent(i in 0..11){
	ShotOA1(objBoss,3,i*24-30,111,20);
	shot = ShotA2(GetEnemyX,GetEnemyY,3.5,30+i*15+7.5,-4/90,0,106,10);
	Manage(shot);
	}
	wait(11);
	}
	AccelMove(objBoss,stgx,150,4,1);
	wait(90);
	T02FN1;
		task Manage(shot){
		wait(90);
		PlaySound("Shot5",100,0);
		ObjMove_AddPatternA1(shot,0,3.5,GetAngleToPlayer(shot));
		}
	}
	
task T02FN1{
	let dir = 0;
	let ang = 0;
	let p = 10;
	let shot;
	let color = [BL_SMALL_BLUE,SMALL_BLUE,LARGE_BLUE];
	ascent(m in 0..3){
	ang = angleToPlayer;
	PlaySound("Shot2",95,0);
	ascent(a in 0..3){
	ascent(i in 0..18){
	if(a<2){ShotOA1(objBoss,1.5+a/2+m/4,i*20+a*12,color[m],20);}
	}
	ascent(i in 0..2+a){
	dir = ang-i*p;
	ShotOA1(objBoss,2.85-a+m/6,dir,106,10);
	dir = ang+i*p;
	ShotOA1(objBoss,2.85-a+m/6,dir,106,10);
	}
	ascent(i in 0..1+a){
	dir = ang-i*p-p/2;
	ShotOA1(objBoss,3.35-a+m/6,dir,106,10);
	dir = ang+i*p+p/2;
	ShotOA1(objBoss,3.35-a+m/6,dir,106,10);
	}
	}
	wait(30);
	TMovement(20,5,5);
	wait(30);
	p +=6;
	}
	wait(30);
	TMovement(35,5,5);
	wait(30);
	ascent(n in 0..6){
	PlaySound("Shot1",95,0);
	 ascent(i in 0..24){
	  ascent(a in 0..2){
	  ShotOA1(objBoss,2+a/2,i*15,BL_SMALL_BLUE,20);
	  }
	  if(n%2==0){
	  shot = ShotA2(GetEnemyX,GetEnemyY,4,i*15+8,-0.05,1,PELLET_GRAY,20);
	  Manage(shot);
	  }
	 }
	 if(n%2==0){wait(30);
	 TMovement(35,5,5);
	 wait(30);
	 }
	 else{
	 wait(15);
	 TMovement(35,5,5);
	 wait(15);
	 }
	}
		task Manage(shot){
		wait(90);
		PlaySound("BulletWave",95,0);
		ObjMove_AddPatternA1(shot,0,3,GetAngleToPlayer(shot));
		}
	T02FS1;
	}
	
task T02FS1{
	let dir = 0;
	let dir2 = 0;
	let spd = 0;
	let acc = 0;
	let shot;
	attack(180);
	maple(2);
	wait(60);
	ascent(n in 0..8){
	 PlaySound("Shot5",95,0);
	 PlaySound("BulletWave",90,70);
	 ascent(i in 0..7){
	 dir = i*360/7+n*13;
	 dir2 = n*27;
	  ascent(a in 0..3){
	  spd = 3+a;
	  acc = -spd/60;
	  shot = ShotA2(GetEnemyX-13,GetEnemyY-40,spd,dir,acc,0,111,5);
	  Manage(shot,dir2);
	  }
	 dir = i*360/7-n*13+180;
	 dir2 = 180-n*27;
	  ascent(a in 0..3){
	  spd = 3+a;
	  acc = -spd/60;
	  shot = ShotA2(GetEnemyX-13,GetEnemyY-40,spd,dir,acc,0,111,5);
	  Manage(shot,dir2);
	  }
	 }
	 wait(15);
	}
		task Manage(shot,dir){
		wait(70);
		ObjMove_AddPatternA1(shot,0,1.5,dir);
		}
		wait(60);
		T02FN2;
	}
	
task T02FN2{
	maple(1);
	wait(120);
	ascent(n in 0..10){
     PlaySound("Shot1",93,0);
	 ascent(i in 0..15){
	  ascent(a in 0..2){
	   ShotOA1(objBoss,2+a*1.5,i*24+angleToPlayer,BL_SMALL_BLUE,25);
	  }
	 }
	 ascent(i in 0..10){
	 ShotOA1(objBoss,1.5,i*36+angleToPlayer+20,DOT_BLUE,15);
	 }
	 if(n%3==0){TMovement(25,5,3);}
	wait(15);
	}
	ascent(n in 0..3){
	PlaySound("Laser2",100,0);
	ascent(i in 0..3){
	CreateLooseLaserA1(GetEnemyX,GetEnemyY,4,angleToPlayer-30+i*30,150,7,16,20);
	}
	ascent(i in 0..24){
	ShotOA1(objBoss,2,i*15,BL_SMALL_AQUA,20);
	ShotOA1(objBoss,3.5,i*15+8,BL_SMALL_AQUA,20);
	}
	TMovement(25,5,3);
	wait(50);
	}
	wait(30);
	T02FS2;
	}
	
task T02FS2{
	let shot;
	let dir = 0;
	let ang = 0;
	let p = 10;
	let freeze = false;
	AccelMove(objBoss,stgx+rand(-100,100),120,3,2);
	ascent(i in 0..120){
	PlaySound("Shot1",90,0);
	loop(2){
	shot = ShotOA1(objBoss,rand(1,4),rand(0,359),48+i%13,15);
	Manage(shot);
	}
	yield;
	}
	maple(2);
	wait(60);
	freeze = true;
	Spam;
		task Manage(shot){
		let t = 0;
		while(freeze==false){yield;}
		ObjMove_SetSpeed(shot,0);
		ObjShot_SetGraphic(shot,48);
		wait(120);
		ObjMove_AddPatternA2(shot,0,0,rand(0,359),0.01,0,rand(1,1.5));
		}
		task Spam{
		let angle = 0;
		let r = 0;
		let spd = 0;
		let acc = 0;
		let dir = 0;
		ascent(n in 0..12){
		PlaySound("Shot1",95,0);
		r = rand(0,120);
		angle = rand(0,359);
		ascent(i in 0..12){
		spd = rand(5,8);
		acc = -spd/15;
		dir = i*30+n*17;
		ShotA2(GetEnemyX+r*cos(angle),GetEnemyY+r*sin(angle),spd,dir,acc,rand(1,3.5),113,12);
		}
		if(n%4==0){TMovement(25,5,3);}
		wait(10);
		}
		}
	wait(120);
	AccelMove(objBoss,stgx,150,2,2);
	wait(90);
	maple(2);
	wait(60);
	PlaySound("Shot1",95,0);
	ascent(m in 0..8){
	ang = m*45;
	ascent(a in -1..3){
	ascent(i in 0..2+a){
	dir = ang-i*p;
	ShotOA1(objBoss,2.5-a+m/6,dir,106,10);
	dir = ang+i*p;
	ShotOA1(objBoss,2.5-a+m/6,dir,106,10);
	}
	ascent(i in 0..1+a){
	dir = ang-i*p-p/2;
	ShotOA1(objBoss,3-a+m/6,dir,106,10);
	dir = ang+i*p+p/2;
	ShotOA1(objBoss,3-a+m/6,dir,106,10);
	}
	p +=2;
	}
	}
	wait(45);
	SetPlayerLife(GetPlayerLife+1);
	PlaySound("Life",100,0);
	wait(45);
	T03MN1;
	}
	
task T03MN1{
	ascent(n in 0..30){
	PlaySound("Shot1",90,0);
	ascent(i in 0..6){
	ShotOA1(objBoss,rand(1,2.5),rand(0,359),SMALL_BLUE,20);
	}
	if(n%5==0){TMovement(5,5,1);}
	wait(3);
	}
	wait(30);
	AccelMove(objBoss,stgx+120,100,1,2);
	ascent(n in 0..2){
	PlaySound("Shot1",95,0);
	 ascent(i in 0..24){
	  ascent(a in 0..2){
	   ShotA1(GetEnemyX+30*cos(i*15),GetEnemyY+30*sin(i*15),2+a/2,i*15,PELLET_RED,25);
	  }
	 }
	wait(30);
	}
	wait(30);
	AccelMove(objBoss,stgx-80,150,0.5,5);
	PlaySound("BulletWave",95,0);
	ascent(i in 0..48){
	ShotOA1(objBoss,1.5,i*7.5,BL_SMALL_RED,30);
	}
	ascent(n in 0..3){
	PlaySound("Shot1",95,0);
	 ascent(i in 0..24){
	  ascent(a in 0..2){
	   ShotA1(GetEnemyX+30*cos(i*15),GetEnemyY+30*sin(i*15),2+a/2,i*15,PELLET_RED,25);
	  }
	 }
	wait(30);
	}
	PlaySound("BulletWave",95,0);
	ascent(i in 0..48){
	ShotOA1(objBoss,1.5,i*7.5,BL_SMALL_RED,30);
	}
	wait(30);
	AccelMove(objBoss,stgx+80,170,0.2,10);
	ascent(n in 0..40){
	PlaySound("Shot1",90,0);
	ascent(i in 0..6){
	ShotOA1(objBoss,rand(1,2.5),rand(0,359),SMALL_BLUE,20);
	}
	if(n%10==0){TMovement(5,5,1);}
	wait(2);
	}
	wait(30);
	AccelMove(objBoss,stgx,150,0.1,30);
	T03MS1;
	}
	
task T03MS1{
	let dir = 0;
	let spd = 0;
	let acc = 0;
	let shot;
	maple(2);
	wait(60);
	attack(180);
	ascent(n in 0..30){
	PlaySound("Shot1",95,0);
	ascent(i in 0..6){
	dir = i*60+n*9;
	spd = 4;
	acc = -4/80;
	shot = ShotA2(GetEnemyX-13,GetEnemyY-40,spd,dir,acc,0.5,PELLET_YELLOW,20);
	ObjMove_AddPatternA2(shot,80,2,dir+150,-2/60,0,0);
	ObjMove_AddPatternA2(shot,140,2,dir-50,0,0,2);
	dir = i*60-n*9+30;
	shot = ShotA2(GetEnemyX-13,GetEnemyY-40,spd,dir,acc,0.5,PELLET_YELLOW,20);
	ObjMove_AddPatternA2(shot,80,2,dir-150,-2/60,0,0);
	ObjMove_AddPatternA2(shot,140,2,dir+50,0,0,2);
	}
	if(n%15==14){
	ascent(i in 0..36){
	ShotOA1(objBoss,1.25,i*10,PELLET_RED,20);
	ShotOA1(objBoss,1.35,i*10,PELLET_RED,20);
	}
	}
	wait(6);
	}
	wait(120);
	T03FN1;
	}
	
task T03FN1{
	ascent(n in 0..30){
	PlaySound("Shot1",95,0);
	ascent(i in 0..10){
	ShotOA1(objBoss,2+n/15,i*36+n*7,PELLET_RED,20);
	}
	wait(4);
	}
	AccelMove(objBoss,stgx-100,100,1,2);
	PlaySound("BulletWave",95,0);
	ascent(n in 30..40){
	PlaySound("Shot1",95,0);
	ascent(i in 0..10){
	ShotOA1(objBoss,2+n/15,i*36+36*sin(n*27),PELLET_RED,20);
	}
	wait(4);
	}
	wait(60);
	ascent(n in 0..30){
	PlaySound("Shot1",95,0);
	ascent(i in 0..10){
	ShotOA1(objBoss,2+n/15,i*36-n*7,PELLET_RED,20);
	}
	wait(4);
	}
	AccelMove(objBoss,stgx,120,1,2);
	PlaySound("BulletWave",95,0);
	ascent(n in 30..40){
	PlaySound("Shot1",95,0);
	ascent(i in 0..10){
	ShotOA1(objBoss,2+n/15,i*36-36*sin(n*27),PELLET_RED,20);
	}
	wait(4);
	}
	T03FS1;
	}
	
task T03FS1{
	let s = 1;
	AccelMove(objBoss,stgx,120,1,2);
	let color = [PELLET_PURPLE,PELLET_BLUE,PELLET_AQUA,PELLET_GREEN,PELLET_YELLOW,PELLET_ORANGE,PELLET_RED];
	maple(2);
	wait(60);
	ascent(n in 0..52){
	ascent(i in 0..7){
	ShotOA1(objBoss,2.6,i*9+n*10*s+30,color[i],18); // colorful
	if(i<6){ShotOA1(objBoss,2.3,i*360/6+n*10*s,color[i],18);
	ShotOA1(objBoss,2.6,i*360/6-n*10*s,color[2],18);
	ShotOA1(objBoss,2.1,i*360/6-n*10*s,color[2],18);}
	}
	ascent(i in 0..4){
	ShotOA1(objBoss,2.6,i*10+n*13*s+210,color[i*2],18);
	}
	if(n==30){s=-s;}
	wait(8);
	}
	AccelMove(objBoss,stgx,150,1,2);
	wait(60);
	T03FN2;
	}
	
task T03FN2{
	let enemy;
	descent(i in 0..3){
	enemy = fam(stgx+i*60+40,0,200,1);
	Control(enemy,stgx+i*60+40,70+i*15);
	enemy = fam(stgx-i*60-40,0,200,1);
	Control(enemy,stgx-i*60-40,70+i*15);
	wait(30);
	}
	wait(30);
	AccelMove(objBoss,stgx-50,210,1,3);
	PlaySound("BulletWave",95,0);
	wait(30);
	PlaySound("Shot1",95,0);
	ascent(i in 0..24){
	ShotOA1(objBoss,rand(2,4),i*15,SMALL_BLUE,22);
	}
	wait(60);
	AccelMove(objBoss,stgx+50,150,1,3);
	PlaySound("BulletWave",95,0);
	wait(30);
	PlaySound("Shot1",95,0);
	ascent(i in 0..24){
	ShotOA1(objBoss,rand(2,4),i*15,SMALL_BLUE,22);
	}
	wait(90);
	ascent(i in 0..24){
	ShotOA1(objBoss,rand(2,4),i*15,SMALL_BLUE,22);
	}
	task Control(obj,i,j){
		let dir;
		AccelMove(obj,i,j,1,2);
		ascent(n in 0..2){
		wait(90);
		dir = GetAngleToPlayer(obj);
		ascent(n in 0..20){
		PlaySound("Shot1",95,0);
		ascent(i in 0..3){
		ShotOA1(obj,2+n/5,dir-40+i*40,98,18);
		}
		if(n%20==0){
		ascent(i in 0..18){
		ShotOA1(obj,2,i*20,SMALL_BLUE,20);
		}
		}
		wait(3);
		}
		wait(30);
		}
		wait(60);
		ObjEnemy_SetLife(obj,0);
		}
		wait(90);
		AccelMove(objBoss,stgx,150,1,3);
		T03FS2;
	}
	
task T03FS2{
	maple(2);
	wait(60);
	let angle = 0;
	let r = 0;
	ascent(n in 0..40){
	PlaySound("Shot1",92,0);
	ascent(i in 0..5){
	angle = i*72+30*sin(n*10);
	ShotA1(GetEnemyX+r*cos(angle),GetEnemyY+r*sin(angle),rand(1.5,4),rand(0,359),SMALL_BLUE,25);
	}
	r = 50+50*sin(n*47);
	wait(3);
	}
	PlaySound("BulletWave",95,0);
	TMovement(35,5,5);
	wait(30);
	ascent(n in 0..50){
	PlaySound("Shot1",92,0);
	ascent(i in 0..5){
	angle = i*72+30*sin(n*10);
	ShotA1(GetEnemyX+r*cos(angle),GetEnemyY+r*sin(angle),rand(1.5,4),rand(0,359),SMALL_BLUE,25);
	}
	r = 60+60*sin(n*43);
	wait(3);
	}
	AccelMove(objBoss,stgx,180,0.5,5);
	wait(60);
	T03FN3;
	}
	
task T03FN3{
	let shot;
	let spd = 0;
	let acc = 0;
	PlaySound("Shot2",95,0);
	ascent(i in 0..30){
	descent(a in 0..6){
	spd = 2+a/2;
	acc = -spd/70;
	let shot = ShotA2(GetEnemyX,GetEnemyY,spd,i*12,acc,0.1,KUNAI_BLUE	,10);
	ObjMove_AddPatternA1(shot,70,4,i*12+200);
	}
	}
	TMovement(20,5,5);
	wait(90);
	PlaySound("Shot2",95,0);
	ascent(i in 0..30){
	descent(a in 0..6){
	spd = 2+a/2;
	acc = -spd/70;
	let shot = ShotA2(GetEnemyX,GetEnemyY,spd,i*12,acc,0.1,KUNAI_RED,10);
	ObjMove_AddPatternA1(shot,70,4,i*12+160-a/2);
	}
	}
	attack(120);
	wait(60);
	Falling;
	task Falling{
		let dir = 0;
		ascent(i in 0..90){
		PlaySound("Shot1",95,0);
		dir = i*77;
		shot = ShotA2(GetEnemyX-13,GetEnemyY-40,4,dir,0,0,PELLET_BLUE,20);
		ObjMove_AddPatternA2(shot,rand(7,15),0,NO_CHANGE,0.02,rand(-0.5,0.5),5);
		yield;
		}
		}
	wait(120);
	AccelMove(objBoss,stgx,150,1,3);
	T03FS3;
	}
	
task T03FS3{
	let x = 0;
	let y = 0;
	let dir = 0;
	let color = [PELLET_GREEN,PELLET_YELLOW,PELLET_PURPLE,PELLET_AQUA];
	let shot;
	maple(2);
	wait(60);
	ascent(n in 0..45){
	PlaySound("Shot1",95,0);
	ascent(i in 0..4){
	dir = i*90+n*10;
	x = GetEnemyX+0*cos(dir);
	y = GetEnemyY+0*sin(dir);
	CreateShotB2(x,y,2*cos(dir),2*sin(dir),0,0.02,0,4,color[i],15);
	}
	yield;
	}
	wait(30);
	PlaySound("BulletWave",95,0);
	AccelMove(objBoss,stgx+120,180,1,4);
	wait(30);
		ascent(i in 0..45){
		PlaySound("Shot1",95,0);
		dir = i*77;
		shot = ShotA2(GetEnemyX,GetEnemyY,4,dir,0,0,PELLET_YELLOW,20);
		ObjMove_AddPatternA2(shot,rand(5,20),0,NO_CHANGE,0.02,rand(-0.3,-0.1),5);
		shot = ShotA2(GetEnemyX,GetEnemyY,4,dir,0,0,PELLET_ORANGE,20);
		ObjMove_AddPatternA2(shot,rand(5,20),0,NO_CHANGE,0.02,rand(0.1,0.3),5);
		wait(2);
		}
	wait(30);
	PlaySound("BulletWave",95,0);
	AccelMove(objBoss,stgx-120,90,0.75,4);
	wait(15);
	ascent(n in 0..60){
	PlaySound("Shot1",95,0);
	ascent(i in 0..4){
	dir = i*90+n*12;
	x = GetEnemyX+0*cos(dir);
	y = GetEnemyY+0*sin(dir);
	CreateShotB2(x,y,2*cos(dir),2*sin(dir),0,0.01,0,4,color[i],15);
	}
	yield;
	}
	wait(30);
	AccelMove(objBoss,stgx,120,1,3);
	T03FS4;
	}
	
task T03FS4{
	let shot;
	let dir = 0;
	let color = [PELLET_PURPLE,PELLET_BLUE,PELLET_AQUA,PELLET_GREEN,PELLET_YELLOW,PELLET_ORANGE,PELLET_RED];
	attack(180);
	wait(30);
		ascent(i in 0..60){
		PlaySound("Shot1",90,0);
		dir = rand(0,359);
		shot = ShotA2(GetEnemyX-13,GetEnemyY-40,5,dir,-0.1,0,PELLET_YELLOW,10);
		ObjMove_AddPatternA2(shot,rand(5,20),0,NO_CHANGE,0.02,rand(-0.3,-0.1),5);
		dir = rand(0,359);
		shot = ShotA2(GetEnemyX-13,GetEnemyY-40,5,dir,-0.1,0,PELLET_ORANGE,10);
		ObjMove_AddPatternA2(shot,rand(5,20),0,NO_CHANGE,0.02,rand(0.1,0.3),5);
		dir = rand(0,359);
		shot = ShotA2(GetEnemyX-13,GetEnemyY-40,5,dir,-0.1,0,PELLET_AQUA,10);
		ObjMove_AddPatternA2(shot,rand(5,20),0,NO_CHANGE,0.02,rand(-0.15,-0.15),5);
		dir = rand(0,359);
		shot = ShotA2(GetEnemyX-13,GetEnemyY-40,5,dir,-0.1,0,PELLET_PURPLE,10);
		ObjMove_AddPatternA2(shot,rand(5,20),0,NO_CHANGE,0.02,rand(-0.15,0.15),5);
		wait(3);
		}
	AccelMove(objBoss,stgx,160,0.5,3);
	wait(30);
	maple(2);
	wait(60);
	PlaySound("BulletWave",95,0);
	ascent(i in 0..24){
	ascent(a in 0..7){
	ShotOA1(objBoss,0.75+a/2.5,i*15+a*4.7,color[a],20);
	ShotOA1(objBoss,0.75+a/2.5,i*15-a*4.7,color[a],20);
	}
	}
	wait(45);
	SetPlayerLife(GetPlayerLife+1);
	PlaySound("Life",100,0);
	wait(45);
	T04MN1;
	}
	
task T04MN1{
	let r = 0;
	let angle = 0;
	ascent(n in 0..7){
	PlaySound("Shot1",95,0);
	ascent(i in 0..8){
	ShotA2(GetEnemyX,GetEnemyY,1.25,i*45+n*11,0.01,3,BUBBLE_BLUE,12);
	}
	wait(22);
	}
	AccelMove(objBoss,stgx-80,180,1,3);
	Ring(0);
	wait(60);
	AccelMove(objBoss,stgx-80,120,1,3);
	wait(60);
	ascent(n in 0..7){
	PlaySound("Shot1",95,0);
	ascent(i in 0..8){
	ShotA2(GetEnemyX,GetEnemyY,1.25,i*45-n*11-22,0.01,3,BUBBLE_BLUE,12);
	}
	wait(22);
	}
	Ring(0);
	AccelMove(objBoss,stgx+100,150,0.5,5);
	wait(45);
	wait(45);
	task Ring(type){
		ascent(n in 0..18){
		r = rand(0,60);
		angle = rand(0,359);
		 PlaySound("Shot1",95,0);
	     ascent(i in 0..15){
		 if(type==0){ShotA1(GetEnemyX+r*cos(angle),GetEnemyY+r*sin(angle),2,i*24+n*9,KUNAI_BLUE,10);}
		 //else{ShotA1(GetEnemyX+r*cos(angle),GetEnemyY+r*sin(angle),2,i*24+n*9,KUNAI_BLUE,10);}
		 }
		 wait(7);
		}
		}
	AccelMove(objBoss,stgx,150,1,3);
	T04FS1;
	}
	
task T04FS1{ // AQUA AND ORANGE
	let dir = 0;
	let shot;
	let v = 0;
	let acc = 0;
	let angle = 0;
	wait(60);
	CyClone;
	ascent(i in 0..4){
	angle = i*90+60;
	NDLaser(GetEnemyX+60*cos(angle),GetEnemyY+60*sin(angle),0.4,angle,150,30,-1,1);
	}
	wait(90);
	ascent(i in 0..4){
	angle = i*90+30;
	NDLaser(GetEnemyX+60*cos(angle),GetEnemyY+60*sin(angle),0.4,angle,160,30,1,0);
	}
	task CyClone{
	ascent(n in 0..5){
	PlaySound("Shot1",95,0);
	PlaySound("Shot1",95,25);
	ascent(i in 0..20){
	ascent(a in 0..2){
	v = 1+a/2;
	acc= -v/600;
	shot = ShotA2(GetEnemyX,GetEnemyY,v,i*18+n*11+a*7,acc,0.5,71,12);
	ObjMove_AddPatternA2(shot,60,v,NO_CHANGE,0.0025+a/400,0.4+a/100,5);
	}
	}
	wait(25);
	ascent(i in 0..20){
	ascent(a in 0..2){
	v = 1+a/2;
	acc= -v/600;
	shot = ShotA2(GetEnemyX,GetEnemyY,v,i*18+n*11-a*7,acc,0.5,77,12);
	ObjMove_AddPatternA2(shot,60,v,NO_CHANGE,0.0025+a/400,-0.4+a/100,5);
	}
	}
	wait(25);
	}
	}
	wait(150);
	T04FS2;
	}
	
task T04FS2{ // CURVYFIREBALL
	let y = 0;
	let dir = 0;
	let v = 0;
	let x = 0;
	let angle = 0;
	let shot;
	TMovement(35,5,5);
	wait(60);
	maple(2);
	wait(60);
	FireBall;
	ascent(i in 0..4){
	angle = i*90+30;
	NDLaser(GetEnemyX+60*cos(angle),GetEnemyY+60*sin(angle),0.4,angle,150,30,1,1);
	}
	wait(60);
	ascent(i in 0..4){
	angle = i*90+60;
	NDLaser(GetEnemyX+60*cos(angle),GetEnemyY+60*sin(angle),0.4,angle,150,30,-1,0);
	}
	wait(180);
		task FireBall{
		let ball;
		let spd = 0;
		wait(60);
		attack(100);
		maple(2);
		wait(60);
		ascent(n in 0..5){
		PlaySound("BulletWave",95,0);
		spd = rand(2,2.25);
		ascent(i in 0..10){
		ascent(a in 0..2){
		ball = ShotA2(GetEnemyX-13,GetEnemyY-40,spd-a,i*36+spd*40*sin(n*77+a*180),0,0,288,12);
		ObjMove_AddPatternA2(ball,0,NO_CHANGE,NO_CHANGE,0,1.5,0);
		ObjMove_AddPatternA2(ball,120,NO_CHANGE,NO_CHANGE,0,0.5,0);
		ObjMove_AddPatternA2(ball,150,spd-a*0.5,NO_CHANGE,0,0,0);
		ball = ShotA2(GetEnemyX-13,GetEnemyY-40,spd-a,i*36-spd*35*sin(n*77+a*180),0,0,288,12);
		ObjMove_AddPatternA2(ball,0,NO_CHANGE,NO_CHANGE,0,-1.5,0);
		ObjMove_AddPatternA2(ball,120,NO_CHANGE,NO_CHANGE,0,-0.5,0);
		ObjMove_AddPatternA2(ball,150,spd-a*0.5,NO_CHANGE,0,0,0);
		ShotA2(GetEnemyX-13,GetEnemyY-40,rand(1,2)+a,i*36+n*29,0,0,288,18);
		}
		}
		wait(9);
		}
		}
	AccelMove(objBoss,stgx,170,1,4);
	wait(30);
	T04FS3;
	}
	
task T04FS3{ // BLUE LASER
	let angle = 0;
	ascent(i in 0..4){
	angle = i*90+60;
	NDLaser(GetEnemyX+60*cos(angle),GetEnemyY+60*sin(angle),0.3,angle,150,30,-1,1);
	}
	wait(60);
	ascent(i in 0..4){
	angle = i*90+30;
	NDLaser(GetEnemyX+60*cos(angle),GetEnemyY+60*sin(angle),0.3,angle,150,30,1,0);
	}
	let dir = 0;
	maple(2);
	attack(150);
	AccelMove(objBoss,stgx+rand(-20,20),170,1,4);
	wait(60);
	ascent(n in 0..13){
	PlaySound("Laser3",95,0);
	dir = angleToPlayer+45-n*3;
	CreateStraightLaserA1(GetEnemyX-13,GetEnemyY-40,dir,400,15,60,7,20);
	dir = angleToPlayer-45+n*3;
	CreateStraightLaserA1(GetEnemyX-13,GetEnemyY-40,dir,400,15,60,7,20);
	wait(8);
 	 if(n%2==0){
	  ascent(i in 0..20){
	  ascent(a in 0..2){
	   ShotOA1(objBoss,2+a,i*20+20*sin(n*44),SMALL_BLUE,20);
	  }
	  }
	 }
	}
	wait(30);
	AccelMove(objBoss,stgx+rand(-20,20),120,0.5,5);
	ascent(n in 0..8){
	ascent(i in 0..10){
	PlaySound("Shot1",95,0);
	ShotOA1(objBoss,2.75,i*20+angleToPlayer-100,BUBBLE_BLUE,15);
	}
	wait(14);
	}
	AccelMove(objBoss,stgx,120,0.5,5);
	wait(30);
	T04FS4;
	}
	
task T04FS4{ // YELLOW RAIN FROM LEFT & RIGHT
	let y = 0;
	let x = 0;
	let dir = 0;
	let v = 0;
	let shot;
	let angle = 0;
	ascent(i in 0..4){
	angle = i*90+60;
	NDLaser(GetEnemyX+60*cos(angle),GetEnemyY+60*sin(angle),0.4,angle,150,30,-1,0);
	}
	ascent(i in 0..4){
	angle = i*90+30;
	NDLaser(GetEnemyX+60*cos(angle),GetEnemyY+60*sin(angle),0.4,angle,150,30,1,0);
	}
	wait(60);
	ascent(i in 0..20){
	PlaySound("Shot1",95,0);
	PlaySound("Shot1",95,3);
	PlaySound("Shot1",95,6);
	v = rand(4,5);
	y = stgy+rand(-300,150);
	x = rand(0,10);
	dir = rand(35,45);
	shot = ShotA2(x,y,v,dir,-0.1,1,PELLET_GREEN,18);
	ObjMove_AddPatternA2(shot,60,1,NO_CHANGE,0.01,rand(-0.1,0.1),3);
	x = rand(406,416);
	dir = rand(135,145);
	wait(3);
	shot = ShotA2(x,y,v,dir,-0.1,1,PELLET_GREEN,18);
	ObjMove_AddPatternA2(shot,60,1,NO_CHANGE,0.01,rand(-0.1,0.1),3);
	wait(3);
	ascent(j in 0..6){
	x =GetEnemyX+60*cos(j*60+i*37);
	y = GetEnemyY+60*sin(j*60+i*37);
	dir = j*60+i*37;
	shot = ShotA2(x,y,v,dir,-0.1,1,PELLET_GREEN,18);
	ObjMove_AddPatternA2(shot,60,1,NO_CHANGE,0.01,rand(-0.1,0.1),3);
	}
	wait(3);
	}
	T04FS5;
}

task T04FS5{ // OUTER YELLOW&GREEN && YELLOW&GREEN BUBBLE 
	let dir = 0;
	let v = 0;
	let acc = 0;
	let x = 0;
	let y = 0;
	let shot;
	AccelMove(objBoss,stgx+rand(-20,20),120,0.5,5);
	wait(60);
	ascent(n in 0..15){
	PlaySound("Shot1",95,0);
	ascent(i in 0..16){
	v = rand(2,3);
	acc = -v/90;
	dir = i*12+12*sin(n*77);
	shot = ShotA2(GetEnemyX,GetEnemyY,v,dir,acc,0,BL_SMALL_YELLOW,12);
	ObjMove_AddPatternA2(shot,80,0,dir+45*sin(n*33),0.05,0,v-0.5);
	}
	ascent(i in 0..7){
	if(n%3==0){ShotOA1(objBoss,2.75,i*360/7+angleToPlayer,BUBBLE_YELLOW,12);}
	}
	wait(15);
	}
	wait(30);
	TMovement(35,5,0);
	wait(30);
	ascent(n in 0..12){
	PlaySound("Shot1",95,0);
	x = stgx+rand(-200,200);
	y = rand(50,150);
	 ascent(i in 0..3){
	 dir = 60+i*30+30*sin(n*37);
	 ShotA1(x,y,2,dir,BUBBLE_GREEN,18);
	 }
	 dir = rand(0,30);
	 ascent(i in 0..12){
	 dir += i*30;
	 ShotA1(x,y,rand(1,3),dir,BL_SMALL_GREEN,12);
	 }
	 wait(17);
	}
	wait(30);
	TMovement(35,5,0);
	wait(30);
	ascent(m in 0..4){
	 ascent(n in 0..2){
	  PlaySound("Shot1",95,0);
	  ascent(i in 0..18){
	   ascent(a in 0..2){
	   if(n==0){ShotOA1(objBoss,2+a,i*20+n*13+m*9,SMALL_GREEN,12);}
	    if(n==1){ShotOA1(objBoss,2+a,i*20+n*13+m*9,SMALL_AQUA,12);}
	   }
	  }
	  wait(10);
	 }
	  PlaySound("Shot1",95,0);
	  ascent(i in 0..11){
	  ShotOA1(objBoss,1.7,i*18-90+angleToPlayer,BUBBLE_YELLOW,12);
	  ShotOA1(objBoss,1.9,i*18-90+angleToPlayer,BUBBLE_YELLOW,12);
	  }
	  wait(30);
	  TMovement(25,5,5);
	}
	AccelMove(objBoss,stgx,150,1,4);
	wait(90);
	T04FS6
	}
	
task T04FS6{ // RED BUBBLE
	let angle = 0;
	let shot;
	ascent(i in 0..4){
	angle = i*90+60;
	NDLaser(GetEnemyX+60*cos(angle),GetEnemyY+60*sin(angle),0.4,angle,120,30,-1,1);
	}
	NDShot;
	wait(90);
	ascent(i in 0..4){
	angle = i*90+30;
	NDLaser(GetEnemyX+60*cos(angle),GetEnemyY+60*sin(angle),0.4,angle,120,30,1,1);
	}
	NDShot;
	wait(60);
	AccelMove(objBoss,stgx+100,150,0.2,10);
	wait(60);
	BUBBLE;
	task BUBBLE{
	AccelMove(objBoss,stgx-100,100,0.1,20);
	ascent(n in 0..6){
	PlaySound("Shot1",95,0);
	ascent(i in 0..10){
	ShotOA1(objBoss,2+1*sin(i*57),i*36+270*sin(n*66),BUBBLE_RED,12);
	 ascent(a in 0..3){
	 ShotOA1(objBoss,1.5+a/2,i*36,SMALL_RED,10);
	 }
	}
	wait(20);
	}
	}
	wait(120);
	T04FS7;
	}

task T04FS7{ // WHITE
	let shot;
	let v = 0;
	let dir = 0;
	let acc = 0;
	AccelMove(objBoss,stgx-100,200,2,2);
	wait(60);
	maple(2);
	wait(60);
	AccelMove(objBoss,stgx+100,80,0.1,60);
	ascent(n in 0..5){
	PlaySound("Shot1",95,0);
	ascent(i in 0..9){
	ascent(a in 0..3){
	v= 1.95+a*1.95;
	acc = -v/60;
	dir = i*40+n*14;
	shot = ShotA2(GetEnemyX,GetEnemyY,v,dir,acc,0,SMALL_GRAY,12);
	ObjMove_AddPatternA1(shot,60,2+0.5*sin(n*67+180)+rand(-0.1,0.1),90);
	}
	}
	wait(20);
	}
	wait(60);
	T04FS8;
	}
	
task T04FS8{ // END ATTACK
	let shot;
	let angle = 0;
	AccelMove(objBoss,stgx,120,0.1,10);
	maple(2);
	wait(60);
	ascent(i in 0..4){
	angle = i*90+30;
	NDLaser(GetEnemyX+60*cos(angle),GetEnemyY+60*sin(angle),0.3,angle,150,30,1,0);
	}
	NDShot2;
	wait(90);
	NDShot2;
	ascent(i in 0..4){
	angle = i*90+60;
	NDLaser(GetEnemyX+60*cos(angle),GetEnemyY+60*sin(angle),0.3,angle,150,30,-1,0);
	}
	wait(90);
	maple(2);
	wait(60);
	ascent(i in 0..10){
	angle = i*36;
	NDLaser(GetEnemyX+60*cos(angle),GetEnemyY+60*sin(angle),0.12,angle,120,60,1,0);
	NDLaser(GetEnemyX+60*cos(angle),GetEnemyY+60*sin(angle),0.12,angle,120,60,-1,0);
	}
	NDShot;
	NDShot2;
	wait(60);
	ascent(i in 0..36){
	ascent(a in 0..4){
	ShotOA1(objBoss,1+a/2,i*10,SMALL_RED,12);
	}
	}
	wait(30);
	SetPlayerLife(GetPlayerLife+1);
	PlaySound("Life",100,0);
	wait(30);
	T05MN1;
	}
	
task T05MN1{
	let dir = 0;
	AccelMove(objBoss,stgx,120,0.5,5);
	wait(60);
	ascent(n in 0..10){
	PlaySound("Shot1",95,0);
	ascent(i in 0..8){
	dir = i*14+n*16-45;
	ShotOA1(objBoss,3.5,dir,KNIFE_BLUE,10);
	}
	wait(8);
	}
	ascent(n in 0..10){
	PlaySound("Shot1",95,0);
	ascent(i in 0..5){
	ascent(a in 0..3){
	dir = 225-i*2.5-n*25;
	ShotOA1(objBoss,1.25+a/2.5,dir,KUNAI_RED,8);
	}
	}
	wait(4);
	}
	TMovement(25,5,5);
	wait(30);
	descent(n in 0..10){
	PlaySound("Shot1",95,0);
	ascent(i in 0..8){
	dir = i*14+n*16-45;
	ShotOA1(objBoss,3.5,dir,KNIFE_BLUE,10);
	}
	wait(8);
	}
	descent(n in 0..10){
	PlaySound("Shot1",95,0);
	ascent(i in 0..5){
	ascent(a in 0..3){
	dir = 225-i*2.5-n*25;
	ShotOA1(objBoss,1.25+a/2.5,dir,KUNAI_RED,8);
	}
	}
	wait(4);
	}
	ascent(n in 0..10){
	PlaySound("Shot1",95,0);
	ascent(i in 0..8){
	dir = i*14+n*16-45;
	ShotOA1(objBoss,3.5,dir,KNIFE_BLUE,10);
	}
	wait(8);
	}
	AccelMove(objBoss,stgx,140,0.5,5);
	wait(60);
	T05MS1;
	}
	
task T05MS1{
	let shot;
	AccelMove(objBoss,stgx+100,140,0.25,5);
	KunaiWall;
	wait(90);
	maple(2);
	wait(60);
	ObjMove_SetPosition(objBoss,stgx-100,120);
	AimKnife;
	wait(120);
	TMovement(35,5,4);
	wait(30);
	maple(2);
	wait(60);
	ObjMove_SetPosition(objBoss,stgx,140);
	wait(10);
	AccelMove(objBoss,stgx-100,140,0.25,5);
	KunaiWall;
	wait(90);
	maple(2);
	wait(60);
	ObjMove_SetPosition(objBoss,stgx+100,120);
	AimKnife;
		task Manage(obj,dir){
		let x = 0;
		let y = 0;
		let t = 0;
		while(!Obj_IsDeleted(obj)){
		x = ObjMove_GetX(obj);
		y = ObjMove_GetY(obj);
		if(x<0 || x>stgx*2 && t==0){
		ObjMove_SetAngle(obj,180-dir);
		t = 1;
		}
		if(y<0 && t==0){ObjMove_SetAngle(obj,-dir); t =1;}
		yield;
		}
		}
				task KunaiWall{
		ascent(n in 0..10){
		PlaySound("Shot1",95,0);
		ascent(i in 0..10){
		ascent(a in 0..2){
		shot = ShotOA1(objBoss,1.25+a*0.75,i*36+angleToPlayer,KUNAI_RED,20);
		Manage(shot,i*36+angleToPlayer);
		}
		}
		wait(7);
		}
		}
			task AimKnife{
				ascent(n in 0..3){
		PlaySound("Shot1",95,0);
		ascent(i in 0..11){
		ascent(a in 0..2){
		ShotOA1(objBoss,2.5+a*1.5,angleToPlayer-90+i*18,KNIFE_BLUE,20+a*20);
		}
		}
		wait(20);
		}
		}
		wait(60);
		T05FN1;
	}
	
task T05FN1{
	AccelMove(objBoss,stgx,120,0.5,5);
	maple(1);
	wait(120);
	let s = 1;
	ascent(i in 0..4){
	let enemy = fam(GetEnemyX,GetEnemyY,2000,2);
	Control(enemy,110+i*20,s);
	enemy = fam(GetEnemyX,GetEnemyY,2000,2);
	Control(enemy,70-i*20,s);
	s = -s;
	}
	wait(135);
	TMovement(20,5,5);
	wait(135);
	ascent(n in 0..15){
	PlaySound("Shot1",95,0);
	ascent(a in 0..8){
	ShotOA1(objBoss,1.25+a/3,93+n*12,KNIFE_PURPLE,8);
	ShotOA1(objBoss,1.25+a/3,87-n*12,KNIFE_PURPLE,8);
	ShotOA1(objBoss,1.25+a/3,96+n*40,KNIFE_PURPLE,8);
	ShotOA1(objBoss,1.25+a/3,84-n*40,KNIFE_PURPLE,8);
	}
	wait(8);
	}
	wait(30);
	TMovement(20,5,5);
	wait(30);
	s =-1;
	ascent(i in 0..4){
	let enemy = fam(GetEnemyX,GetEnemyY,2000,2);
	Control(enemy,110+i*20,s);
	enemy = fam(GetEnemyX,GetEnemyY,2000,2);
	Control(enemy,70-i*20,s);
	s = -s;
	}
	wait(90);
	AccelMove(objBoss,stgx+60,100,0.2,5);
	ascent(n in 0..4){
	PlaySound("Shot1",95,0);
	ascent(i in 0..12){
	ShotOA1(objBoss,2,i*30+n*13,KNIFE_BLUE,8);
	ShotOA1(objBoss,3,i*30+n*17,KNIFE_BLUE,16);
	}
	wait(30);
	}
		task Control(obj,dir,s){
		let dir2 = 0;
		ObjMove_AddPatternA2(obj,0,0.6,dir,-0.001,0,0);
		wait(60);
		ascent(n in 0..23){
		PlaySound("Shot1",92,0);
		ascent(i in 0..4){
		if(s==1){dir2 = dir+i*1.35+n*67*s+90*s;}
		else{dir2 = dir+i*1.35+n*57*s+90*s;}
		if(s==1){ShotOA1(obj,2.2,dir2,PELLET_GREEN,0);}
		else{ShotOA1(obj,2.2,dir2,PELLET_BLUE,0);}
		}
		wait(7);
		}
		wait(30);
		ObjEnemy_SetLife(obj,0);
		}
	AccelMove(objBoss,stgx,150,1,4);
	T05FS1;
	}
	
task T05FS1{
	let shot;
	maple(1);
	wait(120);
	descent(n in 0..2){
	PlaySound("Shot2",95,0);
	ascent(i in 0..7){
	ascent(a in 0..4){
	ShotOA1(objBoss,0.75+a*0.5+rand(-0.25,0.25),i*32+rand(-10,10),BUBBLE_RED,10);
	}
	}
	TMovement(35,5,5);
	wait(60);
	TimeStop;
	ascent(i in 0..11){
	ascent(a in 0..6){
	ascent(j in 0..3){
	shot = ShotA2(20+i*40+rand(-5,5),280-a*40+rand(-5,5),0,0,0.005,rand(2,3),KNIFE_BLUE,0);
	ObjMove_SetAngle(shot,GetAngleToPlayer(shot)-45+j*45+rand(-a/3,a/3));
	ObjMove_AddPatternA2(shot,60,NO_CHANGE,NO_CHANGE,0.03,0,rand(2,3));
	}
	}
	}
	ObjMove_SetPosition(objBoss,stgx+rand(-100,100),120);
	wait(120);
	TMovement(35,5,5);
	if(n<=1){Spam;}
	wait(90+n*90);
	}
	AccelMove(objBoss,stgx-30,140,0.5,5);
	wait(30);
	T05FN2;
		task Spam{
			let v = 0;
			let dir = 0;
			ascent(i in 0..60){
			v = rand(1,4);
			dir = rand(0,359);
			PlaySound("BulletWave",95,0);
			ShotOA1(objBoss,v,dir,KNIFE_RED,10);
			ShotOA1(objBoss,v+1,dir,KNIFE_RED,10);
			wait(3);
			}
			}
	}
	
task T05FN2{
	ascent(i in 0..2){
	let enemy = fam(GetEnemyX,GetEnemyY,2000,2);
	Control(enemy,130+i*50,s);
	enemy = fam(GetEnemyX,GetEnemyY,2000,2);
	Control(enemy,50-i*50,s);
	s = -s;
	}
	wait(90);
	TMovement(65,5,1);
	ascent(n in 0..5){
	PlaySound("Shot1",95,0);
	ascent(i in 0..10){
	ShotOA1(objBoss,2,i*36+n*14,KNIFE_BLUE,8);
	ShotOA1(objBoss,2.5,i*36+n*19,KNIFE_BLUE,8);
	}
	wait(30);
	}
	wait(30);
	TMovement(25,5,1);
	wait(30);
	PlaySound("Shot1",95,0);
	ascent(i in 0..18){
	ShotOA1(objBoss,2.5,i*20+angleToPlayer,KNIFE_BLUE,8);
	}
				task Control(obj,dir,s){
			let dir2 = 0;
			let shot;
			ObjMove_AddPatternA2(obj,0,0.6,dir,-0.001,0,0);
			wait(60);
			ascent(n in 0..15){
			PlaySound("Shot1",92,0);
			ascent(i in 0..4){
			if(s==1){dir2 = dir+i*1+n*47*s+90*s;}
			else{dir2 = dir+i*1+n*57*s+90*s;}
			if(s==1){
			shot = ShotOA1(obj,2.05,dir2,KUNAI_RED,0);
			Manage(shot);
			}
			else{
			shot = ShotOA1(obj,2.05,dir2,KUNAI_BLUE,0);
			Manage(shot);
			}
			}
			wait(12);
			}
			wait(30);
			ObjEnemy_SetLife(obj,0);
			}
						task Manage(obj){
				let x = 0;
				let y = 0;
				let t = 0;
				let dir = 0;
				while(!Obj_IsDeleted(obj)){
				x = ObjMove_GetX(obj);
				y = ObjMove_GetY(obj);
				if(x<0 || x>stgx*2 && t==0){
				dir = ObjMove_GetAngle(obj);
				ObjMove_SetAngle(obj,180-dir);
				t = 1;
				}
				if(y<0 && t==0){
				dir = ObjMove_GetAngle(obj);
				ObjMove_SetAngle(obj,-dir);
				t =1;
				}
				yield;
				}
				}
	T05FS2;
	}
	
task T05FS2{
	let r = 60;
	let dir = 0;
	let r_rand = 0;
	let dir2 = 0;
	let shot;
	let color = KNIFE_BLUE;
	AccelMove(objBoss,stgx,130,1,5);
	maple(2);
	wait(60);
	ascent(m in 0..2){
	if(m==0){
	PlaySound("Shot1",95,0);
	ascent(i in 0..15){
	ascent(a in 0..4){
	ShotOA1(objBoss,1+a/3,i*24+30,288,12);
	ShotOA1(objBoss,1+a/3,i*30+30,288,12);
	}
	}
	}
	else{
	AccelMove(objBoss,stgx+rand(-100,100),100,0.5,6);
	ascent(n in 0..10){
	PlaySound("Shot1",95,0);
	   ascent(i in 0..9){
		ascent(a in 1..3){
		 ShotOA1(objBoss,1+a,i*40+angleToPlayer,288,8);
		}
       }
	   wait(10);
	}
	}
	wait(60);
	TimeStop;
	ObjMove_SetPosition(objBoss,stgx+rand(-100,100),150);
	ascent(i in 0..13){
	dir = 210+i*10;
	ascent(a in 0..12){
	r_rand = rand(0,2);
	r_rand = round(r_rand);
	r = 150+a*20;
	shot = ShotA2(GetPlayerX+r*cos(dir),GetPlayerY+r*sin(dir),0,0,0,0,KNIFE_BLUE,0);
	ObjMove_SetAngle(shot,GetAngleToPlayer(shot));
	if(r_rand<=1){
	dir2 = rand(0,359);
	ObjMove_AddPatternA3(shot,1,0,dir2,0.01,0,rand(1.5,2),KNIFE_GREEN);
	}
	else{
	dir2 = rand(-10,-10);
	ObjMove_AddPatternA2(shot,45,0,NO_CHANGE,0.01,0,rand(1.5,2));
	}
	}
	}
	if(m==0){
	wait(90);
	Spam;
	wait(90);
	}
	}
	T05FN3;
				task Spam{
			let v = 0;
			let dir = 0;
			ascent(i in 0..60){
			v = rand(1,4);
			dir = angleToPlayer+rand(30,90);
			PlaySound("BulletWave",95,0);
			ShotOA1(objBoss,v,dir,KNIFE_RED,10);
			ShotOA1(objBoss,v+1,dir,KNIFE_RED,10);
			dir = angleToPlayer-rand(30,90);
			ShotOA1(objBoss,v,dir,KNIFE_RED,10);
			ShotOA1(objBoss,v+1,dir,KNIFE_RED,10);
			wait(3);
			}
			}
	}
	
task T05FN3{
	let shot;
	let s = 1;
	wait(60);
	AccelMove(objBoss,stgx,140,0.5,5);
	wait(60);
	ascent(m in 0..4){
	if(s==-1){TMovement(45,5,2);}
	ascent(n in 0..6){
	  PlaySound("Shot1",95,0);
	   ascent(i in 0..5){
		ascent(a in 0..1+m/3){
		 if(s==1){shot = ShotOA1(objBoss,1.4+a/3,i*72+n*10-18+36*s,KNIFE_BLUE,12);}
		 else{shot = ShotOA1(objBoss,1.4+a/3,i*72+n*10*s-18+36*s,KNIFE_RED,12);}
		 Manage(shot);
		}
	   }
	   wait(6);
	}
	wait(20);
	s = -s;
	}
	wait(40);
	T05FS3;
				task Manage(obj){
				let x = 0;
				let y = 0;
				let t = 0;
				let dir = 0;
				while(!Obj_IsDeleted(obj)){
				x = ObjMove_GetX(obj);
				y = ObjMove_GetY(obj);
				if(x<0 || x>stgx*2 && t==0){
				dir = ObjMove_GetAngle(obj);
				ObjMove_SetAngle(obj,180-dir);
				t = 1;
				}
				if(y<0 && t==0){
				dir = ObjMove_GetAngle(obj);
				ObjMove_SetAngle(obj,-dir);
				t =1;
				}
				yield;
				}
				}
	}
	
task T05FS3{
	let shot;
	let time = false;
	let s=1;
	AccelMove(objBoss,stgx,130,0.5,5);
	loop(2){
	wait(60);
	maple(2);
	TMovement(35,5,5);
	wait(60);
	ascent(n in 0..8){
	PlaySound("Shot1",95,0);
	   ascent(i in 0..10){
		ascent(a in 0..2){
		 shot = ShotOA1(objBoss,1.25+a/3,i*36+n*5.2*s,KNIFE_BLUE,10);
		 Manage(shot);
		}
	   }
	   wait(5);
	}
	wait(10);
	ascent(n in 0..8){
	PlaySound("Shot1",95,0);
	   ascent(i in 0..6){
		ascent(a in 0..2){
		 shot = ShotOA1(objBoss,1.5+a/2,i*3-n*45*s,KNIFE_RED,5);
		 Manage(shot);
		}
	   }
	   wait(4);
	}
	wait(30);
	TimeStop;
	ObjMove_SetPosition(objBoss,stgx+rand(-100,100),130);
	time = true;
	yield;
	time = false;
	wait(45);
	TMovement(35,5,5);
	Spam;
	wait(45);
	s = -s;
	}
	time = false;
		task Manage(obj){
		let r_rand = 0;
		r_rand = rand(0,1);
		r_rand = round(r_rand);
		while(time==false){yield;}
		if(r_rand==1){
		ObjMove_AddPatternA3(obj,0,0,rand(0,359),rand(0.1,0.2),0,rand(1,2.5),KNIFE_GREEN);
		}
		}
			task Spam{
			let x = 0;
			let y = 0;
			let r = 0;
			let angle = 0;
			let dir2 = 0;
			let v = 0;
			ascent(n in 0..25){
			PlaySound("Shot1",95,0);
			r = rand(0,180);
			v = rand(1.5,3.5);
			angle = rand(0,359);
			dir2 = rand(0,36);
			x = GetEnemyX+r*cos(angle);
			y = GetEnemyY+(r-50)*sin(angle);
			ascent(i in 0..10){
			ShotA1(x,y,v,i*36+dir2,95,12);
			}
			wait(6);
			}
			}
		AccelMove(objBoss,stgx,120,1,5);
		wait(75);
		T05FS4;
	}
	
task T05FS4{ // Eternal Meek
	let shot;
	attack(270);
	wait(30);
	ascent(n in 0..150){
	PlaySound("Shot1",90,0);
	loop(3){
	shot = ShotA1(GetEnemyX+rand(-5,5)-13,GetEnemyY+rand(-5,5)-40,rand(2,5),rand(0,359),LARGE_BLUE,10);
	ObjShot_SetGraphic(shot,SMALL_BLUE);
	}
	if(n>=75){
	loop(3){
	shot = ShotA1(GetEnemyX+rand(-5,5)-13,GetEnemyY+rand(-5,5)-40,rand(2,5),rand(0,359),LARGE_RED,10);
	ObjShot_SetGraphic(shot,SMALL_RED);
	}
	}
	wait(2);
	}
	ascent(n in 0..15){
	PlaySound("Shot1",90,0);
	loop(3){
	shot = ShotA1(GetEnemyX+rand(-5,5)-13,GetEnemyY+rand(-5,5)-40,rand(2,5),rand(0,359),LARGE_BLUE,10);
	ObjShot_SetGraphic(shot,SMALL_BLUE);
	}
	loop(3){
	shot = ShotA1(GetEnemyX+rand(-5,5)-13,GetEnemyY+rand(-5,5)-40,rand(2,5),rand(0,359),LARGE_RED,10);
	ObjShot_SetGraphic(shot,SMALL_RED);
	}
	}
	wait(30);
	SetPlayerLife(GetPlayerLife+1);
	PlaySound("Life",100,0);
	SoundStop(mainsnd);
	AccelMove(objBoss,stgx,150,0.5,6);
	wait(60);
	Opening;
	}
	
task Opening{
	subsnd = Sound(MainSTG~"Remi.mp3");
	Remi = true; 
	bSpell = true;
	wait(60);
	magiccircle2(objBoss,10,true);
	PlaySound("cardcall",100,75);
	wait(75);
	TSpell2;
	wait(5);
	ascent(i in 0..15){
	ascent(a in 0..4){
	ShotOA1(objBoss,1+a/2,i*24,BUBBLE_RED,10);
	}
	}
	wait(180);
	T06FN1;
	}
	
task T06FN1{
	let  x = 0;
	let y = 0;
	let dir = 0;
	let s = 1;
	let color = [SMALL_RED,G_LARGE_RED,BUBBLE_RED];
	ascent(n in 2..18){
	x = GetEnemyX+rand(-150,150);
	y = GetEnemyY+rand(-100,50);
	dir = rand(0,7);
	ascent(i in 0..45){
	ShotA1(x,y,1+n/9,i*8+dir,PELLET_RED,12);
	}
	wait(50);
	}
	SpamC;
	wait(15);
	ascent(i in 0..24){
	ascent(a in 0..4){
	ShotOA1(objBoss,1+a/2,i*15,G_LARGE_RED,10);
	}
	}
	TRapid;
			task SpamC{
			ascent(n in 18..34){
			x = GetEnemyX+rand(-150,150);
			y = GetEnemyY+rand(-100,50);
			dir = rand(0,11);
			ascent(i in 0..30){
			ShotA1(x,y,3,i*12+dir,PELLET_RED,12);
			}
			wait(51);
			}
			SpamC2;
			}
			task SpamC2{
			ascent(n in 18..50){
			x = GetEnemyX+rand(-150,150);
			y = GetEnemyY+rand(-100,50);
			dir = rand(0,23);
			ascent(i in 0..15){
			ShotA1(x,y,3,i*24+dir,PELLET_RED,12);
			}
			wait(25);
			}
			}
			task TRapid{
			ascent(n in 0..48){
			ascent(i in 0..4){
			ShotOA1(objBoss,3,i*9+n*69,SMALL_RED,8);
			ShotOA1(objBoss,3,i*9+n*69+180,SMALL_RED,8);
			}
			if(n>=27){
			ascent(i in 0..4){
			ShotOA1(objBoss,2.8,i*90-n*19,G_LARGE_RED,12);
			}
			}
			wait(15);
			}
			wait(100);
			TRapid2;
			}
			task TRapid2{
			ascent(n in 0..38){
			if(n==19){
			s = -s;
			color = [SMALL_BLUE,G_LARGE_BLUE,BUBBLE_BLUE];
			}
			ascent(i in 0..3){
			ShotOA1(objBoss,2.8,i*7-n*40*s,color[0],4);
			ShotOA1(objBoss,2.8,i*7-n*40*s+180,color[0],4);
			}
			ascent(i in 0..6){
			ShotOA1(objBoss,2.8,i*60+n*17*s,color[1],6);
			}
			ascent(i in 0..5){
			ShotOA1(objBoss,3,i*72-n*27*s,color[2],8);
			}
			wait(20);
			}
			wait(25);
			TRapid3;
			}
			task TRapid3{
			ascent(n in 0..80){
			x = GetEnemyX+rand(-150,150);
			y = GetEnemyY+rand(-150,50);
			dir = rand(0,89);
				if(n== 0 || n==22 || n==43 || n == 63){
					ascent(i in 0..12){
						ascent(a in 0..2){
							ShotOA1(objBoss,1+a/2,i*30+n,BUBBLE_RED,10);
						}
					}
				}
			ascent(i in 0..4){
			ascent(a in 0..5){
			if(n<45){ShotA1(x,y,2+a/3,i*90+dir,PELLET_RED,8);}
				if(n>=45){
					if(n%2==0){
					let shot = ShotA1(x,y,1.55+a/3,i*90+dir,PELLET_PURPLE,8);
					ObjMove_SetAngle(shot,i*90+GetAngleToPlayer(shot));
					}
					else{
					ShotA1(x,y,2+a/3,i*90+dir,PELLET_RED,8);
					}
				}
			}
			}
			wait(10);
			}
			T06FS1;
			}
	}
	
task T06FS1{
	let dir = 0;
	AccelMove(objBoss,stgx,120,1,5);
	DeleteShotAll(TYPE_CHILD,TYPE_FADE);
	wait(20);
	ascent(m in 0..2){
	Cross;
	if(m==1){TMovement(30,5,2);}
	ascent(n in 0..5){
	Scarlet(-10+n*50+rand(-10,10),12);
	wait(12);
	}
	wait(45);
	if(m==1){TMovement(30,5,2);}
	descent(n in 0..5){
	Scarlet(-10+n*50+rand(-10,10)+20,12);
	wait(12);
	}
	wait(30);
	if(m==1){TMovement(30,5,2);}
	ascent(n in 0..2){
	ascent(i in 0..4){
	Scarlet(i*90+n*45+angleToPlayer+22.5,12);
	}
	wait(12);
	}
	wait(30);
	ascent(n in 0..2){
	ascent(i in 0..4){
	Scarlet(i*90+angleToPlayer+n*45,12);
	}
	wait(12);
	}
	wait(30);
	if(m==1){TMovement(30,5,2);}
	ascent(i in 0..8){
	Scarlet(i*45+angleToPlayer+22.5,42);
	}
	wait(105);
	//////////////
	if(m==1){TMovement(30,5,2);}
	descent(n in 0..5){
	Scarlet(-10+n*50+rand(-10,10),12);
	wait(12);
	}
	wait(45);
	if(m==1){TMovement(30,5,2);}
	ascent(n in 0..5){
	Scarlet(-10+n*50+rand(-10,10)+20,12);
	wait(12);
	}
	wait(30);
	if(m==1){TMovement(30,5,2);}
	ascent(n in 0..2){
	ascent(i in 0..4){
	Scarlet(i*90+n*45-22.5+angleToPlayer,12);
	}
	wait(12);
	}
	wait(30);
	if(m==1){TMovement(30,5,2);}
	ascent(n in 0..2){
	ascent(i in 0..4){
	Scarlet(i*90+n*45+angleToPlayer,12);
	}
	wait(12);
	}
	wait(30);
	if(m==1){TMovement(30,5,2);}
	ascent(i in 0..6){
	Scarlet(i*360/6+angleToPlayer+30,50);
	}
	wait(30);
	if(m==1){TMovement(30,5,2);}
	ascent(i in 0..6){
	Scarlet(i*360/6+angleToPlayer+30,50);
	}
	wait(30);
	if(m==1){
	ascent(i in 0..6){
	Scarlet(i*360/6+angleToPlayer+30,50);
	}
	}
	ascent(i in 0..24){
	ascent(a in 0..8){
	ShotOA1(objBoss,1.5+a/2,i*15,PELLET_RED,8);
	}
	}
	wait(30);
	}
	ascent(i in 0..15){
	ascent(a in 0..8){
	ShotOA1(objBoss,1.5+a/2,i*24+angleToPlayer+12,G_LARGE_RED,8);
	}
	}
	T06FS2;
		task Scarlet(dir,delay){
		let x = ObjMove_GetX(objBoss);
		let y = ObjMove_GetY(objBoss);
		ShotA1(x,y,5,dir,BUBBLE_RED,delay);
		ascent(i in 0..12){
			ShotA1(x,y,1.2+i/6,dir+rand(-10,10),BL_SMALL_RED,delay); // 4.5
			}
			wait(delay);
			ascent(i in 0..4){
			ShotA1(x,y,2.75+i/2.5,dir+rand(-8,8),LARGE_RED,0); // 5.6
			}
			}
			task Cross{
			ascent(i in 0..33){
			ascent(a in 0..18){
			ShotA2(GetEnemyX,GetEnemyY,0,i*10+90+20,0.01+a/120,10,293,0);
			}
			}
			}
			
	}
	
task T06FS2{
	let x = 0;
	let y = 0;
	let angle = 0;
	let dir = 0;
	let v = 1;
	AccelMove(objBoss,stgx,150,1,5);
	ascent(n in 0..80){
	if(n<=30){v = 0.5+n/20;}
	if(n==70){Wave(1);}
	ascent(i in 0..4){
	ascent(j in 0..3){
	x = GetEnemyX+120*cos(angle);
	y = GetEnemyY+90*sin(angle);
	angle = i*90+n*5;
	dir = j*120+n*21;
	ShotA1(x,y,v,dir,PELLET_RED,8);
	}
	}
	wait(10);
	}
	ascent(n in 0..80){
	if(n<=35){v = 0.75+n/20;}
	if(n==70){Wave(-1);}
	ascent(i in 0..4){
	ascent(j in 0..3){
	x = GetEnemyX+120*cos(angle);
	y = GetEnemyY+90*sin(angle);
	angle = i*90-n*5;
	dir = j*120-n*21;
	ShotA1(x,y,v,dir,PELLET_PURPLE,8);
	}
	if(n%3==0){
	ShotOA1(objBoss,3,i*72+n*37,BUBBLE_PURPLE,12);
	}
	}
	wait(10);
	}
		task Wave(way){
		ascent(n in 0..75){
		ascent(i in 0..4){
		if(way==1){ShotOA1(objBoss,1+n/20,i*90+n*9*s,KNIFE_RED,8);}
		if(way==-1){ShotOA1(objBoss,1+n/20,i*90+n*9*s,KNIFE_BLUE,8);}
		}
		wait(2);
		}
		}
	wait(120);
	AccelMove(objBoss,stgx+25,160,1,5);
	T06FS3;
	}
	
task T06FS3{
	let x = 0;
	let y = 0;
	let dir = 0;
	let r = 0;
	let angle = 0;
	Kunai(1);
	ascent(n in 0..18){
	PlaySound("Shot1",90,0);
	ascent(i in 0..9){
	dir = i*40+n*13;
	ShotA1(GetEnemyX+(90-n)*cos(dir),GetEnemyY+(90-n)*sin(dir),2,dir+270,KNIFE_RED,12);
	}
	wait(5);
	}
	AccelMove(objBoss,stgx-25,140,1,5);
	wait(90);
	Kunai(-1);
	ascent(n in 0..18){
	PlaySound("Shot1",90,0);
	ascent(i in 0..9){
	dir = i*40-n*13;
	ShotA1(GetEnemyX+(90-n)*cos(dir),GetEnemyY+(90-n)*sin(dir),2,dir-270,KNIFE_PURPLE,12);
	}
	wait(5);
	}
			task Kunai(s){
			let dir2 = 0;
			ascent(n in 0..45){
			PlaySound("Shot1",85,0);
			x = GetEnemyX+rand(60,120)*cos(rand(0,359));
			y = GetEnemyY+rand(60,120)*sin(rand(0,359));
			dir2 = n*1.5*s;
			ascent(i in 0..4){
			if(s==1){ShotA1(x,y,rand(0.8,1.2),dir2+i*90,KUNAI_RED,12);}
			if(s==-1){ShotA1(x,y,rand(0.8,1.2),dir2+i*90,KUNAI_PURPLE,12);}
			}
			wait(2);
			}
			}
	AccelMove(objBoss,stgx,120,1,5);
	wait(60);
	maple(3);
	wait(90);
	ascent(n in 0..36){
	PlaySound("Shot1",90,0);
	r = n*5;
	ascent(i in 0..9){
	dir = i*40-n*13+180;
	ShotA1(GetEnemyX+r*cos(dir),GetEnemyY+r*sin(dir),2.2,dir-180,KNIFE_RED,12);
	}
	ascent(i in 0..9){
	dir = i*40+n*23+180;
	ShotA1(GetEnemyX+r*cos(dir),GetEnemyY+r*sin(dir),2.2,dir+180,KUNAI_RED,12);
	}
	wait(3);
	}
	wait(60);
	ascent(n in 0..48){
	PlaySound("BulletWave",95,0);
	if(n%18==17){TMovement(15,2,3);}
	loop(1){
	angle = rand(0,359);
	x = GetEnemyX+rand(30,150)*cos(angle);
	y = GetEnemyY+rand(30,150)*sin(angle);
	dir = rand(0,359);
	ascent(i in 0..4){
	let shot = ShotA1(x,y,4,dir,KNIFE_RED,7+i*7);
	ObjMove_SetAngularVelocity(shot,6*cos(n*180));
	ObjMove_AddPatternA2(shot,60,3,NO_CHANGE,0,0,0);
	}
	}
	wait(3);
	}
	/*ascent(n in 0..12){
	x = n*35;
	y = 60+rand(-10,10);
	PlaySound("BulletWave",95,0);
	dir = rand(85,95);
	ascent(a in 0..12){
	ShotA2(x,y,0,dir,0.005+a/360,10,KUNAI_PURPLE,12);
	}
	wait(3);
	}*/
	wait(90);
	ascent(m in 0..5){
	 TMovement(35,5,5);
	 ascent(n in 0..12){
	  PlaySound("Shot1",90,0);
	  ascent(i in 0..3){
	   ascent(j in 0..5){
	   ShotOA1(objBoss,3.25,i*120+j*8+m*75,KUNAI_RED,8);
	   }
	   ShotOA1(objBoss,3.25,i*120+n*17+m*75+60,KUNAI_RED,8);
	  }
	  wait(3);
	 }
	}
	AccelMove(objBoss,stgx,120,0.5,5);
	
	maple(3);
	attack(150);
	wait(90);
	PlaySound("um1",100,0);
	PlaySound("um2",100,60);
	Bubble;
	ascent(i in 0..18){
	x = GetEnemyX-13;
	y = GetEnemyY-40;
	let laser = CreateStraightLaserA1(x,y,i*20,0,30,150,194,60);
	Control(laser);
	}
		task Control(obj){
		ascent(i in 0..30){
		let shot = ShotOA1(obj,0,0,SMALL_RED,12);
		ObjShot_SetDeleteFrame(shot,0);
		ObjLaser_SetLength(obj,i*18);
		yield;
		}
		ascent(i in 0..180){
		let shot = ShotOA1(obj,0,0,SMALL_RED,12);
		ObjShot_SetDeleteFrame(shot,0);
		ObjLaser_SetRenderWidth(obj,rand(28,32));
		yield;
		}
		}
	wait(60);
	x = GetEnemyX;
	y = GetEnemyY;
	descent(m in 0..9){
	angle = 270-m*15;
	ascent(n in 0..20){
	PlaySound("Shot1",90,0);
	y = GetEnemyY+n*25*sin(angle);
	x = GetEnemyX+n*25*cos(angle);
	ascent(i in 0..3){
	let shot = ShotA2(x,y,0,i*120+n*17,0.05,2,KUNAI_RED,12);
	ObjMove_AddPatternA2(shot,60,NO_CHANGE,NO_CHANGE,-0.025,0,rand(1,1.5));
	}
	x = GetEnemyX-n*20*cos(angle);
	ascent(i in 0..3){
	let shot = ShotA2(x,y,0,i*120-n*17,0.05,2,KUNAI_RED,12);
	ObjMove_AddPatternA2(shot,60,NO_CHANGE,NO_CHANGE,-0.025,0,rand(1,1.5));
	}
	if(n%2==0){yield;}
	}
	}
		task Bubble{
		wait(60);
		ascent(i in 0..18){
		ascent(a in 0..15){
		ShotA2(GetEnemyX-13,GetEnemyY-40,0,i*20+10,0.005+a/180,7,G_LARGE_RED,10);
		}
		}
		ascent(i in 0..51){
		ascent(a in 0..18){
		ShotA2(GetEnemyX-13,GetEnemyY-40,0,i*6+120,0.005+a/180,7,293,10);
		}
		}
		}
		AccelMove(objBoss,stgx,150,1,5);
		wait(255);
		SoundStop(subsnd);
		Opening2;
	}
	
task Opening2{
	ObjEnemy_SetLife(objBoss,0);
	bSpell2=false;
	}
	
	
task TimeStop{
	White;
	StartSlow(TARGET_ALL,2);
	wait(1);
	StopSlow(TARGET_ALL);
	}

//----------------------------------------------------

task TRender
{
	Aura(0);
	magiccircle(objBoss,1.75,true);
	let imgMiko = GetCurrentScriptDirectory~"img/boss.png";
	let f = 0;
	let t = 0;
	let px = 64;
	let py = 64;
	let ang = 1;
	ObjPrim_SetTexture(objBoss, imgMiko);
	ObjRender_SetScaleXYZ(objBoss,1.05,1.05,1);
	while(!Obj_IsDeleted(objBoss))
	{
		let angle = ObjMove_GetAngle(objBoss);
		let speed = ObjMove_GetSpeed(objBoss);
		if(speed <= 0 && idle == true){
		ObjRender_SetAngleY(objBoss,0);
		if(f<12){ObjSprite2D_SetSourceRect(objBoss, 0, 0, px, py);}
		if(f>=12 && f<24){ObjSprite2D_SetSourceRect(objBoss, px, 0, px*2, py);}
		if(f>=24 && f<36){ObjSprite2D_SetSourceRect(objBoss, px*2, 0, px*3, py);}
		if(f>=36 && f<48){ObjSprite2D_SetSourceRect(objBoss, px*3, 0, px*4, py);}
		if(f>=48){f=0;}
		f++;
		t = 0;
		}
		else if(cos(angle) > 0 || cos(angle) < 0 && t == 0){
		if(cos(angle)<0){ObjRender_SetAngleY(objBoss,180);}
		else{ObjRender_SetAngleY(objBoss,0);}
		manageSprite;
		t = 1;
		}
		ObjSprite2D_SetDestCenter(objBoss);
		//if(ang==1){ObjRender_SetAngleY(objBoss,180);}
		//if(ang==0){ObjRender_SetAngleY(objBoss,0);}
		yield;
	}
}

task NDLaser(x,y,v,angle,time,delay,way,type){
	let laser;
	let shot;
	PlaySound("Laser2",95,0);
	x = GetEnemyX+60*cos(angle);
	y = GetEnemyY+60*sin(angle);
	laser = CreateStraightLaserA1(x,y,angle,450,30,time,195,delay);
	ObjLaser_SetIntersectionWidth(laser,20);
	Manage(laser,x,y,v,angle,time,type);
		task Manage(laser,x,y,v,angle,time,type){
		let c = 0;
		loop(time-30){
		ObjMove_SetPosition(laser,GetEnemyX+60*cos(angle+c),GetEnemyY+60*sin(angle+c));
		ObjStLaser_SetAngle(laser,angle+c);
		shot = CreateShotOA1(laser,0,0,SMALL_BLUE,20);
		ObjShot_SetDeleteFrame(shot,0);
		c+=v*way;
		yield;
		}
		ObjLaser_SetIntersectionWidth(laser,0);
		descent(i in 0..30){
		ObjMove_SetPosition(laser,GetEnemyX+60*cos(angle+c),GetEnemyY+60*sin(angle+c));
		ObjStLaser_SetAngle(laser,angle+c);
		ObjLaser_SetRenderWidth(laser,i);
		if(type==1){c+=v*way;}
		yield;
		}
		Obj_Delete(laser);
		}
	}
	
		task NDShot{
			let shot;
		ascent(n in 0..3){
		 PlaySound("Shot1",95,0);
		  ascent(i in 0..4){
		   ascent(a in 0..2){
		    ascent(j in 0..6){
		    shot = ShotA1(GetEnemyX+60*cos(i*90+n*40),GetEnemyY+60*sin(i*90+n*40),2+a,0,SMALL_RED,12);
			ObjMove_SetAngle(shot,j*60+GetAngleToPlayer(shot));
			if(n==2){
		    shot = ShotOA1(objBoss,2+a,0,SMALL_RED,12);
			ObjMove_SetAngle(shot,j*60+GetAngleToPlayer(shot));
			}
		    }
		   }
		  }
		  wait(30);
		 }
		}
		
		task NDShot2{
		let shot;
		ascent(n in 0..3){
		 PlaySound("Shot1",95,0);
		  ascent(i in 0..4){
		   ascent(a in 0..2){
		    ascent(j in 0..5){
		    shot = ShotA1(GetEnemyX+60*cos(i*90+n*40),GetEnemyY+60*sin(i*90+n*40),2.5,0,SMALL_RED,12);
			ObjMove_SetAngle(shot,j*72+GetAngleToPlayer(shot)-10+a*20);
			if(n==2){
		    shot = ShotOA1(objBoss,2.5,0,SMALL_RED,12);
			ObjMove_SetAngle(shot,j*72+GetAngleToPlayer(shot)-10+a*20);
			}
		    }
		   }
		  }
		  wait(30);
		 }
		}
		
task TSpell{
	TSpell1;
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let c = 0;
	let a = 0;
	ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
	Obj_SetRenderPriority(obj,0.21);
	ObjPrim_SetTexture(obj,bg);
	ObjSprite2D_SetSourceRect(obj,0,0,384,448);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,1,1,1);
	ObjRender_SetX(obj,GetStgFrameWidth()/2);
	ObjRender_SetY(obj,GetStgFrameHeight()/2);
	while( !Obj_IsDeleted(obj) && bSpell == false){
	if(c<60){ObjRender_SetColor(obj,c*4,c*4,c*4);}
	c++;
	yield;
	}
	descent(i in 0..60){
	ObjRender_SetColor(obj,i*4,i*4,i*4);
	yield;
	}
	Obj_Delete(obj);
	}
	
task TSpell1{
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let c = 0;
	let a = 0;
	let s = 0;
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	Obj_SetRenderPriority(obj,0.21);
	ObjPrim_SetTexture(obj,bg1);
	ObjSprite2D_SetSourceRect(obj,0,0,384,448);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,1,1,1);
	ObjRender_SetX(obj,GetStgFrameWidth()/2);
	ObjRender_SetY(obj,GetStgFrameHeight()/2);
	ObjRender_SetAngleXYZ(obj,0,180,0);
	while( !Obj_IsDeleted(obj) && bSpell == false ){
	if(c<60){s+=1;}
	ObjRender_SetColor(obj,s*1.5+60*sin(c),s*1.5+60*sin(c+120),s*1.5+60*sin(c+240));
	ObjSprite2D_SetSourceRect(obj,0,0+c,384,448+c);
	c++;
	yield;
	}
	descent(i in 0..60){
	ObjRender_SetColor(obj,i*4,i*4,i*4);
	yield;
	}
	Obj_Delete(obj);
	}
		
task TSpell2{
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let c = 0;
	let a = 0;
	ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
	Obj_SetRenderPriority(obj,0.21);
	ObjPrim_SetTexture(obj,bg2);
	ObjSprite2D_SetSourceRect(obj,0,0,384,448);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,1,1,1);
	ObjRender_SetX(obj,GetStgFrameWidth()/2);
	ObjRender_SetY(obj,GetStgFrameHeight()/2);
	while( !Obj_IsDeleted(obj) && bSpell2 == false){
	if(a<255){a+=5;}
	ObjRender_SetColor(obj,a-64+64*sin(c*2),0,0);
	c++;
	yield;
	}
	descent(i in 0..60){
	ObjRender_SetColor(obj,i*4,i*4,i*4);
	yield;
	}
	Obj_Delete(obj);
	}

//----------------------------------------------------
task TEnd{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){yield;}
		let arr = GetShotIdInCircleA2(stgx,stgy,600,TARGET_ENEMY);
		Obj_Delete(objBoss);
		if(ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT) +ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) == 0)
		{AddScore(ObjEnemyBossScene_GetInfo(objScene,INFO_SPELL_SCORE));}
		SetAutoDeleteObject(true);
		yield;
		SetAutoDeleteObject(false);
		ascent(i in 0..length(arr)){
		effbreak(arr[i],"AQUA");
		Obj_Delete(arr[i]);
		}
		wait(20);
		SetAutoDeleteObject(true);
		CloseScript(GetOwnScriptID());
		return;
	}
