
#ScriptVersion[3]
#Title["NonSpell3L"]
#Text["NonSpell3L"]
#Background["./BG.txt"]
#Player[DEFAULT]
#System["./system/Default_System.txt"]
#Player["./MoF_Reimu/Reimu.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss.txt"
#include"./Shot/Default_ShotConst.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 slash = 1;
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(4000);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
}

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

task TFam{
	PlaySound("Eff5",100,0);
	let enemy = fam(GetEnemyX,GetEnemyY,200,2,false);
	Control(enemy,1);
	enemy = fam(GetEnemyX,GetEnemyY,200,2,false);
	Control(enemy,-1);
			task Control(obj,way){
		let c=0;
		Bullet;
		while(!Obj_IsDeleted(obj)){
		ObjMove_SetDestAtWeight(obj,GetEnemyX+120*cos(c*1.5+90-90*way),GetEnemyY+120*sin(c*1.5+90-90*way),10,7);
		c+= 1*way;
		yield;
		}
			task Bullet{
				let dir = 0;
				wait(60);
				while(!Obj_IsDeleted(obj)){
					ascent(i in 0..6){
					PlaySound("BulletWave",90,0);
					let shot = ShotA2(ObjMove_GetX(obj),ObjMove_GetY(obj),5,i*60-dir,-5/15,0,13+slash,0,8);
					ObjMove_AddPatternB2(shot,10,NO_CHANGE,NO_CHANGE,0,0.015,0,3);
					if(slash==2){
					dir += 3*way;
					wait(4);
					}
					}
					dir += 11*way;
					if(slash==1){wait(24);}
				}
			}
	}
	}
	
task TShot1{
		let px = 0;
		let py = 0;
		while(!Obj_IsDeleted(objBoss)){
		maple(2);
		wait(25);
		attack(30,30,1);
		wait(30);
		ascent(n in 0..30){
		PlaySound("Shot6",95,0);
			ascent(a in 0..4){
			px = n*15;
			py = GetEnemyY+60-n*3;
			ascent(i in 0..6){
			let shot = ShotA1(n*15,py,1+a/1,getDotAngle(GetPlayerX,GetPlayerY,px,py)-60+i*60,171,0,12);
			spongy(shot,15);
			}
			}
			wait(n%2);
		}
		slash = 2;
		wait(90);
		TAccel(50,5,0.05,60);
		wait(90);
		maple(2);
		wait(25);
		attack(30,30,1);
		wait(30);
		ascent(n in 0..30){
		PlaySound("Shot6",95,0);
			ascent(a in 0..8){
			px = n*15;
			py = GetEnemyY+60-n*3;
			let shot = ShotA1(464-n*15,py,0.75+a/2,getDotAngle(GetPlayerX,GetPlayerY,px,py),177,0,12);
			spongy(shot,15);
			}
			wait(n%2);
		}
		slash = 1;
		wait(105);
		TAccel(50,5,0.05,60);
		wait(105);
		}
	}


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

task TRender
{
	DrawBoss;
}

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

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