class 1 wisdom_chest : citizen
{
handler:
	EventHandler TALK_SELECTED(fhtml0,i0,i1,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,334) == 1 && talker.flag == 4 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"The Wishing Potion (Continue)");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			if( _code == 0 )
			{
				if( _from_choice == 0 || ( myself::HaveMemo(talker,334) == 1 && talker.flag == 4 ) )
				{
					myself::SetCurrentQuestID(334);
					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;
					}
					i0 = gg::Rand(10);
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						if( i0 < 2 )
						{
							myself::ShowPage(talker,"wisdom_chest_q0334_01.htm");
						}
						else if( i0 >= 2 && i0 < 4 )
						{
							myself::ShowPage(talker,"wisdom_chest_q0334_02.htm");
						}
						else if( i0 >= 4 && i0 < 6 )
						{
							myself::ShowPage(talker,"wisdom_chest_q0334_03.htm");
						}
						else if( i0 == 6 )
						{
							myself::ShowPage(talker,"wisdom_chest_q0334_04.htm");
						}
						else if( i0 >= 7 && i0 < 9 )
						{
							myself::ShowPage(talker,"wisdom_chest_q0334_05.htm");
						}
						else if( i0 == 9 )
						{
							myself::ShowPage(talker,"wisdom_chest_q0334_06.htm");
						}
						switch(gg::Rand(34))
						{
							case 0:
							{
								myself::GiveItem1(talker,3081,1);
								break;
							}
							case 1:
							{
								myself::GiveItem1(talker,3076,1);
								break;
							}
							case 2:
							{
								myself::GiveItem1(talker,3075,1);
								break;
							}
							case 3:
							{
								myself::GiveItem1(talker,3074,1);
								break;
							}
							case 4:
							{
								myself::GiveItem1(talker,4917,1);
								break;
							}
							case 5:
							{
								myself::GiveItem1(talker,3077,1);
								break;
							}
							case 6:
							{
								myself::GiveItem1(talker,3080,1);
								break;
							}
							case 7:
							{
								myself::GiveItem1(talker,3079,1);
								break;
							}
							case 8:
							{
								myself::GiveItem1(talker,3078,1);
								break;
							}
							case 9:
							{
								myself::GiveItem1(talker,4928,1);
								break;
							}
							case 10:
							{
								myself::GiveItem1(talker,4931,1);
								break;
							}
							case 11:
							{
								myself::GiveItem1(talker,4932,1);
								break;
							}
							case 12:
							{
								myself::GiveItem1(talker,5013,1);
								break;
							}
							case 13:
							{
								myself::GiveItem1(talker,3067,1);
								break;
							}
							case 14:
							{
								myself::GiveItem1(talker,3064,1);
								break;
							}
							case 15:
							{
								myself::GiveItem1(talker,3061,1);
								break;
							}
							case 16:
							{
								myself::GiveItem1(talker,3062,1);
								break;
							}
							case 17:
							{
								myself::GiveItem1(talker,3058,1);
								break;
							}
							case 18:
							{
								myself::GiveItem1(talker,4206,1);
								break;
							}
							case 19:
							{
								myself::GiveItem1(talker,3065,1);
								break;
							}
							case 20:
							{
								myself::GiveItem1(talker,3060,1);
								break;
							}
							case 21:
							{
								myself::GiveItem1(talker,3063,1);
								break;
							}
							case 22:
							{
								myself::GiveItem1(talker,4208,1);
								break;
							}
							case 23:
							{
								myself::GiveItem1(talker,3057,1);
								break;
							}
							case 24:
							{
								myself::GiveItem1(talker,3059,1);
								break;
							}
							case 25:
							{
								myself::GiveItem1(talker,3066,1);
								break;
							}
							case 26:
							{
								myself::GiveItem1(talker,4911,1);
								break;
							}
							case 27:
							{
								myself::GiveItem1(talker,4918,1);
								break;
							}
							case 28:
							{
								myself::GiveItem1(talker,3092,1);
								break;
							}
							case 29:
							{
								myself::GiveItem1(talker,3039,1);
								break;
							}
							case 30:
							{
								myself::GiveItem1(talker,4922,1);
								break;
							}
							case 31:
							{
								myself::GiveItem1(talker,3091,1);
								break;
							}
							case 32:
							{
								myself::GiveItem1(talker,3093,1);
								break;
							}
							case 33:
							{
								myself::GiveItem1(talker,3431,1);
								break;
							}
						}
						switch(gg::Rand(34))
						{
							case 0:
							{
								myself::GiveItem1(talker,3430,1);
								break;
							}
							case 1:
							{
								myself::GiveItem1(talker,3429,1);
								break;
							}
							case 2:
							{
								myself::GiveItem1(talker,3073,1);
								break;
							}
							case 3:
							{
								myself::GiveItem1(talker,3941,1);
								break;
							}
							case 4:
							{
								myself::GiveItem1(talker,3071,1);
								break;
							}
							case 5:
							{
								myself::GiveItem1(talker,3069,1);
								break;
							}
							case 6:
							{
								myself::GiveItem1(talker,3072,1);
								break;
							}
							case 7:
							{
								myself::GiveItem1(talker,4200,1);
								break;
							}
							case 8:
							{
								myself::GiveItem1(talker,3068,1);
								break;
							}
							case 9:
							{
								myself::GiveItem1(talker,3070,1);
								break;
							}
							case 10:
							{
								myself::GiveItem1(talker,4912,1);
								break;
							}
							case 11:
							{
								myself::GiveItem1(talker,3100,1);
								break;
							}
							case 12:
							{
								myself::GiveItem1(talker,3101,1);
								break;
							}
							case 13:
							{
								myself::GiveItem1(talker,3098,1);
								break;
							}
							case 14:
							{
								myself::GiveItem1(talker,3094,1);
								break;
							}
							case 15:
							{
								myself::GiveItem1(talker,3102,1);
								break;
							}
							case 16:
							{
								myself::GiveItem1(talker,4913,1);
								break;
							}
							case 17:
							{
								myself::GiveItem1(talker,3095,1);
								break;
							}
							case 18:
							{
								myself::GiveItem1(talker,3096,1);
								break;
							}
							case 19:
							{
								myself::GiveItem1(talker,3097,1);
								break;
							}
							case 20:
							{
								myself::GiveItem1(talker,3099,1);
								break;
							}
							case 21:
							{
								myself::GiveItem1(talker,3085,1);
								break;
							}
							case 22:
							{
								myself::GiveItem1(talker,3086,1);
								break;
							}
							case 23:
							{
								myself::GiveItem1(talker,3082,1);
								break;
							}
							case 24:
							{
								myself::GiveItem1(talker,4907,1);
								break;
							}
							case 25:
							{
								myself::GiveItem1(talker,3088,1);
								break;
							}
							case 26:
							{
								myself::GiveItem1(talker,4207,1);
								break;
							}
							case 27:
							{
								myself::GiveItem1(talker,3087,1);
								break;
							}
							case 28:
							{
								myself::GiveItem1(talker,3084,1);
								break;
							}
							case 29:
							{
								myself::GiveItem1(talker,3083,1);
								break;
							}
							case 30:
							{
								myself::GiveItem1(talker,4929,1);
								break;
							}
							case 31:
							{
								myself::GiveItem1(talker,4933,1);
								break;
							}
							case 32:
							{
								myself::GiveItem1(talker,4919,1);
								break;
							}
							case 33:
							{
								myself::GiveItem1(talker,3045,1);
								break;
							}
						}
						switch(gg::Rand(33))
						{
							case 0:
							{
								myself::GiveItem1(talker,4923,1);
								break;
							}
							case 1:
							{
								myself::GiveItem1(talker,4201,1);
								break;
							}
							case 2:
							{
								myself::GiveItem1(talker,4914,1);
								break;
							}
							case 3:
							{
								myself::GiveItem1(talker,3942,1);
								break;
							}
							case 4:
							{
								myself::GiveItem1(talker,3090,1);
								break;
							}
							case 5:
							{
								myself::GiveItem1(talker,4909,1);
								break;
							}
							case 6:
							{
								myself::GiveItem1(talker,3089,1);
								break;
							}
							case 7:
							{
								myself::GiveItem1(talker,4930,1);
								break;
							}
							case 8:
							{
								myself::GiveItem1(talker,4934,1);
								break;
							}
							case 9:
							{
								myself::GiveItem1(talker,4920,1);
								break;
							}
							case 10:
							{
								myself::GiveItem1(talker,3041,1);
								break;
							}
							case 11:
							{
								myself::GiveItem1(talker,4924,1);
								break;
							}
							case 12:
							{
								myself::GiveItem1(talker,3114,1);
								break;
							}
							case 13:
							{
								myself::GiveItem1(talker,3105,1);
								break;
							}
							case 14:
							{
								myself::GiveItem1(talker,3110,1);
								break;
							}
							case 15:
							{
								myself::GiveItem1(talker,3104,1);
								break;
							}
							case 16:
							{
								myself::GiveItem1(talker,3113,1);
								break;
							}
							case 17:
							{
								myself::GiveItem1(talker,3103,1);
								break;
							}
							case 18:
							{
								myself::GiveItem1(talker,4204,1);
								break;
							}
							case 19:
							{
								myself::GiveItem1(talker,3108,1);
								break;
							}
							case 20:
							{
								myself::GiveItem1(talker,4926,1);
								break;
							}
							case 21:
							{
								myself::GiveItem1(talker,3112,1);
								break;
							}
							case 22:
							{
								myself::GiveItem1(talker,3107,1);
								break;
							}
							case 23:
							{
								myself::GiveItem1(talker,4205,1);
								break;
							}
							case 24:
							{
								myself::GiveItem1(talker,3109,1);
								break;
							}
							case 25:
							{
								myself::GiveItem1(talker,3111,1);
								break;
							}
							case 26:
							{
								myself::GiveItem1(talker,3106,1);
								break;
							}
							case 27:
							{
								myself::GiveItem1(talker,4925,1);
								break;
							}
							case 28:
							{
								myself::GiveItem1(talker,3117,1);
								break;
							}
							case 29:
							{
								myself::GiveItem1(talker,3115,1);
								break;
							}
							case 30:
							{
								myself::GiveItem1(talker,3118,1);
								break;
							}
							case 31:
							{
								myself::GiveItem1(talker,3116,1);
								break;
							}
							case 32:
							{
								myself::GiveItem1(talker,4927,1);
								break;
							}
						}
						if( gg::Rand(3) == 0 )
						{
							myself::GiveItem1(talker,3943,1);
						}
						myself::GiveItem1(talker,4408,1);
						myself::GiveItem1(talker,4409,1);
						talker.flag = 0;
						myself::Despawn();
					}
				}
			}
			return;
		}
		super;
	}

	EventHandler TIMER_FIRED_EX(timer_id)
	{
		myself::SetCurrentQuestID(334);
		if( timer_id == 2336007 )
		{
			myself::Despawn();
		}
		super;
	}

	EventHandler CREATED(i0)
	{
		myself::SetCurrentQuestID(334);
		myself::AddTimerEx(2336007,( 120 * 1000 ));
		myself::Say(myself::MakeFString(33421,"","","","",""));
		super;
	}

}
