class 1 asamah : merchant
{
property:
	BuySellList SellList0 = {{"trap_stone";35};{"elrokian_trap";35}};

handler:
	EventHandler TALK_SELECTED(talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,124) == 0 )
			{
				if( myself::GetOneTimeQuestFlag(talker,124) == 0 )
				{
					_choiceN = ( _choiceN + 1 );
					_code = 0;
					myself::AddChoice(0,"Meeting the Elroki");
				}
				else
				{
					_choiceN = ( _choiceN + 1 );
					_code = 1;
					myself::AddChoice(1,"Meeting the Elroki - Complete");
				}
			}
			else
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Meeting the Elroki - In Progress");
			}
			if( myself::HaveMemo(talker,111) == 0 )
			{
				if( myself::GetOneTimeQuestFlag(talker,111) == 0 )
				{
					_choiceN = ( _choiceN + 1 );
					_code = 3;
					myself::AddChoice(3,"Elrokian Hunter's Proof");
				}
				else
				{
					_choiceN = ( _choiceN + 1 );
					_code = 4;
					myself::AddChoice(4,"Elrokian Hunter's Proof - Complete");
				}
			}
			else
			{
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Elrokian Hunter's Proof - In Progress");
			}
			if( myself::HaveMemo(talker,126) == 0 )
			{
				if( myself::GetOneTimeQuestFlag(talker,126) == 0 )
				{
					_choiceN = ( _choiceN + 1 );
					_code = 6;
					myself::AddChoice(6,"In the Name of Evil - Part 2");
				}
				else
				{
					_choiceN = ( _choiceN + 1 );
					_code = 7;
					myself::AddChoice(7,"In the Name of Evil Part 2 - Complete");
				}
			}
			else
			{
				_choiceN = ( _choiceN + 1 );
				_code = 8;
				myself::AddChoice(8,"In the Name of Evil Part 2 - In Progress");
			}
		}
		if( _choiceN > 1 )
		{
			myself::ShowChoicePage(talker,1);
			return;
		}
		if( _from_choice || _choiceN == 1 )
		{
			switch(_code)
			{
				case 0:
				{
					myself::ShowPage(talker,"asamah_q124_007.htm");
					break;
				}
				case 1:
				{
					myself::SetCurrentQuestID(124);
					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,"asamah_q124_008.htm");
					break;
				}
				case 2:
				{
					myself::SetCurrentQuestID(124);
					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::GetMemoState(talker,124) < 3 )
					{
						myself::ShowPage(talker,"asamah_q124_007.htm");
						return;
					}
					if( myself::GetMemoState(talker,124) == 3 )
					{
						myself::ShowPage(talker,"asamah_q124_001.htm");
						return;
					}
					if( myself::GetMemoState(talker,124) == 6 )
					{
						myself::ShowPage(talker,"asamah_q124_005.htm");
						return;
					}
					myself::ShowPage(talker,"asamah_q124_004.htm");
					break;
				}
				case 3:
				{
					myself::ShowPage(talker,"asamah_q111_008.htm");
					break;
				}
				case 4:
				{
					myself::SetCurrentQuestID(111);
					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:
				{
					myself::SetCurrentQuestID(111);
					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::GetMemoState(talker,111) < 2 )
					{
						myself::ShowPage(talker,"asamah_q111_008.htm");
						return;
					}
					if( myself::GetMemoState(talker,111) == 2 )
					{
						myself::ShowPage(talker,"asamah_q111_001.htm");
						return;
					}
					if( myself::GetMemoState(talker,111) < 8 )
					{
						myself::ShowPage(talker,"asamah_q111_002.htm");
						return;
					}
					if( myself::GetMemoState(talker,111) == 8 )
					{
						myself::ShowPage(talker,"asamah_q111_003.htm");
						return;
					}
					if( myself::GetMemoState(talker,111) == 9 )
					{
						myself::ShowPage(talker,"asamah_q111_005.htm");
						return;
					}
					if( myself::GetMemoState(talker,111) < 11 )
					{
						myself::ShowPage(talker,"asamah_q111_006.htm");
						return;
					}
					if( myself::GetMemoState(talker,111) == 11 )
					{
						if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
						{
							talker.quest_last_reward_time = myself::GetCurrentTick();
							if( myself::OwnItemCount(talker,8770) >= 10 && myself::OwnItemCount(talker,8771) >= 10 && myself::OwnItemCount(talker,8772) >= 10 )
							{
								myself::DeleteItem1(talker,8770,myself::OwnItemCount(talker,8770));
								myself::DeleteItem1(talker,8771,myself::OwnItemCount(talker,8771));
								myself::DeleteItem1(talker,8772,myself::OwnItemCount(talker,8772));
								if( myself::OwnItemCount(talker,8773) > 0 )
								{
									myself::DeleteItem1(talker,8773,myself::OwnItemCount(talker,8773));
								}
								myself::GiveItem1(talker,8773,1);
								myself::SetMemoState(talker,111,12);
								myself::SetFlagJournal(talker,111,12);
								myself::ShowPage(talker,"asamah_q111_007.htm");
								myself::SoundEffect(talker,"ItemSound.quest_middle");
							}
							else
							{
								myself::SetMemoState(talker,111,10);
								myself::SetFlagJournal(talker,111,10);
								myself::ShowPage(talker,"asamah_q111_006.htm");
								myself::SoundEffect(talker,"ItemSound.quest_middle");
							}
						}
						return;
					}
					myself::ShowPage(talker,"asamah_q111_007.htm");
					break;
				}
				case 6:
				{
					if( myself::GetOneTimeQuestFlag(talker,125) == 1 )
					{
						if( talker.level >= 77 )
						{
							myself::ShowPage(talker,"asama_q0126_01.htm");
						}
						else
						{
							myself::ShowPage(talker,"asama_q0126_02.htm");
						}
					}
					else
					{
						myself::ShowPage(talker,"asama_q0126_04.htm");
					}
					break;
				}
				case 7:
				{
					myself::ShowPage(talker,"finishedquest.htm");
					break;
				}
				case 8:
				{
					myself::SetCurrentQuestID(125);
					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::GetMemoState(talker,126) == 1 )
					{
						myself::ShowPage(talker,"asama_q0126_01.htm");
					}
					else if( myself::GetMemoState(talker,126) >= 2 && myself::GetMemoState(talker,126) < 21 )
					{
						myself::ShowPage(talker,"asama_q0126_12.htm");
					}
					else if( myself::GetMemoState(talker,126) == 21 )
					{
						myself::ShowPage(talker,"asama_q0126_13.htm");
					}
					else if( myself::GetMemoState(talker,126) >= 22 )
					{
						myself::ShowPage(talker,"asama_q0126_29.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 124 )
		{
			myself::SetCurrentQuestID(124);
			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( reply == 1 )
			{
				myself::SetMemoState(talker,124,4);
				myself::SetFlagJournal(talker,124,4);
				myself::ShowPage(talker,"asamah_q124_004.htm");
				myself::SoundEffect(talker,"ItemSound.quest_middle");
				return;
			}
			if( reply == 2 )
			{
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					if( myself::OwnItemCount(talker,8778) == 0 )
					{
						myself::SetMemoState(talker,124,4);
						myself::SetFlagJournal(talker,124,4);
						myself::ShowPage(talker,"asamah_q124_004.htm");
						myself::SoundEffect(talker,"ItemSound.quest_middle");
						return;
					}
					myself::DeleteItem1(talker,8778,myself::OwnItemCount(talker,8778));
					myself::SetOneTimeQuestFlag(talker,124,1);
					myself::RemoveMemo(talker,124);
					myself::GiveItem1(talker,57,71318);
					myself::SoundEffect(talker,"ItemSound.quest_finish");
				}
				return;
			}
		}
		if( ask == 111 )
		{
			myself::SetCurrentQuestID(111);
			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( reply == 1 )
			{
				myself::SetMemoState(talker,111,3);
				myself::SetFlagJournal(talker,111,3);
				myself::ShowPage(talker,"asamah_q111_002.htm");
				myself::SoundEffect(talker,"ItemSound.quest_middle");
				return;
			}
			if( reply == 2 )
			{
				myself::SetMemoState(talker,111,9);
				myself::SetFlagJournal(talker,111,9);
				myself::ShowPage(talker,"asamah_q111_004.htm");
				myself::SoundEffect(talker,"ItemSound.quest_middle");
				return;
			}
			if( reply == 3 )
			{
				myself::SetMemoState(talker,111,10);
				myself::SetFlagJournal(talker,111,10);
				myself::ShowPage(talker,"asamah_q111_006.htm");
				myself::SoundEffect(talker,"ItemSound.quest_middle");
				return;
			}
		}
		if( ask == 126 )
		{
			myself::SetCurrentQuestID(126);
			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( reply == 1 )
			{
				myself::SetMemoState(talker,126,1);
				myself::SetFlagJournal(talker,126,1);
				myself::ShowPage(talker,"asama_q0126_05.htm");
				return;
			}
			if( reply == 2 )
			{
				myself::SetMemoState(talker,126,22);
				myself::SetFlagJournal(talker,126,22);
				myself::ShowPage(talker,"asama_q0126_28.htm");
				return;
			}
		}
		super;
	}

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

}
