
#ScriptVersion[3]
#Title["YuyukoEnd2"]
#Text["YuyukoEnd2"]
#Player[DEFAULT]
#System["./system/Default_System.txt"]
#Background["./BG.txt"]
#Player["./MoF_Reimu/Reimu.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss.txt"
#include"./Shot/AllStarShot_Const.dnh"
#include"./system/Default_Effect.Txt"
#include"./Portrait_Const.dnh"
#include"./DialogueFunctions.dnh"


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
{
SetBoss("Yuyuko",false);
}

@MainLoop
{
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),25);
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),26);
	if(GetCommonData("IsFan",false)==true){
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss)-90,ObjMove_GetY(objBoss),26*3.5);
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss)+90,ObjMove_GetY(objBoss),26*3.5);
	}
	yield;

}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		SetScriptResult(1);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(55);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(35000000);
	}
}

//----------------------------------------------------
task mainTask{
	NotifyEventAll(EV_FAM_DIE,objBoss);
	DamageRateAtFrame(100,25,360);
	ObjMove_SetDestAtWeight(objBoss,stgx,120,10,10);
	magiccircle(objBoss,1,-1);
	if(GetCommonData("IsFan",false)==true)
	{
		CallFan(0);
	}
	else
	{
		CallFan(1);
	}
	yield;
	ObjEnemy_SetLife(objBoss,0);
	}

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


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

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

task TEnd{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){yield;}
			if(ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT) +ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) == 0)
			{AddScore(ObjEnemyBossScene_GetInfo(objScene,INFO_SPELL_SCORE));}
			else{PlaySound("Shot2",95,0);}
		let color = GetColor("PURPLE");
		let color2 = GetColor("AQUA");
		PlaySound("enemoff",100,0);
		ClearBullet(120,10);
		StartSlow(TARGET_ALL,30);
		ascent(i in 0..45){
		Maple(stgx,150,rand(0.5,1),rand(0,360),color[0],color[1],color[2]);
		Maple(stgx,150,rand(1,1.5),rand(0,360),color[0],color[1],color[2]);
		Maple(stgx,150,rand(0.5,1),rand(0,360),color2[0],color2[1],color2[2]);
		Maple(stgx,150,rand(1,1.5),rand(0,360),color2[0],color2[1],color2[2]);
		wait(2);
		}
		wait(30);
		ObjMove_SetPosition(objBoss,stgx,-1000);
		StopSlow(TARGET_ALL);
		PlaySound("enemoff",100,0);
		MapleExplode(stgx,150,1,"PURPLE");
		MapleExplode(stgx,150,1.5,"AQUA");
		MapleExplode(stgx,150,2,"PURPLE");
		MapleExplode(stgx,150,2.5,"AQUA");
		descent(i in 0..30){
		Maple(stgx,150,1+i/30,rand(0,360),color[0],color[1],color[2]);
		Maple(stgx,150,1+i/30,rand(0,360),color2[0],color2[1],color2[2]);
		yield;
		}
		wait(60);
		Obj_Delete(objBoss);
		wait(120);
		CloseScript(GetOwnScriptID());
	}