#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["S3"]
#Text["S3"]
#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"
#BGM["./boss6.mp3"]


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 objScene=GetEnemyBossSceneObjectID();
let color = [0,0];
@Initialize
{
SetBoss(false);
}

@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(2500);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(50);
	}
}

//----------------------------------------------------
task mainTask{
	DamageRateAtFrame(100,50,120);
	Circle(64,64,64,10);
	ObjMove_SetDestAtWeight(objBoss,stgx,150,10,7);
	wait(30);
	maple(1);
	wait(60);
	Pipe;
	PlaySound("Shot1",100,30);
	wait(75);
	TShot1;
	}
//----------------------------------------------------

task TShot1{
		let s = 1;
		color = [91,206];
		while(!Obj_IsDeleted(objBoss)){
		ascent(m in 0..2){
		ascent(n in -4..5){
			PlaySound("Shot1",90,0);
			let px = GetEnemyX-70;
			let py = GetEnemyY-20;
			ascent(i in 0..3){AimShot(px,py,180+i*20,20-i*20+n*10*s);}
			px = GetEnemyX-60;
			py = GetEnemyY-46;
			ascent(i in 0..3){AimShot(px,py,195+i*20,20-i*20+n*10*s);}
			px = GetEnemyX+55;
			py = GetEnemyY-12;
			ascent(i in 0..3){AimShot(px,py,360-i*20,-20+i*20+n*10*s);}
			px = GetEnemyX+60;
			py = GetEnemyY-46;
			ascent(i in 0..3){AimShot(px,py,345-i*20,-20+i*20+n*10*s);}
			wait(3);
		}
		s = -s;
		}
		s = -s;
		if(s==1){color = [91,206];}
		else{color = [89,205];}
		wait(30);
		}
		
		
			task AimShot(x,y,dir,sig){
			let shot = ShotA2(x,y,4,dir,-4/60,0,color[0],color[1],8);
			wait(60);
			PlaySound("BulletWave",90,0);
			ObjMove_AddPatternA1(shot,0,4.5,GetAngleToPlayer(shot)+sig);
			}
	}

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

task TRender
{
	DrawBoss;
}

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

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