#“Œ•û’e–‹•—[Single]
#ScriptVersion[3]
#Title["NonSpell"]
#Text["NonSpell"]
#Background["./BG.txt"]
#Player[DEFAULT]
#BGM["./theme.mp3"]
#System["./system/Default_System.txt"]
#Player["./MoF_Reimu/Reimu.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss.txt"
#include"script/Marisa/Shot/Default_ShotConst.txt"
#include"script/Default_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 objScene=GetEnemyBossSceneObjectID();
let arr = [1,6,4,2,3,5,0];
@Initialize
{
SetBoss;
}

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

//----------------------------------------------------
task mainTask{
	magiccircle(objBoss,0.8,true);
	ObjMove_SetDestAtWeight(objBoss,stgx,150,10,7);
	wait(120);
	TShot1;
	}
//----------------------------------------------------

task TShot1{
	PlaySound("Eff5",100,0);
	ascent(i in 0..6){
	let enemy = fam(GetEnemyX,GetEnemyY,300,arr[i],false);
	Control(enemy,i*360/6,60,i,1);
	}
	ascent(i in 0..6){
	let enemy = fam(GetEnemyX,GetEnemyY,300,arr[i],false);
	Control(enemy,i*360/6,120,i,-1);
	}
	wait(60);
	ObjEnemy_SetDamageRate(objBoss,100,50);
	}
	
	task Control(ene,angle,rs,num,way){
	let r = 0;
	let c = 0;
	let s = 1;
	let acc = 3;
	let d = 0;
	let color = [31,32,33,34,35,37,38];
	let color2 = [131,132,133,134,135,137,138];
	let count = 0;
	Fire;
	while(!Obj_IsDeleted(ene)){
	ObjMove_SetPosition(ene,GetEnemyX+r*cos(angle+c*3*way),GetEnemyY+r*sin(angle+c*3*way));
	if(r<rs){r+=3;}
	c+=acc;
	count++;
	if(acc>0.5){acc -= 0.03;}
	if(count>7800){ObjEnemy_SetLife(ene,0);}
	yield;
	}
		task Fire{
		if(way==1){
		wait(360);
			while(!Obj_IsDeleted(ene)){
				PlaySound("Shot8",95,0);
				ascent(n in 0..15){
				ascent(i in 0..6){
				ShotOA1(ene,0.75+n/5,GetAngleToPlayer(ene)+i*60,color[num],0,8);
				}
				wait(4);
				}
				wait(120);
				TMovement(35,5,5);
				wait(120);
			}
		}
		else{
		wait(120);
			while(!Obj_IsDeleted(ene)){
			ascent(i in 0..2){
			PlaySound("Shot1",85,0);
			ShotOA1(ene,1+0.5*sin(d/4),i*180+d*s,color2[num],0,8);
			wait(7);
			}
			if(d%340==0){s=-s;}
			d+=17;
			}
		}
		}
	}

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

task TRender
{
	DrawBoss;
}

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

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