class 1 ice_shelf : citizen
{
handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,648) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"An Ice Merchant Dream");
			}
			else if( myself::GetMemoState(talker,648) == 2 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"An Ice Merchant Dream (continue...)");
			}
			else
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"An Ice Merchant Dream");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			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;
			}
			else
			{
				switch(_code)
				{
					case 0:
					{
						myself::ShowPage(talker,"noquest.htm");
						break;
					}
					case 1:
					{
						myself::SetCurrentQuestID(648);
						myself::ShowPage(talker,"ice_shelf_q648_001.htm");
						break;
					}
				}
				return;
			}
		}
	}

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 648 )
		{
			myself::SetCurrentQuestID(648);
			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;
			}
			else if( reply == 1 )
			{
				myself::ShowPage(talker,"ice_shelf_q648_002.htm");
			}
			if( reply == 2 )
			{
				if( myself::OwnItemCount(talker,8077) > 0 )
				{
					if( gg::Rand(100) > 49 )
					{
						myself::ShowPage(talker,"ice_shelf_q648_003.htm");
					}
					else
					{
						myself::DeleteItem1(talker,8077,1);
						myself::ShowPage(talker,"ice_shelf_q648_005.htm");
					}
				}
				else
				{
					myself::ShowPage(talker,"ice_shelf_q648_004.htm");
				}
			}
			if( reply == 3 )
			{
				if( myself::OwnItemCount(talker,8077) > 0 )
				{
					if( gg::Rand(100) > 49 )
					{
						myself::GiveItem1(talker,8078,1);
						myself::DeleteItem1(talker,8077,1);
						myself::ShowPage(talker,"ice_shelf_q648_006.htm");
					}
					else
					{
						myself::DeleteItem1(talker,8077,1);
						myself::ShowPage(talker,"ice_shelf_q648_005.htm");
					}
				}
				else
				{
					myself::ShowPage(talker,"ice_shelf_q648_004.htm");
				}
			}
		}
	}

}
