class 1 pupina : cleric_coach
{
handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,227) == 0 && myself::GetOneTimeQuestFlag(talker,227) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Test of the Reformer");
			}
			if( myself::HaveMemo(talker,227) == 0 && myself::GetOneTimeQuestFlag(talker,227) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Test of the Reformer (Complete)");
			}
			if( myself::HaveMemo(talker,227) == 1 && myself::OwnItemCount(talker,2832) >= 1 && myself::GetMemoState(talker,227) == 3 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Test of the Reformer (Continue)");
			}
			if( myself::HaveMemo(talker,227) == 1 && myself::GetMemoState(talker,227) >= 1 && myself::GetMemoState(talker,227) < 3 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Test of the Reformer (Continue)");
			}
			if( myself::HaveMemo(talker,227) == 1 && myself::GetMemoState(talker,227) >= 4 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Test of the Reformer (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,227) == 0 && myself::GetOneTimeQuestFlag(talker,227) == 0 ) )
					{
						myself::SetCurrentQuestID(227);
						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.occupation == 15 || talker.occupation == 42 )
							{
								if( talker.level >= 39 )
								{
									myself::FHTML_SetFileName(fhtml0,"pupina_q0227_03.htm");
									myself::FHTML_SetInt(fhtml0,"quest_id",227);
									myself::ShowFHTML(talker,fhtml0);
								}
								else
								{
									myself::ShowPage(talker,"pupina_q0227_01.htm");
								}
							}
							else
							{
								myself::ShowPage(talker,"pupina_q0227_02.htm");
							}
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,227) == 0 && myself::GetOneTimeQuestFlag(talker,227) == 1 ) )
					{
						myself::SetCurrentQuestID(227);
						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,227) == 1 && myself::OwnItemCount(talker,2832) >= 1 && myself::GetMemoState(talker,227) == 3 ) )
					{
						myself::SetCurrentQuestID(227);
						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,"pupina_q0227_05.htm");
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,227) == 1 && myself::GetMemoState(talker,227) >= 1 && myself::GetMemoState(talker,227) < 3 ) )
					{
						myself::SetCurrentQuestID(227);
						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,"pupina_q0227_04a.htm");
					}
					break;
				}
				case 4:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,227) == 1 && myself::GetMemoState(talker,227) >= 4 ) )
					{
						myself::SetCurrentQuestID(227);
						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,"pupina_q0227_07.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(quest_id,talker)
	{
		if( quest_id == 227 )
		{
			myself::SetCurrentQuestID(227);
			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");
				if( myself::OwnItemCount(talker,2822) == 0 )
				{
					myself::GiveItem1(talker,2822,1);
				}
				myself::ShowPage(talker,"pupina_q0227_04.htm");
				myself::SetMemoState(talker,227,1);
				myself::SetFlagJournal(talker,227,1);
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 227 )
		{
			myself::SetCurrentQuestID(227);
			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 == 227 )
		{
			if( reply == 1 )
			{
				if( myself::OwnItemCount(talker,2822) >= 1 )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::ShowPage(talker,"pupina_q0227_06.htm");
						myself::DeleteItem1(talker,2822,1);
						myself::GiveItem1(talker,2823,1);
						myself::SetMemoState(talker,227,4);
						myself::DeleteItem1(talker,2832,myself::OwnItemCount(talker,2832));
						myself::SetFlagJournal(talker,227,4);
					}
				}
			}
		}
		super;
	}

}
