#“Œ•û’e–‹•—[Single]
#ScriptVersion[3]
#Title["Spell3"]
#Text["Spell3"]
#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\"Melody Spark\"",15);
	ObjEnemyBossScene_StartSpell(objScene);
	ObjMove_SetDestAtWeight(objBoss,stgx,130,10,7);
	wait(90);
	Rapid;
	ObjEnemy_SetDamageRate(objBoss,50,25);
	}
//----------------------------------------------------

task Rapid{
		let p = 0;
		while(!Obj_IsDeleted(objBoss)){
		PlaySound("Shot6",85,0);
		ascent(i in 0..9){
		let dir = i*40+40*sin(p*33);
		let ang = 0.5*sin(p*33);
		let shot = ShotA2(GetEnemyX+30*cos(dir),GetEnemyY+30*sin(dir),4,dir,-0.1,1,12+p%2,0,12);
		ObjMove_AddPatternA2(shot,30,NO_CHANGE,NO_CHANGE,0.005,ang,5);
		ObjMove_AddPatternA2(shot,90,NO_CHANGE,NO_CHANGE,0.005,0,5);
		}
		p+=0.5;
		if(p%18==10){CurveLaser;}
		if(p%18==17){TMovement(35,5,5);}
		wait(12);
		}
	}

task CurveLaser{
	maple(2);
	wait(50);
	PlaySound("Laser2",100,0);
	let py = stgy*2/4.5;
	ascent(i in 0..5){
	CreateLooseLaserA1(GetEnemyX,GetEnemyY,10,150+i*25,500,10,23,0);
	}
	wait(90);
	PlaySound("BulletWave",100,0);
	ascent(i in 0..5){
	let obj = CreateCurveLaserA1(-30,py*i,0,30,100,10,23,0);
	ObjMove_AddPatternA2(obj,0,1,NO_CHANGE,0.1,-0.5,10);
	Manage(obj,i);
	}
	wait(90);
	TMovement(35,5,5);
		task Manage(obj,num){
			let way = 1;
			let p = rand(0,72);
			wait(15);
			while(!Obj_IsDeleted(obj)){
			let px = ObjMove_GetX(obj);
			let py = ObjMove_GetY(obj);
			FireShot(px,py,p+num*72);
			wait(2);
			way = -way;
			p+=23;
			}
						task FireShot(px,py,ang){
				wait(60);
				if(!Obj_IsDeleted(obj)){
				let shot = ShotA2(px,py,0,ang,0.0025,5,23,0,8);
				ObjMove_AddPatternA2(shot,60,0,NO_CHANGE,0.0075,0,rand(0.75,1));
				 DelayShot(shot,173,2,192,12,60);
				 wait(60);
				ObjRender_SetBlendType(shot,BLEND_ADD_ARGB);
				}
			}
		}
	}

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

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;
	}
