class 1 ancestor_martankus : citizen
{
handler:
	EventHandler TALK_SELECTED(talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,215) == 1 && myself::GetMemoState(talker,215) == 2 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Trial of the Pilgrim (Continue)");
			}
			if( myself::HaveMemo(talker,215) == 1 && myself::GetMemoState(talker,215) == 3 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Trial of the Pilgrim (Continue)");
			}
			if( myself::HaveMemo(talker,215) == 1 && myself::GetMemoState(talker,215) == 4 && myself::OwnItemCount(talker,2725) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Trial of the Pilgrim (Continue)");
			}
			if( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3412) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Test of the Lord (Continue)");
			}
			if( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3413) == 1 && myself::OwnItemCount(talker,3415) == 0 && myself::OwnItemCount(talker,3414) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Test of the Lord (Continue)");
			}
			if( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3413) >= 1 && myself::OwnItemCount(talker,3415) >= 1 && myself::OwnItemCount(talker,3414) >= 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Test of the Lord (Continue)");
			}
			if( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3416) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"Test of the Lord (Continue)");
			}
			if( myself::HaveMemo(talker,233) == 1 && myself::OwnItemCount(talker,2882) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 7;
				myself::AddChoice(7,"Test of the War Spirit (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,215) == 1 && myself::GetMemoState(talker,215) == 2 ) )
					{
						myself::SetCurrentQuestID(215);
						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,"ancestor_martankus_q0215_01.htm");
						myself::SetMemoState(talker,215,3);
						myself::SetFlagJournal(talker,215,3);
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,215) == 1 && myself::GetMemoState(talker,215) == 3 ) )
					{
						myself::SetCurrentQuestID(215);
						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,"ancestor_martankus_q0215_02.htm");
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,215) == 1 && myself::GetMemoState(talker,215) == 4 && myself::OwnItemCount(talker,2725) ) )
					{
						myself::SetCurrentQuestID(215);
						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,"ancestor_martankus_q0215_03.htm");
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3412) == 1 ) )
					{
						myself::SetCurrentQuestID(232);
						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,"ancestor_martankus_q0232_01.htm");
					}
					break;
				}
				case 4:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3413) == 1 && myself::OwnItemCount(talker,3415) == 0 && myself::OwnItemCount(talker,3414) == 0 ) )
					{
						myself::SetCurrentQuestID(232);
						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,"ancestor_martankus_q0232_05.htm");
					}
					break;
				}
				case 5:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3413) >= 1 && myself::OwnItemCount(talker,3415) >= 1 && myself::OwnItemCount(talker,3414) >= 1 ) )
					{
						myself::SetCurrentQuestID(232);
						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,"ancestor_martankus_q0232_06.htm");
							myself::DeleteItem1(talker,3413,myself::OwnItemCount(talker,3413));
							myself::DeleteItem1(talker,3414,myself::OwnItemCount(talker,3414));
							myself::DeleteItem1(talker,3415,1);
							myself::GiveItem1(talker,3416,1);
						}
					}
					break;
				}
				case 6:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3416) == 1 ) )
					{
						myself::SetCurrentQuestID(232);
						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,"ancestor_martankus_q0232_08.htm");
						if( myself::Maker_GetNpcCount() == 1 )
						{
							myself::CreateOnePrivateEx(1030643,"first_orc",0,0,21036,-107690,-3038,0,0,0,0);
						}
					}
					break;
				}
				case 7:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,233) == 1 && myself::OwnItemCount(talker,2882) == 1 ) )
					{
						myself::SetCurrentQuestID(233);
						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,"ancestor_martankus_q0233_01.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 215 )
		{
			myself::SetCurrentQuestID(215);
			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 == 215 )
		{
			if( reply == 1 && myself::OwnItemCount(talker,2725) > 0 && myself::GetMemoState(talker,215) == 4 )
			{
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::ShowPage(talker,"ancestor_martankus_q0215_04.htm");
					myself::GiveItem1(talker,2724,1);
					myself::DeleteItem1(talker,2725,1);
					myself::SetMemoState(talker,215,5);
					myself::SetFlagJournal(talker,215,5);
				}
			}
		}
		if( ask == 232 )
		{
			myself::SetCurrentQuestID(232);
			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 == 232 )
		{
			if( reply == 1 )
			{
				myself::ShowPage(talker,"ancestor_martankus_q0232_02.htm");
			}
			if( reply == 2 )
			{
				myself::ShowPage(talker,"ancestor_martankus_q0232_03.htm");
			}
			if( reply == 3 )
			{
				if( myself::OwnItemCount(talker,3412) >= 1 )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::ShowPage(talker,"ancestor_martankus_q0232_04.htm");
						myself::DeleteItem1(talker,3412,1);
						myself::GiveItem1(talker,3413,1);
					}
				}
			}
			if( reply == 4 )
			{
				myself::ShowPage(talker,"ancestor_martankus_q0232_07.htm");
				if( myself::Maker_GetNpcCount() == 1 )
				{
					myself::CreateOnePrivateEx(1030643,"first_orc",0,0,21036,-107690,-3038,0,0,0,0);
				}
			}
		}
		if( ask == 233 )
		{
			myself::SetCurrentQuestID(233);
			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 == 233 )
		{
			if( reply == 1 )
			{
				myself::ShowPage(talker,"ancestor_martankus_q0233_02.htm");
			}
			if( reply == 2 )
			{
				if( myself::OwnItemCount(talker,2912) >= 1 )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::DeleteItem1(talker,2882,myself::OwnItemCount(talker,2882));
						myself::DeleteItem1(talker,2911,myself::OwnItemCount(talker,2911));
						myself::DeleteItem1(talker,2913,myself::OwnItemCount(talker,2913));
						myself::DeleteItem1(talker,2914,myself::OwnItemCount(talker,2914));
						myself::DeleteItem1(talker,2881,myself::OwnItemCount(talker,2881));
						myself::IncrementParam(talker,0,63483);
						myself::IncrementParam(talker,1,17500);
						myself::DeleteItem1(talker,2912,1);
						myself::GiveItem1(talker,2879,1);
						myself::ShowPage(talker,"ancestor_martankus_q0233_03.htm");
						myself::RemoveMemo(talker,233);
						myself::SoundEffect(talker,"ItemSound.quest_finish");
						myself::SetOneTimeQuestFlag(talker,233,1);
					}
				}
			}
		}
		super;
	}

}
