@LabelIndex 378914
@StringIndex 55655
class 0 magistrates_keeper : royal_rush_npc {
handler:
	EventHandler TALK_SELECTED(fhtml0,talker) {
		if( _from_choice == 0 ) {
			if( gg::HaveMemo(talker,620) == 1 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Four Goblets (In Progress)");
			}
			if( _choiceN > 1 ) {
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 ) {
			switch(_code) {
				case 0: {
					if( _from_choice == 0 || gg::HaveMemo(talker,620) == 1 ) {
						myself::SetCurrentQuestID(620);
						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,"magistrates_keeper_q0620_01.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,c0,c1,fhtml0,i0,i1,i2,party0,reply,talker) {
		if( ask == 620 ) {
			myself::SetCurrentQuestID(620);
			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 == 620 ) {
			if( reply == 1 ) {
				if( gg::HaveMemo(talker,620) ) {
					i0 = gg::GetDateTime(0,4);
					c0 = gg::Party_GetLeader(talker);
					party0 = gg::GetParty(talker);
					i1 = gg::Party_GetCount(talker);
					if( i0 >= 0 && i0 < 55 ) {
						myself::ShowPage(talker,"magistrates_keeper_q0620_02.htm");
					} else if( myself::IsNullParty(party0) || i1 < 4 ) {
						myself::ShowPage(talker,"magistrates_keeper_q0620_04.htm");
					} else if( talker != c0 ) {
						myself::ShowPage(talker,"magistrates_keeper_q0620_03.htm");
					} else {
						for(i2 = 0; i2 < i1; i2++) {
							c1 = gg::Party_GetCreature(talker,i2);
							if( gg::OwnItemCount(c1,7075) == 0 ) {
								myself::FHTML_SetFileName(fhtml0,"magistrates_keeper_q0620_05.htm");
								myself::FHTML_SetStr(fhtml0,"member1",c1.name);
								myself::ShowFHTML(talker,fhtml0);
								return;
							} else if( gg::HaveMemo(c1,620) == 0 ) {
								myself::FHTML_SetFileName(fhtml0,"magistrates_keeper_q0620_06.htm");
								myself::FHTML_SetStr(fhtml0,"member1",c1.name);
								myself::ShowFHTML(talker,fhtml0);
								return;
							}
						}
						if( myself.av_quest0::CompareExchange(1,0) == 1 ) {
							myself::ShowPage(talker,"magistrates_keeper_q0620_07.htm");
						} else {
							for(i2 = 0; i2 < i1; i2++) {
								c1 = gg::Party_GetCreature(talker,i2);
								if( gg::OwnItemCount(c1,7262) == 0 ) {
									myself::GiveItem1(c1,7261,1);
								}
								myself::DeleteItem1(c1,7075,1);
								myself::SetMemoStateEx(c1,620,1,1);
								myself::DeleteItem1(c1,7260,gg::OwnItemCount(c1,7260));
							}
							myself::TeleportParty(party0.id,175615,-82365,-7216,1000,0);
							gg::AddLog(9,talker,4);
						}
					}
				}
			}
		}
		super;
	}

}
