#“Œ•û’e–‹•—[Single]
#ScriptVersion[3]
#Title["NonSpell4"]
#Text["NonSpell4"]
#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();
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(3750);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
}

//----------------------------------------------------
task mainTask{
	magiccircle(objBoss,0.8,true);
	ObjMove_SetDestAtWeight(objBoss,stgx,120,10,7);
	wait(90);
	TMove;
	wait(60);
	ObjEnemy_SetDamageRate(objBoss,92,50);
	}
//----------------------------------------------------

task TMove{
	let s = 1;
	let way = 1;
	while(!Obj_IsDeleted(objBoss)){
	loop(2){
	maple(2);
	ObjMove_SetDestAtWeight(objBoss,stgx-120*way,60,10,7);
	wait(50);
	AccelMove(objBoss,stgx+60*way,600,0.1,90);
	ascent(n in 0..20){
	PlaySound("BulletWave",95,0);
	let dir = ObjMove_GetAngle(objBoss)+180;
	let shot = ShotA2(GetEnemyX,GetEnemyY,2,dir,-2/60,0,251+n%7,0,12);
	Cluster(shot,dir,n%7,n,s);
	s = -s;
	wait(6);
	}
	ObjMove_SetPosition(objBoss,stgx+60*way,-120);
	ObjMove_SetDestAtWeight(objBoss,stgx+120*way,60,10,7);
	wait(75);
	ObjMove_SetDestAtWeight(objBoss,stgx+60*way,60,10,1);
	ascent(n in 0..14){
	ascent(i in 0..7){
	let dir = angleToPlayer-60+i*20;
	PlaySound("Shot6",95,0);
	let shot = ShotA2(GetEnemyX,GetEnemyY,4,dir,-4/60,0,91+n%7,0,8);
	Spread(shot,n%7);
	}
	wait(7+way);
	}
	way = -way;
	}
	wait(30);
	ObjMove_SetDestAtWeight(objBoss,stgx,150,10,1);
	ascent(n in 0..3){
		PlaySound("Shot6",95,0);
		ascent(i in 0..24){
		ShotOA1(objBoss,1+n,i*15+n*7.5,138,0,4+n*4);
		}
		ascent(i in 0..9){
		ShotOA1(objBoss,1.5+n,i*40+n*20,258,0,8+n*8);
		}
		wait(20);
	}
	maple(2);
	wait(50);
	s = 1;
	loop(2){
	ascent(i in 0..6){
	PlaySound("Eff2",90,0);
	let ene = fam(GetEnemyX,GetEnemyY,200,arr[i],false);
	Control(ene,i,s);
	wait(4);
	}
	s = -s;
	}
	wait(30);
	PlaySound("Eff1",100,0);
	ascent(a in 0..6){
	ascent(i in 0..12){
	let shot = ShotOA1(objBoss,0.5+a/2.5,i*30+a*13*s,251+a,0,2+a*3);
	ObjMove_SetAngularVelocity(shot,a/9*s);
	}
	s = -s;
	}
	wait(45);
	PlaySound("Laser5",100,60);
	ascent(i in 0..18){
	let obj = CreateStraightLaserA1(GetEnemyX,GetEnemyY,i*20+5,0,25,60,141+i%6,60);
	SetLaser(obj);
	}
	wait(120);
	maple(1);
	wait(100);
	AccelMove(objBoss,stgx,60,0.1,60);
	descent(n in 0..12){
	PlaySound("Eff1",95,0);
	ascent(i in 0..9){
	ShotOA1(objBoss,0.75+n/4,i*40+n*17,259,0,8);
	ShotOA1(objBoss,0.75+n/4,i*40-n*11,139,0,8);
	}
	wait(5);
	}
	wait(90);
	}
		task SetLaser(obj){
		ascent(i in 0..60){
		ObjLaser_SetLength(obj,i*7.5);
		yield;
		}
		wait(65);
		descent(i in 0..25){
		ObjLaser_SetRenderWidth(obj,i);
		ObjLaser_SetIntersectionWidth(obj,i);
		yield;
		}
		}
		task Control(ene,num,s){
		ObjMove_AddPatternA2(ene,0,7+s*2,num*60,-0.25,2*s,0);
		let color = ReturnColor(num);
		wait(30);
		PlaySound("Shot1",95,0);
		let dir = rand(0,360/7);
		ascent(i in 0..7){
			ascent(a in 0..2){
				ShotOA1(ene,0.75+a,i*360/7+dir,41+num,0,4+a*2);
			}
		}
		ObjEnemy_SetLife(ene,0);
		}
		task Spread(shot,num){
			wait(60);
			if(!Obj_IsDeleted(shot)){
			ascent(i in 0..3){
			let dir = GetAngleToPlayer(shot)-45+i*45;
			ShotA2(ObjMove_GetX(shot),ObjMove_GetY(shot),0,dir,0.075,3.5+num/2,91+num,0,8);
			}
			fragment(shot,0,1);
			Obj_Delete(shot);
			}
		}
		task Cluster(shot,dir,num,t,s){
		wait(60);
		if(!Obj_IsDeleted(shot)){
				ascent(i in 0..5){
				ShotOA1(shot,0.5+t/12,i*72-t*17*way,51+num,0,8);
				ShotOA1(shot,0.5+i/5,dir+90*s,101+num,0,8);
				}
			let obj = ShotOA1(shot,0,0,31+num,0,8);
			Cluster2(obj);
			fragment(shot,0,1);
			Obj_Delete(shot);
			}
				task Cluster2(obj){
					wait(60);
					if(!Obj_IsDeleted(obj)){
						ascent(i in 0..7){
						ShotOA1(obj,0.5+t/15,i*360/7-t*17*way,131+num,0,8);
					}
					fragment(obj,0,1);
					Obj_Delete(obj);
					}
				}
		}
	}
	
//----------------------------------------------------

task TRender
{
	DrawBoss;
}

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

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