
#ScriptVersion[3]
#Title["NonSpell7"]
#Text["NonSpell7"]
#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(90);
	TShot1;
	}
//----------------------------------------------------

task TShot1{
	//SetCommonData("Difficulty","Extra");
	let n = 0;
	let shot = [0,0];
	smaple(0,90,40,-1.5,1,45);
	wait(60);
	TMovement(15,5,5);
	wait(30);
	if(GetLevel=="Normal"){shot = [9,23];}
	else if(GetLevel=="Extra"){shot = [12,17];}
	while(!Obj_IsDeleted(objBoss)){
	PlaySound("Shot6",90,0);
	ascent(i in 0..shot[0]){
	Shot(i*360/shot[0]+n*shot[1]);
	}
	n++;
	wait(40);
	if(n%4==0){
	TMovement(15,5,5);}
	wait(40);
	}
		task Shot(ang){
			ascent(i in 0..2){
				let shot = ShotA2(GetEnemyX,GetEnemyY,5,ang-2+i*4,-5/30,5/3,100,0,8);
				Manage(shot,5);
				shot = ShotA2(GetEnemyX,GetEnemyY,4,ang-2+i*4,-4/30,4/3,100,0,8);
				Manage(shot,4);
			}
			ascent(i in 0..3){
				let shot = ShotA2(GetEnemyX,GetEnemyY,4.5,ang-4+i*4,-4.5/30,4.5/3,100,0,8);
				Manage(shot,4.5);
			}
		}
			task Manage(shot,v){
			let a = 1.5;
			while(ObjMove_GetX(shot)>0 && ObjMove_GetX(shot)<384){yield;}
			ObjMove_AddPatternA2(shot,0,NO_CHANGE,NO_CHANGE,NO_CHANGE,0,v/4);
			ObjMove_SetAngle(shot,180-ObjMove_GetAngle(shot));
			DelayShot(shot,99,2,128,20,0);
			PlaySound("BulletWave",90,0);
			loop(15){
			ObjMove_SetSpeed(shot,ObjMove_GetSpeed(shot)*a);
			a-= 0.1;
			yield;
			}
			}
	}

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

task TRender
{
	DrawBoss;
}

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

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