class 1 master_reoria : fighter_coach
{
handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,407) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Path to an Elven Scout");
			}
			if( myself::HaveMemo(talker,407) == 1 && myself::OwnItemCount(talker,1207) > 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Path to an Elven Scout (Continue)");
			}
			if( myself::HaveMemo(talker,407) == 1 && myself::GetMemoState(talker,407) == 1 && myself::OwnItemCount(talker,1207) == 0 && myself::OwnItemCount(talker,1216) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Path to an Elven Scout (Continue)");
			}
			if( myself::HaveMemo(talker,407) == 1 && myself::OwnItemCount(talker,1216) > 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Path to an Elven Scout (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,407) == 0 )
					{
						myself::SetCurrentQuestID(407);
						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,"master_reoria_q0407_01.htm");
							myself::FHTML_SetInt(fhtml0,"quest_id",407);
							myself::ShowFHTML(talker,fhtml0);
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,407) == 1 && myself::OwnItemCount(talker,1207) > 0 ) )
					{
						myself::SetCurrentQuestID(407);
						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,"master_reoria_q0407_06.htm");
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,407) == 1 && myself::GetMemoState(talker,407) == 1 && myself::OwnItemCount(talker,1207) == 0 && myself::OwnItemCount(talker,1216) == 0 ) )
					{
						myself::SetCurrentQuestID(407);
						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,"master_reoria_q0407_08.htm");
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,407) == 1 && myself::OwnItemCount(talker,1216) > 0 ) )
					{
						myself::SetCurrentQuestID(407);
						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_reoria_q0407_07.htm");
							myself::DeleteItem1(talker,1216,1);
							myself::GiveItem1(talker,1217,1);
							myself::IncrementParam(talker,0,3200);
							myself::IncrementParam(talker,1,1000);
							myself::RemoveMemo(talker,407);
							myself::AddLog(2,talker,407);
							myself::SoundEffect(talker,"ItemSound.quest_finish");
						}
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(quest_id,talker)
	{
		if( quest_id == 407 )
		{
			myself::SetCurrentQuestID(407);
			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.occupation == 18 )
			{
				if( talker.level >= 19 )
				{
					if( myself::OwnItemCount(talker,1217) > 0 )
					{
						myself::ShowPage(talker,"master_reoria_q0407_04.htm");
					}
					else if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::ShowPage(talker,"master_reoria_q0407_05.htm");
						myself::GiveItem1(talker,1207,1);
						myself::SetMemo(talker,quest_id);
						myself::AddLog(1,talker,407);
						myself::SetMemoState(talker,407,0);
						myself::SetFlagJournal(talker,407,1);
						myself::SoundEffect(talker,"ItemSound.quest_accept");
					}
				}
				else
				{
					myself::ShowPage(talker,"master_reoria_q0407_03.htm");
				}
			}
			else if( talker.occupation == 22 )
			{
				myself::ShowPage(talker,"master_reoria_q0407_02a.htm");
			}
			else
			{
				myself::ShowPage(talker,"master_reoria_q0407_02.htm");
			}
			return;
		}
		super;
	}

}
