class 1 master_sidra : mage_coach
{
handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,413) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Path to a Shillien Oracle");
			}
			if( myself::HaveMemo(talker,413) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Path to a Shillien Oracle (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,413) == 0 )
					{
						myself::SetCurrentQuestID(413);
						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::ShowPage(talker,"master_sidra_q0413_01.htm");
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || myself::HaveMemo(talker,413) == 1 )
					{
						myself::SetCurrentQuestID(413);
						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::OwnItemCount(talker,1262) == 1 )
						{
							myself::ShowPage(talker,"master_sidra_q0413_07.htm");
						}
						else if( myself::OwnItemCount(talker,1263) > 0 || myself::OwnItemCount(talker,1264) > 0 )
						{
							myself::ShowPage(talker,"master_sidra_q0413_08.htm");
						}
						else if( myself::OwnItemCount(talker,1269) == 0 && ( ( ( myself::OwnItemCount(talker,1266) + myself::OwnItemCount(talker,1265) ) + myself::OwnItemCount(talker,1267) ) + myself::OwnItemCount(talker,1268) ) > 0 )
						{
							myself::ShowPage(talker,"master_sidra_q0413_09.htm");
						}
						else if( myself::OwnItemCount(talker,1269) == 1 && myself::OwnItemCount(talker,1265) == 1 )
						{
							if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
							{
								talker.quest_last_reward_time = myself::GetCurrentTick();
								myself::ShowPage(talker,"master_sidra_q0413_10.htm");
								myself::DeleteItem1(talker,1269,1);
								myself::DeleteItem1(talker,1265,1);
								myself::GiveItem1(talker,1270,1);
								myself::IncrementParam(talker,0,3200);
								myself::IncrementParam(talker,1,3120);
								myself::RemoveMemo(talker,413);
								myself::AddLog(2,talker,413);
								myself::SoundEffect(talker,"ItemSound.quest_finish");
							}
						}
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(quest_id,talker)
	{
		if( quest_id == 413 )
		{
			myself::SetCurrentQuestID(413);
			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,"master_sidra_q0413_06.htm");
				myself::SetMemo(talker,413);
				myself::AddLog(1,talker,413);
				myself::SetFlagJournal(talker,413,1);
				myself::SoundEffect(talker,"ItemSound.quest_accept");
				myself::GiveItem1(talker,1262,1);
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,fhtml0,reply,talker)
	{
		if( ask == 413 )
		{
			myself::SetCurrentQuestID(413);
			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( ask == 413 )
		{
			if( reply == 1 )
			{
				if( talker.level >= 19 && talker.occupation == 38 && myself::OwnItemCount(talker,1270) == 0 )
				{
					myself::FHTML_SetFileName(fhtml0,"master_sidra_q0413_05.htm");
					myself::FHTML_SetInt(fhtml0,"quest_id",413);
					myself::ShowFHTML(talker,fhtml0);
				}
				else if( talker.occupation != 38 )
				{
					if( talker.occupation == 42 )
					{
						myself::ShowPage(talker,"master_sidra_q0413_02a.htm");
					}
					else
					{
						myself::ShowPage(talker,"master_sidra_q0413_03.htm");
					}
				}
				else if( talker.level < 19 && talker.occupation == 38 )
				{
					myself::ShowPage(talker,"master_sidra_q0413_02.htm");
				}
				else if( talker.level >= 19 && talker.occupation == 38 && myself::OwnItemCount(talker,1270) == 1 )
				{
					myself::ShowPage(talker,"master_sidra_q0413_04.htm");
				}
			}
		}
		super;
	}

}
