class 1 el_lord_chamber_ghost : royal_rush_teleporter
{
handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,620) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Four Goblets (Continue)");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			if( _code == 0 )
			{
				if( _from_choice == 0 || myself::HaveMemo(talker,620) == 1 )
				{
					myself::SetCurrentQuestID(620);
					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,"el_lord_chamber_ghost_q0620_01.htm");
				}
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,i0,i1,i2,reply,talker)
	{
		if( ask == 620 )
		{
			myself::SetCurrentQuestID(620);
			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 == 620 )
		{
			if( reply == 1 )
			{
				if( myself::HaveMemo(talker,620) && myself::OwnItemCount(talker,7255) >= 1 )
				{
					if( gg::Rand(100) < 50 )
					{
						if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
						{
							talker.quest_last_reward_time = myself::GetCurrentTick();
							i0 = gg::Rand(5);
							i2 = 0;
							if( i0 == 0 )
							{
								i2 = 1;
								myself::GiveItem1(talker,57,10000);
							}
							else if( i0 == 1 )
							{
								if( gg::Rand(1000) < 848 )
								{
									i2 = 1;
									i1 = gg::Rand(1000);
									if( i1 < 43 )
									{
										myself::GiveItem1(talker,1884,42);
									}
									else if( i1 < 66 )
									{
										myself::GiveItem1(talker,1895,36);
									}
									else if( i1 < 184 )
									{
										myself::GiveItem1(talker,1876,4);
									}
									else if( i1 < 250 )
									{
										myself::GiveItem1(talker,1881,6);
									}
									else if( i1 < 287 )
									{
										myself::GiveItem1(talker,5549,8);
									}
									else if( i1 < 484 )
									{
										myself::GiveItem1(talker,1874,1);
									}
									else if( i1 < 681 )
									{
										myself::GiveItem1(talker,1889,1);
									}
									else if( i1 < 799 )
									{
										myself::GiveItem1(talker,1877,1);
									}
									else if( i1 < 902 )
									{
										myself::GiveItem1(talker,1894,1);
									}
									else
									{
										myself::GiveItem1(talker,4043,1);
									}
								}
								if( gg::Rand(1000) < 323 )
								{
									i2 = 1;
									i1 = gg::Rand(1000);
									if( i1 < 335 )
									{
										myself::GiveItem1(talker,1888,1);
									}
									else if( i1 < 556 )
									{
										myself::GiveItem1(talker,4040,1);
									}
									else if( i1 < 725 )
									{
										myself::GiveItem1(talker,1890,1);
									}
									else if( i1 < 872 )
									{
										myself::GiveItem1(talker,5550,1);
									}
									else if( i1 < 962 )
									{
										myself::GiveItem1(talker,1893,1);
									}
									else if( i1 < 986 )
									{
										myself::GiveItem1(talker,4046,1);
									}
									else
									{
										myself::GiveItem1(talker,4048,1);
									}
								}
							}
							else if( i0 == 2 )
							{
								if( gg::Rand(1000) < 847 )
								{
									i2 = 1;
									i1 = gg::Rand(1000);
									if( i1 < 148 )
									{
										myself::GiveItem1(talker,1878,8);
									}
									else if( i1 < 175 )
									{
										myself::GiveItem1(talker,1882,24);
									}
									else if( i1 < 273 )
									{
										myself::GiveItem1(talker,1879,4);
									}
									else if( i1 < 322 )
									{
										myself::GiveItem1(talker,1880,6);
									}
									else if( i1 < 357 )
									{
										myself::GiveItem1(talker,1885,6);
									}
									else if( i1 < 554 )
									{
										myself::GiveItem1(talker,1875,1);
									}
									else if( i1 < 685 )
									{
										myself::GiveItem1(talker,1883,1);
									}
									else if( i1 < 803 )
									{
										myself::GiveItem1(talker,5220,1);
									}
									else if( i1 < 901 )
									{
										myself::GiveItem1(talker,4039,1);
									}
									else
									{
										myself::GiveItem1(talker,4044,1);
									}
								}
								if( gg::Rand(1000) < 251 )
								{
									i2 = 1;
									i1 = gg::Rand(1000);
									if( i1 < 350 )
									{
										myself::GiveItem1(talker,1887,1);
									}
									else if( i1 < 587 )
									{
										myself::GiveItem1(talker,4042,1);
									}
									else if( i1 < 798 )
									{
										myself::GiveItem1(talker,1886,1);
									}
									else if( i1 < 922 )
									{
										myself::GiveItem1(talker,4041,1);
									}
									else if( i1 < 966 )
									{
										myself::GiveItem1(talker,1892,1);
									}
									else if( i1 < 996 )
									{
										myself::GiveItem1(talker,1891,1);
									}
									else
									{
										myself::GiveItem1(talker,4047,1);
									}
								}
							}
							else if( i0 == 3 )
							{
								if( gg::Rand(1000) < 31 )
								{
									i2 = 1;
									i1 = gg::Rand(1000);
									if( i1 < 223 )
									{
										myself::GiveItem1(talker,730,1);
									}
									else if( i1 < 893 )
									{
										myself::GiveItem1(talker,948,1);
									}
									else
									{
										myself::GiveItem1(talker,960,1);
									}
								}
								if( gg::Rand(1000) < 5 )
								{
									i2 = 1;
									i1 = gg::Rand(1000);
									if( i1 < 202 )
									{
										myself::GiveItem1(talker,729,1);
									}
									else if( i1 < 928 )
									{
										myself::GiveItem1(talker,947,1);
									}
									else
									{
										myself::GiveItem1(talker,959,1);
									}
								}
							}
							else if( i0 == 4 )
							{
								if( gg::Rand(1000) < 329 )
								{
									i2 = 1;
									i1 = gg::Rand(1000);
									if( i1 < 88 )
									{
										myself::GiveItem1(talker,6698,1);
									}
									else if( i1 < 185 )
									{
										myself::GiveItem1(talker,6699,1);
									}
									else if( i1 < 238 )
									{
										myself::GiveItem1(talker,6700,1);
									}
									else if( i1 < 262 )
									{
										myself::GiveItem1(talker,6701,1);
									}
									else if( i1 < 292 )
									{
										myself::GiveItem1(talker,6702,1);
									}
									else if( i1 < 356 )
									{
										myself::GiveItem1(talker,6703,1);
									}
									else if( i1 < 420 )
									{
										myself::GiveItem1(talker,6704,1);
									}
									else if( i1 < 482 )
									{
										myself::GiveItem1(talker,6705,1);
									}
									else if( i1 < 554 )
									{
										myself::GiveItem1(talker,6706,1);
									}
									else if( i1 < 576 )
									{
										myself::GiveItem1(talker,6707,1);
									}
									else if( i1 < 640 )
									{
										myself::GiveItem1(talker,6708,1);
									}
									else if( i1 < 704 )
									{
										myself::GiveItem1(talker,6709,1);
									}
									else if( i1 < 777 )
									{
										myself::GiveItem1(talker,6710,1);
									}
									else if( i1 < 799 )
									{
										myself::GiveItem1(talker,6711,1);
									}
									else if( i1 < 863 )
									{
										myself::GiveItem1(talker,6712,1);
									}
									else if( i1 < 927 )
									{
										myself::GiveItem1(talker,6713,1);
									}
									else
									{
										myself::GiveItem1(talker,6714,1);
									}
								}
								if( gg::Rand(1000) < 54 )
								{
									i2 = 1;
									i1 = gg::Rand(1000);
									if( i1 < 100 )
									{
										myself::GiveItem1(talker,6688,1);
									}
									else if( i1 < 198 )
									{
										myself::GiveItem1(talker,6689,1);
									}
									else if( i1 < 298 )
									{
										myself::GiveItem1(talker,6690,1);
									}
									else if( i1 < 398 )
									{
										myself::GiveItem1(talker,6691,1);
									}
									else if( i1 < 499 )
									{
										myself::GiveItem1(talker,7579,1);
									}
									else if( i1 < 601 )
									{
										myself::GiveItem1(talker,6693,1);
									}
									else if( i1 < 703 )
									{
										myself::GiveItem1(talker,6694,1);
									}
									else if( i1 < 801 )
									{
										myself::GiveItem1(talker,6695,1);
									}
									else if( i1 < 902 )
									{
										myself::GiveItem1(talker,6696,1);
									}
									else
									{
										myself::GiveItem1(talker,6697,1);
									}
								}
							}
							myself::DeleteItem1(talker,7255,1);
							if( i2 == 1 )
							{
								myself::ShowPage(talker,"el_lord_chamber_ghost_q0620_03.htm");
							}
							else if( i2 == 0 )
							{
								myself::ShowPage(talker,"el_lord_chamber_ghost_q0620_04.htm");
							}
						}
					}
					else
					{
						myself::DeleteItem1(talker,7255,1);
						myself::ShowPage(talker,"el_lord_chamber_ghost_q0620_05.htm");
					}
				}
				else if( myself::HaveMemo(talker,620) && myself::OwnItemCount(talker,7255) == 0 )
				{
					myself::ShowPage(talker,"el_lord_chamber_ghost_q0620_06.htm");
				}
			}
		}
		super;
	}

}
