
#ScriptVersion[3]
#Title["NonSpell6"]
#Text["NonSpell6"]
#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(3250);
	}
	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(180);
	TShot2;
	wait(240);
	TShot3;
	}
//----------------------------------------------------

task TShot3{
	let p =0;
	let spiral = 0;
	if(GetLevel=="Normal"){spiral = 18;}
	else if(GetLevel=="Extra"){spiral = 24;}
	while(!Obj_IsDeleted(objBoss)){
	smaple(0,-60,50,1.5,1,45);
	wait(75);
		ascent(i in 0..6){
			ascent(j in 0..spiral){
			ShotA2(GetEnemyX,GetEnemyY,4,i*60+j*1.5+p,-0.05,1,67,0,12);
			}
		}
	wait(60);
	TMovement(25,5,5);
	wait(60);
	p+=30;
	}
	}

task TShot2{
		let spiral = 0;
		if(GetLevel=="Normal"){spiral = 24;}
		else if(GetLevel=="Extra"){spiral = 36;}
		while(!Obj_IsDeleted(objBoss)){
			ascent(i in 0..spiral){
			ShotA2(GetEnemyX,GetEnemyY,5-(i%2)*2,i*360/spiral+angleToPlayer,-0.1,2,328,0,12);
			}
			wait(90);
		}
	}


task TShot1{
	//SetCommonData("Difficulty","Extra");
	let dir = 0;
	let r = 60;
	let c = 0;
	let p = 0;
	let s = 1;
	let count = 0;
	let ang = 0;
	let ang2 = 0;
	let ang3 = 0;
	let shot = [0,0];
	if(GetLevel=="Normal"){shot=[10,14];} // w,c
	else if(GetLevel=="Extra"){shot=[9,16,];}
	smaple(0,-90,40,1.5,1,45);
	wait(75);
		while(!Obj_IsDeleted(objBoss)){
			PlaySound("Shot1",85,0);
			ascent(i in 0..4){
			if(i%2==0){s=-1;}
			else{s=1;}
			ascent(j in 0..2){
			ang = i*90+p*s+45;
			ang2 = i*90-p*s+45;
			ang3 = i*90-p*s+45;
			ShotA2(GetEnemyX+r*cos(ang),GetEnemyY+r*sin(ang),1.25+j/2,ang,0.005,3.5,50,0,8);
			ShotA2(GetEnemyX+r*cos(ang2),GetEnemyY+r*sin(ang2),1.25+j/2,ang2,0.005,3.5,98,0,8);
				if(count>60){
				//if(c%4==0){ShotA2(GetEnemyX,GetEnemyY,1.5+j/4,i*60+angleToPlayer,0.01,3.5,324,0,8);}
				}
			}
			}
		if(c==shot[1]){
		c=0;
		}
		if(c<shot[1]/2){
		dir+=10;
		}
		if(c>=shot[1]/2){
		dir+=-10;
		}
		p +=17;
		c++;
		count++;
		wait(shot[0]);
		}
	}
	
task Fam{
	ascent(i in 0..4){
	let ene = fam(GetEnemyX,GetEnemyY,25000,0.5,3,false);
	Control(ene,i,1);
	}
	ascent(i in 0..4){
	let ene = fam(GetEnemyX,GetEnemyY,25000,0.5,3,false);
	Control(ene,i,-1);
	}
		task Control(ene,num,way){
			let maxa = num*90;
			let ang = 0;
			let c = 0;
			let r = 0;
			while(!Obj_IsDeleted(ene)){
			if(ang<maxa){ang += maxa/120;}
			if(r<60){r+=0.5;}
			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());
	}