class 1 raldo : citizen
{
handler:
	EventHandler TALK_SELECTED(talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,211) == 1 && myself::OwnItemCount(talker,2630) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Trial of the Challenger (Continue)");
			}
			if( myself::HaveMemo(talker,211) == 1 && myself::GetMemoState(talker,211) == 7 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Trial of the Challenger (Continue)");
			}
			if( myself::HaveMemo(talker,211) == 1 && myself::GetMemoState(talker,211) == 9 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Trial of the Challenger (Continue)");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			switch(_code)
			{
				case 0:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,211) == 1 && myself::OwnItemCount(talker,2630) ) )
					{
						myself::SetCurrentQuestID(211);
						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,"raldo_q0211_01.htm");
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,211) == 1 && myself::GetMemoState(talker,211) == 7 ) )
					{
						myself::SetCurrentQuestID(211);
						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,"raldo_q0211_06a.htm");
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,211) == 1 && myself::GetMemoState(talker,211) == 9 ) )
					{
						myself::SetCurrentQuestID(211);
						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::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
						{
							talker.quest_last_reward_time = myself::GetCurrentTick();
							myself::IncrementParam(talker,0,72394);
							myself::IncrementParam(talker,1,11250);
							myself::GiveItem1(talker,7562,8);
							myself::ShowPage(talker,"raldo_q0211_07.htm");
							myself::GiveItem1(talker,2627,1);
							myself::DeleteItem1(talker,2632,myself::OwnItemCount(talker,2632));
							myself::SoundEffect(talker,"ItemSound.quest_finish");
							myself::SetOneTimeQuestFlag(talker,211,1);
							myself::RemoveMemo(talker,211);
							myself::AddLog(2,talker,211);
						}
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler TIMER_FIRED_EX(timer_id)
	{
		myself::SetCurrentQuestID(211);
		if( timer_id == 21101 )
		{
			myself::Despawn();
		}
		super;
	}

	EventHandler CREATED(i0)
	{
		myself::SetCurrentQuestID(211);
		myself::AddTimerEx(21101,( 1000 * 100 ));
		super;
	}

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 211 )
		{
			myself::SetCurrentQuestID(211);
			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 == 211 )
		{
			if( reply == 1 )
			{
				myself::ShowPage(talker,"raldo_q0211_02.htm");
			}
			else if( reply == 2 )
			{
				myself::ShowPage(talker,"raldo_q0211_03.htm");
			}
			else if( reply == 3 && myself::OwnItemCount(talker,2630) > 0 )
			{
				myself::ShowPage(talker,"raldo_q0211_04.htm");
				myself::SetMemoState(talker,211,7);
				myself::SetFlagJournal(talker,211,8);
				myself::DeleteItem1(talker,2630,1);
			}
			else if( reply == 4 && myself::OwnItemCount(talker,2630) > 0 )
			{
				myself::ShowPage(talker,"raldo_q0211_06.htm");
				myself::SetMemoState(talker,211,7);
				myself::SetFlagJournal(talker,211,8);
				myself::DeleteItem1(talker,2630,1);
			}
		}
		super;
	}

}
