#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Finalize"]

#include "./../functions_talk.txt"
#include"./functions2.txt"

timer = 0;
let text = GetCommonData("TEXT_ENABLED",true);

@Initialize
{
	Obj_SetValue(GetEnemyBossSceneObjectID,"INIT",true);
	TEnemyWork;
}

@MainLoop
{
	yield;
}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
		{
		SetScriptResult(1/(10^10));
		}
	case(EV_REQUEST_TIMER)
		{
		SetScriptResult(timer);
		}
	case(EV_REQUEST_SPELL_SCORE)
		{
		SetScriptResult(0);
		}
}

task TEnemyWork
{	
	yield;
	SetForbidPlayerShot(true);
	SetForbidPlayerSpell(true);
	TShake;
	yield;
	PlaySound("se_Die3",200);

	if(text == true)
		{
		InitializeEvent(1,1);

		Talking(0,LEFT);
		ObjEvent_SetGraphic(LEFT,0,KoishiJoy);
		ObjEvent_SetGraphic(RIGHT,0,ReisenDSad);
		SetText(LEFT,0,0,"That's it for you~");
		Talking(0,RIGHT);
		SetText(RIGHT,0,0,"How cruel, for the winner to pick on us small fry...");
		Talking(0,LEFT);
		ObjEvent_SetGraphic(LEFT,0,KoishiPlain);
		SetText(LEFT,0,0,"That's how it is, here in the big leagues!");
		SetText(LEFT,0,0,"Anyway, since you'll never be able to compete with me,");
		SetText(LEFT,0,0,"I guess it's time to find the next opponent!");
		ObjEvent_SetGraphic(LEFT,0,"");
		loop(20){yield;}
		Talking(0,RIGHT);
		SetText(RIGHT,0,0,"She really was a weird one.");
		SetText(RIGHT,0,0,"...");
		SetText(RIGHT,0,0,"Well, at least this is just a small fan script.");
		ObjEvent_SetGraphic(RIGHT,0,ReisenDJoy);
		SetText(RIGHT,0,0,"This loss won't effect my popularity[r]at all once the real game comes out!");
		Talking(0,RIGHT);
		SetText(RIGHT,5,10,"Udonge! Stop fooling around!");
		Talking(0,RIGHT);
		ObjEvent_SetGraphic(RIGHT,0,ReisenDSad);
		SetText(RIGHT,0,0,"Ah! I'm coming master!");
		ObjEvent_SetGraphic(RIGHT,0,"");
		loop(20){yield;}
		FinalizeEvent;	
		}
	else
		{
		loop(150){yield;}
		}
	yield;
	Obj_Delete(GetEnemyBossSceneObjectID);
	CloseScript(GetOwnScriptID);
}