class 1 vicious_altar1 : citizen
{
handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,16) == 1 && myself::GetMemoState(talker,16) == 1 && myself::GetOneTimeQuestFlag(talker,16) == 0 && myself::OwnItemCount(talker,7167) >= 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"The Coming Darkness (Continue)");
			}
			if( myself::HaveMemo(talker,16) == 1 && myself::GetMemoState(talker,16) == 1 && myself::GetOneTimeQuestFlag(talker,16) == 0 && myself::OwnItemCount(talker,7167) < 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"The Coming Darkness (Continue)");
			}
			if( myself::HaveMemo(talker,16) == 1 && myself::GetMemoState(talker,16) == 2 && myself::GetOneTimeQuestFlag(talker,16) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"The Coming Darkness (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,16) == 1 && myself::GetMemoState(talker,16) == 1 && myself::GetOneTimeQuestFlag(talker,16) == 0 && myself::OwnItemCount(talker,7167) >= 1 ) )
					{
						myself::SetCurrentQuestID(16);
						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,"vicious_altar1_q0016_01.htm");
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,16) == 1 && myself::GetMemoState(talker,16) == 1 && myself::GetOneTimeQuestFlag(talker,16) == 0 && myself::OwnItemCount(talker,7167) < 1 ) )
					{
						myself::SetCurrentQuestID(16);
						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,"vicious_altar1_q0016_04.htm");
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,16) == 1 && myself::GetMemoState(talker,16) == 2 && myself::GetOneTimeQuestFlag(talker,16) == 0 ) )
					{
						myself::SetCurrentQuestID(16);
						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,"vicious_altar1_q0016_05.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 16 )
		{
			myself::SetCurrentQuestID(16);
			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 == 16 )
		{
			if( reply == 1 && myself::HaveMemo(talker,16) == 1 && myself::GetMemoState(talker,16) == 1 && myself::GetOneTimeQuestFlag(talker,16) == 0 )
			{
				if( myself::OwnItemCount(talker,7167) >= 1 )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::DeleteItem1(talker,7167,1);
						myself::SetMemoState(talker,16,2);
						myself::SetFlagJournal(talker,16,2);
						myself::AddUseSkillDesire(myself.sm,1164545,0,0,1000000);
						myself::ShowPage(talker,"vicious_altar1_q0016_02.htm");
					}
				}
				else
				{
					myself::ShowPage(talker,"vicious_altar1_q0016_03.htm");
				}
			}
		}
		super;
	}

}
