
#ScriptVersion[3]
#Title["DoremyS2"]
#Text["DoremyS2"]
#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"


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(2250);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(42);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(35000000);
	}
}

//----------------------------------------------------
task mainTask{
	magiccircle(objBoss,1,-1);
	DamageRateAtFrame(50,25,240);
	ObjMove_SetDestAtWeight(objBoss,stgx,140,10,7);
	Cutin("Dream Sign\"Dreamy Labyrinth\"",15,"SHINKI");
	ObjEnemyBossScene_StartSpell(objScene);
	Sound(GCSD ~ "Butterfly.mp3");
	wait(120);
	TShot1;
	wait(1200);
	DamageRateAtFrame(75,40,0);
	}
//----------------------------------------------------

task TShot1
{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0)
	{
		MapleExplode(GetEnemyX,GetEnemyY,1.5,"PINK");
		HalfCircle(-1);
		wait(180-Level*15);
		TMovement(35,10,5);
		wait(180-Level*15);
		MapleExplode(GetEnemyX,GetEnemyY,1.5,"PINK");
		HalfCircle(1);
		wait(180-Level*15);
		TMovement(35,10,5);
		wait(180-Level*15);
	}
}

task HalfCircle(way)
{
	let angle = GetAngleToPlayer(objBoss);
	let r = 150;
	let px = GetPlayerX;
	let py = GetPlayerY;
	let p = 90+90*way+rand(0,90)-45;
	ascent(n in 0..72)
	{
		r = 100;
		let x = px+r*cos(n*5*way-90+p);
		let y = py+r*sin(n*5*way-90+p);
		let dir = GetPointAngle(px,py,x,y);
		let obj = TShotA1(x,y,0.15,0,165,12);
		ObjMove_SetAngle(obj,dir);
		PlaySound("BulletWave",95,120);
		ObjMove_AddPatternA2(obj,120,NO_CHANGE,NO_CHANGE,0.015+Level/100,0,1.5+Level);
			if(n%2==0)
			{
				ascent(i in 0..6)
				{
					r = 150;
					let x = px+r*cos(n*5*way+p);
					let y = py+r*sin(n*5*way+p);
					obj = TShotA1(x,y,0.15,0,55,12);
					ObjMove_SetAngle(obj,dir+i*60);
					ObjMove_AddPatternA2(obj,120,NO_CHANGE,NO_CHANGE,0.015+Level/100,0,1.5+Level);
				}
			}
				ascent(i in 0..4)
				{
					r = 210;
					let x = px+r*cos(n*5*way*-1+90+p);
					let y = py+r*sin(n*5*way*-1+90+p);
					let dir = GetPointAngle(px,py,x,y);
					obj = TShotA1(x,y,0.15,0,9,12);
					ImmuneDelay(obj);
					ObjMove_SetAngle(obj,dir+i*90);
					ObjMove_AddPatternA2(obj,120,NO_CHANGE,NO_CHANGE,0.015+Level/100,0,1.5+Level);
				}
		if(n%3!=0){wait(1);}
	}
}

task ImmuneDelay(obj)
{
	ObjShot_SetAutoDelete(obj,true);
	wait(300);
	ObjShot_SetAutoDelete(obj,false);
}

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

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