class 1 piotur : citizen
{
handler:
	EventHandler TALK_SELECTED(fhtml0,i0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,221) == 1 && myself::OwnItemCount(talker,3239) == 1 && myself::OwnItemCount(talker,3242) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Testimony of Prosperity (Continue)");
			}
			if( myself::HaveMemo(talker,221) == 1 && myself::OwnItemCount(talker,3239) == 1 && myself::OwnItemCount(talker,3242) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Testimony of Prosperity (Continue)");
			}
			if( myself::HaveMemo(talker,221) == 1 && myself::OwnItemCount(talker,3240) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Testimony of Prosperity (Continue)");
			}
			if( myself::HaveMemo(talker,327) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Recover the Farmland");
			}
			if( myself::HaveMemo(talker,327) && myself::OwnItemCount(talker,5012) >= 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Recover the Farmland (Continue)");
			}
			if( myself::HaveMemo(talker,327) && myself::OwnItemCount(talker,5012) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Recover the Farmland (Continue)");
			}
			if( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) == 2 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"Repent Your Sins (Continue)");
			}
			if( myself::GetMemoState(talker,422) == 6 && myself::OwnItemCount(talker,4327) < 10 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 7;
				myself::AddChoice(7,"Repent Your Sins (Continue)");
			}
			if( myself::GetMemoState(talker,422) == 6 && myself::OwnItemCount(talker,4327) >= 10 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 8;
				myself::AddChoice(8,"Repent Your Sins (Continue)");
			}
			if( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) == 10 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 9;
				myself::AddChoice(9,"Repent Your Sins (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,221) == 1 && myself::OwnItemCount(talker,3239) == 1 && myself::OwnItemCount(talker,3242) == 0 ) )
					{
						myself::SetCurrentQuestID(221);
						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,"piotur_q0221_01.htm");
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,221) == 1 && myself::OwnItemCount(talker,3239) == 1 && myself::OwnItemCount(talker,3242) == 1 ) )
					{
						myself::SetCurrentQuestID(221);
						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,"piotur_q0221_03.htm");
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,221) == 1 && myself::OwnItemCount(talker,3240) == 1 ) )
					{
						myself::SetCurrentQuestID(221);
						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,"piotur_q0221_04.htm");
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || myself::HaveMemo(talker,327) == 0 )
					{
						myself::SetCurrentQuestID(327);
						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 < 25 )
							{
								myself::ShowPage(talker,"piotur_q0327_01.htm");
							}
							else
							{
								myself::FHTML_SetFileName(fhtml0,"piotur_q0327_02.htm");
								myself::FHTML_SetInt(fhtml0,"quest_id",327);
								myself::ShowFHTML(talker,fhtml0);
							}
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 4:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,327) && myself::OwnItemCount(talker,5012) >= 1 ) )
					{
						myself::SetCurrentQuestID(327);
						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,"piotur_q0327_03a.htm");
						myself::DeleteItem1(talker,5012,myself::OwnItemCount(talker,5012));
						myself::SetFlagJournal(talker,327,3);
					}
					break;
				}
				case 5:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,327) && myself::OwnItemCount(talker,5012) == 0 ) )
					{
						myself::SetCurrentQuestID(327);
						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,1846) + myself::OwnItemCount(talker,1847) ) < 1 )
						{
							myself::ShowPage(talker,"piotur_q0327_04.htm");
						}
						else if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
						{
							talker.quest_last_reward_time = myself::GetCurrentTick();
							myself::ShowPage(talker,"piotur_q0327_05.htm");
							if( ( myself::OwnItemCount(talker,1846) + myself::OwnItemCount(talker,1847) ) >= 10 )
							{
								myself::GiveItem1(talker,57,( ( 619 + ( myself::OwnItemCount(talker,1846) * 40 ) ) + ( myself::OwnItemCount(talker,1847) * 50 ) ));
							}
							else
							{
								myself::GiveItem1(talker,57,( ( myself::OwnItemCount(talker,1846) * 40 ) + ( myself::OwnItemCount(talker,1847) * 50 ) ));
							}
							myself::DeleteItem1(talker,1846,myself::OwnItemCount(talker,1846));
							myself::DeleteItem1(talker,1847,myself::OwnItemCount(talker,1847));
							myself::AddLog(3,talker,327);
							myself::SetFlagJournal(talker,327,4);
						}
					}
					break;
				}
				case 6:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) == 2 ) )
					{
						myself::SetCurrentQuestID(422);
						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::SetMemoState(talker,422,6);
						myself::ShowPage(talker,"piotur_q0422_01.htm");
						myself::SetFlagJournal(talker,422,7);
					}
					break;
				}
				case 7:
				{
					if( _from_choice == 0 || ( myself::GetMemoState(talker,422) == 6 && myself::OwnItemCount(talker,4327) < 10 ) )
					{
						myself::SetCurrentQuestID(422);
						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,"piotur_q0422_02.htm");
					}
					break;
				}
				case 8:
				{
					if( _from_choice == 0 || ( myself::GetMemoState(talker,422) == 6 && myself::OwnItemCount(talker,4327) >= 10 ) )
					{
						myself::SetCurrentQuestID(422);
						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::SetMemoState(talker,422,10);
						myself::DeleteItem1(talker,4327,myself::OwnItemCount(talker,4327));
						myself::ShowPage(talker,"piotur_q0422_03.htm");
						myself::SetFlagJournal(talker,422,11);
					}
					break;
				}
				case 9:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) == 10 ) )
					{
						myself::SetCurrentQuestID(422);
						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,"piotur_q0422_04.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

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

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 221 )
		{
			myself::SetCurrentQuestID(221);
			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 == 221 )
		{
			if( reply == 1 )
			{
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::ShowPage(talker,"piotur_q0221_02.htm");
					myself::GiveItem1(talker,3242,1);
					if( myself::OwnItemCount(talker,3241) >= 1 && myself::OwnItemCount(talker,3243) >= 1 && myself::OwnItemCount(talker,3244) >= 1 )
					{
						myself::SetFlagJournal(talker,221,2);
					}
				}
			}
		}
		if( ask == 327 )
		{
			myself::SetCurrentQuestID(327);
			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 == 327 )
		{
			if( reply == 1 )
			{
				myself::ShowPage(talker,"piotur_q0327_06.htm");
				myself::RemoveMemo(talker,327);
				myself::AddLog(2,talker,327);
				myself::SoundEffect(talker,"ItemSound.quest_finish");
			}
			else if( reply == 2 )
			{
				myself::ShowPage(talker,"piotur_q0327_07.htm");
			}
		}
		super;
	}

}
