class 1 chest_of_bifrons : citizen
{
handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,340) == 1 && myself::GetMemoState(talker,340) == 5 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Subjugation of Lizardmen (Continue)");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			if( _code == 0 )
			{
				if( _from_choice == 0 || ( myself::HaveMemo(talker,340) == 1 && myself::GetMemoState(talker,340) == 5 ) )
				{
					myself::SetCurrentQuestID(340);
					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,"chest_of_bifrons_q0340_01.htm");
				}
			}
			return;
		}
		super;
	}

	EventHandler TIMER_FIRED_EX(timer_id)
	{
		myself::SetCurrentQuestID(340);
		if( timer_id == 3401 )
		{
			myself::Despawn();
		}
		super;
	}

	EventHandler CREATED(i0)
	{
		myself::SetCurrentQuestID(340);
		myself::AddTimerEx(3401,( 30 * 1000 ));
		super;
	}

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 340 )
		{
			myself::SetCurrentQuestID(340);
			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 == 340 )
		{
			if( reply == 1 )
			{
				if( myself::HaveMemo(talker,340) == 1 && myself::GetMemoState(talker,340) == 5 )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::SetMemoState(talker,340,6);
						myself::SetFlagJournal(talker,340,6);
						myself::ShowPage(talker,"chest_of_bifrons_q0340_02.htm");
						myself::GiveItem1(talker,4258,1);
					}
				}
				else
				{
					myself::ShowPage(talker,"chest_of_bifrons_q0340_03.htm");
				}
			}
		}
		super;
	}

}
