class 1 dorothy_the_locksmith : citizen
{
handler:
	EventHandler TALK_SELECTED(fhtml0,i0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,345) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Method to Raise the Dead");
			}
			if( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Method to Raise the Dead (Continue)");
			}
			if( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 1 && ( myself::OwnItemCount(talker,4274) == 0 || myself::OwnItemCount(talker,4275) == 0 || myself::OwnItemCount(talker,4276) == 0 || myself::OwnItemCount(talker,4277) == 0 || myself::OwnItemCount(talker,4278) == 0 ) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Method to Raise the Dead (Continue)");
			}
			if( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 1 && myself::OwnItemCount(talker,4274) >= 1 && myself::OwnItemCount(talker,4275) >= 1 && myself::OwnItemCount(talker,4276) >= 1 && myself::OwnItemCount(talker,4277) >= 1 && myself::OwnItemCount(talker,4278) >= 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Method to Raise the Dead (Continue)");
			}
			if( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 2 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Method to Raise the Dead (Continue)");
			}
			if( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 3 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Method to Raise the Dead (Continue)");
			}
			if( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 7 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"Method to Raise the Dead (Continue)");
			}
			if( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 8 && ( myself::GetMemoStateEx(talker,345,1) == 1 || myself::GetMemoStateEx(talker,345,1) == 2 ) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 7;
				myself::AddChoice(7,"Method to Raise the Dead (Continue)");
			}
			if( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 8 && myself::GetMemoStateEx(talker,345,1) == 3 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 8;
				myself::AddChoice(8,"Method to Raise the Dead (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,345) == 0 )
					{
						myself::SetCurrentQuestID(345);
						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( talker.level < 35 )
							{
								myself::ShowPage(talker,"dorothy_the_locksmith_q0345_01.htm");
							}
							else if( talker.level >= 35 )
							{
								myself::FHTML_SetFileName(fhtml0,"dorothy_the_locksmith_q0345_02.htm");
								myself::FHTML_SetInt(fhtml0,"quest_id",345);
								myself::ShowFHTML(talker,fhtml0);
							}
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 0 ) )
					{
						myself::SetCurrentQuestID(345);
						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,"dorothy_the_locksmith_q0345_04.htm");
						myself::SetMemoState(talker,345,1);
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 1 && ( myself::OwnItemCount(talker,4274) == 0 || myself::OwnItemCount(talker,4275) == 0 || myself::OwnItemCount(talker,4276) == 0 || myself::OwnItemCount(talker,4277) == 0 || myself::OwnItemCount(talker,4278) == 0 ) ) )
					{
						myself::SetCurrentQuestID(345);
						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,"dorothy_the_locksmith_q0345_05.htm");
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 1 && myself::OwnItemCount(talker,4274) >= 1 && myself::OwnItemCount(talker,4275) >= 1 && myself::OwnItemCount(talker,4276) >= 1 && myself::OwnItemCount(talker,4277) >= 1 && myself::OwnItemCount(talker,4278) >= 1 ) )
					{
						myself::SetCurrentQuestID(345);
						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,"dorothy_the_locksmith_q0345_06.htm");
					}
					break;
				}
				case 4:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 2 ) )
					{
						myself::SetCurrentQuestID(345);
						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,"dorothy_the_locksmith_q0345_08.htm");
					}
					break;
				}
				case 5:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 3 ) )
					{
						myself::SetCurrentQuestID(345);
						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,"dorothy_the_locksmith_q0345_09.htm");
					}
					break;
				}
				case 6:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 7 ) )
					{
						myself::SetCurrentQuestID(345);
						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,"dorothy_the_locksmith_q0345_12.htm");
					}
					break;
				}
				case 7:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 8 && ( myself::GetMemoStateEx(talker,345,1) == 1 || myself::GetMemoStateEx(talker,345,1) == 2 ) ) )
					{
						myself::SetCurrentQuestID(345);
						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::GiveItem1(talker,4407,3);
							myself::GiveItem1(talker,57,( 5390 + ( 70 * myself::OwnItemCount(talker,4280) ) ));
							myself::DeleteItem1(talker,4280,myself::OwnItemCount(talker,4280));
							myself::RemoveMemo(talker,345);
							myself::AddLog(2,talker,345);
							myself::SoundEffect(talker,"ItemSound.quest_finish");
							myself::ShowPage(talker,"dorothy_the_locksmith_q0345_13.htm");
						}
					}
					break;
				}
				case 8:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 8 && myself::GetMemoStateEx(talker,345,1) == 3 ) )
					{
						myself::SetCurrentQuestID(345);
						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();
							i0 = gg::Rand(100);
							if( i0 <= 92 )
							{
								myself::GiveItem1(talker,4407,5);
							}
							else
							{
								myself::GiveItem1(talker,3456,1);
							}
							myself::GiveItem1(talker,57,( 3040 + ( 70 * myself::OwnItemCount(talker,4280) ) ));
							myself::DeleteItem1(talker,4280,myself::OwnItemCount(talker,4280));
							myself::RemoveMemo(talker,345);
							myself::SoundEffect(talker,"ItemSound.quest_finish");
							myself::ShowPage(talker,"dorothy_the_locksmith_q0345_14.htm");
						}
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(quest_id,talker)
	{
		if( quest_id == 345 )
		{
			myself::SetCurrentQuestID(345);
			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::SetMemo(talker,quest_id);
				myself::SetMemoState(talker,345,0);
				myself::AddLog(1,talker,345);
				myself::SetFlagJournal(talker,345,1);
				myself::SoundEffect(talker,"ItemSound.quest_accept");
				myself::ShowPage(talker,"dorothy_the_locksmith_q0345_03.htm");
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 345 )
		{
			myself::SetCurrentQuestID(345);
			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 == 345 )
		{
			if( reply == 1 )
			{
				myself::ShowPage(talker,"dorothy_the_locksmith_q0345_04.htm");
				myself::SetMemoState(talker,345,1);
			}
			if( reply == 2 )
			{
				if( myself::HaveMemo(talker,345) == 1 && myself::GetMemoState(talker,345) == 1 && myself::OwnItemCount(talker,4274) >= 1 && myself::OwnItemCount(talker,4275) >= 1 && myself::OwnItemCount(talker,4276) >= 1 && myself::OwnItemCount(talker,4277) >= 1 && myself::OwnItemCount(talker,4278) >= 1 )
				{
					myself::SetMemoState(talker,345,2);
					myself::SetFlagJournal(talker,345,2);
					myself::ShowPage(talker,"dorothy_the_locksmith_q0345_07.htm");
				}
			}
		}
		super;
	}

}
