#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Horizontal\"Side Storm Arrows [Lunatic]\""]
#Text["SpellL"]
#Background["./BG.txt"]
#Player[DEFAULT]
#System["./system/Default_System2.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss.txt"
#include"./Shot/ZUNShot_Const.txt"
#include"./system/Default_Effect.Txt"


let objBoss;
let GCSD=GetCurrentScriptDirectory~"";
let enemy;
let bSpell=false;
let stgx=GetStgFrameWidth()/2;
let stgy=GetStgFrameHeight()/2;
let fog = 0;
let objScene=GetEnemyBossSceneObjectID();
let arr = [1,6,4,2,3,5,0];
let xis = 0;
let yis = 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(2000);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(3000000);
	}
}

//----------------------------------------------------
task mainTask{
	SetShotAutoDeleteClip(64,64,64,16);
	DamageRateAtFrame(50,0,180);
	DamageRateAtFrame(75,0,1380);
	magiccircle(objBoss,0.8,true);
	ObjMove_SetDestAtWeight(objBoss,stgx,140,10,7);
	Cutin("Horizontal\"Side Storm Arrows [Lunatic]\"",15);
	ObjEnemyBossScene_StartSpell(objScene);
	ang = 0;
	wait(60);
	TShot1;
	}
//----------------------------------------------------

task TShot1{
	let c = 0;
	let m = 0.5;
	let color = [411,413,414,415];
	let delaycolor = [235,237,238,239];
	maple(3);
	wait(120);
	while(!Obj_IsDeleted(objBoss)){
	PlaySound("Shot1",95,0);
	ascent(i in 0..4){
	ShotA1(15,rand(0,480),rand(1.5,3)+i,180+rand(-5,5),color[i],delaycolor[i],12);
	ShotA1(625,rand(0,480),rand(1.5,3)+i,180+rand(-5,5),color[i],delaycolor[i],12);
	}
	wait(4.5-m);
	c++;
	if(c%60==50){
	m = -m;
	TRotate2;
	}
	
	}
}

task TRotate{
	if(ang==180){ReverseAng;}
	maple(2);
	wait(70);
	PlaySound("Boon1",100,0);
	loop(60){
	Set2DCameraRatioX(cos(xis));
	xis+=3;
	yield;
	}
}

task TRotate2{
	maple(2);
	wait(70);
	ClearBullet(30,30);
	SetPlayerInvincibilityFrame(30);
	PlaySound("Boon1",100,0);
	loop(60){
		if(Obj_IsDeleted(objBoss)){break;}
		Set2DCameraRatioX(cos(xis));
		xis+=3;
		yield;
	}
}

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

task TRender
{
	DrawBoss;
}

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

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