
#ScriptVersion[3]
#Title["NonSpell8"]
#Text["NonSpell8"]
#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];
let shot = [0,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(3500);
	}
	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(240);
	TShot2;
	}
//----------------------------------------------------

task TShot2{
		let s = 1;
		let o = 0;
		let spiral = 0;
		if(GetLevel=="Normal"){spiral = 12;}
		else if(GetLevel=="Extra"){spiral = 15;}
		while(!Obj_IsDeleted(objBoss)){
		smaple(0,270,50,-1.5,1,45);
		smaple(0,220,50,1.5,1,45);
		wait(75);
			ascent(n in 0..2+o){
			PlaySound("Shot1",90,0);
			PlaySound("BulletWave",90,90);
			ascent(i in 0..spiral){
				let ang =  rand(2,2.5)*s;
				ascent(j in 0..4){
				let shot = ShotA2(GetEnemyX,GetEnemyY,4,i*360/spiral+j*3,-4/120,1,103,0,12);
				ObjMove_SetAngularVelocity(shot,ang);
				ObjMove_AddPatternA2(shot,90,NO_CHANGE,NO_CHANGE,0,0,0);
				DelayShot(shot,87,2.5,0,12,90);
				}
				s = -s;
			}
			wait(30);
			}
			o++;
			wait(150);
		}
	}

task TShot1{
		SetCommonData("Difficulty","Extra");
		let dir = 0;
		let s = 1;
		let a = 0;
		let c = 0;
		smaple(0,270,50,-1.5,1,45);
		smaple(0,220,50,1.5,1,45);
		if(GetLevel=="Normal"){shot = [4,6,5];}
		else if(GetLevel=="Extra"){shot = [5,5,4];} //string,frequently,w
		wait(75);
		while(!Obj_IsDeleted(objBoss)){
		PlaySound("Shot6",90,0);
		a = rand(0.75,1.25)*s;
		ascent(i in 0..2){
		CurveShot(dir+i*180,a);
		}
		dir += 33;
		s = -s;
		c++;
		if(c%60==0){TAccel(35,5,0.05,60);}
		wait(shot[2]);
		}
				task	CurveShot(dir,ang){
				ascent(n in 0..shot[0]){
				let v = 2;
				let obj = ShotA2(GetEnemyX+60*cos(dir),GetEnemyY+60*sin(dir),v,dir,-v/180,0.5,104,0,12);
				ObjMove_SetAngularVelocity(obj,ang);
				ObjMove_AddPatternA2(obj,60,NO_CHANGE,NO_CHANGE,0.025,-ang/2,5);
				ObjMove_AddPatternA2(obj,185,NO_CHANGE,NO_CHANGE,0.025,0,5);
				wait(shot[1]);
				}
			}
	}
	
task Fam{
	ascent(i in 0..3){
	let ene = fam(GetEnemyX,GetEnemyY,25000,0.5,4,false);
	Control(ene,i,1);
	}
	ascent(i in 0..3){
	let ene = fam(GetEnemyX,GetEnemyY,25000,0.5,4,false);
	Control(ene,i,-1);
	}
		task Control(ene,num,way){
			let maxa = num*120;
			let ang = 0;
			let c = 0;
			let r = 0;
			while(!Obj_IsDeleted(ene)){
			if(ang<maxa){ang += maxa/120;}
			if(r<60 && way==1){r+=0.5;}
			if(r<120 && way==-1){r+=1;}
			ObjMove_SetPosition(ene,GetEnemyX+r*cos(ang*way+c),GetEnemyY+r*sin(ang*way+c));
			c+=way+0.125;
			yield;
			}
		}
	}

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

task TRender
{
	DrawBoss;
}

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

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