class 1 kalinta : citizen
{
handler:
	EventHandler TALK_SELECTED(talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,410) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Path to a Palus Knight (Continue)");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			if( _code == 0 )
			{
				if( _from_choice == 0 || myself::HaveMemo(talker,410) == 1 )
				{
					myself::SetCurrentQuestID(410);
					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,1239) )
					{
						myself::ShowPage(talker,"kalinta_q0410_01.htm");
					}
					else if( myself::OwnItemCount(talker,1240) && myself::OwnItemCount(talker,1242) == 0 && myself::OwnItemCount(talker,1241) == 0 )
					{
						myself::ShowPage(talker,"kalinta_q0410_03.htm");
					}
					else if( myself::OwnItemCount(talker,1240) && myself::OwnItemCount(talker,1242) == 0 && myself::OwnItemCount(talker,1241) > 0 )
					{
						myself::ShowPage(talker,"kalinta_q0410_04.htm");
					}
					else if( myself::OwnItemCount(talker,1240) && myself::OwnItemCount(talker,1242) >= 5 && myself::OwnItemCount(talker,1241) > 0 )
					{
						myself::ShowPage(talker,"kalinta_q0410_05.htm");
					}
					else if( myself::OwnItemCount(talker,1240) && myself::OwnItemCount(talker,1242) > 0 && myself::OwnItemCount(talker,1241) >= 0 )
					{
						myself::ShowPage(talker,"kalinta_q0410_04.htm");
					}
					else if( myself::OwnItemCount(talker,1243) )
					{
						myself::ShowPage(talker,"kalinta_q0410_06.htm");
					}
				}
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,fhtml0,reply,talker)
	{
		if( ask == 410 )
		{
			myself::SetCurrentQuestID(410);
			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 == 410 )
		{
			if( reply == 1 && myself::OwnItemCount(talker,1239) > 0 )
			{
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::ShowPage(talker,"kalinta_q0410_02.htm");
					myself::DeleteItem1(talker,1239,1);
					myself::GiveItem1(talker,1240,1);
					myself::SetFlagJournal(talker,410,4);
				}
			}
			else if( reply == 2 && myself::OwnItemCount(talker,1240) > 0 && myself::OwnItemCount(talker,1242) > 0 && myself::OwnItemCount(talker,1241) > 0 )
			{
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::ShowPage(talker,"kalinta_q0410_06.htm");
					myself::DeleteItem1(talker,1240,1);
					myself::DeleteItem1(talker,1242,myself::OwnItemCount(talker,1242));
					myself::DeleteItem1(talker,1241,myself::OwnItemCount(talker,1241));
					myself::GiveItem1(talker,1243,1);
					myself::SetFlagJournal(talker,410,6);
				}
			}
		}
		super;
	}

}
