
#ScriptVersion[3]
#Title["YoumuN1"]
#Text["YoumuN1"]
#Player[DEFAULT]
#System["./system/Default_System.txt"]
#Background["./BG.txt"]
#Player["./MoF_Reimu/Reimu.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss.txt"
#include"./Shot/AllStarShot_Const.dnh"
#include"./system/Default_Effect.Txt"
#include"./Portrait_Const.dnh"
#include"./DialogueFunctions.dnh"


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 color = [0,0];
@Initialize
{
SetBoss("Youmu",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(4250);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(55);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(35000000);
	}
}

//----------------------------------------------------
task mainTask{
	ObjMove_SetPosition(objBoss,384/2,-120);
	ObjMove_SetDestAtWeight(objBoss,stgx,120,10,10);
	DamageRateAtFrame(100,50,180);
	SetCommonData("CircleSize",0);
	magiccircle(objBoss,1,-1);
	wait(60);
	PlaySound("Charge3",100,0);
	RayCharge("AQUA",2,60);
	attack(90,30,1);
	wait(90);
	TShot1;
	}

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

task TShot1
{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){
	BasicShot;
	wait(270);
	TMovement(35,10,5);
	wait(60);
	KnifeShot;
	ObjMove_SetDestAtWeight(objBoss,stgx,120,10,10);
	wait(30);
	attack(60,60,1);
	maple;
	wait(60);
	CycleShot;
	wait(210);
	}
}

task CycleShot
{
	let r = 0;
	let angle = 0;
	PlaySound("Slash",95,0);
	ascent(n in 0..48)
	{
		PlaySound("Shot1",95,0);
		ascent(j in 0..1+Level)
		{
			ascent(k in -1..2)
			{
				if(k==0)
				{
				TShotA1(GetEnemyX+r*cos(angle),GetEnemyY+r*sin(angle),3.5-n/18+j/2,angle+180+n+18+k*5,5-j*2+500,12);
				TShotA1(GetEnemyX+r*cos(180-angle),GetEnemyY+r*sin(180-angle),3.5-n/18+j/2,-angle-n-18+k*5,5-j*2+500,12);
				TShotA1(GetEnemyX+r*cos(-angle),GetEnemyY+r*sin(-angle),3.5-n/18+j/2,-angle+180+n+18+k*5,5-j*2+500,12);
				TShotA1(GetEnemyX+r*cos(180+angle),GetEnemyY+r*sin(180+angle),3.5-n/18+j/2,angle-n-18+k*5,5-j*2+500,12);
				}
			}
		}
		r += 5;
		angle -= 17;
		wait(3);
	}
}

function KnifeShot
{
	maple;
	attack(60,30,2);
	wait(60);
	Knife(GetEnemyY-20,3.25,0,1);
	wait(25);
	Knife(GetEnemyY-20,3.25,0,-1);
	wait(25);
	Knife(GetEnemyY-30,3,-12,1);
	wait(25);
	Knife(GetEnemyY-30,3,12,-1);
	wait(25);
	Knife(GetEnemyY-40,2.75,-24,1);
	Knife(GetEnemyY-40,2.75,24,-1);
	TMovement(35,10,5);
	wait(25);
	attack(60,30,2);
	wait(60);
	Knife2(GetEnemyY-40,3.25,0,1);
	wait(20);
	Knife2(GetEnemyY-40,3.25,0,-1);
	wait(20);
	Knife2(GetEnemyY-50,3,-25,1);
	wait(20);
	Knife2(GetEnemyY-50,3,25,-1);
	wait(20);
	Knife2(GetEnemyY-60,2.75,-50,1);
	Knife2(GetEnemyY-60,2.75,50,-1);
	wait(20);
	Knife2(GetEnemyY-70,2.5,-35,1);
	Knife2(GetEnemyY-70,2.5,35,-1);
		task Knife(py,spd,plusx,type)
		{
			let color;
			let px = stgx+stgx*-type+plusx;
			if(type==1){color = 15;}
			if(type==-1){color = 14;}
			ascent(n in 0..15)
			{
					PlaySound("Shot1",92,0);
					ascent(j in 1..2+Level)
					{
						let obj = TShotA1(px,py,spd/2+j*(spd/5),90+n*-type*3,color,8);
					}
					wait(2);
					px += 384/10*type;
					py -= 1;
			}
		}
		
		task Knife2(py,spd,plusx,type)
		{
			let color;
			let px = stgx+stgx*-type+plusx;
			if(type==1){color = 15;}
			if(type==-1){color = 14;}
			ascent(n in 0..8)
			{
					PlaySound("Shot1",92,0);
					ascent(i in -Level..1+Level){
					ascent(j in 0..1)
					{
						let obj = TShotA1(px+i*10,py,spd-(spd/12)*(|i|),90+n*-type*3,color,8);
					}
					}
					wait(2+n%2);
					px += 384/6*type;
					py -= 1;
			}
		}
}

task BasicShot
{
	let px;
	let py;
	ascent(n in 0..40){
	PlaySound("Shot1",90,0);
	px = GetEnemyX+120*sin(n*5+45);
	if(n<20)
	{
	py = GetEnemyY+150-n*7.5;
	}
	else
	{
	py = GetEnemyY+150-20*7.5+50-n*2.5;
	}
	ascent(j in 0..6+Level*3){
	TShotA2(px,py,0,j*360/(6+Level*3)-60+n*13,0.02,1.25,43,8);
	}
	px = GetEnemyX-120*sin(n*5+45);
	ascent(j in 0..6+Level*3){
	TShotA2(px,py,0,j*360/(6+Level*3)+60-n*13,0.02,1.25,40,8);
	}
	wait(5);
	}
}

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

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