#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["SP1"]
#Text["SP1"]
#Background["./BG.txt"]
#Player[DEFAULT]
#System["./system/Default_System.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 s = 1;
let objScene=GetEnemyBossSceneObjectID();
let arr = [1,6,4,2,3,5,0];
@Initialize
{
SetBoss(true);
SetCommonData("Bomb",1);
}

@MainLoop
{
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),25);
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),26);
	yield;

}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		SetScriptResult(1750);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(3000000);
	}
}

//----------------------------------------------------
task mainTask{
	DamageRateAtFrame(50,25,240);
	DamageRateAtFrame(75,25,900);
	magiccircle(objBoss,0.8,true);
	ObjMove_SetDestAtWeight(objBoss,stgx,130,10,7);
	Cutin("First Card\"Harvest Festival\"",15,"SHOU");
	ObjEnemyBossScene_StartSpell(objScene);
	wait(60);
	TShot1;
	wait(720);
	TShot2;
	}
//----------------------------------------------------

task TShot1{
	let c = 0;
	maple(1);
	wait(100);
	while(!Obj_IsDeleted(objBoss)){
		let px = 0;
		let py = stgy+210*sin(c*7);
		PlaySound("Shot1",90,0);
			ascent(i in 0..4){
			ShotA2(px,py,1.75+0.25*sin(c*7),i*90-c*19,0,0,51,202,8);
			}
			px = 384;
			py = stgy-210*sin(c*7);
			ascent(i in 0..4){
			ShotA2(px,py,1.75+0.25*sin(c*7),i*90+c*19,0,0,59,206,8);
			}
			wait(5);
			c++;
			if(c%40==0){TMovement(35,5,3);}
	}
}

task TShot2{
	ObjMove_SetDestAtWeight(objBoss,stgx,130,10,3);
	while(!Obj_IsDeleted(objBoss)){
	PlaySound("Shot6",95,0);
	ascent(i in 0..6){
	AimOval(i*60,0);
	}
	wait(25);
	PlaySound("Shot6",95,0);
	ascent(i in 0..6){
	AimOval(i*60,45);
	AimOval(i*60,-45);
	}
	wait(25);
	}
		task AimOval(dir,sig){
		let shot = ShotA2(GetEnemyX,GetEnemyY,3,dir,-3/30,0,314,0,8);
		wait(30);
		PlaySound("BulletWave",95,0);
		ObjMove_AddPatternA1(shot,0,4,GetAngleToPlayer(shot)+sig);
		}
}

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

task TRender
{
	DrawBoss;
}

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

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