class 1 sentry_krpion : guard_stand
{
handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,168) == 1 && myself::OwnItemCount(talker,1156) == 1 && myself::OwnItemCount(talker,1154) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Deliver Supplies (Continue)");
			}
			if( myself::HaveMemo(talker,168) == 1 && myself::OwnItemCount(talker,1156) == 0 && myself::OwnItemCount(talker,1157) >= 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Deliver Supplies (Continue)");
			}
			if( myself::HaveMemo(talker,265) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Chains of Slavery");
			}
			if( myself::HaveMemo(talker,265) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Chains of Slavery (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,168) == 1 && myself::OwnItemCount(talker,1156) == 1 && myself::OwnItemCount(talker,1154) == 0 ) )
					{
						myself::SetCurrentQuestID(168);
						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,"sentry_krpion_q0325_01.htm");
							myself::DeleteItem1(talker,1156,1);
							myself::GiveItem1(talker,1157,1);
							if( myself::OwnItemCount(talker,1157) >= 1 )
							{
								myself::SetFlagJournal(talker,168,4);
							}
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,168) == 1 && myself::OwnItemCount(talker,1156) == 0 && myself::OwnItemCount(talker,1157) >= 1 ) )
					{
						myself::SetCurrentQuestID(168);
						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,"sentry_krpion_q0325_02.htm");
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || myself::HaveMemo(talker,265) == 0 )
					{
						myself::SetCurrentQuestID(265);
						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 >= 6 && talker.race == 2 )
							{
								myself::FHTML_SetFileName(fhtml0,"sentry_krpion_q0265_02.htm");
								myself::FHTML_SetInt(fhtml0,"quest_id",265);
								myself::ShowFHTML(talker,fhtml0);
							}
							else if( talker.race != 2 )
							{
								myself::ShowPage(talker,"sentry_krpion_q0265_00.htm");
							}
							else if( talker.level < 6 )
							{
								myself::ShowPage(talker,"sentry_krpion_q0265_01.htm");
							}
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || myself::HaveMemo(talker,265) == 1 )
					{
						myself::SetCurrentQuestID(265);
						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,1368) > 0 )
						{
							if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
							{
								talker.quest_last_reward_time = myself::GetCurrentTick();
								if( myself::OwnItemCount(talker,1368) >= 10 )
								{
									myself::GiveItem1(talker,57,( ( 12 * myself::OwnItemCount(talker,1368) ) + 500 ));
								}
								else
								{
									myself::GiveItem1(talker,57,( 12 * myself::OwnItemCount(talker,1368) ));
								}
								myself::DeleteItem1(talker,1368,myself::OwnItemCount(talker,1368));
								if( talker.level < 25 && myself::IsNewbie(talker) && myself::IsInCategory(0,talker.occupation) && ( myself::GetMemoStateEx(talker,255,1) % 100 ) != 10 )
								{
									myself::GiveItem1(talker,5789,6000);
									myself::SetMemoStateEx(talker,255,1,10);
									myself::ShowQuestionMark(talker,26);
									myself::VoiceEffect(talker,"tutorial_voice_026",1000);
								}
								if( talker.level < 25 && myself::IsNewbie(talker) && myself::IsInCategory(1,talker.occupation) && ( myself::GetMemoStateEx(talker,255,1) % 100 ) != 10 )
								{
									myself::VoiceEffect(talker,"tutorial_voice_027",1000);
									myself::GiveItem1(talker,5790,3000);
									myself::SetMemoStateEx(talker,255,1,10);
									myself::ShowQuestionMark(talker,26);
								}
								myself::ShowPage(talker,"sentry_krpion_q0265_05.htm");
								myself::AddLog(3,talker,265);
							}
						}
						else
						{
							myself::ShowPage(talker,"sentry_krpion_q0265_04.htm");
						}
					}
					break;
				}
			}
			return;
		}
		super;
	}

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

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 265 )
		{
			myself::SetCurrentQuestID(265);
			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 == 265 )
		{
			if( reply == 1 )
			{
				myself::ShowPage(talker,"sentry_krpion_q0265_06.htm");
				myself::RemoveMemo(talker,265);
				myself::AddLog(2,talker,265);
				myself::SoundEffect(talker,"ItemSound.quest_finish");
			}
			else if( reply == 2 )
			{
				myself::ShowPage(talker,"sentry_krpion_q0265_07.htm");
			}
		}
		super;
	}

}
