#“Œ•û’e–‹•—[Single]
#ScriptVersion[3]
#Title["NonSpell3"]
#Text["NonSpell3"]
#Background["./BG.txt"]
#Player[DEFAULT]
#BGM["./Magician.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();
let arr = [1,6,4,2,3,5,0];
@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(3000);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
}

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

task TShot1{
	PlaySound("Eff5",100,0);
	ascent(i in 0..6){
	let enemy = fam(GetEnemyX,GetEnemyY,200,arr[i],false);
	Control(enemy,i,1);
	}
	let s = -1;
	wait(240);
	while(!Obj_IsDeleted(objBoss)){
	PlaySound("Eff5",100,0);
	ascent(i in 0..6){
	let enemy = fam(GetEnemyX,GetEnemyY,200,arr[i],false);
	Control2(enemy,i,s);
	}
	wait(240);
		s = -s;
	PlaySound("Eff5",100,0);
	ascent(i in 0..6){
	let enemy = fam(GetEnemyX,GetEnemyY,200,arr[i],false);
	Control2(enemy,i,s);
	}
	wait(120);
	TMovement(50,5,5);
	wait(120);
	}
	}

task Control(ene,num,way){
	let v = -4;
	let c = 0;
	let count = 0;
	let r = 0;
	let color2 = [131,132,133,134,135,137,138];
	ManageSpeed;
	task ManageSpeed{
		loop(90){
		r+=1.5;
		v += 0.12;
		yield;
		}
		Fire;
	}
	while(!Obj_IsDeleted(ene)){
	ObjMove_SetPosition(ene,GetEnemyX+r*cos(num*60+c),GetEnemyY+r*sin(num*60+c));
	c+=v*way;
	count++;
	yield;
	}
	task Fire{
	let dir = 0;
		while(!Obj_IsDeleted(ene)){
		dir += 3;
		PlaySound("Shot1",88,0);
		PlaySound("Shot1",88,4);
		ascent(a in 0..1){
		ShotOA1(ene,a+1.5,num*60+dir,color2[num],0,8);
		}
		wait(8);
		}
	}
	}
	
task Control2(ene,num,way){
	let c = 0;
	let x = ObjMove_GetX(ene);
	let y = ObjMove_GetY(ene);;
	ObjMove_AddPatternA2(ene,0,0,num*60,0.05,0.5*way,5);
	while(x>0 && x<stgx*2 && y>0 && y<stgy*2){
	x = ObjMove_GetX(ene);
	y = ObjMove_GetY(ene);
	yield;
	}
	let obj;
	if(y>=stgy*2){obj = CreateStraightLaserA1(ObjMove_GetX(ene),ObjMove_GetY(ene),270,400,20,15,141+num,75);}
	else{obj = CreateStraightLaserA1(ObjMove_GetX(ene),ObjMove_GetY(ene),GetAngleToPlayer(ene),400,20,30,141+num,75);}
			SetLaser(obj);
			 task SetLaser(obj){
				PlaySound("Laser6",95,75);
				ascent(i in 0..105){
				ObjMove_SetSpeed(ene,0);
				let dummy =  ShotOA1(obj,0,0,21+num,0,6);
				ObjShot_SetDeleteFrame(dummy,0);
				if(Obj_IsDeleted(ene)){Obj_Delete(obj);}
				if(ObjLaser_GetLength(obj,)<600){ObjLaser_SetLength(obj,i*15);}
				ObjLaser_SetRenderWidth(obj,rand(18,21));
				yield;
				}
				Obj_Delete(ene);
			 }
	}

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

task TRender
{
	DrawBoss;
}

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

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