class 1 gilbert : chief_guard
{
handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,257) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"The Guard is Busy");
			}
			if( myself::HaveMemo(talker,257) == 1 && myself::OwnItemCount(talker,752) < 1 && myself::OwnItemCount(talker,1085) < 1 && myself::OwnItemCount(talker,1086) < 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"The Guard is Busy (Continue)");
			}
			if( myself::HaveMemo(talker,257) == 1 && ( myself::OwnItemCount(talker,752) > 0 || myself::OwnItemCount(talker,1085) > 0 || myself::OwnItemCount(talker,1086) > 0 ) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"The Guard is Busy (Continue)");
			}
			if( myself::HaveMemo(talker,402) == 1 && myself::OwnItemCount(talker,1176) == 0 && myself::OwnItemCount(talker,1271) && myself::OwnItemCount(talker,1166) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Path to a Knight (Continue)");
			}
			if( myself::HaveMemo(talker,402) == 1 && myself::OwnItemCount(talker,1176) > 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Path to a Knight (Continue)");
			}
			if( myself::HaveMemo(talker,402) == 1 && myself::OwnItemCount(talker,1166) > 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Path to a Knight (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,257) == 0 )
					{
						myself::SetCurrentQuestID(257);
						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.level >= 6 )
							{
								myself::FHTML_SetFileName(fhtml0,"gilbert_q0257_02.htm");
								myself::FHTML_SetInt(fhtml0,"quest_id",257);
								myself::ShowFHTML(talker,fhtml0);
							}
							else
							{
								myself::ShowPage(talker,"gilbert_q0257_01.htm");
							}
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,257) == 1 && myself::OwnItemCount(talker,752) < 1 && myself::OwnItemCount(talker,1085) < 1 && myself::OwnItemCount(talker,1086) < 1 ) )
					{
						myself::SetCurrentQuestID(257);
						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,"gilbert_q0257_04.htm");
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,257) == 1 && ( myself::OwnItemCount(talker,752) > 0 || myself::OwnItemCount(talker,1085) > 0 || myself::OwnItemCount(talker,1086) > 0 ) ) )
					{
						myself::SetCurrentQuestID(257);
						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,"gilbert_q0257_07.htm");
						if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
						{
							talker.quest_last_reward_time = myself::GetCurrentTick();
							if( ( ( myself::OwnItemCount(talker,752) + myself::OwnItemCount(talker,1085) ) + myself::OwnItemCount(talker,1086) ) >= 10 )
							{
								myself::GiveItem1(talker,57,( ( ( ( 10 * myself::OwnItemCount(talker,752) ) + ( 20 * myself::OwnItemCount(talker,1085) ) ) + ( 20 * myself::OwnItemCount(talker,1086) ) ) + 1000 ));
							}
							else
							{
								myself::GiveItem1(talker,57,( ( ( 10 * myself::OwnItemCount(talker,752) ) + ( 20 * myself::OwnItemCount(talker,1085) ) ) + ( 20 * myself::OwnItemCount(talker,1086) ) ));
							}
							if( talker.level < 25 && myself::IsNewbie(talker) && myself::IsInCategory(0,talker.occupation) && ( myself::GetMemoStateEx(talker,255,1) % 100 ) != 10 )
							{
								myself::VoiceEffect(talker,"tutorial_voice_026",1000);
								myself::GiveItem1(talker,5789,6000);
								myself::SetMemoStateEx(talker,255,1,10);
								myself::ShowQuestionMark(talker,26);
							}
							if( talker.level < 25 && myself::IsNewbie(talker) && myself::IsInCategory(1,talker.occupation) && ( myself::GetMemoStateEx(talker,255,1) % 100 ) != 10 )
							{
								myself::VoiceEffect(talker,"tutorial_voice_027",1000);
								myself::GiveItem1(talker,5790,3000);
								myself::SetMemoStateEx(talker,255,1,10);
								myself::ShowQuestionMark(talker,26);
							}
							myself::DeleteItem1(talker,752,myself::OwnItemCount(talker,752));
							myself::DeleteItem1(talker,1085,myself::OwnItemCount(talker,1085));
							myself::DeleteItem1(talker,1086,myself::OwnItemCount(talker,1086));
							myself::AddLog(3,talker,257);
						}
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,402) == 1 && myself::OwnItemCount(talker,1176) == 0 && myself::OwnItemCount(talker,1271) && myself::OwnItemCount(talker,1166) == 0 ) )
					{
						myself::SetCurrentQuestID(402);
						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,"gilbert_q0402_01.htm");
					}
					break;
				}
				case 4:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,402) == 1 && myself::OwnItemCount(talker,1176) > 0 ) )
					{
						myself::SetCurrentQuestID(402);
						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,1177) < 20 )
						{
							myself::ShowPage(talker,"gilbert_q0402_03.htm");
						}
						else if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
						{
							talker.quest_last_reward_time = myself::GetCurrentTick();
							myself::ShowPage(talker,"gilbert_q0402_04.htm");
							myself::DeleteItem1(talker,1177,myself::OwnItemCount(talker,1177));
							myself::DeleteItem1(talker,1176,1);
							myself::GiveItem1(talker,1166,1);
						}
					}
					break;
				}
				case 5:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,402) == 1 && myself::OwnItemCount(talker,1166) > 0 ) )
					{
						myself::SetCurrentQuestID(402);
						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,"gilbert_q0402_05.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

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

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 257 )
		{
			myself::SetCurrentQuestID(257);
			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 == 257 )
		{
			if( reply == 2 )
			{
				myself::ShowPage(talker,"gilbert_q0257_05.htm");
				talker.quest_last_reward_time = myself::GetCurrentTick();
				myself::DeleteItem1(talker,1084,myself::OwnItemCount(talker,1084));
				myself::RemoveMemo(talker,257);
				myself::AddLog(2,talker,257);
				myself::SoundEffect(talker,"ItemSound.quest_finish");
			}
			else if( reply == 3 )
			{
				myself::ShowPage(talker,"gilbert_q0257_06.htm");
			}
		}
		if( ask == 402 )
		{
			myself::SetCurrentQuestID(402);
			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 == 402 )
		{
			if( reply == 1 )
			{
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::ShowPage(talker,"gilbert_q0402_02.htm");
					myself::GiveItem1(talker,1176,1);
				}
			}
		}
		super;
	}

}
