class 1 uno : merchant_for_newbie
{
property:
	BuySellList SellList0 = {{"small_sword";15};{"club";15};{"bone_dagger";15};{"short_bow";15};{"broad_sword";15};{"heavy_chisel";15};{"knife";15};{"doomed_dagger";15};{"bow";15};{"mace";15};{"sickle";15};{"brandish";15};{"gladius";15};{"orcish_sword";15};{"handmade_sword";15};{"dwarven_mace";15};{"dirk";15};{"hunting_bow";15};{"long_sword";15};{"throw_knife";15};{"bow_of_forest";15};{"short_spear";15};{"zweihander";15}};
	BuySellList SellList1 = {{"apprentice_s_rod";15};{"buffalo_horn";15};{"willow_staff";15};{"apprentice_s_spellbook";15};{"cedar_staff";15};{"apprentice_s_staff";15};{"relic_of_saints";15};{"cotton_shirt";15};{"striped_cotton_shirt";15}};

handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,160) != 0 && myself::OwnItemCount(talker,1026) != 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Nerupa's Request");
			}
			if( myself::HaveMemo(talker,160) != 0 && myself::OwnItemCount(talker,1027) != 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Nerupa's Request");
			}
			if( myself::HaveMemo(talker,160) != 0 && myself::OwnItemCount(talker,1029) != 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Nerupa's Request");
			}
			if( myself::HaveMemo(talker,162) == 0 && myself::GetOneTimeQuestFlag(talker,162) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Curse of the Underground Fortress");
			}
			if( myself::HaveMemo(talker,162) == 0 && myself::GetOneTimeQuestFlag(talker,162) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Curse of the Underground Fortress");
			}
			if( myself::HaveMemo(talker,162) == 1 && ( myself::OwnItemCount(talker,1159) + myself::OwnItemCount(talker,1158) ) < 13 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Curse of the Underground Fortress");
			}
			if( myself::HaveMemo(talker,162) == 1 && ( myself::OwnItemCount(talker,1159) + myself::OwnItemCount(talker,1158) ) >= 13 && myself::GetOneTimeQuestFlag(talker,162) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"Curse of the Underground Fortress");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			switch(_code)
			{
				case 0:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,160) != 0 && myself::OwnItemCount(talker,1026) != 0 ) )
					{
						myself::SetCurrentQuestID(160);
						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::DeleteItem1(talker,1026,myself::OwnItemCount(talker,1026));
						if( myself::OwnItemCount(talker,1027) == 0 )
						{
							myself::GiveItem1(talker,1027,1);
						}
						myself::ShowPage(talker,"uno_q0311_01.htm");
						myself::SetFlagJournal(talker,160,2);
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,160) != 0 && myself::OwnItemCount(talker,1027) != 0 ) )
					{
						myself::SetCurrentQuestID(160);
						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,"uno_q0311_02.htm");
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,160) != 0 && myself::OwnItemCount(talker,1029) != 0 ) )
					{
						myself::SetCurrentQuestID(160);
						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,"uno_q0311_03.htm");
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,162) == 0 && myself::GetOneTimeQuestFlag(talker,162) == 0 ) )
					{
						myself::SetCurrentQuestID(162);
						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 )
						{
							if( talker.race == 2 )
							{
								myself::ShowPage(talker,"uno_q0314_00.htm");
							}
							else if( talker.level >= 12 )
							{
								myself::ShowPage(talker,"uno_q0314_02.htm");
							}
							else
							{
								myself::ShowPage(talker,"uno_q0314_01.htm");
							}
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 4:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,162) == 0 && myself::GetOneTimeQuestFlag(talker,162) == 1 ) )
					{
						myself::SetCurrentQuestID(162);
						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,"finishedquest.htm");
					}
					break;
				}
				case 5:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,162) == 1 && ( myself::OwnItemCount(talker,1159) + myself::OwnItemCount(talker,1158) ) < 13 ) )
					{
						myself::SetCurrentQuestID(162);
						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,"uno_q0314_05.htm");
					}
					break;
				}
				case 6:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,162) == 1 && ( myself::OwnItemCount(talker,1159) + myself::OwnItemCount(talker,1158) ) >= 13 && myself::GetOneTimeQuestFlag(talker,162) == 0 ) )
					{
						myself::SetCurrentQuestID(162);
						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,"uno_q0314_06.htm");
							myself::GiveItem1(talker,625,1);
							myself::GiveItem1(talker,57,24000);
							myself::DeleteItem1(talker,1159,myself::OwnItemCount(talker,1159));
							myself::DeleteItem1(talker,1158,myself::OwnItemCount(talker,1158));
							myself::RemoveMemo(talker,162);
							myself::AddLog(2,talker,162);
							myself::SoundEffect(talker,"ItemSound.quest_finish");
							myself::SetOneTimeQuestFlag(talker,162,1);
						}
					}
					break;
				}
			}
			return;
		}
		super;
	}

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

	EventHandler MENU_SELECTED(ask,fhtml0,quest_id,reply,talker)
	{
		if( ask == 162 )
		{
			myself::SetCurrentQuestID(162);
			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 == 162 )
		{
			if( reply == 1 )
			{
				myself::FHTML_SetFileName(fhtml0,"uno_q0314_03.htm");
				myself::FHTML_SetInt(fhtml0,"quest_id",162);
				myself::ShowFHTML(talker,fhtml0);
			}
		}
		super;
	}

}
