
#ScriptVersion[3]
#Title["NonSpell4"]
#Text["NonSpell4"]
#Background["./BG.txt"]
#Player["./MoF_Reimu/Reimu.txt"]
#BGM["./Emotion.mp3"]
#System["./system/Default_System.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 idle = true;
let atk = false;
let fog = 0;
let objScene=GetEnemyBossSceneObjectID();
let arr = [1,6,4,2,3,5,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(3000);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
}

//----------------------------------------------------
task mainTask{
	DamageRateAtFrame(100,50,120);
	magiccircle(objBoss,0.8,true);
	ObjMove_SetDestAtWeight(objBoss,stgx,140,10,7);
	wait(30);
	Fam;
	wait(60);
	TShot1;
	wait(300);
	TShot2;
	}
//----------------------------------------------------

task TShot2{
	let s = 1;
	let p = 20;
	let w = 0;
	if(GetLevel=="Normal"){w=2;} // GREEN,Large,divide
	else if(GetLevel=="Extra"){w=3;}
	while(!Obj_IsDeleted(objBoss)){
	smaple(0,30+30*s,50,-1.5*s,1,45);
	wait(75);
		ascent(n in 0..12){
			ascent(i in 0..9){
			ShotA2(GetEnemyX,GetEnemyY,6-n/12,i*40+n+p,-0.2,2,70,0,8);
			ShotA2(GetEnemyX,GetEnemyY,6-n/12,i*40-n+p,-0.2,2,70,0,8);
			}
		wait(w);
		}
		p+=30;
		wait(75);
		TAccel(30,5,0.1,30);
		wait(75);
	}
	}

task TShot1{
	//SetCommonData("Difficulty","Extra");
	let dir = 0;
	let r = 60;
	let c = 0;
	let s = 1;
	let shot = [0,0];
	if(GetLevel=="Normal"){shot=[1,1];} // GREEN,Large,divide
	else if(GetLevel=="Extra"){shot=[2,2,];}
	smaple(0,-240,40,-1.5,1,45);
	wait(75);
		while(!Obj_IsDeleted(objBoss)){
			PlaySound("Shot1",85,0);
			ascent(i in 0..6){
			ascent(j in 0..shot[0]){
			ShotA2(GetEnemyX+r*cos(i*60),GetEnemyY+r*sin(i*60),1+j/2.5,i*60+dir+j*1,0.02,2.2,101,0,8);
			ShotA2(GetEnemyX+r*cos(i*60),GetEnemyY+r*sin(i*60),1+j/2.5,i*60-dir-j*1,0.02,2.2,101,0,8);
			}
			}
		if(c==16){c=0;}
		if(c<8){
		dir+=12;
		}
		if(c==8){
			ascent(i in 0..15){
			ascent(a in 0..shot[1]){
			let shot = ShotA2(GetEnemyX,GetEnemyY,1+a/2,i*24+angleToPlayer+a*12,0.01,5,299,0,8);
			ObjMove_SetAngularVelocity(shot,1*s);
			ObjMove_AddPatternA2(shot,60,NO_CHANGE,NO_CHANGE,0,0,0);
			}
			}
			s = -s;
		}
		if(c>=8){
		dir+=-12;
		}
		c++;
		wait(8);
		}
	}

task Fam{
	ascent(i in 0..5){
	let ene = fam(GetEnemyX,GetEnemyY,25000,0.5,2,false);
	Control(ene,i);
	}
		task Control(ene,num){
			let maxa = num*72;
			let ang = 0;
			let c = 0;
			let r = 0;
			while(!Obj_IsDeleted(ene)){
			if(ang<maxa){ang += maxa/120;}
			if(r<90){r++;}
			ObjMove_SetPosition(ene,GetEnemyX+r*cos(-ang-c),GetEnemyY+r*sin(-ang-c));
			c+=0.5;
			yield;
			}
		}
	}

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

task TRender
{
	DrawBoss;
}

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

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