class 1 iason_haine : citizen
{
handler:
	EventHandler TALK_SELECTED(fhtml0,i0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,348) == 1 && myself::GetMemoStateEx(talker,348,0) == 18 && ( myself::GetMemoStateEx(talker,348,1) % 8 ) < 4 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"An Arrogant Search (Continue)");
			}
			if( myself::HaveMemo(talker,348) == 1 && myself::GetMemoStateEx(talker,348,0) == 18 && ( myself::GetMemoStateEx(talker,348,1) % 8 ) >= 4 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"An Arrogant Search (Continue)");
			}
			if( myself::HaveMemo(talker,351) == 1 && myself::GetMemoState(talker,351) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Black Swan (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,348) == 1 && myself::GetMemoStateEx(talker,348,0) == 18 && ( myself::GetMemoStateEx(talker,348,1) % 8 ) < 4 ) )
					{
						myself::SetCurrentQuestID(348);
						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,4295) >= 6 )
						{
							myself::DeleteItem1(talker,4295,6);
							i0 = ( myself::GetMemoStateEx(talker,348,1) + 4 );
							myself::SetMemoStateEx(talker,348,1,i0);
							myself::ShowPage(talker,"iason_haine_q0348_01.htm");
						}
						else if( myself::OwnItemCount(talker,4295) < 6 )
						{
							myself::ShowPage(talker,"iason_haine_q0348_03.htm");
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,348) == 1 && myself::GetMemoStateEx(talker,348,0) == 18 && ( myself::GetMemoStateEx(talker,348,1) % 8 ) >= 4 ) )
					{
						myself::SetCurrentQuestID(348);
						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,"iason_haine_q0348_02.htm");
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,351) == 1 && myself::GetMemoState(talker,351) == 1 ) )
					{
						myself::SetCurrentQuestID(351);
						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,"iason_haine_q0351_01.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 351 )
		{
			myself::SetCurrentQuestID(351);
			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 == 351 )
		{
			if( reply == 1 )
			{
				if( myself::OwnItemCount(talker,4297) == 0 )
				{
					myself::ShowPage(talker,"iason_haine_q0351_02.htm");
				}
				else if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					if( myself::OwnItemCount(talker,4297) >= 10 )
					{
						myself::GiveItem1(talker,57,( 3880 + ( 20 * myself::OwnItemCount(talker,4297) ) ));
					}
					else
					{
						myself::GiveItem1(talker,57,( 20 * myself::OwnItemCount(talker,4297) ));
					}
					myself::DeleteItem1(talker,4297,myself::OwnItemCount(talker,4297));
					myself::ShowPage(talker,"iason_haine_q0351_03.htm");
				}
			}
			if( reply == 2 )
			{
				if( myself::OwnItemCount(talker,4298) == 0 )
				{
					myself::ShowPage(talker,"iason_haine_q0351_04.htm");
				}
				else if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::GiveItem1(talker,4407,myself::OwnItemCount(talker,4298));
					if( myself::OwnItemCount(talker,4298) >= 10 )
					{
						myself::GiveItem1(talker,57,( 3880 + ( 20 * myself::OwnItemCount(talker,4298) ) ));
					}
					else
					{
						myself::GiveItem1(talker,57,( 2000 * myself::OwnItemCount(talker,4298) ));
					}
					myself::DeleteItem1(talker,4298,myself::OwnItemCount(talker,4298));
					myself::ShowPage(talker,"iason_haine_q0351_05.htm");
					myself::SetFlagJournal(talker,351,2);
				}
			}
			if( reply == 3 )
			{
				myself::ShowPage(talker,"iason_haine_q0351_06.htm");
			}
			if( reply == 4 )
			{
				if( myself::OwnItemCount(talker,4298) == 0 && myself::OwnItemCount(talker,4297) == 0 )
				{
					myself::ShowPage(talker,"iason_haine_q0351_07.htm");
				}
				else
				{
					myself::ShowPage(talker,"iason_haine_q0351_08.htm");
				}
			}
			if( reply == 5 )
			{
				myself::ShowPage(talker,"iason_haine_q0351_09.htm");
				if( myself::OwnItemCount(talker,4296) > 0 )
				{
					myself::DeleteItem1(talker,4296,1);
				}
				myself::RemoveMemo(talker,351);
				myself::SoundEffect(talker,"ItemSound.quest_finish");
			}
		}
		super;
	}

}
