
#ScriptVersion[3]
#Title["HecatiaN1"]
#Text["HecatiaN1"]
#Player[DEFAULT]
#System["./system/Default_System.txt"]
#Background["./BG.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss2.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 objScene=GetEnemyBossSceneObjectID();
@Initialize
{
SetBoss("Hecatia Lapislazuli",false);
}

@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(5500);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(55);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(35000000);
	}
}

//----------------------------------------------------
task mainTask{
	ObjMove_SetPosition(objBoss,384+100,-120);
	ObjMove_SetDestAtWeight(objBoss,stgx,120,10,15);
	SetCommonData("CircleSize",0);
	magiccircle(objBoss,1,-1);
	SetCommonData("Scroll",1);
	wait(60);
	SizeCircle;
	wait(90);
	TShot1;
	DamageRateAtFrame(100,50,60);
	yield;
	}

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

task TShot1
{
	maple;
	wait(70);
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0)
	{
		//--------------------------Hell--------------------------//
		HellWave(1);
		wait(60);
		TMovement(35,5,5);
		wait(60);
		HellWave(-1);
		//----------------------------------------------------//
		ObjMove_SetDestAtWeight(objBoss,stgx,120,10,15);
		wait(45);
		ChangeForm(0,2);
		wait(45);
		//--------------------------Earth--------------------------//
		EarthWave(1);
		wait(30);
		TMovement(35,5,5);
		wait(30);
		EarthWave(-1);
		//----------------------------------------------------//
		ObjMove_SetDestAtWeight(objBoss,stgx,120,10,15);
		wait(45);
		ChangeForm(2,1);
		wait(45);
		//--------------------------Moon---------------------//
		MoonWave(1);
		wait(30);
		TMovement(35,5,5);
		wait(30);
		MoonWave(-1);
		//----------------------------------------------------//
		ObjMove_SetDestAtWeight(objBoss,stgx,120,10,15);
		wait(45);
		ChangeForm(1,0);
		wait(45);
		DeleteAllSound;
	}
}

function MoonWave(way)
{
	let r = 30;
	let num = 22+2*Level;
	ascent(n in 0..20)
	{
		PlaySound("BulletWave",95,0);
		ascent(i in 0..num)
		{
			ascent(j in -2..3)
			{
				let angle = i*360/num*way+j*(0.2+n/12)*way+n*2*way;
				TShotA2(GetEnemyX+r*cos(angle),GetEnemyY+r*sin(angle),0.5,angle,0.05,5,78,8);
			}
		}
		wait(5);
	}
}

function HellWave(way)
{
	let r = 30;
	let speed = 2.25+Level*0.25;
	let num = 26+Level*4;
	ascent(n in 0..12)
	{
		PlaySound("Shot1",95,0);
		ascent(i in 0..num)
		{
			let angle = i*360/num+(360/num)*(5/12)*n*way;
			ascent(j in 0..2)
			{
				TShotA1(GetEnemyX+r*cos(angle+j*way),GetEnemyY+r*sin(angle+j*way),speed,angle+j*way,69,8);
			}
		}
		if(n%2==0&&Level>0)
		{
			ascent(i in 0..num/2)
			{
				let angle = i*360/(num/2)+n*360/(num/2)*(7/24)*way;
				ascent(j in 0..8)
				{
					TShotA1(GetEnemyX+r*cos(angle+j*way),GetEnemyY+r*sin(angle+j*way),1.25,angle+j*way,69,8);
				}
			}
		}
		wait(7);
	}
}

function EarthWave(way)
{
	let r = 30;
	let num = 26+4*Level;
	ascent(n in 0..9)
	{
		PlaySound("Shot1",95,0);
		ascent(i in 0..num)
		{
			ascent(j in 0..2)
			{
				let angle = i*360/num+n*way+j*way;
				TShotA1(GetEnemyX+r*cos(angle),GetEnemyY+r*sin(angle),1.25,angle,71,8);
			}
		}
		wait(7);
	}
	wait(15);
	ascent(n in 0..9)
	{
		PlaySound("Shot1",95,0);
		ascent(i in 0..num)
		{
			ascent(j in 0..2)
			{
				let angle = i*360/num-n*way+j*way;
				TShotA1(GetEnemyX+r*cos(angle),GetEnemyY+r*sin(angle),3,angle,71,8);
			}
		}
		if(way==1)
		{
			ascent(i in 0..num-10)
			{
				ascent(j in 0..2)
				{
					let angle = i*360/(num-10)-n*360/(num-10)*(10/18)*way+j*way;
					TShotA1(GetEnemyX+0*cos(angle),GetEnemyY+0*sin(angle),1.25,angle,71,8);
				}
			}
		}
		wait(7);
		
	}
}


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

task SizeCircle
{
	ascent(i in 0..60)
	{
		SetCommonData("CircleSize",sin(i*1.5));
		yield;
	}
}	

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

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