class 1 gatekeeper_wirphy : teleporter_need_item
{
parameter:
	int	PrimeHours = 1;

property:
	TelPosList Position = {{"The Town of Gludio"; -12694; 122776; -3114; 32000; 1 };{"Town of Schuttgart"; 87478; -142297; -1352; 4400; 9 };{"Dark Elf Village"; 9716; 15502; -4500; 22000; 0 };{"Talking Island Village"; -84141; 244623; -3729; 46000; 0 };{"Elven Village"; 46890; 51531; -2976; 23000; 0 };{"Orc Village"; -45186; -112459; -236; 17000; 0 };{"Kamael Village"; -117251; 46771; 360; 32000; 0 };{"Mithril Mines"; 171946; -173352; 3440; 2200; 0 };{"Abandoned Coal Mines"; 139714; -177456; -1536; 690; 0 };{"Eastern Mining Zone (Northeastern Shore)"; 169008; -208272; -3496; 2400; 0 };{"Western Mining Zone (Central Shore)"; 136910; -205082; -3664; 970; 0 }};
	TelPosList PositionPrimeHours = {{"The Town of Gludio"; -12694; 122776; -3114; 16000; 1 };{"Town of Schuttgart"; 87478; -142297; -1352; 2200; 9 };{"Dark Elf Village"; 9716; 15502; -4500; 11000; 0 };{"Talking Island Village"; -84141; 244623; -3729; 28000; 0 };{"Elven Village"; 46890; 51531; -2976; 12500; 0 };{"Orc Village"; -45186; -112459; -236; 18500; 0 };{"Kamael Village"; -117251; 46771; 360; 16000; 0 };{"Mithril Mines"; 171946; -173352; 3440; 1100; 0 };{"Abandoned Coal Mines"; 139714; -177456; -1536; 345; 0 };{"Eastern Mining Zone (Northeastern Shore)"; 169008; -208272; -3496; 1200; 0 };{"Western Mining Zone (Central Shore)"; 136910; -205082; -3664; 485; 0 }};
	TelPosList PositionNoblessNeedItemTown = {{"Gludin Village"; -80749; 149834; -3043; 1; 0 };{"Gludio Castle Town"; -12787; 122779; -3114; 1; 0 };{"Dion Castle Town"; 15744; 142928; -2704; 1; 0 };{"Heine"; 111455; 219400; -3546; 1; 0 };{"Giran Castle Town"; 83336; 147972; -3404; 1; 0 };{"The Town of Oren"; 83011; 53207; -1470; 1; 0 };{"Hunters Village"; 117088; 76931; -2670; 1; 0 };{"Aden Castle Town"; 146783; 25808; -2000; 1; 0 };{"Rune Castle Town"; 43826; -47688; -792; 1; 0 };{"Goddard Castle Town"; 147978; -55408; -2728; 1; 0 };{"Town of Schuttgart"; 87478; -142297; -1352; 1; 0 };{"Gludin Arena"; -87328; 142266; -3640; 1; 0 };{"Giran Arena"; 73579; 142709; -3768; 1; 0 };{"Coliseum"; 146440; 46723; -3400; 1; 0 }};
	TelPosList PositionNoblessNeedItemField = {{"Gludin Arena"; -87328; 142266; -3640; 1; 0 };{"Giran Arena"; 73579; 142709; -3768; 1; 0 };{"The Center of the Mithril Mines"; 175499; -181586; -904; 1; 0 };{"The Center of the Abandoned Coal Mines"; 144706; -173223; -1520; 1; 0 };{"Coliseum"; 146440; 46723; -3400; 1; 0 }};
	TelPosList PositionNoblessNeedItemSSQ = {{"Necropolis of Sacrifice"; -41184; 206752; -3357; 1; 0 };{"Heretics Catacomb"; 39232; 143568; -3651; 1; 0 };{"Pilgrims Necropolis"; 45600; 126944; -3686; 1; 0 };{"Catacomb of the Branded"; 43200; 170688; -3251; 1; 0 };{"Worshipers Necropolis"; 107514; 174329; -3704; 1; 0 };{"Catacomb of the Apostate"; 74672; 78032; -3398; 1; 0 };{"Patriots Necropolis"; -25472; 77728; -3446; 1; 0 };{"Catacomb of the Witch"; 136672; 79328; -3702; 1; 0 };{"Ascetics Necropolis"; -56064; 78720; -3011; 1; 0 };{"Martyr's Necropolis"; 114496; 132416; -3101; 1; 0 };{"Disciples Necropolis"; 168560; -17968; -3174; 1; 0 };{"Saints Necropolis"; 79296; 209584; -3709; 1; 0 };{"Catacomb of Dark Omens"; -22480; 13872; -3174; 1; 0 };{"Catacomb of the Forbidden Path"; 110912; 84912; -4816; 1; 0 }};
	TelPosList PositionNoblessNoItemTown = {{"Gludin Village"; -80749; 149834; -3043; 1000; 0 };{"Gludio Castle Town"; -12787; 122779; -3114; 1000; 0 };{"Dion Castle Town"; 15744; 142928; -2704; 1000; 0 };{"Heine"; 111455; 219400; -3546; 1000; 0 };{"Giran Castle Town"; 83336; 147972; -3404; 1000; 0 };{"The Town of Oren"; 83011; 53207; -1470; 1000; 0 };{"Hunters Village"; 117088; 76931; -2670; 1000; 0 };{"Aden Castle Town"; 146783; 25808; -2000; 1000; 0 };{"Rune Castle Town"; 43826; -47688; -792; 1000; 0 };{"Goddard Castle Town"; 147978; -55408; -2728; 1000; 0 };{"Town of Schuttgart"; 87478; -142297; -1352; 1000; 0 };{"Gludin Arena"; -87328; 142266; -3640; 1000; 0 };{"Giran Arena"; 73579; 142709; -3768; 1000; 0 };{"Coliseum"; 146440; 46723; -3400; 1000; 0 }};
	TelPosList PositionNoblessNoItemField = {{"Gludin Arena"; -87328; 142266; -3640; 1000; 0 };{"Giran Arena"; 73579; 142709; -3768; 1000; 0 };{"The Center of the Mithril Mines"; 175499; -181586; -904; 1000; 0 };{"The Center of the Abandoned Coal Mines"; 144706; -173223; -1520; 1000; 0 };{"Coliseum"; 146440; 46723; -3400; 1000; 0 }};
	TelPosList PositionNoblessNoItemSSQ = {{"Necropolis of Sacrifice"; -41184; 206752; -3357; 1000; 0 };{"Heretics Catacomb"; 39232; 143568; -3651; 1000; 0 };{"Pilgrims Necropolis"; 45600; 126944; -3686; 1000; 0 };{"Catacomb of the Branded"; 43200; 170688; -3251; 1000; 0 };{"Worshipers Necropolis"; 107514; 174329; -3704; 1000; 0 };{"Catacomb of the Apostate"; 74672; 78032; -3398; 1000; 0 };{"Patriots Necropolis"; -25472; 77728; -3446; 1000; 0 };{"Catacomb of the Witch"; 136672; 79328; -3702; 1000; 0 };{"Ascetics Necropolis"; -56064; 78720; -3011; 1000; 0 };{"Martyr's Necropolis"; 114496; 132416; -3101; 1000; 0 };{"Disciples Necropolis"; 168560; -17968; -3174; 1000; 0 };{"Saints Necropolis"; 79296; 209584; -3709; 1000; 0 };{"Catacomb of Dark Omens"; -22480; 13872; -3174; 1000; 0 };{"Catacomb of the Forbidden Path"; 110912; 84912; -4816; 1000; 0 }};

handler:
	EventHandler MENU_SELECTED(talker,ask,reply)
	{
		if( ask == -6 )
		{
			if( myself::OwnItemCount(talker,ItemNeeded) != 0 )
			{
				myself::DeleteItem1(talker,ItemNeeded,1);
				myself::InstantTeleport(talker,-80749,149834,-3043);
				return;
			}
			else
			{
				myself::ShowPage(talker,fnNoItem);
			}
		}
		super;
	}

	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,297) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Gatekeeper's Favor");
			}
			if( myself::HaveMemo(talker,297) == 1 && myself::OwnItemCount(talker,1573) < 20 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Gatekeeper's Favor (Continue)");
			}
			if( myself::HaveMemo(talker,297) == 1 && myself::OwnItemCount(talker,1573) >= 20 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Gatekeeper's Favor (Continue)");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			switch(_code)
			{
				case 0:
				{
					if( _from_choice == 0 || myself::HaveMemo(talker,297) == 0 )
					{
						myself::SetCurrentQuestID(297);
						if( myself::GetInventoryInfo(talker,0) >= ( myself::GetInventoryInfo(talker,1) * 0.800000 ) || myself::GetInventoryInfo(talker,2) >= ( myself::GetInventoryInfo(talker,3) * 0.800000 ) )
						{
							myself::ShowSystemMessage(talker,1118);
							return;
						}
						if( myself::GetMemoCount(talker) < 26 )
						{
							myself::FHTML_SetFileName(fhtml0,"gatekeeper_wirphy_q0297_02.htm");
							myself::FHTML_SetInt(fhtml0,"quest_id",297);
							myself::ShowFHTML(talker,fhtml0);
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,297) == 1 && myself::OwnItemCount(talker,1573) < 20 ) )
					{
						myself::SetCurrentQuestID(297);
						if( myself::GetInventoryInfo(talker,0) >= ( myself::GetInventoryInfo(talker,1) * 0.800000 ) || myself::GetInventoryInfo(talker,2) >= ( myself::GetInventoryInfo(talker,3) * 0.800000 ) )
						{
							myself::ShowSystemMessage(talker,1118);
							return;
						}
						myself::ShowPage(talker,"gatekeeper_wirphy_q0297_04.htm");
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,297) == 1 && myself::OwnItemCount(talker,1573) >= 20 ) )
					{
						myself::SetCurrentQuestID(297);
						if( myself::GetInventoryInfo(talker,0) >= ( myself::GetInventoryInfo(talker,1) * 0.800000 ) || myself::GetInventoryInfo(talker,2) >= ( myself::GetInventoryInfo(talker,3) * 0.800000 ) )
						{
							myself::ShowSystemMessage(talker,1118);
							return;
						}
						if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
						{
							talker.quest_last_reward_time = myself::GetCurrentTick();
							myself::ShowPage(talker,"gatekeeper_wirphy_q0297_05.htm");
							myself::DeleteItem1(talker,1573,myself::OwnItemCount(talker,1573));
							myself::GiveItem1(talker,1659,2);
							myself::RemoveMemo(talker,297);
							myself::AddLog(2,talker,297);
							myself::SoundEffect(talker,"ItemSound.quest_finish");
						}
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(quest_id,talker)
	{
		if( quest_id == 297 )
		{
			myself::SetCurrentQuestID(297);
			if( myself::GetInventoryInfo(talker,0) >= ( myself::GetInventoryInfo(talker,1) * 0.800000 ) || myself::GetInventoryInfo(talker,2) >= ( myself::GetInventoryInfo(talker,3) * 0.800000 ) )
			{
				myself::ShowSystemMessage(talker,1118);
				return;
			}
			if( talker.level >= 15 )
			{
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::ShowPage(talker,"gatekeeper_wirphy_q0297_03.htm");
					myself::SetMemo(talker,297);
					myself::SetFlagJournal(talker,297,1);
					myself::AddLog(1,talker,297);
					myself::SoundEffect(talker,"ItemSound.quest_accept");
				}
			}
			else
			{
				myself::ShowPage(talker,"gatekeeper_wirphy_q0297_01.htm");
			}
			return;
		}
		super;
	}

}
