
#ScriptVersion[3]
#Title["NonSpell9"]
#Text["NonSpell9"]
#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
{
//StartItemScript(GCSD ~"Item.txt");
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(3250);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
}

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

task TShot1{
	//SetCommonData("Difficulty","Extra");
	let dir = 0;
	let n = 0;
	let s = 1;
	let d = 0;
	let w = [0,0];
	if(GetLevel=="Normal"){w=[5,32];}
	else if(GetLevel=="Extra"){w=[5,40];}
	smaple(0,180,30,-1.5,1,45);
	smaple(0,-30,30,1.5,1,45);
	wait(75);
			while(!Obj_IsDeleted(objBoss)){
			PlaySound("Shot6",90,0);
			ascent(i in 0..2){
			dir = 180*i+d;
			Shot(dir);
			}
			n++;
			d+= 21*s;
			if(n%w[1]==21){
			Ball(n*13);
			s = -s;
			}
			wait(w[0]);
			}
			task Ball(dir){
			ascent(n in 0..10){
			PlaySound("Eff1",90,0);
			let v = rand(2,3);
			let shot = ShotA2(GetEnemyX,GetEnemyY,v,n*36*s+dir,-v/120,0.5,399+n,0,12);
			EffShot(shot);
			if(GetLevel=="Extra"){
			Homing(shot,0.45,0,0);
			}
			ObjMove_AddPatternA2(shot,120,NO_CHANGE,NO_CHANGE,0.02,0,6);
			wait(10);
			}
			}
}

task EffShot(shot){
	while(!Obj_IsDeleted(shot)){
	spongy(shot,0.05,10);
	wait(8);
	}
	}

		task Shot(ang){
			ascent(i in 0..2){
				let shot = ShotA2(GetEnemyX,GetEnemyY,6,ang-1.5+i*3,-6/30,6/2,272,0,8);
				shot = ShotA2(GetEnemyX,GetEnemyY,5,ang-1.5+i*3,-5/30,5/2,272,0,8);
			}
			ascent(i in 0..3){
				let shot = ShotA2(GetEnemyX,GetEnemyY,5.5,ang-3+i*3,-5.5/30,5.5/2,271,0,8);
			}
		}

task Fam{
	ascent(i in 0..8){
	let ene = fam(GetEnemyX,GetEnemyY,25000,0.5,i%4+1,false);
	Control(ene,i);
	}
		task Control(ene,num){
			let maxang = num*45;
			let ang = 0;
			let c = 0;
			let r = 0;
			while(!Obj_IsDeleted(ene)){
			if(ang<maxang){ang += maxang/120;}
			if(r<60){r+=0.5;}
			ObjMove_SetPosition(ene,GetEnemyX+r*cos(ang+c),GetEnemyY+r*sin(ang+c));
			c+=1;
			yield;
			}
		}
	}

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

task TRender
{
	DrawBoss;
}

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

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