#“Œ•û’e–‹•—[Single]
#ScriptVersion[3]
#Title["NonSpell2"]
#Text["NonSpell2"]
#Background["./BG.txt"]
#Player[DEFAULT]
#BGM["./theme.mp3"]
#System["./system/Default_System.txt"]
#Player["./MoF_Reimu/Reimu.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss.txt"
#include"script/Marisa/Shot/Default_ShotConst.txt"
#include"script/Default_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();
@Initialize
{
SetBoss;
}

@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{
	magiccircle(objBoss,0.8,true);
	ObjMove_SetDestAtWeight(objBoss,stgx,130,10,7);
	wait(90);
	ObjEnemy_SetDamageRate(objBoss,100,50);
	TShot1;
	}
//----------------------------------------------------

task TShot1{
	let way = 1;
	let v = 0;
	let acc = 0;
	let dir = 0;
	let s = 1;
	while(!Obj_IsDeleted(objBoss)){
	AccelMove(objBoss,stgx-175*way,75,1,5);
	maple(2);
	wait(60);
	AccelMove(objBoss,stgx+350*way,200,0.1,90);
	ascent(n in 0..30){
	PlaySound("BulletWave",90,0);
	ascent(i in 0..2){
	v = 0.25+n/10;
	acc = -v/60;
	dir = ObjMove_GetAngle(objBoss)-90+i*180;
	let shot = ShotA2(GetEnemyX,GetEnemyY,v,dir,acc,0,251+n%8,0,12);
	Cluster(shot,v,n%8,1);
	}
	if(n%3==2){
	ascent(i in 0..3){
	ascent(a in 0..6){
	ShotA2(GetEnemyX,GetEnemyY,0,angleToPlayer-40+i*40,0.01+a/100,10,138,0,6);
	}
	}
	}
	wait(4);
	}
	wait(30);
	ObjMove_SetPosition(objBoss,stgx-350*way,200);
	AccelMove(objBoss,stgx+350*way,75,0.1,90);
	wait(30);
	descent(n in 0..30){
	PlaySound("BulletWave",90,0);
	ascent(i in 0..2){
	v = 0.25+n/15;
	acc = -v/60;
	dir = ObjMove_GetAngle(objBoss)-90+i*180;
	let shot = ShotA2(GetEnemyX,GetEnemyY,v,dir,acc,0,251+n%8,0,12);
	Cluster(shot,v,n%8,-1);
	}
	wait(4);
	}
	wait(30);
	ObjMove_SetPosition(objBoss,stgx-350*way,200);
	AccelMove(objBoss,stgx-150*way,75,0.2,30);
	wait(60);
	descent(n in 3..6){
	PlaySound("Shot1",90,0);
	ascent(i in 0..9){
	ascent(a in 0..6){
	ShotA1(GetEnemyX+n*10*cos(i*40+a*n*s),GetEnemyY+n*10*sin(i*40+a*n*s),a/6+n/6,i*40+a*n*s,31+n%8,0,12);
	}
	}
	s = -s;
	wait(10);
	}
	AccelMove(objBoss,stgx-350*way,75,0.1,30);
	wait(30);
	ObjMove_SetPosition(objBoss,stgx+350*way,75);
	AccelMove(objBoss,stgx-350*way,75,0.2,30);
	wait(45);
	ascent(n in 0..7){
	PlaySound("byoro07",90,0);
	let enemy = fam(GetEnemyX,GetEnemyY,200,n,true);
	Control(enemy);
	wait(10);
	}
	wait(90);
	ObjMove_SetPosition(objBoss,stgx,-50);
	ObjMove_SetDestAtWeight(objBoss,stgx,120,10,6);
	wait(60);
	ascent(a in 0..8){
	PlaySound("Shot1",85,0);
	ascent(i in 0..18){
	ShotA1(GetEnemyX,GetEnemyY,0.5+a/2.5,i*20+a*11*s,251+a,0,2+a*4);
	}
	wait(5);
	}
	if(s==1){
	wait(60);
	ascent(a in 0..8){
	PlaySound("Shot1",85,0);
	ascent(i in 0..5){
	ShotA1(GetEnemyX,GetEnemyY,0.5+a/2.5,angleToPlayer-5+i*2.5,251+a,0,2+a*4);
	}
	wait(4);
	}
	}
	wait(90);
	way = -way;
	}
		task Cluster(shot,v,num,type){
		wait(60);
		fragment(shot,0.25,3);
		if(!Obj_IsDeleted(shot)){
		ascent(i in 0..5){
		ShotOA1(shot,v,i*360/5+num*19*way,131+num,0,8);
		}
		}
		Obj_Delete(shot);
		}
		task Control(obj){
		let shot = CreateStraightLaserA1(ObjMove_GetX(obj),ObjMove_GetY(obj),90,0,30,60,149,60);
		let time = 0;
		Manage(obj,shot);
		PlaySound("Shot6",90,60);
		wait(150);
		ObjEnemy_SetLife(obj,0);
		}
	}

	task Manage(enemy,obj){
	PlusL;
	Source;
	task PlusL{
		ascent(i in 0..30){
		ObjLaser_SetLength(obj,i*15);
		yield;
		}
	}
	task Source{
		while(!Obj_IsDeleted(enemy)){
		let dummy = ShotOA1(enemy,0,0,168,0,6);
		ObjShot_SetDeleteFrame(dummy,0);
		yield;
		}
		Obj_Delete(obj);
	}
	}

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

task TRender
{
	DrawBoss;
}

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

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