
#ScriptVersion[3]
#Title["DoremyS2"]
#Text["DoremyS2"]
#Player[DEFAULT]
#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 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(1250);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(35000000);
	}
}

//----------------------------------------------------
task mainTask{
	magiccircle(objBoss,1,-1);
	DamageRateAtFrame(10,20,200);
	ObjMove_SetDestAtWeight(objBoss,stgx,140,10,7);
	Cutin("Bluish Dream 'The Lost Souls Wandering in Space'",13,"SHINKI");
	ObjEnemyBossScene_StartSpell(objScene);
	Sound(GCSD ~ "Butterfly.mp3");
	wait(120);
	TShot1;
	wait(1200);
	DamageRateAtFrame(75,40,0);
	}
//----------------------------------------------------

task TShot1
{
        attack(30,1);
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0)
	{
		MapleExplode(GetEnemyX,GetEnemyY,1.5,"BLUE");
		wait(20);
		MapleExplode(GetEnemyX,GetEnemyY,1.5,"YELLOW");
		Star(-1);
                HellSet2;
		wait(180);
		Star(-1);
		wait(180);
	}
}

task Star(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..60)
	{
		r = 0;
		let x = rand(0,400);
		let y = 0;
		let dir = GetPointAngle(px,py,x,y);
		let obj = TShotA1(x,y,2,90,773,12);
		ObjMove_SetAngle(0,dir);
		PlaySound("BulletWave",95,120);
			if(n%2==0)
			{
				ascent(i in 0..4)
				{
					r = 0;
					let x = rand(0,360);
					let y = rand(0,360);

					ObjMove_SetAngle(obj,90);
					ObjMove_AddPatternA2(obj,120,90,90,270,0,1.5);
				}
			}

		if(n%3!=0){wait(1);}
	}
}

task HellSet2
{
	let r = 30;
	let num = 3;
	let num2 = 0;
	let curve = 1;
	let acc = 0.01;
	let multi = 1;
	let c = 0;
	let c2 = 0;
	let count = 0;
	wait(60);
		MapleExplode(GetEnemyX,GetEnemyY,1.5,"YELLOW");
		wait(20);
		MapleExplode(GetEnemyX,GetEnemyY,1.5,"BLUE");
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0)
	{
		PlaySound("Shot1",92,0);
		PlaySound("BulletWave",92,60);
		ascent(i in 0..num)
		{
			let angle = i*360/num+180/num+c+count;
			TrickyBullet(GetEnemyX+r*cos(angle),GetEnemyY+r*sin(angle),1,angle,834,acc,curve*sin(count*10),12);
		}
		//count++;
		wait(9);
		PlaySound("Shot1",95,0);
		PlaySound("BulletWave",95,60);
		ascent(i in 0..num2)
		{
			let angle = i*360/(num2)+c2+count;
			if(i%20>8-Level && i%20<12+Level)
			{
				TrickyBullet(GetEnemyX+r*cos(angle),GetEnemyY+r*sin(angle),1,angle,834,acc,curve*sin(count*10),12);
			}
		}
		count++;
		c+=180/num;
		c2+=multi*360/(num2);
		wait(9);
	}
		task TrickyBullet(x,y,v,angle,color,acc,ang,delay)
		{
			let obj = TShotA2(x,y,v,angle,0,0,color,delay);
			wait(60);
			
			ObjMove_AddPatternA2(obj,0,NO_CHANGE,NO_CHANGE,acc,ang,10);
			wait(90);
			ObjMove_AddPatternA2(obj,0,NO_CHANGE,NO_CHANGE,acc,0,10);
		}
}

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

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

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