
#ScriptVersion[3]
#Title["ClownpieceEnd"]
#Text["ClownpieceEnd"]
#Player[DEFAULT]
#System["./system/Default_System.txt"]
#Background["./BG.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss.txt"
#include"./Shot/AllStarShot_Const.dnh"
#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 objScene=GetEnemyBossSceneObjectID();
@Initialize
{
SetBoss("Clownpiece",false);
}

@MainLoop
{
	yield;

}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		SetScriptResult(0);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(55);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(35000000);
	}
}

//----------------------------------------------------
task mainTask{
	}

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


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

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));}
			else{PlaySound("Shot2",95,0);}
		let color = GetColor("PINK2");
		PlaySound("enemoff",100,0);
		ClearBullet(120,10);
		TMovement(35,5,2);
		ascent(i in 0..45){
		Maple(stgx,150,rand(0.5,1),rand(0,360),color[0],color[1],color[2]);
		Maple(stgx,150,rand(1,1.5),rand(0,360),color[0],color[1],color[2]);
		wait(2);
		}
		ObjMove_SetPosition(objBoss,stgx,-1000);
		PlaySound("enemoff",100,0);
		MapleExplode(stgx,150,1,"PURPLE");
		MapleExplode(stgx,150,1.5,"PURPLE");
		MapleExplode(stgx,150,2,"PURPLE");
		descent(i in 0..30){
		Maple(stgx,150,1+i/30,rand(0,360),color[0],color[1],color[2]);
		yield;
		}
		wait(60);
		Obj_Delete(objBoss);
		wait(120);
		CloseScript(GetOwnScriptID());
	}