#“Œ•û’e–‹•—[Single]
#ScriptVersion[3]
#Title["Spell"]
#Text["Spell"]
#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(1500);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(3000000);
	}
}

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

task Star{
	while(!Obj_IsDeleted(objBoss)){
	PlaySound("um3",70,0);
	let ang = rand(-0.25,0.25);
	ascent(i in 0..9){
	let dir = i*20-80+angleToPlayer;
	let shot = ShotA2(GetEnemyX,GetEnemyY,0.5,dir,0.015,4,136,0,8);
	ObjMove_SetAngularVelocity(shot,ang);
	ObjMove_AddPatternA2(shot,90,NO_CHANGE,NO_CHANGE,-0.015,rand(-0.25,0.25),0.75);
	ObjMove_AddPatternA2(shot,180,NO_CHANGE,NO_CHANGE,-0.015,rand(-0.5,0.5),0.75);
	ObjMove_AddPatternA2(shot,270,NO_CHANGE,NO_CHANGE,-0.015,rand(-0.5,0.5),0.75);
	ObjMove_AddPatternA2(shot,360,NO_CHANGE,NO_CHANGE,-0.015,rand(-0.5,0.5),0.75);
	ObjMove_AddPatternA2(shot,450,NO_CHANGE,NO_CHANGE,-0.015,0,0.75);
	}
	wait(10);
	}
	}

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

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