
#ScriptVersion[3]
#Title["NonSpellH"]
#Text["NonSpellH"]
#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 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(5000);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
}

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

task TShot1{
	let px = 0;
	let py = 0;
	ascent(n in 0..40){
	PlaySound("Shot1",90,0);
	px = GetEnemyX+100*sin(n*5+45);
	py = GetEnemyY+150-n*7.5;
	ascent(j in 0..9){
	ShotA2(px,py,0,j*360/9-60+n*13,0.02,1.25,14,0,8);
	}
	px = GetEnemyX-100*sin(n*5+45);
	ascent(j in 0..9){
	ShotA2(px,py,0,j*360/9+60-n*13,0.02,1.25,15,0,8);
	}
	wait(5);
	}
	wait(60);
	TAccel(50,5,0.1,30);
	wait(60);
	TShot2;
	}

task TShot2{
	ascent(n in 0..30){
	PlaySound("Shot1",90,0);
	ascent(a in 0..4){
	ShotOA1(objBoss,1+a/1,0+n*10+a/2,264,154,12);
	ShotOA1(objBoss,1+a/1,180-n*10-a/2,265,155,12);
	ShotOA1(objBoss,1+a/1,0-n*10+a/2,264,154,12);
	ShotOA1(objBoss,1+a/1,180+n*10-a/2,265,155,12);
	}
	wait(6);
	}
	TAccel(50,5,0.1,30);
	wait(60);
	TShot3;
	}
	
task TShot3{
	maple(2);
	wait(55);
	ascent(n in 0..240){
	let ang = rand(0,359);
	let r = rand(-100,100);
	if(n%1==0){
		PlaySound("Shot1",85,0);
	ShotB2(GetEnemyX+r*cos(ang),GetEnemyY+r*sin(ang),rand(-4,4),rand(-3,1.5),0,0.02,0,2,157,0,12);
	}
	if(n%6==0 && n>0 && n<120){
		ascent(a in 0..8){
		ShotOA1(objBoss,1+a/2,n*2-60,266,156,8);
		}
	}

	if(n%6==0 && n>120){
		ascent(a in 0..8){
		ShotOA1(objBoss,1+a/2,-n*2+60,261,151,8);
		}
	}
	yield;
	}
	TAccel(50,10,0.05,30);
	wait(60);
	maple(2);
	attack(55,100,1);
	wait(50);
	loop(2){
	ascent(n in 0..20){
	PlaySound("Shot1",90,0);
	PlaySound("BulletWave",90,30);
	let px = n*20;
	let py = GetEnemyY-20+n*2;
	ascent(i in 0..3){
	ascent(a in 0..2){
	let shot = ShotA2(px,py,0,getDotAngle(GetPlayerX,GetPlayerY,px,py)-30+i*30,0.01,1,262,0,12);
	ObjMove_AddPatternA2(shot,30,0,getDotAngle(GetPlayerX,GetPlayerY,px,py)-30+i*30,0.025+a/20,0,5);
	}
	}
	yield;
	}
	ascent(n in 0..20){
	PlaySound("Shot1",90,0);
	PlaySound("BulletWave",90,30);
	let px = 400-n*20;
	let py = GetEnemyY-20+n*2;
	ascent(i in 0..3){
	ascent(a in 0..2){
	let shot = ShotA2(px,py,0,getDotAngle(GetPlayerX,GetPlayerY,px,py)-30+i*30,0.01,1,263,0,12);
	ObjMove_AddPatternA2(shot,30,0,getDotAngle(GetPlayerX,GetPlayerY,px,py)-30+i*30,0.025+a/20,0,5);
	}
	}
	yield;
	}
	}
	wait(90);
	ascent(i in 0..12){
	ascent(a in 0..7){
	ShotOA1(objBoss,1+a/2,i*30+a*10,261,0,8);
	}
	}
	ascent(i in 0..15){
	ascent(a in 0..6){
	ShotOA1(objBoss,1+a/2,i*24-a*8,261,0,8);
	}
	}
	wait(60);
	AccelMove(objBoss,stgx,120,0.1,60);
	wait(60);
	TShot1;
	}

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

task TRender
{
	DrawBoss;
}

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

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