#“Œ•û’e–‹•—[Single]
#ScriptVersion[3]
#Title["Spell4"]
#Text["Spell4"]
#Background["./BG.txt"]
#Player[DEFAULT]
#System["./system/Default_System.txt"]
#Player["./MoF_Reimu/Reimu.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss.txt"
#include"script/VsKirisameMarisa/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 s = 1;
let objScene=GetEnemyBossSceneObjectID();
let Nuclear = GCSD~"img/Nuclear.png";
@Initialize
{
SetBoss;
LoadTexture(Nuclear);
}

@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(1750);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(3000000);
	}
}

//----------------------------------------------------
task mainTask{
	magiccircle(objBoss,0.8,true);
	wait(45);
	Cutin("Love Sign\"Six Stars\"",15);
	ObjEnemyBossScene_StartSpell(objScene);
	ObjMove_SetDestAtWeight(objBoss,stgx,130,10,7);
	wait(90);
	CurveLaser;
	ObjEnemy_SetDamageRate(objBoss,50,25);
	}
//----------------------------------------------------


task CurveLaser{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0)
	{
	let result = rand(0,360/6);
	maple(2);
	wait(50);
	Burst;
	PlaySound("Laser2",100,0);
	ascent(i in 0..6){
	let obj = CreateCurveLaserA1(GetEnemyX,GetEnemyY,5,i*360/6+result,100,10,23,0);
	Manage(obj,i,1);
	}
	wait(150);
	TMovement(35,5,5);
	wait(150);
	maple(2);
	wait(50);
	Burst;
	PlaySound("Laser2",100,0);
	ascent(i in 0..6){
	let obj = CreateCurveLaserA1(GetEnemyX,GetEnemyY,5,i*360/6+result,100,10,23,0);
	Manage(obj,i,-1);
	}
	wait(180);
	TMovement(35,5,5);
	wait(180);
	}
		task Manage(obj,num,way)
		{
			let count = 0;
			ObjMove_AddPatternA2(obj,0,8,NO_CHANGE,-0.05,2*way,3);
			ObjMove_AddPatternA2(obj,60,NO_CHANGE,NO_CHANGE,0.01,1.75*way,6);
			ObjMove_AddPatternA2(obj,240,NO_CHANGE,NO_CHANGE,0.02,0.5,10);
			while(!Obj_IsDeleted(obj))
			{
				if(count==195){Obj_Delete(obj);}
				if(count%5==0)
				{
					ascent(i in 0..2)
					{
						let shot = ShotA2(ObjMove_GetX(obj),ObjMove_GetY(obj),0,ObjMove_GetAngle(obj)+i*180,0.0025,1.5,133+way+(count%2)*2,0,12);
						ObjMove_AddPatternA2(shot,150,NO_CHANGE,NO_CHANGE,0.01,0,rand(1.5,1.75));
					}
				}
				if(count%11==12 && count<210)
				{
					let shot = ShotA2(ObjMove_GetX(obj),ObjMove_GetY(obj),1,GetAngleToPlayer(obj),0.01,2.5,153+way+count%2,0,12);
				}
				count++;
				yield;
			}
		}
	}
	
task Burst
{
	ascent(i in 0..10)
	{
		ascent(j in -1..2)
		{
			ShotA1(GetEnemyX,GetEnemyY,0.75,i*36+j*3+angleToPlayer+18,258,0,12);
			ShotA1(GetEnemyX,GetEnemyY,1.5,i*36+j*3+angleToPlayer,258,0,12);
		}
	}
}

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

task TRender
{
	DrawBoss;
}

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

task TEnd{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){yield;}
		if(ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT) +ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) == 0)
		{AddScore(ObjEnemyBossScene_GetInfo(objScene,INFO_SPELL_SCORE));}
		EndBoss(1);
		wait(60);
		CloseScript(GetOwnScriptID());
		return;
	}
