class 1 atuba_chief_varkees : citizen
{
handler:
	EventHandler TALK_SELECTED(fhtml0,i0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,4) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Long Live the Pa'agrio Lord (Continue)");
			}
			if( myself::HaveMemo(talker,273) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Invaders of the Holy Land");
			}
			if( myself::HaveMemo(talker,273) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Invaders of the Holy Land (Continue)");
			}
			if( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3391) == 1 && myself::OwnItemCount(talker,3400) == 0 && myself::OwnItemCount(talker,3392) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Test of the Lord (Continue)");
			}
			if( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3400) == 0 && myself::OwnItemCount(talker,3399) == 0 && myself::OwnItemCount(talker,3391) >= 1 && myself::OwnItemCount(talker,3392) >= 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Test of the Lord (Continue)");
			}
			if( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3400) == 0 && myself::OwnItemCount(talker,3391) >= 1 && myself::OwnItemCount(talker,3392) >= 1 && myself::OwnItemCount(talker,3399) >= 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Test of the Lord (Continue)");
			}
			if( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3392) == 0 && myself::OwnItemCount(talker,3391) >= 1 && myself::OwnItemCount(talker,3400) >= 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"Test of the Lord (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,4) == 1 )
					{
						myself::SetCurrentQuestID(4);
						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,1541) < 1 )
						{
							if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
							{
								talker.quest_last_reward_time = myself::GetCurrentTick();
								myself::ShowPage(talker,"atuba_chief_varkees_q0004_01.htm");
								myself::GiveItem1(talker,1541,1);
								if( ( ( ( ( ( myself::OwnItemCount(talker,1541) + myself::OwnItemCount(talker,1542) ) + myself::OwnItemCount(talker,1543) ) + myself::OwnItemCount(talker,1544) ) + myself::OwnItemCount(talker,1545) ) + myself::OwnItemCount(talker,1546) ) >= 5 )
								{
									myself::SetFlagJournal(talker,4,2);
								}
								myself::SoundEffect(talker,"ItemSound.quest_itemget");
							}
						}
						else if( myself::OwnItemCount(talker,1541) >= 1 )
						{
							myself::ShowPage(talker,"atuba_chief_varkees_q0004_02.htm");
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || myself::HaveMemo(talker,273) == 0 )
					{
						myself::SetCurrentQuestID(273);
						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.race != 3 )
							{
								myself::ShowPage(talker,"atuba_chief_varkees_q0273_00.htm");
							}
							else if( talker.level < 6 )
							{
								myself::ShowPage(talker,"atuba_chief_varkees_q0273_01.htm");
							}
							else
							{
								myself::FHTML_SetFileName(fhtml0,"atuba_chief_varkees_q0273_02.htm");
								myself::FHTML_SetInt(fhtml0,"quest_id",273);
								myself::ShowFHTML(talker,fhtml0);
							}
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || myself::HaveMemo(talker,273) )
					{
						myself::SetCurrentQuestID(273);
						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::OwnItemCount(talker,1475) + myself::OwnItemCount(talker,1476) ) == 0 )
							{
								myself::ShowPage(talker,"atuba_chief_varkees_q0273_04.htm");
							}
							else if( myself::OwnItemCount(talker,1476) == 0 )
							{
								i0 = myself::OwnItemCount(talker,1475);
								myself::ShowPage(talker,"atuba_chief_varkees_q0273_05.htm");
								if( myself::OwnItemCount(talker,1475) >= 10 )
								{
									myself::GiveItem1(talker,57,( ( i0 * 3 ) + 1500 ));
								}
								else
								{
									myself::GiveItem1(talker,57,( i0 * 3 ));
								}
								myself::DeleteItem1(talker,1475,i0);
								myself::AddLog(3,talker,273);
								myself::SoundEffect(talker,"ItemSound.quest_finish");
								if( talker.level < 25 && myself::IsNewbie(talker) && ( myself::GetMemoStateEx(talker,255,1) % 100 ) != 10 )
								{
									myself::VoiceEffect(talker,"tutorial_voice_026",1000);
									myself::GiveItem1(talker,5789,6000);
									myself::SetMemoStateEx(talker,255,1,10);
									myself::ShowQuestionMark(talker,26);
								}
							}
							else
							{
								myself::ShowPage(talker,"atuba_chief_varkees_q0273_06.htm");
								if( ( myself::OwnItemCount(talker,1475) + myself::OwnItemCount(talker,1476) ) >= 10 )
								{
									myself::GiveItem1(talker,57,( ( ( myself::OwnItemCount(talker,1476) * 10 ) + ( myself::OwnItemCount(talker,1475) * 3 ) ) + 1800 ));
								}
								else
								{
									myself::GiveItem1(talker,57,( ( myself::OwnItemCount(talker,1476) * 10 ) + ( myself::OwnItemCount(talker,1475) * 3 ) ));
								}
								myself::DeleteItem1(talker,1475,myself::OwnItemCount(talker,1475));
								myself::DeleteItem1(talker,1476,myself::OwnItemCount(talker,1476));
								if( talker.level < 25 && myself::IsNewbie(talker) && ( myself::GetMemoStateEx(talker,255,1) % 100 ) != 10 )
								{
									myself::VoiceEffect(talker,"tutorial_voice_026",1000);
									myself::GiveItem1(talker,5789,6000);
									myself::SetMemoStateEx(talker,255,1,10);
									myself::ShowQuestionMark(talker,26);
								}
								myself::AddLog(3,talker,273);
								myself::SoundEffect(talker,"ItemSound.quest_finish");
							}
						}
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3391) == 1 && myself::OwnItemCount(talker,3400) == 0 && myself::OwnItemCount(talker,3392) == 0 ) )
					{
						myself::SetCurrentQuestID(232);
						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,"atuba_chief_varkees_q0232_01.htm");
					}
					break;
				}
				case 4:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3400) == 0 && myself::OwnItemCount(talker,3399) == 0 && myself::OwnItemCount(talker,3391) >= 1 && myself::OwnItemCount(talker,3392) >= 1 ) )
					{
						myself::SetCurrentQuestID(232);
						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,"atuba_chief_varkees_q0232_03.htm");
					}
					break;
				}
				case 5:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3400) == 0 && myself::OwnItemCount(talker,3391) >= 1 && myself::OwnItemCount(talker,3392) >= 1 && myself::OwnItemCount(talker,3399) >= 1 ) )
					{
						myself::SetCurrentQuestID(232);
						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::ShowPage(talker,"atuba_chief_varkees_q0232_04.htm");
							myself::DeleteItem1(talker,3392,myself::OwnItemCount(talker,3392));
							myself::DeleteItem1(talker,3399,1);
							myself::GiveItem1(talker,3400,1);
						}
					}
					break;
				}
				case 6:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,232) == 1 && myself::OwnItemCount(talker,3392) == 0 && myself::OwnItemCount(talker,3391) >= 1 && myself::OwnItemCount(talker,3400) >= 1 ) )
					{
						myself::SetCurrentQuestID(232);
						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,"atuba_chief_varkees_q0232_05.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

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

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 273 )
		{
			myself::SetCurrentQuestID(273);
			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 == 273 )
		{
			if( reply == 1 )
			{
				myself::ShowPage(talker,"atuba_chief_varkees_q0273_07.htm");
				myself::RemoveMemo(talker,273);
				myself::AddLog(2,talker,273);
				myself::SoundEffect(talker,"ItemSound.quest_finish");
			}
			else if( reply == 2 )
			{
				myself::ShowPage(talker,"atuba_chief_varkees_q0273_08.htm");
				myself::SoundEffect(talker,"ItemSound.quest_accept");
			}
		}
		if( ask == 232 )
		{
			myself::SetCurrentQuestID(232);
			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 == 232 )
		{
			if( reply == 1 )
			{
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::ShowPage(talker,"atuba_chief_varkees_q0232_02.htm");
					myself::GiveItem1(talker,3392,1);
				}
			}
		}
		super;
	}

}
