class 1 black_judge : citizen
{
handler:
	EventHandler TALKED(talker)
	{
		myself::ShowPage(talker,fnHi);
	}

	EventHandler TALK_SELECTED(fhtml0,item0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,422) == 0 && talker.pk_count == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Repent Your Sins");
			}
			if( myself::HaveMemo(talker,422) == 0 && talker.pk_count > 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Repent Your Sins");
			}
			if( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) == 1000 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Repent Your Sins (Continue)");
			}
			if( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) < 9 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Repent Your Sins (Continue)");
			}
			if( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) >= 9 && myself::GetMemoState(talker,422) <= 12 && myself::OwnItemCount(talker,4331) == 0 && myself::OwnItemCount(talker,4426) == 0 && myself::OwnItemCount(talker,4330) == 0 && myself::OwnItemCount(talker,4425) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Repent Your Sins (Continue)");
			}
			if( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) >= 9 && myself::GetMemoState(talker,422) <= 12 && myself::OwnItemCount(talker,4331) >= 1 && myself::OwnItemCount(talker,4426) == 0 && myself::OwnItemCount(talker,4330) == 0 && myself::OwnItemCount(talker,4425) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Repent Your Sins (Continue)");
			}
			if( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) >= 9 && myself::GetMemoState(talker,422) <= 12 && myself::OwnItemCount(talker,4331) == 0 && myself::OwnItemCount(talker,4426) == 0 && myself::OwnItemCount(talker,4330) >= 1 && myself::OwnItemCount(talker,4425) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"Repent Your Sins (Continue)");
			}
			if( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) >= 9 && myself::GetMemoState(talker,422) <= 12 && myself::OwnItemCount(talker,4425) >= 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 7;
				myself::AddChoice(7,"Repent Your Sins (Continue)");
			}
			if( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) >= 9 && myself::GetMemoState(talker,422) <= 12 && myself::OwnItemCount(talker,4426) >= 1 && myself::OwnItemCount(talker,4425) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 8;
				myself::AddChoice(8,"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,422) == 0 && talker.pk_count == 0 ) )
					{
						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,"black_judge_q0422_01.htm");
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,422) == 0 && talker.pk_count > 0 ) )
					{
						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::FHTML_SetFileName(fhtml0,"black_judge_q0422_02.htm");
						myself::FHTML_SetInt(fhtml0,"quest_id",422);
						myself::ShowFHTML(talker,fhtml0);
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) == 1000 ) )
					{
						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::DeleteItem1(talker,4425,1);
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) < 9 ) )
					{
						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;
						}
						if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
						{
							talker.quest_last_reward_time = myself::GetCurrentTick();
							myself::ShowPage(talker,"black_judge_q0422_07.htm");
						}
					}
					break;
				}
				case 4:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) >= 9 && myself::GetMemoState(talker,422) <= 12 && myself::OwnItemCount(talker,4331) == 0 && myself::OwnItemCount(talker,4426) == 0 && myself::OwnItemCount(talker,4330) == 0 && myself::OwnItemCount(talker,4425) == 0 ) )
					{
						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;
						}
						if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
						{
							talker.quest_last_reward_time = myself::GetCurrentTick();
							myself::GiveItem1(talker,4331,1);
							myself::ShowPage(talker,"black_judge_q0422_08.htm");
							myself::SetFlagJournal(talker,422,14);
						}
					}
					break;
				}
				case 5:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) >= 9 && myself::GetMemoState(talker,422) <= 12 && myself::OwnItemCount(talker,4331) >= 1 && myself::OwnItemCount(talker,4426) == 0 && myself::OwnItemCount(talker,4330) == 0 && myself::OwnItemCount(talker,4425) == 0 ) )
					{
						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,"black_judge_q0422_09.htm");
					}
					break;
				}
				case 6:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) >= 9 && myself::GetMemoState(talker,422) <= 12 && myself::OwnItemCount(talker,4331) == 0 && myself::OwnItemCount(talker,4426) == 0 && myself::OwnItemCount(talker,4330) >= 1 && myself::OwnItemCount(talker,4425) == 0 ) )
					{
						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,"black_judge_q0422_10.htm");
					}
					break;
				}
				case 7:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) >= 9 && myself::GetMemoState(talker,422) <= 12 && myself::OwnItemCount(talker,4425) >= 1 ) )
					{
						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;
						}
						item0 = myself::GetItemData(talker,4425);
						if( item0.pet_level < ( myself::GetMemoStateEx(talker,422,1) + 1 ) )
						{
							myself::ShowPage(talker,"black_judge_q0422_12.htm");
						}
						else
						{
							myself::ShowPage(talker,"black_judge_q0422_13.htm");
						}
					}
					break;
				}
				case 8:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,422) == 1 && myself::GetMemoState(talker,422) >= 9 && myself::GetMemoState(talker,422) <= 12 && myself::OwnItemCount(talker,4426) >= 1 && myself::OwnItemCount(talker,4425) == 0 ) )
					{
						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,"black_judge_q0422_16t.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(quest_id,talker)
	{
		if( quest_id == 422 )
		{
			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;
			}
			if( myself::GetMemoCount(talker) < 26 )
			{
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::SoundEffect(talker,"ItemSound.quest_accept");
					myself::AddLog(1,talker,422);
					myself::SetMemo(talker,quest_id);
					if( talker.level < 21 )
					{
						myself::ShowPage(talker,"black_judge_q0422_03.htm");
						myself::SetMemoState(talker,422,1);
						myself::SetMemoStateEx(talker,422,1,0);
						myself::SetFlagJournal(talker,422,2);
					}
					else if( talker.level > 20 && talker.level < 31 )
					{
						myself::ShowPage(talker,"black_judge_q0422_04.htm");
						myself::SetMemoState(talker,422,2);
						myself::SetFlagJournal(talker,422,3);
					}
					else if( talker.level > 30 && talker.level < 41 )
					{
						myself::ShowPage(talker,"black_judge_q0422_05.htm");
						myself::SetMemoState(talker,422,3);
						myself::SetFlagJournal(talker,422,4);
					}
					else
					{
						myself::ShowPage(talker,"black_judge_q0422_06.htm");
						myself::SetMemoState(talker,422,4);
						myself::SetFlagJournal(talker,422,5);
					}
				}
			}
			else
			{
				myself::ShowPage(talker,"fullquest.htm");
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,c0,i0,i1,item0,reply,talker)
	{
		if( ask == 422 )
		{
			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;
			}
		}
		if( ask == 422 )
		{
			if( reply == 1 )
			{
				if( myself::GetMemoState(talker,422) >= 9 && ( myself::GetMemoState(talker,422) <= 12 && ( myself::OwnItemCount(talker,4426) >= 1 || myself::OwnItemCount(talker,4330) >= 1 ) ) )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						if( myself::OwnItemCount(talker,4330) > 0 )
						{
							myself::DeleteItem1(talker,4330,1);
						}
						if( myself::OwnItemCount(talker,4426) > 0 )
						{
							myself::DeleteItem1(talker,4426,1);
						}
						item0 = myself::GetItemData(talker,4425);
						myself::SetMemoStateEx(talker,422,1,talker.level);
						myself::CreatePet(talker,4425,1012564,talker.level);
						myself::ShowPage(talker,"black_judge_q0422_11.htm");
						myself::SetFlagJournal(talker,422,16);
					}
				}
			}
			if( reply == 2 )
			{
				if( myself::GetMemoState(talker,422) >= 9 && myself::GetMemoState(talker,422) <= 12 )
				{
					myself::ShowPage(talker,"black_judge_q0422_14.htm");
				}
			}
			if( reply == 3 )
			{
				if( myself::GetMemoState(talker,422) >= 9 && myself::GetMemoState(talker,422) <= 12 )
				{
					c0 = myself::GetSummon(talker);
					if( c0 )
					{
						myself::ShowPage(talker,"black_judge_q0422_15t.htm");
					}
					else
					{
						item0 = myself::GetItemData(talker,4425);
						if( talker.level > myself::GetMemoStateEx(talker,422,1) )
						{
							i1 = ( ( item0.pet_level - myself::GetMemoStateEx(talker,422,1) ) - ( talker.level - myself::GetMemoStateEx(talker,422,1) ) );
						}
						else
						{
							i1 = ( item0.pet_level - myself::GetMemoStateEx(talker,422,1) );
						}
						if( i1 < 0 )
						{
							i1 = 0;
						}
						i0 = ( gg::Rand(( 10 * i1 )) + 1 );
						if( talker.pk_count <= i0 )
						{
							if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
							{
								talker.quest_last_reward_time = myself::GetCurrentTick();
								myself::GiveItem1(talker,4426,1);
								if( item0 )
								{
									myself::DestroyPet(talker,item0.dbid);
								}
								myself::ShowPage(talker,"black_judge_q0422_15.htm");
								myself::IncrementParam(talker,9,-( 1 * talker.pk_count ));
								myself::RemoveMemo(talker,422);
								myself::SoundEffect(talker,"ItemSound.quest_finish");
								myself::AddLog(3,talker,422);
							}
						}
						else if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
						{
							talker.quest_last_reward_time = myself::GetCurrentTick();
							myself::GiveItem1(talker,4426,1);
							if( item0 )
							{
								myself::DestroyPet(talker,item0.dbid);
							}
							myself::ShowPage(talker,"black_judge_q0422_16.htm");
							myself::IncrementParam(talker,9,-( 1 * i0 ));
							myself::SetMemoStateEx(talker,422,1,0);
						}
					}
				}
			}
			if( reply == 4 )
			{
				if( myself::GetMemoState(talker,422) >= 9 && myself::GetMemoState(talker,422) <= 12 )
				{
					myself::ShowPage(talker,"black_judge_q0422_17.htm");
				}
			}
			if( reply == 5 )
			{
				if( myself::GetMemoState(talker,422) >= 9 && myself::GetMemoState(talker,422) <= 12 )
				{
					myself::ShowPage(talker,"black_judge_q0422_18.htm");
					myself::RemoveMemo(talker,422);
					myself::DeleteItem1(talker,4326,myself::OwnItemCount(talker,4326));
					myself::DeleteItem1(talker,4327,myself::OwnItemCount(talker,4327));
					myself::DeleteItem1(talker,4328,myself::OwnItemCount(talker,4328));
					myself::DeleteItem1(talker,4329,myself::OwnItemCount(talker,4329));
					myself::DeleteItem1(talker,4330,myself::OwnItemCount(talker,4330));
					myself::DeleteItem1(talker,4331,myself::OwnItemCount(talker,4331));
					myself::DeleteItem1(talker,4425,myself::OwnItemCount(talker,4425));
					myself::SoundEffect(talker,"ItemSound.quest_finish");
					myself::AddLog(3,talker,422);
				}
			}
			if( reply == 10 )
			{
				if( myself::OwnItemCount(talker,57) >= 50400 )
				{
					myself::DeleteItem1(talker,57,50400);
					myself::AddUseSkillDesire(talker,1299713,0,1,1000000);
					myself::ShowPage(talker,"black_judge_dp_clean.htm");
				}
				else
				{
					myself::ShowPage(talker,"black_judge_dp_nomoney.htm");
				}
			}
		}
		super;
	}

}
