#ScriptVersion[3]
#Title["YukariN6"]
#Text["YukariN6"]
#Player["./Hecatia/Hecatia.txt"]
#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 objScene=GetEnemyBossSceneObjectID();
let color = [0,0];
@Initialize
{
SetCommonData("Scroll",0);
SetBoss("Yukari",false);
}

@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(4000);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(75);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(35000000);
	}
}

//----------------------------------------------------
task mainTask{
	StartCountDown;
                //ObjPlayer_ClearIntersection(GetPlayerObjectID);
	ObjMove_SetDestAtWeight(objBoss,stgx,120,10,10);
	SetCommonData("CircleSize",0);
	YukariCircle(objBoss,1,-1);
	SetCommonData("Scroll",1);
	NotifyEventAll(EV_SET_SONG,1);
	wait(60);
	SizeCircle;
	wait(90);
	TShot1;
	yield;
	}

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

task TShot1
{
	attack( 120 );
	let r = 70;
	let angle = rand(0,80);
	let dir = 0;
	let s = 1;
	maple;
	wait( 80 );
	PatternBorder1;
	PatternBorder2;
	wait( 300 );
	DamageRateAtFrame(150,20,0);
	PatternMove;
	}

              task PatternMove{
              while( !Obj_IsDeleted( objBoss )){
              	TMovement(15,15,3);
              	wait( 250 );
		}
	}

              task PatternBorder2{ 
              while( !Obj_IsDeleted( objBoss )){

              			let speed = 2.2;
			let angle = GetAngleToPlayer( objBoss );
	                                	let way = 28;
                                                	let shote = 294;
			let delay = 20;

			ascent( i in 0..way ){

			let R = 120;

                      	                	let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss ) - R;
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjMove_SetAngle( sht1, GetAngleToPlayer( sht1 ) + i*360/way );

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

			}
			PlaySound("LenenShot1",80,0);
                        		wait( 60 );

	}

   }


              task PatternBorder1{ 
              let angle1 = 0;
              let angle2 = 180;
              let gap = 9.6;
              while( !Obj_IsDeleted( objBoss )){
              let speed = 2.2;
              loop( 3 ){
	                                	let way = 6;
                                                	let shote = 311;
			let delay = 20;

			loop( way ){

			let R = 100;

                      	                	let sx1 = ObjMove_GetX( objBoss ) + R;
                      	                	let sx2 = ObjMove_GetX( objBoss ) - R;
                        		let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx1, sy, speed, angle1, 0, speed, shote, delay );
				let sht2 = TShotA2( sx2, sy, speed, angle2, 0, speed, shote, delay );

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

				angle1+= 360 / way;
				angle2+= 360 / way;

			
			}
			speed -= 0.24;
			}
			angle1 += gap;
			angle2 -= gap;
			PlaySound("LenenShot1",80,0);
                        		wait( 18 );

	}

   }

	task StartCountDown
	{
		wait((75*60) - (10*60));
		loop(5)
		{
			PlaySound("time1",100,0);
			wait(60);
		}
		loop(5)
		{
			PlaySound("time2",100,0);
			wait(60);
		}
	}



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

task SizeCircle
{
	ascent(i in 0..60)
	{
		SetCommonData("CircleSize",sin(i*1.5));
		yield;
	}
}	

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

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