
#ScriptVersion[3]
#Title["N2L"]
#Text["Easy"]
#Background["./BG.txt"]
#Player[DEFAULT]
#System["./system/Default_System.txt"]
#include"./Functions/Index.txt"
#include"./SetMidBoss.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(2500);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(3000000);
	}
}

//----------------------------------------------------
task mainTask{
	DamageRateAtFrame(100,50,120);
	magiccircle(objBoss,0.8,true);
	ObjMove_SetDestAtWeight(objBoss,stgx,140,10,7);
	wait(90);
	TShot1;
	}
//----------------------------------------------------

task TShot1{
	let s = 1;
	let c = 0;
	maple(2);
	wait(30);
	while(!Obj_IsDeleted(objBoss)){
	Action(40);
	wait(30);
	PlaySound("Laser2",97,0);
	ascent(i in 0..24){
		ascent(j in 0..2){
		let shot = CurvyLaser(GetEnemyX,GetEnemyY-30,5,i*15+j*5*s,5,30,501,0);
		ObjMove_AddPatternA2(shot,0,NO_CHANGE,NO_CHANGE,-0.1,0,-5.5);
		ObjMove_AddPatternA2(shot,55,NO_CHANGE,i*15+j*5*s+15*s,-0.15,0,-5.5);
		}
	}
	wait(45);
	if(s==-1){
	TMovement(35,5,5);
	}
	if(c==1){TShot2;}
	wait(45);
	s = -s;
	c++;
	}
	}
	
task TShot2{
	while(!Obj_IsDeleted(objBoss)){
		PlaySound("BulletWave",90,0);
		let ang = rand(0,360);
		let r = rand(30,60);
		let angb = rand(0,360);
			ascent(a in 0..5){
			ShotA1(GetEnemyX+r*cos(angb)+a*10*cos(ang),GetEnemyY+r*sin(angb)+a*10*sin(ang),3,ang+90,46,235,12);
			}
			ang += 180;
			ascent(a in 0..5){
			ShotA1(GetEnemyX+r*cos(angb)+a*10*cos(ang),GetEnemyY+r*sin(angb)+a*10*sin(ang),3,ang+90,46,235,12);
			}
			wait(5);
		}
	}

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

task TRender
{
	DrawBoss;
}

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

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