
#ScriptVersion[3]
#Title["NonSpell2"]
#Text["NonSpell2"]
#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(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 = 0;
	while(!Obj_IsDeleted(objBoss)){
	smaple(0,90+30*-1,50,-1.5*-1,1,45);
	wait(75);
		ascent(n in 0..12){
			PlaySound("Shot3",90,0);
			if(GetLevel=="Extra"){
			ascent(a in 0..6){
			let v = 6+a/1;
				ascent(i in 0..6){
				ShotA2(GetEnemyX,GetEnemyY,v,i*60+n*1*s+p,-v/20,v/3,60,0,12);
				}
			}
			}
			else if(GetLevel=="Normal"){
				let v = 9;
				ascent(i in 0..6){
				ShotA2(GetEnemyX,GetEnemyY,v,i*60+n*1*s+p,-v/20,v/3,301,0,12);
				}
			}
			wait(2);
		}
		wait(90);
		TAccel(30,5,0.1,30);
		wait(90);
		s = -s;
		p+=47;
		}
	}

task TShot1{
	//SetCommonData("Difficulty","Normal");
	let dir = 0;
	let r = 60;
	let c = 0;
	let shot = [0,0];
			if(GetLevel=="Normal"){shot=[1,3,2];} // RED,OVAL,divide
			else if(GetLevel=="Extra"){shot=[2,5,2.5];}
	smaple(0,-60,50,-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),2,i*60+dir+j*2,0.02,2.5,92,0,8);
			ShotA2(GetEnemyX+r*cos(i*60),GetEnemyY+r*sin(i*60),2,i*60-dir-j*2,0.02,2.5,92,0,8);
			}
			}
		if(c==16){c=0;}
		if(c<8){
		dir+=10;
		}
		if(c==8){
			ascent(i in 0..12){
			ascent(a in 0..shot[1]){
			ShotOA1(objBoss,1+a/shot[2],i*30+angleToPlayer,334,0,8);
			}
			}
		}
		if(c>=8){
		dir+=-10;
		}
		c++;
		wait(9);
		}
	}

task Fam{
	ascent(i in 0..5){
	let ene = fam(GetEnemyX,GetEnemyY,25000,0.5,1,false);
	Control(ene,i);
	}
		task Control(ene,num){
			let maxang = num*72;
			let ang = 0;
			let c = 0;
			let r = 0;
			while(!Obj_IsDeleted(ene)){
			if(ang<maxang){ang += maxang/120;}
			if(r<90){r++;}
			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());
	}