#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Hecatia Overdrive 1"]
#Text["Hecatia Overdrive 1"]
#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",true);
SetPlayerLife(0);
SetPlayerSpell(0);
}

@MainLoop
{
	if(GetPlayerState==STATE_END){CloseStgScene();}
	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(2000);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(50);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(35000000);
	}
}

//----------------------------------------------------
task mainTask{
	ObjMove_SetDestAtWeight(objBoss,stgx,120,10,15);
	SetCommonData("CircleSize",0);
	magiccircle(objBoss,1,-1);
	DamageRateAtFrame(50,25,180);
	Cutin("\"Hellish Glory Maelstrom [Overdrive]\"",15,"SHINKI");
	HellSet2;
	ObjEnemyBossScene_StartSpell(objScene);
	wait(1500);
	DamageRateAtFrame(75,40,0);
	yield;
	}

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

task HellSet2
{
	let r = 30;
	let num =20;
	let num2 = 200;
	let curve = 0.5;
	let acc = 0.05;
	let multi = 10;
	let c = 0;
	let c2 = 0;
	let count = 0;
	wait(60);
	maple;
	wait(70);
	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,833,acc,curve*sin(count*10),12);
		}
		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>7 && i%20<13)
			{
				TrickyBullet(GetEnemyX+r*cos(angle),GetEnemyY+r*sin(angle),1,angle,832,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 TEnd{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){yield;}
		EndBoss(1);
		yield;
		CloseScript(GetOwnScriptID());
	}