class 1 jundin : npc_elder
{
handler:
	EventHandler TALKED(quest_id,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::OwnItemCount(talker,1070) > 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Dark Elf's Tutorial");
			}
			if( myself::OwnItemCount(talker,1070) == 0 && myself::GetMemoStateEx(talker,255,1) > 3 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Dark Elf's Tutorial");
			}
			if( myself::OwnItemCount(talker,1070) == 0 && myself::GetMemoStateEx(talker,255,1) <= 3 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Dark Elf's Tutorial");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,0);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			switch(_code)
			{
				case 0:
				{
					if( _from_choice == 0 || myself::OwnItemCount(talker,1070) > 0 )
					{
						myself::SetCurrentQuestID(204);
						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,"jundin001.htm");
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::OwnItemCount(talker,1070) == 0 && myself::GetMemoStateEx(talker,255,1) > 3 ) )
					{
						myself::SetCurrentQuestID(204);
						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,"jundin004.htm");
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::OwnItemCount(talker,1070) == 0 && myself::GetMemoStateEx(talker,255,1) <= 3 ) )
					{
						myself::SetCurrentQuestID(204);
						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,"jundin003.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler TIMER_FIRED_EX(talker,timer_id)
	{
		myself::SetCurrentQuestID(204);
		if( timer_id <= 1000000 )
		{
			return;
		}
		talker = myself::GetCreatureFromIndex(( timer_id - 1000000 ));
		if( talker.alive == 0 || talker.is_pc == 0 )
		{
			return;
		}
		if( myself::GetMemoStateEx(talker,255,1) >= 4 && timer_id >= 1000000 )
		{
			myself::ShowQuestionMark(talker,7);
			myself::SoundEffect(talker,"ItemSound.quest_tutorial");
			myself::VoiceEffect(talker,"tutorial_voice_025",1000);
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 204 )
		{
			myself::SetCurrentQuestID(204);
			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 == 420 )
		{
			if( reply == 31 && myself::OwnItemCount(talker,1070) > 0 )
			{
				if( myself::IsInCategory(0,talker.occupation) && myself::OwnItemCount(talker,5789) <= 200 )
				{
					myself::VoiceEffect(talker,"tutorial_voice_026",1000);
					myself::GiveItem1(talker,5789,200);
					myself::IncrementParam(talker,1,50);
				}
				if( myself::IsInCategory(1,talker.occupation) && myself::OwnItemCount(talker,5789) <= 200 && myself::OwnItemCount(talker,5790) <= 100 )
				{
					if( talker.occupation == 49 )
					{
						myself::VoiceEffect(talker,"tutorial_voice_026",1000);
						myself::GiveItem1(talker,5789,200);
					}
					else
					{
						myself::VoiceEffect(talker,"tutorial_voice_027",1000);
						myself::GiveItem1(talker,5790,100);
					}
					myself::IncrementParam(talker,1,50);
				}
				myself::ShowPage(talker,"jundin002.htm");
				myself::DeleteItem1(talker,1070,1);
				myself::AddTimerEx(( myself::GetIndexFromCreature(talker) + 1000000 ),( 1000 * 60 ));
				myself::ShowRadar(talker,17024,13296,-3744,2);
				if( myself::GetMemoStateEx(talker,255,1) <= 3 )
				{
					myself::SetMemoStateEx(talker,255,1,4);
				}
			}
		}
		super;
	}

}
