
#ScriptVersion[3]
#Title["DoremyS1"]
#Text["DoremyS1"]
#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);
SetCommonData("Bomb",1);
}

@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(45);
	}
		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\"Sweet Pink Dreams\"",15,"SHINKI");
	ObjEnemyBossScene_StartSpell(objScene);
	Sound(GCSD ~ "Butterfly.mp3");
	wait(120);
	TShot1;
	wait(1200);
	DamageRateAtFrame(75,40,0);
	}
//----------------------------------------------------

task TShot1
{
	let s = 1;
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){
		MapleExplode(GetEnemyX,GetEnemyY,1.5,"PINK");
		TrapWave;
		TrueWave;
		wait(165);
		TMovement(35,10,5);
		wait(165);
	}
}

task TrapWave
{
	let r = 120;
	let degree = 0;
	let sangle = GetAngleToPlayer(objBoss)-90;
	descent(n in -18..15)
	{
		ascent(j in 0..4)
		{
			degree = 2.75+j;
			r = 60+j*60;
			let obj = TShotA1(GetEnemyX+r*cos(n*degree+sangle),GetEnemyY+r*sin(n*degree+sangle),0.2,60+n*degree+sangle,808,18);
			ObjMove_AddPatternA2(obj,120,NO_CHANGE,NO_CHANGE,0.02,0,2.5);
			obj = TShotA1(GetEnemyX+r*cos(180-n*degree+sangle),GetEnemyY+r*sin(180-n*degree+sangle),0.2,120-n*degree+sangle,808,18);
			ObjMove_AddPatternA2(obj,120,NO_CHANGE,NO_CHANGE,0.02,0,2.5);
		}
		yield;
	}
}

task TrueWave
{
	let r = 0;
	let degree = 0;
	let sangle = GetAngleToPlayer(objBoss)-90;
	ascent(n in 0..24+Level*24)
	{
		PlaySound("BulletWave",100,120);
		ascent(j in 0..4)
		{
			degree = (8+j*2)*(1-Level/2);
			r = 25+j*60;
			let obj = TShotA1(GetEnemyX+r*cos(n*degree+240+sangle),GetEnemyY+r*sin(n*degree+240+sangle),0.2,n*degree-30-j*20+sangle,553,18);
			if(j>1){CheckNearPlayer(obj);}
			ObjMove_AddPatternA2(obj,120,NO_CHANGE,NO_CHANGE,0.02,0,2);
			obj = TShotA1(GetEnemyX+r*cos(-n*degree-60+sangle),GetEnemyY+r*sin(-n*degree-60+sangle),0.2,210-n*degree+j*20+sangle,553,18);
			if(j>1){CheckNearPlayer(obj);}
			ObjMove_AddPatternA2(obj,120,NO_CHANGE,NO_CHANGE,0.02,0,2);
		}
		yield;
	}
}

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



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

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