class 1 valkon : warehouse_keeper
{
handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,216) == 0 && myself::GetOneTimeQuestFlag(talker,216) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Trial of the Guildsman");
			}
			if( myself::HaveMemo(talker,216) == 0 && myself::GetOneTimeQuestFlag(talker,216) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Trial of the Guildsman (Complete)");
			}
			if( myself::HaveMemo(talker,216) == 1 && myself::OwnItemCount(talker,3120) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Trial of the Guildsman (Continue)");
			}
			if( myself::HaveMemo(talker,216) == 1 && myself::OwnItemCount(talker,3122) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Trial of the Guildsman (Continue)");
			}
			if( myself::HaveMemo(talker,214) == 1 && myself::OwnItemCount(talker,2705) == 1 && myself::OwnItemCount(talker,2710) == 0 && myself::OwnItemCount(talker,2714) == 0 && myself::OwnItemCount(talker,2707) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Trial of the Scholar (Continue)");
			}
			if( myself::HaveMemo(talker,214) == 1 && myself::OwnItemCount(talker,2705) == 1 && myself::OwnItemCount(talker,2710) == 1 && myself::OwnItemCount(talker,2714) == 0 && myself::OwnItemCount(talker,2707) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Trial of the Scholar (Continue)");
			}
			if( myself::HaveMemo(talker,214) == 1 && myself::OwnItemCount(talker,2705) == 1 && myself::OwnItemCount(talker,2710) == 0 && myself::OwnItemCount(talker,2714) == 1 && myself::OwnItemCount(talker,2707) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"Trial of the Scholar (Continue)");
			}
			if( myself::HaveMemo(talker,214) == 1 && myself::OwnItemCount(talker,2705) == 1 && myself::OwnItemCount(talker,2710) == 0 && myself::OwnItemCount(talker,2714) == 0 && myself::OwnItemCount(talker,2707) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 7;
				myself::AddChoice(7,"Trial of the Scholar (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,216) == 0 && myself::GetOneTimeQuestFlag(talker,216) == 0 ) )
					{
						myself::SetCurrentQuestID(216);
						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.occupation == 56 || talker.occupation == 54 )
							{
								if( talker.level < 35 )
								{
									myself::ShowPage(talker,"valkon_q0216_02.htm");
								}
								else
								{
									myself::ShowPage(talker,"valkon_q0216_03.htm");
								}
							}
							else
							{
								myself::ShowPage(talker,"valkon_q0216_01.htm");
							}
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,216) == 0 && myself::GetOneTimeQuestFlag(talker,216) == 1 ) )
					{
						myself::SetCurrentQuestID(216);
						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 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,216) == 1 && myself::OwnItemCount(talker,3120) == 1 ) )
					{
						myself::SetCurrentQuestID(216);
						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,"valkon_q0216_07.htm");
						myself::SetFlagJournal(talker,216,3);
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,216) == 1 && myself::OwnItemCount(talker,3122) == 1 ) )
					{
						myself::SetCurrentQuestID(216);
						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,3139) < 7 )
						{
							myself::ShowPage(talker,"valkon_q0216_08.htm");
						}
						else
						{
							myself::ShowPage(talker,"valkon_q0216_09.htm");
						}
					}
					break;
				}
				case 4:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,214) == 1 && myself::OwnItemCount(talker,2705) == 1 && myself::OwnItemCount(talker,2710) == 0 && myself::OwnItemCount(talker,2714) == 0 && myself::OwnItemCount(talker,2707) == 0 ) )
					{
						myself::SetCurrentQuestID(214);
						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,"valkon_q0214_01.htm");
					}
					break;
				}
				case 5:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,214) == 1 && myself::OwnItemCount(talker,2705) == 1 && myself::OwnItemCount(talker,2710) == 1 && myself::OwnItemCount(talker,2714) == 0 && myself::OwnItemCount(talker,2707) == 0 ) )
					{
						myself::SetCurrentQuestID(214);
						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,"valkon_q0214_05.htm");
					}
					break;
				}
				case 6:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,214) == 1 && myself::OwnItemCount(talker,2705) == 1 && myself::OwnItemCount(talker,2710) == 0 && myself::OwnItemCount(talker,2714) == 1 && myself::OwnItemCount(talker,2707) == 0 ) )
					{
						myself::SetCurrentQuestID(214);
						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,"valkon_q0214_06.htm");
							myself::DeleteItem1(talker,2714,1);
							myself::GiveItem1(talker,2707,1);
						}
					}
					break;
				}
				case 7:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,214) == 1 && myself::OwnItemCount(talker,2705) == 1 && myself::OwnItemCount(talker,2710) == 0 && myself::OwnItemCount(talker,2714) == 0 && myself::OwnItemCount(talker,2707) == 1 ) )
					{
						myself::SetCurrentQuestID(214);
						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,"valkon_q0214_07.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(quest_id,talker)
	{
		if( quest_id == 216 )
		{
			myself::SetCurrentQuestID(216);
			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,57) >= 2000 )
			{
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::SetMemo(talker,quest_id);
					myself::SoundEffect(talker,"ItemSound.quest_accept");
					if( myself::OwnItemCount(talker,3120) == 0 )
					{
						myself::GiveItem1(talker,3120,1);
					}
					myself::ShowPage(talker,"valkon_q0216_06.htm");
					myself::DeleteItem1(talker,57,2000);
					myself::SetFlagJournal(talker,216,1);
				}
			}
			else
			{
				myself::ShowPage(talker,"valkon_q0216_05b.htm");
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,fhtml0,reply,talker)
	{
		if( ask == 216 )
		{
			myself::SetCurrentQuestID(216);
			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 == 216 )
		{
			if( reply == 1 )
			{
				myself::ShowPage(talker,"valkon_q0216_04.htm");
			}
			if( reply == 2 )
			{
				myself::FHTML_SetFileName(fhtml0,"valkon_q0216_05.htm");
				myself::FHTML_SetInt(fhtml0,"quest_id",216);
				myself::ShowFHTML(talker,fhtml0);
			}
			if( reply == 3 )
			{
				if( myself::HaveMemo(talker,216) == 1 && myself::OwnItemCount(talker,3122) >= 1 && myself::OwnItemCount(talker,3139) >= 7 )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::ShowPage(talker,"valkon_q0216_09a.htm");
						myself::RemoveMemo(talker,216);
						myself::SoundEffect(talker,"ItemSound.quest_finish");
						myself::SetOneTimeQuestFlag(talker,216,1);
						myself::IncrementParam(talker,0,80993);
						myself::IncrementParam(talker,1,12250);
						myself::GiveItem1(talker,7562,8);
						myself::DeleteItem1(talker,3139,myself::OwnItemCount(talker,3139));
						myself::DeleteItem1(talker,3122,myself::OwnItemCount(talker,3122));
						myself::DeleteItem1(talker,3024,myself::OwnItemCount(talker,3024));
						myself::GiveItem1(talker,3119,1);
					}
				}
			}
			if( reply == 4 )
			{
				if( myself::HaveMemo(talker,216) == 1 && myself::OwnItemCount(talker,3122) >= 1 && myself::OwnItemCount(talker,3139) >= 7 )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::IncrementParam(talker,0,241321);
						myself::GiveItem1(talker,7562,8);
						myself::ShowPage(talker,"valkon_q0216_09b.htm");
						myself::RemoveMemo(talker,216);
						myself::SoundEffect(talker,"ItemSound.quest_finish");
						myself::SetOneTimeQuestFlag(talker,216,1);
						myself::DeleteItem1(talker,3139,myself::OwnItemCount(talker,3139));
						myself::DeleteItem1(talker,3122,myself::OwnItemCount(talker,3122));
						myself::DeleteItem1(talker,3024,myself::OwnItemCount(talker,3024));
						myself::GiveItem1(talker,3119,1);
					}
				}
			}
		}
		if( ask == 214 )
		{
			myself::SetCurrentQuestID(214);
			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 == 214 )
		{
			if( reply == 1 )
			{
				myself::ShowPage(talker,"valkon_q0214_02.htm");
			}
			if( reply == 2 )
			{
				myself::ShowPage(talker,"valkon_q0214_03.htm");
			}
			if( reply == 3 )
			{
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::ShowPage(talker,"valkon_q0214_04.htm");
					myself::GiveItem1(talker,2710,1);
				}
			}
		}
		super;
	}

}
