class 1 quilt : human_mage_lv1_master
{
handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,158) == 0 && myself::GetOneTimeQuestFlag(talker,158) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Seed of Evil");
			}
			if( myself::HaveMemo(talker,158) == 0 && myself::GetOneTimeQuestFlag(talker,158) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Seed of Evil (Complete)");
			}
			if( myself::HaveMemo(talker,158) != 0 && myself::OwnItemCount(talker,1025) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Seed of Evil (Continue)");
			}
			if( myself::HaveMemo(talker,158) != 0 && myself::OwnItemCount(talker,1025) != 0 && myself::GetOneTimeQuestFlag(talker,158) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Seed of Evil (Continue)");
			}
			if( myself::HaveMemo(talker,402) == 1 && myself::OwnItemCount(talker,1178) == 0 && myself::OwnItemCount(talker,1271) && myself::OwnItemCount(talker,1167) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Path to a Knight (Continue)");
			}
			if( myself::HaveMemo(talker,402) == 1 && myself::OwnItemCount(talker,1178) > 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Path to a Knight (Continue)");
			}
			if( myself::HaveMemo(talker,402) == 1 && myself::OwnItemCount(talker,1167) > 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"Path to a Knight (Continue)");
			}
			if( myself::HaveMemo(talker,217) == 1 && myself::GetMemoState(talker,217) == 19 && myself::OwnItemCount(talker,2744) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 7;
				myself::AddChoice(7,"Testimony of Trust (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,158) == 0 && myself::GetOneTimeQuestFlag(talker,158) == 0 ) )
					{
						myself::SetCurrentQuestID(158);
						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 >= 21 )
							{
								myself::FHTML_SetFileName(fhtml0,"quilt_q0309_03.htm");
								myself::FHTML_SetInt(fhtml0,"quest_id",158);
								myself::ShowFHTML(talker,fhtml0);
							}
							else
							{
								myself::ShowPage(talker,"quilt_q0309_02.htm");
							}
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,158) == 0 && myself::GetOneTimeQuestFlag(talker,158) == 1 ) )
					{
						myself::SetCurrentQuestID(158);
						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,"finishedquest.htm");
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,158) != 0 && myself::OwnItemCount(talker,1025) == 0 ) )
					{
						myself::SetCurrentQuestID(158);
						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,"quilt_q0309_05.htm");
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,158) != 0 && myself::OwnItemCount(talker,1025) != 0 && myself::GetOneTimeQuestFlag(talker,158) == 0 ) )
					{
						myself::SetCurrentQuestID(158);
						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::DeleteItem1(talker,1025,myself::OwnItemCount(talker,1025));
							myself::RemoveMemo(talker,158);
							myself::AddLog(2,talker,158);
							myself::SoundEffect(talker,"ItemSound.quest_finish");
							myself::SetOneTimeQuestFlag(talker,158,1);
							myself::GiveItem1(talker,956,1);
							myself::ShowPage(talker,"quilt_q0309_06.htm");
						}
					}
					break;
				}
				case 4:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,402) == 1 && myself::OwnItemCount(talker,1178) == 0 && myself::OwnItemCount(talker,1271) && myself::OwnItemCount(talker,1167) == 0 ) )
					{
						myself::SetCurrentQuestID(402);
						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,"quilt_q0402_01.htm");
					}
					break;
				}
				case 5:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,402) == 1 && myself::OwnItemCount(talker,1178) > 0 ) )
					{
						myself::SetCurrentQuestID(402);
						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,1179) < 10 )
						{
							myself::ShowPage(talker,"quilt_q0402_03.htm");
						}
						else if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
						{
							talker.quest_last_reward_time = myself::GetCurrentTick();
							myself::ShowPage(talker,"quilt_q0402_04.htm");
							myself::DeleteItem1(talker,1179,myself::OwnItemCount(talker,1179));
							myself::DeleteItem1(talker,1178,1);
							myself::GiveItem1(talker,1167,1);
						}
					}
					break;
				}
				case 6:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,402) == 1 && myself::OwnItemCount(talker,1167) > 0 ) )
					{
						myself::SetCurrentQuestID(402);
						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,"quilt_q0402_05.htm");
					}
					break;
				}
				case 7:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,217) == 1 && myself::GetMemoState(talker,217) == 19 && myself::OwnItemCount(talker,2744) ) )
					{
						myself::SetCurrentQuestID(217);
						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,39571);
							myself::IncrementParam(talker,1,2500);
							myself::GiveItem1(talker,7562,16);
							myself::ShowPage(talker,"quilt_q0217_01.htm");
							myself::DeleteItem1(talker,2744,1);
							myself::GiveItem1(talker,2734,1);
							myself::RemoveMemo(talker,217);
							myself::AddLog(2,talker,217);
							myself::SoundEffect(talker,"ItemSound.quest_finish");
							myself::SetOneTimeQuestFlag(talker,217,1);
						}
					}
					break;
				}
			}
			return;
		}
		super;
	}

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

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 402 )
		{
			myself::SetCurrentQuestID(402);
			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 == 402 )
		{
			if( reply = 1 )
			{
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::ShowPage(talker,"quilt_q0402_02.htm");
					myself::GiveItem1(talker,1178,1);
				}
			}
		}
		super;
	}

}
