class 1 varika : citizen
{
handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,412) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Path to a Dark Wizard");
			}
			if( myself::HaveMemo(talker,412) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Path to a Dark Wizard (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,412) == 0 )
					{
						myself::SetCurrentQuestID(412);
						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::GetMemoCount(talker) < 26 )
						{
							if( myself::OwnItemCount(talker,1261) == 0 )
							{
								myself::FHTML_SetFileName(fhtml0,"varika_q0412_01.htm");
								myself::FHTML_SetInt(fhtml0,"quest_id",412);
								myself::ShowFHTML(talker,fhtml0);
							}
							else
							{
								myself::ShowPage(talker,"varika_q0412_04.htm");
							}
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || myself::HaveMemo(talker,412) == 1 )
					{
						myself::SetCurrentQuestID(412);
						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::OwnItemCount(talker,1254) && myself::OwnItemCount(talker,1255) && myself::OwnItemCount(talker,1256) && myself::OwnItemCount(talker,1253) )
						{
							if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
							{
								talker.quest_last_reward_time = myself::GetCurrentTick();
								myself::ShowPage(talker,"varika_q0412_16.htm");
								myself::DeleteItem1(talker,1255,1);
								myself::DeleteItem1(talker,1253,1);
								myself::DeleteItem1(talker,1256,1);
								myself::DeleteItem1(talker,1254,1);
								myself::GiveItem1(talker,1261,1);
								myself::IncrementParam(talker,0,3200);
								myself::IncrementParam(talker,1,1650);
								myself::RemoveMemo(talker,412);
								myself::AddLog(2,talker,412);
								myself::SoundEffect(talker,"ItemSound.quest_finish");
							}
						}
						else if( myself::OwnItemCount(talker,1254) == 1 && myself::OwnItemCount(talker,1257) == 0 && myself::OwnItemCount(talker,1277) == 0 && myself::OwnItemCount(talker,1278) == 0 && myself::OwnItemCount(talker,1279) == 0 && myself::OwnItemCount(talker,1259) == 0 && myself::OwnItemCount(talker,1260) == 0 )
						{
							myself::ShowPage(talker,"varika_q0412_17.htm");
						}
						else if( myself::OwnItemCount(talker,1254) == 1 && myself::GetMemoState(talker,412) == 1 && myself::OwnItemCount(talker,1253) == 0 )
						{
							myself::ShowPage(talker,"varika_q0412_08.htm");
						}
						else if( myself::OwnItemCount(talker,1254) == 1 && myself::GetMemoState(talker,412) == 2 && myself::OwnItemCount(talker,1255) == 0 )
						{
							myself::ShowPage(talker,"varika_q0412_19.htm");
						}
						else if( myself::OwnItemCount(talker,1254) == 1 && myself::GetMemoState(talker,412) == 3 && myself::OwnItemCount(talker,1256) == 0 )
						{
							myself::ShowPage(talker,"varika_q0412_13.htm");
						}
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(quest_id,talker)
	{
		if( quest_id == 412 )
		{
			myself::SetCurrentQuestID(412);
			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::HaveMemo(talker,412) == 0 )
			{
				if( talker.level >= 19 && talker.occupation == 38 && myself::OwnItemCount(talker,1261) == 0 )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::SetMemo(talker,412);
						myself::AddLog(1,talker,412);
						myself::SoundEffect(talker,"ItemSound.quest_accept");
						myself::GiveItem1(talker,1254,1);
						myself::ShowPage(talker,"varika_q0412_05.htm");
						myself::SetFlagJournal(talker,412,1);
					}
				}
				else if( talker.occupation != 38 )
				{
					if( talker.occupation == 39 )
					{
						myself::ShowPage(talker,"varika_q0412_02a.htm");
					}
					else
					{
						myself::ShowPage(talker,"varika_q0412_03.htm");
					}
				}
				else if( talker.level < 19 && talker.occupation == 38 )
				{
					myself::ShowPage(talker,"varika_q0412_02.htm");
				}
				else if( talker.level >= 19 && talker.occupation == 38 && myself::OwnItemCount(talker,1261) == 1 )
				{
					myself::ShowPage(talker,"varika_q0412_04.htm");
				}
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 412 )
		{
			myself::SetCurrentQuestID(412);
			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 == 412 )
		{
			if( reply == 1 )
			{
				if( myself::OwnItemCount(talker,1253) )
				{
					myself::ShowPage(talker,"varika_q0412_06.htm");
				}
				else
				{
					myself::ShowPage(talker,"varika_q0412_07.htm");
					myself::SetMemoState(talker,412,1);
				}
			}
			else if( reply == 2 )
			{
				if( myself::OwnItemCount(talker,1255) )
				{
					myself::ShowPage(talker,"varika_q0412_09.htm");
				}
				else
				{
					myself::ShowPage(talker,"varika_q0412_10.htm");
					myself::SetMemoState(talker,412,2);
				}
			}
			else if( reply == 3 )
			{
				if( myself::OwnItemCount(talker,1256) )
				{
					myself::ShowPage(talker,"varika_q0412_12.htm");
				}
				else if( myself::OwnItemCount(talker,1256) == 0 && myself::OwnItemCount(talker,1254) )
				{
					myself::ShowPage(talker,"varika_q0412_13.htm");
					myself::SetMemoState(talker,412,3);
				}
			}
		}
		super;
	}

}
