class 1 blacksmith_pinter : blacksmith
{
handler:
	EventHandler TALK_SELECTED(talker,c0)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,118) == 0 && myself::GetOneTimeQuestFlag(talker,118) == 0 && talker.division == -1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 7;
				myself::AddChoice(7,"To Lead And Be Led");
			}
			if( myself::HaveMemo(talker,118) && myself::GetMemoState(talker,118) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 8;
				myself::AddChoice(8,"To Lead And Be Led (Continue)");
			}
			if( myself::HaveMemo(talker,118) && myself::GetMemoState(talker,118) == 2 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 9;
				myself::AddChoice(9,"To Lead And Be Led (Continue)");
			}
			if( myself::HaveMemo(talker,118) && myself::GetMemoState(talker,118) == 3 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 10;
				myself::AddChoice(10,"To Lead And Be Led (Continue)");
			}
			if( talker.division != -1 && talker.sponsor_index != 0 )
			{
				c0 = myself::GetCreatureFromIndex(talker.sponsor_index);
				if( c0 != 0 && myself::HaveMemo(c0,118) && myself::GetMemoState(c0,118) == 3 )
				{
					_choiceN = ( _choiceN + 1 );
					_code = 11;
					myself::AddChoice(11,"To Lead And Be Led (Continue)");
				}
			}
			if( myself::HaveMemo(talker,118) && myself::GetMemoState(talker,118) == 4 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 12;
				myself::AddChoice(12,"To Lead And Be Led (Continue)");
			}
			if( myself::HaveMemo(talker,118) && myself::GetMemoState(talker,118) == 5 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 13;
				myself::AddChoice(13,"To Lead And Be Led (Continue)");
			}
			if( myself::HaveMemo(talker,118) && myself::GetMemoState(talker,118) == 6 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 14;
				myself::AddChoice(14,"To Lead And Be Led (Continue)");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			switch(_code)
			{
				case 7:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,118) == 0 && myself::GetOneTimeQuestFlag(talker,118) == 0 && talker.division == -1 ) )
					{
						myself::SetCurrentQuestID(118);
						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 >= 19 && talker.sponsor_index != 0 )
							{
								myself::ShowPage(talker,"blacksmith_pinter_q0118_01.htm");
							}
							else
							{
								myself::ShowPage(talker,"blacksmith_pinter_q0118_00.htm");
							}
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 8:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,118) == 1 && myself::GetMemoState(target,118) == 1 ) )
					{
						myself::SetCurrentQuestID(118);
						myself::ShowPage(talker,"blacksmith_pinter_q0118_03.htm");
					}
					break;
				}
				case 9:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,118) == 1 && myself::GetMemoState(target,118) == 2 ) )
					{
						myself::SetCurrentQuestID(118);
						myself::ShowPage(talker,"blacksmith_pinter_q0118_04.htm");
					}
					break;
				}
				case 10:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,118) == 1 && myself::GetMemoState(target,118) == 3 ) )
					{
						myself::SetCurrentQuestID(118);
						myself::ShowPage(talker,"blacksmith_pinter_q0118_05.htm");
					}
					break;
				}
				case 11:
				{
					if( _from_choice != 0 && talker.division != -1 && talker.sponsor_index != 0 )
					{
						c0 = myself::GetCreatureFromIndex(talker.sponsor_index);
					}
					if( _from_choice == 0 || ( c0 != 0 && myself::HaveMemo(c0,118) && myself::GetMemoState(c0,118) == 3 ) )
					{
						myself::SetCurrentQuestID(118);
						if( myself::GetMemoStateEx(c0,118,1) == 1 )
						{
							myself::ShowPage(talker,"blacksmith_pinter_q0118_08.htm");
						}
						else if( myself::GetMemoStateEx(c0,118,1) == 2 )
						{
							myself::ShowPage(talker,"blacksmith_pinter_q0118_09.htm");
						}
						else if( myself::GetMemoStateEx(c0,118,1) == 3 )
						{
							myself::ShowPage(talker,"blacksmith_pinter_q0118_10.htm");
						}
					}
					break;
				}
				case 12:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,118) == 1 && myself::GetMemoState(target,118) == 4 ) )
					{
						myself::SetCurrentQuestID(118);
						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,"blacksmith_pinter_q0118_13.htm");
					}
					break;
				}
				case 13:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,118) == 1 && myself::GetMemoState(target,118) == 5 ) )
					{
						myself::SetCurrentQuestID(118);
						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,"blacksmith_pinter_q0118_14.htm");
					}
					break;
				}
				case 14:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,118) == 1 && myself::GetMemoState(target,118) == 6 ) )
					{
						myself::SetCurrentQuestID(118);
						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();
							if( myself::GetMemoStateEx(talker,118,1) == 1 )
							{
								myself::GiveItem1(talker,7850,1);
								myself::GiveItem1(talker,7851,1);
								myself::GiveItem1(talker,7852,1);
								myself::GiveItem1(talker,7853,1);
								myself::RemoveMemo(talker,118);
								myself::AddLog(2,talker,118);
								myself::SoundEffect(talker,"ItemSound.quest_finish");
								myself::SetOneTimeQuestFlag(talker,118,1);
								myself::ShowPage(talker,"blacksmith_pinter_q0118_15.htm");
							}
							else if( myself::GetMemoStateEx(talker,118,1) == 2 )
							{
								myself::GiveItem1(talker,7850,1);
								myself::GiveItem1(talker,7854,1);
								myself::GiveItem1(talker,7855,1);
								myself::GiveItem1(talker,7856,1);
								myself::RemoveMemo(talker,118);
								myself::AddLog(2,talker,118);
								myself::SoundEffect(talker,"ItemSound.quest_finish");
								myself::SetOneTimeQuestFlag(talker,118,1);
								myself::ShowPage(talker,"blacksmith_pinter_q0118_15.htm");
							}
							else if( myself::GetMemoStateEx(talker,118,1) == 3 )
							{
								myself::GiveItem1(talker,7850,1);
								myself::GiveItem1(talker,7857,1);
								myself::GiveItem1(talker,7858,1);
								myself::GiveItem1(talker,7859,1);
								myself::RemoveMemo(talker,118);
								myself::AddLog(2,talker,118);
								myself::SoundEffect(talker,"ItemSound.quest_finish");
								myself::SetOneTimeQuestFlag(talker,118,1);
								myself::ShowPage(talker,"blacksmith_pinter_q0118_15.htm");
							}
						}
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,reply,talker,c0)
	{
		if( ask == 118 )
		{
			if( reply == 1 )
			{
				if( myself::OwnItemCount(talker,8062) >= 10 )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::ShowPage(talker,"blacksmith_pinter_q0118_05.htm");
						myself::DeleteItem1(talker,8062,myself::OwnItemCount(talker,8062));
						myself::SetMemoState(talker,118,3);
						myself::SetMemoStateEx(talker,118,1,1);
						myself::SetFlagJournal(talker,118,3);
					}
				}
			}
			if( reply == 2 )
			{
				if( myself::OwnItemCount(talker,8062) >= 10 )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::ShowPage(talker,"blacksmith_pinter_q0118_06.htm");
						myself::DeleteItem1(talker,8062,myself::OwnItemCount(talker,8062));
						myself::SetMemoState(talker,118,3);
						myself::SetMemoStateEx(talker,118,1,2);
						myself::SetFlagJournal(talker,118,4);
					}
				}
			}
			if( reply == 3 )
			{
				if( myself::OwnItemCount(talker,8062) >= 10 )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::ShowPage(talker,"blacksmith_pinter_q0118_07.htm");
						myself::DeleteItem1(talker,8062,myself::OwnItemCount(talker,8062));
						myself::SetMemoState(talker,118,3);
						myself::SetMemoStateEx(talker,118,1,3);
						myself::SetFlagJournal(talker,118,5);
					}
				}
			}
			if( reply == 4 )
			{
				if( talker.sponsor_index != 0 )
				{
					c0 = myself::GetCreatureFromIndex(talker.sponsor_index);
					if( c0 != 0 && myself::HaveMemo(c0,118) && myself::GetMemoState(c0,118) == 3 )
					{
						if( myself::GetMemoStateEx(c0,118,1) == 1 )
						{
							if( myself::OwnItemCount(talker,1458) >= 922 )
							{
								myself::ShowPage(talker,"blacksmith_pinter_q0118_12.htm");
								myself::DeleteItem1(talker,1458,922);
								myself::SetMemoState(c0,118,4);
								myself::SetFlagJournal(c0,118,6);
							}
							else
							{
								myself::ShowPage(talker,"blacksmith_pinter_q0118_11.htm");
							}
						}
						else if( myself::GetMemoStateEx(c0,118,1) == 2 )
						{
							if( myself::OwnItemCount(talker,1458) >= 771 )
							{
								myself::ShowPage(talker,"blacksmith_pinter_q0118_12.htm");
								myself::DeleteItem1(talker,1458,771);
								myself::SetMemoState(c0,118,4);
								myself::SetFlagJournal(c0,118,6);
							}
							else
							{
								myself::ShowPage(talker,"blacksmith_pinter_q0118_11.htm");
							}
						}
						else if( myself::GetMemoStateEx(c0,118,1) == 3 )
						{
							if( myself::OwnItemCount(talker,1458) >= 771 )
							{
								myself::ShowPage(talker,"blacksmith_pinter_q0118_12.htm");
								myself::DeleteItem1(talker,1458,771);
								myself::SetMemoState(c0,118,4);
								myself::SetFlagJournal(c0,118,6);
							}
							else
							{
								myself::ShowPage(talker,"blacksmith_pinter_q0118_11.htm");
							}
						}
					}
				}
			}
			if( reply == 5 )
			{
				myself::ShowPage(talker,"blacksmith_pinter_q0118_14.htm");
				myself::SetMemoState(talker,118,5);
				myself::SetFlagJournal(talker,118,7);
			}
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(quest_id,talker)
	{
		if( quest_id == 118 )
		{
			if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
			{
				talker.quest_last_reward_time = myself::GetCurrentTick();
				myself::ShowPage(talker,"blacksmith_pinter_q0118_02.htm");
				myself::SetMemo(talker,quest_id);
				myself::SetMemoState(talker,118,1);
				myself::SetFlagJournal(talker,118,1);
				myself::AddLog(1,talker,118);
				myself::SoundEffect(talker,"ItemSound.quest_accept");
			}
			return;
		}
		super;
	}

}
