
#ScriptVersion[3]
#Title["MokouEnd"]
#Text["MokouEnd"]

#System["./system/Default_System_2.txt"]
#Background["./BGA.txt"]
#include"./Functions/Index2.txt"
#include"./SetBossA.txt"
#include"./Shot/AllStarShot_Const.dnh"
#include"./system/Default_Effect.Txt"
#include"./Functions/DialogueFunctions.dnh"
#include"./Functions/Portrait_Const.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
{
SetCommonData("Scroll",0);
SetBoss("Yukari",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(0);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(0);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(0);
	}
}

//----------------------------------------------------
task mainTask{
	StopSlow( TARGET_ALL );
	SetCommonData("ForceLifebar",1);
	ScreenShake(60);
	PlaySound("enemoff",92,0);
	MapleExplodeC(ObjMove_GetX( objBoss ),ObjMove_GetY( objBoss ),1.5,"WHITE");
	MapleExplodeC(ObjMove_GetX( objBoss ),ObjMove_GetY( objBoss ),2,"WHITE");
	MapleExplodeC(ObjMove_GetX( objBoss ),ObjMove_GetY( objBoss ),2.5,"WHITE");
	MapleExplodeC(ObjMove_GetX( objBoss ),ObjMove_GetY( objBoss ),3,"WHITE");
	ObjMove_SetPosition( objBoss, 640/2, -300 );
	}

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


task MapleExplodeC(px,py,speed,c){
	let color = GetColor(c);
	let st = rand(0,30);
	ascent(i in 0..18){
		Maple(px,py,speed+speed/(5/3)*sin(i*177),i*30+st,color[0],color[1],color[2]);
		wait(i%2);
	}
	}

task ScreenShake(time){
				loop(time/2){
				Set2DCameraFocusX(Get2DCameraX + rand(-40, 40));
				Set2DCameraFocusY(Get2DCameraY + rand(-40, 40));
				yield;
				Reset2DCamera;
				yield;
				}
				Reset2DCamera;
			}	

task TEnd{
	wait( 120 );
	Obj_Delete( objBoss );
	CloseScript(GetOwnScriptID());
}

		