//#東方弾幕風[Single]
#ScriptVersion[3]
#Title["DK3"]
#Text[" "]
#Background["./background/Default_Background.txt"]
#System["./system/Default_System.txt"]
#BGM["./BGM1.mp3"]

#include"./lib/All.txt"

let objEnemy;
let objPlayer;
let objScene = GetEnemyBossSceneObjectID();
SetCommonData("dia", 1);

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		SetScriptResult(1);
	}
	case( EV_REQUEST_IS_DURABLE_SPELL )
	{
		SetScriptResult( true );
	}
}

@Initialize
{
        objPlayer = GetPlayerObjectID();
	objEnemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objEnemy);
	renderKoishiSA(objEnemy);
	SetCommonData("boss", "KOISHI");

	ObjEnemy_SetDamageRate(objEnemy, 0, 0);
	ObjMove_SetPosition(objEnemy, 192, 100);
	Dialogue;
}

@MainLoop
{
	let ex = ObjMove_GetX(objEnemy);
	let ey = ObjMove_GetY(objEnemy);

	//ObjEnemy_SetIntersectionCircleToShot(objEnemy, ex, ey, 32);
	//ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ex, ey, 24);

	if(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) <= 0)
	{
		Obj_Delete(objEnemy);
		DeleteShotAll(TYPE_ALL, TYPE_ITEM);
		CloseScript(GetOwnScriptID());
        }
	yield;
}

task Dialogue
{
	SetForbidPlayerShot(true);
	SetForbidPlayerSpell(true);
	SetCommonData("dia", 1);
	loop(60){ yield; }
	loop(90){ yield; }

	DiaBubble(ObjMove_GetX(objEnemy) + 20, ObjMove_GetY(objEnemy) - 4, 1, "CONTROL", 0, 1.3, 0);
	DiaText(ObjMove_GetX(objEnemy) + 48, ObjMove_GetY(objEnemy) + 12, "That was fun!", "CONTROL", 0, 20);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){ yield; }

	loop(15){ yield; }
	DiaBubble(ObjMove_GetX(objPlayer) + 20, ObjMove_GetY(objPlayer) + 5, 1, "CONTROL", 0, 2.3, 180);
	DiaText(ObjMove_GetX(objPlayer) + 45, ObjMove_GetY(objPlayer) - 30, "Then, I should be going now...", "CONTROL", 0, 20);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){ yield; }

	loop(15){ yield; }
	DiaBubble(ObjMove_GetX(objEnemy) + 20, ObjMove_GetY(objEnemy) - 4, 1, "CONTROL", 0, 0.9, 0);
	DiaText(ObjMove_GetX(objEnemy) + 48, ObjMove_GetY(objEnemy) + 12, "Bye bye!", "CONTROL", 0, 20);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){ yield; }

	loop(15){ yield; }
	DiaBubble(ObjMove_GetX(objPlayer) + 20, ObjMove_GetY(objPlayer) + 5, 1, "CONTROL", 0, 1.3, 180);
	DiaText(ObjMove_GetX(objPlayer) + 45, ObjMove_GetY(objPlayer) - 30, "Oh, by the way...", "CONTROL", 0, 20);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){ yield; }

	loop(15){ yield; }
	DiaBubble(ObjMove_GetX(objPlayer) + 20, ObjMove_GetY(objPlayer) + 5, 2, "CONTROL", 0, 1.9, 180);
	DiaText(ObjMove_GetX(objPlayer) + 45, ObjMove_GetY(objPlayer) - 65, "Do you happen to see", "CONTROL", 0, 20);
	DiaText(ObjMove_GetX(objPlayer) + 45, ObjMove_GetY(objPlayer) - 45, "some beast spirits?", "CONTROL", 0, 20);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){ yield; }

	loop(15){ yield; }
	DiaBubble(ObjMove_GetX(objEnemy) + 20, ObjMove_GetY(objEnemy) - 4, 1, "CONTROL", 0, 1, 0);
	DiaText(ObjMove_GetX(objEnemy) + 48, ObjMove_GetY(objEnemy) + 12, "No, I guess...", "CONTROL", 0, 20);
	while(GetVirtualKeyState(VK_SHOT) != KEY_PUSH){ yield; }

	loop(15){ yield; }
	DiaBubble(ObjMove_GetX(objPlayer) + 20, ObjMove_GetY(objPlayer) + 5, 1, "CONTROL", 0, 0.9, 180);
	DiaText(ObjMove_GetX(objPlayer) + 45, ObjMove_GetY(objPlayer) - 30, "Oh, really...", "CONTROL", 0, 20);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){ yield; }

	loop(15){ yield; }
	DiaBubble(ObjMove_GetX(objEnemy) + 20, ObjMove_GetY(objEnemy) - 4, 2, "CONTROL", 0, 2.3, 0);
	DiaText(ObjMove_GetX(objEnemy) + 48, ObjMove_GetY(objEnemy) + 28, "Wait, someone told me to go", "CONTROL", 0, 20);
	DiaText(ObjMove_GetX(objEnemy) + 48, ObjMove_GetY(objEnemy) + 48, "to Hell to do something...", "CONTROL", 0, 20);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){ yield; }

	loop(15){ yield; }
	DiaBubble(ObjMove_GetX(objEnemy) + 20, ObjMove_GetY(objEnemy) - 4, 2, "CONTROL", 0, 2.1, 0);
	DiaText(ObjMove_GetX(objEnemy) + 48, ObjMove_GetY(objEnemy) + 28, "She said something about ", "CONTROL", 0, 20);
	DiaText(ObjMove_GetX(objEnemy) + 48, ObjMove_GetY(objEnemy) + 48, "some beast spirits...", "CONTROL", 0, 20);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){ yield; }

	loop(15){ yield; }
	DiaBubble(ObjMove_GetX(objEnemy) + 20, ObjMove_GetY(objEnemy) - 4, 1, "CONTROL", 0, 1.9, 0);
	DiaText(ObjMove_GetX(objEnemy) + 48, ObjMove_GetY(objEnemy) + 12, "But I don't remember!", "CONTROL", 0, 20);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){ yield; }

	loop(15){ yield; }
	DiaBubble(ObjMove_GetX(objPlayer) + 20, ObjMove_GetY(objPlayer) + 5, 1, "CONTROL", 0, 1.1, 180);
	DiaText(ObjMove_GetX(objPlayer) + 45, ObjMove_GetY(objPlayer) - 30, "Oh, thank you!", "CONTROL", 0, 20);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){ yield; }

	loop(15){ yield; }
	DiaBubble(ObjMove_GetX(objPlayer) + 20, ObjMove_GetY(objPlayer) + 5, 1, "CONTROL", 0, 1.7, 180);
	DiaText(ObjMove_GetX(objPlayer) + 45, ObjMove_GetY(objPlayer) - 30, "Then, see you later!", "CONTROL", 0, 20);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){ yield; }

	loop(15){ yield; }
	DiaBubble(ObjMove_GetX(objEnemy) + 20, ObjMove_GetY(objEnemy) - 4, 1, "CONTROL", 0, 0.9, 0);
	DiaText(ObjMove_GetX(objEnemy) + 48, ObjMove_GetY(objEnemy) + 12, "Bye bye!", "CONTROL", 0, 20);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){ yield; }

	loop(30){ yield; }
	ObjMove_SetDestAtFrame(objEnemy, -50, -50, 60);
	loop(60){ yield; }
	ObjEnemy_SetLife(objEnemy, 0);
	Obj_Delete(objEnemy);
	SetCommonData("dia", 0);
	loop(20){ yield; }
	CloseScript(GetOwnScriptID());
}