
#ScriptVersion[3]
#Title["DoremyS4"]
#Text["DoremyS4"]
#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(2400);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(45);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(35000000);
	}
}

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

task TShot1
{
	let s = 1;
	PlaySound("Charge3",100,0);
	RayCharge("PURPLE",2,60);
	RayCharge("AQUA",2,60);
	wait(120);
	MapleExplode(GetEnemyX,GetEnemyY,1.5,"PINK");
	MapleExplode(GetEnemyX,GetEnemyY,1.25,"AQUA");
	wait(10);
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0)
	{
		DarkWave(GetPlayerX,GetPlayerY,633,1*s);
		wait(135);
		TMovement(30,5,3);
		wait(135);
		DarkWave(GetEnemyX,GetEnemyY,637,-1*s);
		wait(135);
		TMovement(30,5,3);
		wait(135);
		s = -s;
		MapleExplode(GetEnemyX,GetEnemyY,1.25,"PINK");
		wait(9);
	}
}

task DarkWave(x,y,color,s)
{
	let r = 60;
	let angle = 0;
	let rangle = 6*s;
	let dir = 0;
	ascent(n in 0..120)
	{
		PlaySound("BulletWave",95,0);
		ascent(i in 0..2)
		{
			ascent(j in 0..1+Level)
			{
				let obj = TShotA1(x+r*cos(angle+i*180),y+r*sin(angle+i*180),0.1+j/10,dir+i*180,color,12);
				CheckNearPlayer(obj);
				ObjMove_AddPatternA2(obj,150-j*30,NO_CHANGE,NO_CHANGE,0.015,0,1.75);
			}
			
		}
		r+= 2;
		dir += 35;
		angle += rangle;
		wait(3);
	}
}

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());
	}