
#ScriptVersion[3]
#Title["Doremy Last Spell"]
#Text["Doremy Last Spell"]
#Player[DEFAULT]
#System["./system/Default_System.txt"]
#Background["./BG.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss.txt"
#include"./Shot/AllStarShot_Const.dnh"
#include"./system/Default_Effect.Txt"


let objBoss;
let GCSD=GetCurrentScriptDirectory~"";
let enemy;
let bSpell=false;
let stgx=GetStgFrameWidth()/2;
let stgy=GetStgFrameHeight()/2;
let idle = true;
let atk = false;
let fog = 0;
let action = false;
let objScene=GetEnemyBossSceneObjectID();
let color = [276,277,278];
let color2 = [51,53,55];
let dcolor = [308,309,310];
@Initialize
{
SetBoss("Doremy",true);
}

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

}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		SetScriptResult(11000);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(300);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(35000000);
	}
}

//----------------------------------------------------
task mainTask{
	magiccircle(objBoss,1,-1);
	DamageRateAtFrame(20,50,180);
	ObjMove_SetDestAtWeight(objBoss,stgx,stgy-100,10,7);
	Cutin("Eternal Dream 'Eternal Nameless Dream'",15,"SHINKI");
	ObjEnemyBossScene_StartSpell(objScene);
	Sound(GCSD ~ "Butterfly.mp3");
	wait(105);
	TShot1;
	wait(1200);
	}
//----------------------------------------------------

task TShot1
{
        attack(99990,1);
	let s = 1;
	PlaySound("Charge3",100,0);
	wait(10);
    MapleExplode(GetEnemyX,GetEnemyY,1.5,"RED");
	PatternRemiliaNon1;
	PatternRemiliaNon2;
	PatternRemiliaNon3;
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 10000){ yield; }

                DeleteShotAll( TYPE_ALL, TYPE_ITEM );

                wait( 120 );
                MapleExplode(GetEnemyX,GetEnemyY,1.5,"PURPLE");
                wait( 90 );
                PatternYuyukoNon1;
                wait( 300 );
                PatternYuyukoNon2;
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 9000){ yield; }

                DeleteShotAll( TYPE_ALL, TYPE_ITEM );

                wait( 120 );
                MapleExplode(GetEnemyX,GetEnemyY,1.5,"PINK");
                wait( 90 );
                PatternEirinNon1;
                wait( 280 );
                PatternEirinNon2;
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 8000){ yield; }
                DeleteShotAll( TYPE_ALL, TYPE_ITEM );

                wait( 120 );
                MapleExplode(GetEnemyX,GetEnemyY,1.5,"PINK");
                wait( 90 );
                PatternKaguyaNon;
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 7000){ yield; }
                DeleteShotAll( TYPE_ALL, TYPE_ITEM );

                wait( 120 );
                MapleExplode(GetEnemyX,GetEnemyY,1.5,"ORANGE");
                wait( 90 );
                PatternEikiNon1;
                wait( 180 );
                PatternEikiNon2;
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 6000){ yield; }
                DeleteShotAll( TYPE_ALL, TYPE_ITEM );

                wait( 120 );
                MapleExplode(GetEnemyX,GetEnemyY,1.5,"YELLOW");
                wait( 90 );
                PatternKanakoNon;
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 5000){ yield; }
                DeleteShotAll( TYPE_ALL, TYPE_ITEM );

                wait( 120 );
                MapleExplode(GetEnemyX,GetEnemyY,1.5,"GREEN");
                wait( 90 );
                PatternOkuuNon;
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 4000){ yield; }
                DeleteShotAll( TYPE_ALL, TYPE_ITEM );

                wait( 120 );
                MapleExplode(GetEnemyX,GetEnemyY,1.5,"AQUA");
                wait( 90 );
                PatternByakurenNon;
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 3000){ yield; }
                DeleteShotAll( TYPE_ALL, TYPE_ITEM );

                wait( 120 );
                MapleExplode(GetEnemyX,GetEnemyY,1.5,"BLUE");
                wait( 90 );
                PatternMikoNon;
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 2000){ yield; }
                DeleteShotAll( TYPE_ALL, TYPE_ITEM );

                wait( 120 );
                MapleExplode(GetEnemyX,GetEnemyY,1.5,"GRAY");
                wait( 90 );
                PatternShinmyoumaruNon;
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 1000){ yield; }
                DeleteShotAll( TYPE_ALL, TYPE_ITEM );

                wait( 120 );
                MapleExplode(GetEnemyX,GetEnemyY,1.5,"WHITE");
                wait( 90 );
                PatternJunkoNon;
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){ yield; }
}

                 task PatternJunkoNon{
                 let x = 5;
	 while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){
	 let angle = rand( 0, 360 );
                 loop( x ){

			let way = 90;
			let speed = 1.2;
			let shote = 548; 
			let delay = 30;

			let sx = ObjMove_GetX( objBoss );
		       	let sy = ObjMove_GetY( objBoss );

			loop( way ){

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0)){
				
				let sht = TShotA2( sx, sy, speed, angle, 0, speed, shote , delay );

				NotifyEventAll( EV_USER + 40, [ sht, delay ] );

				angle += 360 / way;
			}
			}
                                                angle += (360 / way)/2;
			PlaySound("Shot1",92,0);
			if( wait( 15 ) ){ return; }
		}
			x += 0.25;
			if( wait( 80 ) ){ return; }
		}
                     }

              task PatternShinmyoumaruNon{
              let angle = rand( 0, 360 );
              while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 1000){

              let angle1 = angle;
              let angle2 = angle;
              let angle3 = angle;
              let angle4 = angle;
              let quarterway = 11;
              let speed = 2.3;
              let a = 0.1;
              loop( quarterway ){

	                	let way = 1;
			let shote1 = 299;
			let delay = 10;

			loop( way ){

				let sx = ObjMove_GetX( objBoss );
				let sy = ObjMove_GetY( objBoss );

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 1000)){
				
				let sht1 = TShotA2( sx, sy, speed, angle1, 0, speed, shote1, delay );
				let sht2 = TShotA2( sx, sy, speed, angle2, 0, speed, shote1, delay );
				let sht3 = TShotA2( sx, sy, speed, angle3+180, 0, speed, shote1, delay );
				let sht4 = TShotA2( sx, sy, speed, angle4+180, 0, speed, shote1, delay );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht2, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht3, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht4, delay ] );

				angle += 360 / way;

			}
			}
                        		speed += a;
                                                a += 0.025;
                        		angle1 += 95 / quarterway;
                        		angle2 -= 95 / quarterway;
                        		angle3 += 95 / quarterway;
                        		angle4 -= 95 / quarterway; 

			PlaySound("Shot1",92,0);

                        if( wait( 0 ) ){ return; }
	}
                        angle -= 7.5;
                        if( wait( 18 ) ){ return; }
	}

   }

                 task PatternMikoNon{
	 while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 2000){
	 let speed = 4;
	 let angle1 = rand( 0, 360 );
                 loop( 3 ){
                        
			let way = 52;
			let shote = 366; 
			let delay = 30;
	 		let angle = rand( 0, 360 );

			let sx = ObjMove_GetX( objBoss );
		       	let sy = ObjMove_GetY( objBoss ) - 60;

			loop( way ){

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 2000)){
				
				let sht = TShotA2( sx, sy, speed, angle, -0.031, 0, shote , delay );

				PatternMikoNon1( sht, angle1 );

				NotifyEventAll( EV_USER + 40, [ sht, delay ] );

				angle += 360 / way;
			}
			}
                                                speed -= 0.3;
			PlaySound("Shot1",92,0);
			if( wait( 0 ) ){ return; }
		}
			if( wait( 350 ) ){ return; }
		}
                     }

                 task PatternMikoNon1( sht, angle1 ){
                 wait( 180 );
                 loop( 1 ){

			let speed = 0.8;
			let way = 8;
			let shote = 183; 
			let delay = 30;

			let sx = ObjMove_GetX( sht );
		       	let sy = ObjMove_GetY( sht );

                                                if( Obj_IsDeleted( sht ) ){ break; }

			loop( way ){
				
				let sht1 = TShotA2( sx, sy, speed, angle1, 0, speed, shote , delay );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle1 += 360 / way;
			
			}

			PlaySound("Shot1",92,0);

			if( wait( 0 ) ){ return; }
		}
                     Obj_Delete( sht );
                     }

                 task PatternByakurenNon{
	 while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 3000){
	 let angle1 = rand( 0, 360 );
	 let angle2 = rand( 0, 360 );
	 let angle3 = rand( 0, 360 );
	 let angle4 = rand( 0, 360 );
	 let angle5 = rand( 0, 360 );
                 loop( 70 ){
	 let speed = 2.6;
                 loop( 6 ){
                        
			let way = 1;
			let shote1 = 57; 
			let shote2 = 57; 
			let shote3 = 57; 
			let delay = 30;
                                                let a = 60;
                                                let r = 20;

			let sx1 = (ObjMove_GetX( objBoss ) - 80) + r*cos( angle1 + a );
		       	let sy1 = (ObjMove_GetY( objBoss ) - 80) + r*sin( angle1 + a );
			let sx2 = (ObjMove_GetX( objBoss ) + 80) + r*cos( angle2 + a );
		       	let sy2 = (ObjMove_GetY( objBoss ) - 80) + r*sin( angle2 + a );
			let sx3 = (ObjMove_GetX( objBoss ) - 120) + r*cos( angle3 + a );
		       	let sy3 = (ObjMove_GetY( objBoss ) + 60) + r*sin( angle3 + a );
			let sx4 = (ObjMove_GetX( objBoss ) + 120) + r*cos( angle4 + a );
		       	let sy4 = (ObjMove_GetY( objBoss ) + 60) + r*sin( angle4 + a );
			let sx5 = ObjMove_GetX( objBoss ) + r*cos( angle5 + a );
		       	let sy5 = ObjMove_GetY( objBoss ) + r*sin( angle5 + a );

			loop( way ){

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 3000)){
				
				let sht1 = TShotA2( sx1, sy1, speed, angle1, 0, speed, shote1 , delay );
				let sht2 = TShotA2( sx2, sy2, speed, angle2, 0, speed, shote1 , delay );
				let sht3 = TShotA2( sx3, sy3, speed, angle3, 0, speed, shote2 , delay );
				let sht4 = TShotA2( sx4, sy4, speed, angle4, 0, speed, shote2 , delay );
				let sht5 = TShotA2( sx5, sy5, speed, angle5, 0, speed, shote3 , delay );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht2, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht3, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht4, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht5, delay ] );

				angle1 += 360 / way;
				angle2 += 360 / way;
				angle3 += 360 / way;
				angle4 += 360 / way;
				angle5 += 360 / way;
			}
			}
                                                speed -= 0.072;
			PlaySound("Shot1",92,0);
			if( wait( 0 ) ){ return; }
		}
                                                angle1 -= 12.5;
                                                angle2 += 12.5;
                                                angle3 += 12.5;
                                                angle4 -= 12.5;
                                                angle5 += 12.5;
			if( wait( 1 ) ){ return; }
		}
			if( wait( 90 ) ){ return; }
		}
                     }

                 task PatternOkuuNon{
	 while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 4000){
	 let angle = rand( 0, 360 );
                 loop( 45 ){
                        
			let way = 26;
			let speed = 8;
			let shote = 780; 
			let delay = 30;

			let sx = ObjMove_GetX( objBoss );
		       	let sy = ObjMove_GetY( objBoss );

			loop( way ){

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 4000)){
				
				let sht1 = TShotA2( sx, sy, 1, angle, 0.1, speed, shote , delay );
				let sht2 = TShotA2( sx, sy, 1, angle, 0.1, speed, shote , delay );

				WaitForAngular( 0, sht1 ,1.7 , 150);
				WaitForAngular( 0, sht2 ,-1.7 , 150);

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht2, delay ] );

				angle += 360 / way;
			}
			}

			PlaySound("Shot1",92,0);
			if( wait( 3 ) ){ return; }
		}
			if( wait( 100 ) ){ return; }
		}
                     }

              task PatternKanakoNon{
              PatternKanakoNon5;
              PatternKanakoNon1; 
              PatternKanakoNon2;
              wait( 50 ); 
              PatternKanakoNon3;
              PatternKanakoNon4;
              }
              

              task PatternKanakoNon5{ 
              while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 5000){

	                	let way = 1;
			let speed = 6;
			let shote = 94;
			let delay = 20;
			loop( way ){

				let sx = ObjMove_GetX( objBoss );
				let sy = ObjMove_GetY( objBoss );

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 5000)){
				
				let sht1 = TShotA2( sx, sy, speed, 40, 0, speed, shote, delay );
				let sht2 = TShotA2( sx, sy, speed, 45, 0, speed, shote, delay );
				let sht3 = TShotA2( sx, sy, speed, 50, 0, speed, shote, delay );

				let sht4 = TShotA2( sx, sy, speed, 130, 0, speed, shote, delay );
				let sht5 = TShotA2( sx, sy, speed, 135, 0, speed, shote, delay );
				let sht6 = TShotA2( sx, sy, speed, 140, 0, speed, shote, delay );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht2, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht3, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht4, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht5, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht6, delay ] );


			}		
			}
			PlaySound("Shot1",92,0);
                        		if( wait( 15 ) ){ return; }
	}

   }

              task PatternKanakoNon4{ 
              while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 5000){
              let a = 0;
              let b = 0;
              loop( 10 ){

	                	let way = 16;
			let speed = 5;
                        		let nspeed = 7;
			let shote = 94;
			let delay = 5;
	                	let angle = 236.5;
			loop( way ){

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 5000)){

				let sx = ObjMove_GetX( objBoss )+45;
				let sy = ObjMove_GetY( objBoss )-10;
				
				let sht = TShotA2( sx, sy, speed, angle, -0.12, 0, shote, delay );
                                		DelayAimPatternA3( sht, 45 + a, nspeed, angle, 0 , 0, nspeed, b ); 

				NotifyEventAll( EV_USER + 40, [ sht, delay ] );
				angle += 180 / way;
			}
			}
                        		a += 1;
                        		b -= 1;
			PlaySound("Shot1",92,0);
                        		if( wait( 3 ) ){ return; }
	}
                        		if( wait( 75 ) ){ return; }
	}

   }

              task PatternKanakoNon3{ 
              while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 5000){
              let a = 0;
              let b = 0;
              loop( 10 ){

	                	let way = 16;
			let speed = 5;
                        		let nspeed = 7;
			let shote = 94;
			let delay = 5;
	               		let angle = 135;
			loop( way ){

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 5000)){

				let sx = ObjMove_GetX( objBoss )-45;
				let sy = ObjMove_GetY( objBoss )-10;
				
				let sht = TShotA2( sx, sy, speed, angle, -0.12, 0, shote, delay );
                                		DelayAimPatternA3( sht, 45 + a, nspeed, angle, 0 , 0, nspeed, b ); 

				NotifyEventAll( EV_USER + 40, [ sht, delay ] );
				angle += 180 / way;
			}
			}
                        		a += 1;
                        		b -= 1;
			PlaySound("Shot1",92,0);
                        		if( wait( 3 ) ){ return; }
	}
                        		if( wait( 75 ) ){ return; }
	}

   }


              task PatternKanakoNon2{ 
              while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 5000){
              let a = 0;
              let b = 0;
              loop( 10 ){

	                let way = 16;
			let speed = 5;
                        		let nspeed = 7;
			let shote = 94;
			let delay = 5;
	                	let angle = 236.5;
			loop( way ){

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 5000)){

				let sx = ObjMove_GetX( objBoss )+45;
				let sy = ObjMove_GetY( objBoss )-10;
				
				let sht = TShotA2( sx, sy, speed, angle, -0.12, 0, shote, delay );
                                		DelayAimPatternA3( sht, 45 + a, nspeed, angle, 0 , 0, nspeed, b ); 

				NotifyEventAll( EV_USER + 40, [ sht, delay ] );
				angle += 180 / way;
			}
			}
                        		a += 1;
                        		b += 1;
			PlaySound("Shot1",92,0);
                        		if( wait( 3 ) ){ return; }
	}
                        		if( wait( 75 ) ){ return; }
	}

   }

              task PatternKanakoNon1{ 
              while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 5000){
              let a = 0;
              let b = 0;
              loop( 10 ){

	                let way = 16;
			let speed = 5;
                        		let nspeed = 7;
			let shote = 94;
			let delay = 5;
	                	let angle = 180 - 45;
			loop( way ){

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 5000)){

				let sx = ObjMove_GetX( objBoss )-45;
				let sy = ObjMove_GetY( objBoss )-10;
				
				let sht = TShotA2( sx, sy, speed, angle, -0.12, 0, shote, delay );
                                		DelayAimPatternA3( sht, 45 + a, nspeed, angle, 0 , 0, nspeed, b ); 

				NotifyEventAll( EV_USER + 40, [ sht, delay ] );
				angle += 180 / way;
			}
			}
                        		a += 1;
                        		b += 1;
			PlaySound("Shot1",92,0);
                        		if( wait( 3 ) ){ return; }
	}
                        		if( wait( 75 ) ){ return; }
	}

   }

                 task PatternEikiNon2{
	 while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 6000){
                        
			let way = 1;
			let speed = rand( 1, 2.5 );
			let angle = 90;
			let shote = 838; 
			let delay = 40;
                        		let r = rand( -0.3, 0.3 );

			let sx = rand( 0, GetStgFrameWidth );
		       	let sy = rand( ObjMove_GetY( objBoss ) - 130, ObjMove_GetY( objBoss ) + 60 );

			loop( way ){

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 6000)){
				
				let sht = TShotA2( sx, sy, speed, angle, 0, speed, shote , delay );

				NotifyEventAll( EV_USER + 40, [ sht, delay ] );
				angle += 360 / way;
			}
			}

			PlaySound("Shot1",92,0);
			if( wait( 6 ) ){ return; }
		}
                     }

              task PatternEikiNon1{ 
	      let angle = 230;
	      while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 6000){

	                	let way = 2;
			//let speed = 1.8;
			let speed = 2.5;
			let shote = 63;
			let delay = 20;
			loop( way ){
				let sx = ObjMove_GetX( objBoss );
				let sy = ObjMove_GetY( objBoss );

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 6000)){
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				let sht2 = TShotA2( sx, sy, speed, angle + 120/7, 0, speed, shote, delay );
				let sht3 = TShotA2( sx, sy, speed, angle + (120/7)*2, 0, speed, shote, delay );
				let sht4 = TShotA2( sx, sy, speed, angle + (120/7)*3, 0, speed, shote, delay );
				let sht5 = TShotA2( sx, sy, speed, angle + (120/7)*4, 0, speed, shote, delay );
				let sht6 = TShotA2( sx, sy, speed, angle + (120/7)*5, 0, speed, shote, delay );
				let sht7 = TShotA2( sx, sy, speed, angle + (120/7)*6, 0, speed, shote, delay );

                                		ObjShot_SetSpellResist( sht1, true );
				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

                                		ObjShot_SetSpellResist( sht2, true );
				NotifyEventAll( EV_USER + 40, [ sht2, delay ] );

                                		ObjShot_SetSpellResist( sht3, true );
				NotifyEventAll( EV_USER + 40, [ sht3, delay ] );

                                		ObjShot_SetSpellResist( sht4, true );
				NotifyEventAll( EV_USER + 40, [ sht4, delay ] );

                                		ObjShot_SetSpellResist( sht5, true );
				NotifyEventAll( EV_USER + 40, [ sht5, delay ] );

                                		ObjShot_SetSpellResist( sht6, true );
				NotifyEventAll( EV_USER + 40, [ sht6, delay ] );

                                		ObjShot_SetSpellResist( sht7, true );
				NotifyEventAll( EV_USER + 40, [ sht7, delay ] );

				angle += 360 / way;
			}
			}
                        		angle += 14.5;
			PlaySound("Shot1",92,0);

                        //if( wait( 10 ) ){ return; }
                        if( wait( 8 ) ){ return; }
	}

   }
                 task PatternKaguyaNon{
                 let p = 0;
	 while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 7000){
                        
			let way = 6;
			let speed = 4;
			let angle = p;
			let shote = 309; 
			let delay = 40;
                        		let r = rand( -0.3, 0.3 );

			let sx = ObjMove_GetX( objBoss );
		       	let sy = ObjMove_GetY( objBoss );

			loop( way ){

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 7000)){
				
				let sht = TShotA2( sx, sy, speed, angle, -0.025, 0, shote , delay );
                                		ObjMove_AddPatternA4( sht, 180, 0.4, rand( 0, 360 ), 0, 0, 0.4, 0, 309 );

				NotifyEventAll( EV_USER + 40, [ sht, delay ] );
				angle += 360 / way;
			}
			}
                        		p += 12 + r;
			PlaySound("Shot1",92,0);
			if( wait( 5 ) ){ return; }
		}
                     }

              task PatternEirinNon2{
	     while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 8000){
			let angle = rand( 0, 360 );
	                                let way = 64;
			let speed = 1.2;
			let shote = 133;
			let delay = 20;
			loop( way ){

				let sx = ObjMove_GetX( objBoss );
				let sy = ObjMove_GetY( objBoss );

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 8000)){
				
				let sht = TShotA2( sx, sy, 0, angle, speed, speed, shote, delay );

				NotifyEventAll( EV_USER + 40, [ sht, delay ] );
				angle += 360 / way;
			}
			}
			PlaySound("Shot1",92,0);
			if( wait( 30 ) ){ return; }
		}

	}

              task PatternEirinNon1{
	let angle1 = 0;
	let angle2 = 0;
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 8000){
	                                let way = 4;
			let speed = 3;
			let shote1 = 309;
			let shote2 = 309;
			let delay = 20;
			loop( way ){

				let sx = ObjMove_GetX( objBoss );
				let sy = ObjMove_GetY( objBoss );

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 8000)){
				
				let sht1 = TShotA2( sx, sy, speed, angle1, -0.02, 1, shote1, delay );
				let sht2 = TShotA2( sx, sy, speed, angle2, -0.02, 1, shote2, delay );

				WaitForAngular( 0, sht1 ,-1.7 , 120);
				WaitForAngular( 0, sht2 ,1.7 , 120);

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht2, delay ] );

				angle1 += 360 / way;
				angle2 += 360 / way;
			}
			}
			angle1 -= 8.5;
			angle2 += 8.5;
			PlaySound("Shot1",92,0);
			if( wait( 5 ) ){ return; }
		}

	}

              task PatternYuyukoNon2{ 
              let w = 90;
              while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 9000){
	                	let way = 7;
			let speed = 3;
			let shote = 827;
			let delay = 30;
		        	let sx = rand( 0, GetStgFrameWidth );
			let sy = ObjMove_GetY( objBoss );
	                	let angle = GetAngleToPlayer( objBoss );

                                                if( w < 60 ){ w = 60; }

			ascent(i in 0..way){

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 9000)){
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
                                		ObjMove_SetAngle( sht1, GetAngleToPlayer( sht1 ) + i*90/way );

				let sht2 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
                                		ObjMove_SetAngle( sht2, GetAngleToPlayer( sht2 ) - i*90/way );

                                		ObjShot_SetSpellResist( sht1, true );
                                		ObjShot_SetSpellResist( sht2, true );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht2, delay ] );
			
                 }
	}
			w -= 1.5;
			PlaySound("Shot1",92,0);
                                                if( wait( w )){ return; }
	}
	}

              task PatternYuyukoNon1{ 
              while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 9000){
              loop( 1 ){
	                	let way = 2;
			let speed = 1.2;
			let shote1 = 36;
			let shote2 = 793;
			let delay = 30;
		        	let sx = rand( 0, GetStgFrameWidth );
			let sy = ObjMove_GetY( objBoss );
	                	let angle = GetAngleToPlayer( objBoss );
                                                let a = 3;

			ascent(i in 0..way){

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 9000)){
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote2, delay );
                                		ObjMove_SetAngle( sht1, GetAngleToPlayer( sht1 ) + i*60/way );

				let sht2 = TShotA2( sx, sy, speed, angle, 0, speed, shote2, delay );
                                		ObjMove_SetAngle( sht2, GetAngleToPlayer( sht2 ) - i*60/way );

				let sht3 = TShotA2( sx, sy, speed, angle, 0, speed, shote1, delay );
                                		ObjMove_SetAngle( sht3, GetAngleToPlayer( sht3 ) + i*60/way );

				let sht4 = TShotA2( sx, sy, speed, angle, 0, speed, shote1, delay );
                                		ObjMove_SetAngle( sht4, GetAngleToPlayer( sht4 ) - i*60/way );

				WaitForAngular( 90, sht3 ,a , 30);
				WaitForAngular( 90, sht4 ,a , 30);

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht2, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht3, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht4, delay ] );
			
                 }
	}	

			PlaySound("Shot1",92,0);
	}
              wait( 10 );
              loop( 1 ){
	                	let way = 2;
			let speed = 1.2;
			let shote1 = 36;
			let shote2 = 36;
			let delay = 30;
		        	let sx = rand( 0, GetStgFrameWidth );
			let sy = ObjMove_GetY( objBoss );
	                	let angle = GetAngleToPlayer( objBoss );
                                                let a = -3;

			ascent(i in 0..way){

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 9000)){
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote2, delay );
                                		ObjMove_SetAngle( sht1, GetAngleToPlayer( sht1 ) + i*60/way );

				let sht2 = TShotA2( sx, sy, speed, angle, 0, speed, shote2, delay );
                                		ObjMove_SetAngle( sht2, GetAngleToPlayer( sht2 ) - i*60/way );

				let sht3 = TShotA2( sx, sy, speed, angle, 0, speed, shote1, delay );
                                		ObjMove_SetAngle( sht3, GetAngleToPlayer( sht3 ) + i*60/way );

				let sht4 = TShotA2( sx, sy, speed, angle, 0, speed, shote1, delay );
                                		ObjMove_SetAngle( sht4, GetAngleToPlayer( sht4 ) - i*60/way );

				WaitForAngular( 90, sht3 ,a , 30);
				WaitForAngular( 90, sht4 ,a , 30);

                                		ObjShot_SetSpellResist( sht1, true );
                                		ObjShot_SetSpellResist( sht2, true );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht2, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht3, delay ] );
				NotifyEventAll( EV_USER + 40, [ sht4, delay ] );
			
                 }
	}

			PlaySound("Shot1",92,0);
	}
                                                if( wait( 10 )){ return; }
}        

   }

              task PatternRemiliaNon1{
              while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 10000){
	let angle = rand( 0, 360 );
	      loop( 60 ){
	                                let way = 8;
			let speed = 3.2;
			let shote = 276;
			let delay = 20;
			loop( way ){

				let sx = ObjMove_GetX( objBoss );
				let sy = ObjMove_GetY( objBoss );

				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 10000)){
				
				let sht = TShotA2( sx, sy, 0, angle, speed, speed, shote, delay );

				NotifyEventAll( EV_USER + 40, [ sht, delay ] );
				angle += 360 / way;
			}
			}
			angle += 9;
			PlaySound("Shot1",92,0);
			if( wait( 8 )){ return; }
		}
	}
		if( wait( 60 ) ){ return; }

	}

              task PatternRemiliaNon2{
              while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 10000){
	let angle = rand( 0, 360 );
	      loop( 48 ){
	                                let way = 6;
			let speed = 3.7;
			let shote = 823;
			let delay = 20;
			loop( way ){

				let sx = ObjMove_GetX( objBoss );
				let sy = ObjMove_GetY( objBoss );


				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 10000)){
				
				let sht = TShotA2( sx, sy, 0, angle, speed, speed, shote, delay );

				NotifyEventAll( EV_USER + 40, [ sht, delay ] );
				angle += 360 / way;
			}
                                                }
			angle -= 22;
			PlaySound("Shot1",92,0);
			if( wait( 10 )){ return; }
		}
		if( wait( 60 ) ){ return; }

	}

	}

              task PatternRemiliaNon3{
              while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 10000){
	let angle = rand( 0, 360 );
	      loop( 48 ){
	                                let way = 5;
			let speed = 3.2;
			let shote = 35;
			let delay = 20;
			loop( way ){

				let sx = ObjMove_GetX( objBoss );
				let sy = ObjMove_GetY( objBoss );


				if((ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 10000)){
				
				let sht = TShotA2( sx, sy, 0, angle, speed, speed, shote, delay );

				NotifyEventAll( EV_USER + 40, [ sht, delay ] );
				angle += 36 / way;
			}
			}
			angle += 8;
			PlaySound("Shot1",92,0);
			if( wait( 10 ) ){ return; }
		}

		if( wait( 60 ) ){ return; }

	}

	}

task DelayAimPatternA3(obj,frame,v,angle,acc,angular,vmax,a)
{
   wait(frame);
   angle = GetAngleToPlayer(obj) + a;
   ObjMove_AddPatternA2(obj,0,v,angle,acc,angular,vmax);
   
}


task WaitForAngular(wtime,obj,anv,time){

      wait( wtime );
      //ObjSound_Play( CreateShotSE[ 1 ] );
      ObjMove_SetAngularVelocity( obj,anv );
      wait( time );
      ObjMove_SetAngularVelocity( obj,0 );
}


task WSpread // White
{
	let angle = [10,10,10];
		let result = GetAngleToPlayer(objBoss)+rand(-5,5);
		ascent(i in 0..50)
		{
			PlaySound("Shot1",85,0);
			TShotA1(GetEnemyX+30*cos(i*rand(0,360)+result),GetEnemyY+30*sin(i*angle+result),15,i*angle+result,613,12);
			wait(2);
		}
}

task CheckNearPlayer(obj)
{
	wait(11);
	if(GetDistance(ObjMove_GetX(obj),ObjMove_GetY(obj),GetPlayerX,GetPlayerY)<20)
	{
		Obj_Delete(obj);
	}
}

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

task TEnd{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){yield;}
		EndBoss(1);
		yield;
		CloseScript(GetOwnScriptID());
	}