@LabelIndex 398700
@StringIndex 59640
class 0 manager_of_remnants : ai_manager_of_remnants {
handler:
	EventHandler TALK_SELECTED(c0,c1,fhtml0,i0,i1,i2,i3,party0,talker) {
		if( _from_choice == 0 ) {
			if( gg::HaveMemo(talker,693) == 0 && talker.level >= 75 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Defeat the Dragon Race Defeated Troops");
			}
			if( gg::HaveMemo(talker,693) == 0 && talker.level < 75 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Defeat the Dragon Race Defeated Troops (in progress)");
			}
			if( gg::HaveMemo(talker,693) == 1 && gg::GetMemoState(talker,693) == 2 && gg::GetMemoStateEx(talker,693,1) >= 2 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Defeat the Dragon Race Defeated Troops (in progress)");
			}
			if( gg::HaveMemo(talker,693) == 1 && gg::GetMemoState(talker,693) == 1 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Defeat the Dragon Race Defeated Troops (in progress)");
			}
			if( gg::HaveMemo(talker,693) == 1 && gg::GetMemoState(talker,693) > 10 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Defeat the Dragon Race Defeated Troops (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,693) == 0 && talker.level >= 75 ) ) {
						myself::SetCurrentQuestID(693);
						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 ) {
							myself::FHTML_SetFileName(fhtml0,"manager_of_remnants_q0693_01.htm");
							myself::FHTML_SetInt(fhtml0,"quest_id",693);
							myself::ShowQuestFHTML(talker,fhtml0,693);
						} else {
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,693) == 0 && talker.level < 75 ) ) {
						myself::SetCurrentQuestID(693);
						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::ShowQuestPage(talker,"manager_of_remnants_q0693_02.htm",693);
					}
					break;
				}
				case 2: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,693) == 1 && gg::GetMemoState(talker,693) == 2 && gg::GetMemoStateEx(talker,693,1) >= 2 ) ) {
						myself::SetCurrentQuestID(693);
						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,"manager_of_remnants_q0693_09.htm");
					}
					break;
				}
				case 3: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,693) == 1 && gg::GetMemoState(talker,693) == 1 ) ) {
						myself::SetCurrentQuestID(693);
						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;
						}
						party0 = gg::GetParty(talker);
						if( gg::IsNull(party0) == 1 ) {
							myself::ShowPage(talker,"manager_of_remnants_q0693_06.htm");
						} else {
							c0 = gg::Party_GetLeader(talker);
							if( talker == c0 && myself::IsNullCreature(c0) == 0 ) {
								i1 = gg::Party_GetCount(talker);
								for(i0 = 0; i0 < i1; i0++) {
									c1 = gg::Party_GetCreature(c0,i0);
									if( gg::IsNull(c1) == 0 ) {
										if( gg::HaveMemo(c1,693) == 0 ) {
											myself::FHTML_SetFileName(fhtml0,"manager_of_remnants_q0693_08.htm");
											myself::FHTML_SetStr(fhtml0,"name",c1.name);
											myself::ShowFHTML(talker,fhtml0);
											return;
										}
									}
								}
								myself::ShowQuestPage(talker,"manager_of_remnants_q0693_11.htm",693);
							} else {
								myself::FHTML_SetFileName(fhtml0,"manager_of_remnants_q0693_07.htm");
								myself::FHTML_SetStr(fhtml0,"name",c0.name);
								myself::ShowFHTML(talker,fhtml0);
							}
						}
					}
					break;
				}
				case 4: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,693) == 1 && gg::GetMemoState(talker,693) > 10 ) ) {
						myself::SetCurrentQuestID(693);
						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( gg::GetMemoStateEx(talker,693,1) == 2 ) {
							i0 = gg::Rand(1000);
							i1 = ( ( 10000 / gg::GetMemoState(talker,693) ) * 3 );
							if( i0 < i1 ) {
								myself::GiveItem1(talker,14635,1);
								myself::ShowPage(talker,"manager_of_remnants_q0693_18.htm");
							} else {
								myself::ShowPage(talker,"manager_of_remnants_q0693_19.htm");
							}
						} else if( gg::GetMemoStateEx(talker,693,1) == 3 ) {
							i0 = gg::Rand(1000);
							i1 = ( ( 10000 / gg::GetMemoState(talker,693) ) * 5 );
							if( i0 < i1 ) {
								myself::GiveItem1(talker,14636,1);
								myself::ShowPage(talker,"manager_of_remnants_q0693_18.htm");
							} else {
								myself::ShowPage(talker,"manager_of_remnants_q0693_19.htm");
							}
						} else if( gg::GetMemoStateEx(talker,693,1) == 4 ) {
							i0 = gg::Rand(1000);
							i1 = ( ( 10000 / gg::GetMemoState(talker,693) ) * 7 );
							if( i0 < i1 ) {
								myself::GiveItem1(talker,14637,1);
								myself::ShowPage(talker,"manager_of_remnants_q0693_18.htm");
							} else {
								myself::ShowPage(talker,"manager_of_remnants_q0693_19.htm");
							}
						} else if( gg::GetMemoStateEx(talker,693,1) == 5 ) {
							i0 = gg::Rand(1000);
							i1 = ( ( 10000 / gg::GetMemoState(talker,693) ) * 9 );
							if( i0 < i1 ) {
								myself::GiveItem1(talker,14638,1);
								myself::ShowPage(talker,"manager_of_remnants_q0693_18.htm");
							} else {
								myself::ShowPage(talker,"manager_of_remnants_q0693_19.htm");
							}
						}
						myself::RemoveMemo(talker,693);
						myself::SoundEffect(talker,"ItemSound.quest_finish");
						gg::AddLog(2,talker,693);
						gg::AddLog(3,talker,693);
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(quest_id,talker) {
		if( quest_id == 693 ) {
			myself::SetCurrentQuestID(693);
			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( gg::HaveMemo(talker,693) == 0 && talker.level >= 75 && myself::GetOneTimeQuestFlag(talker,693) == 0 ) {
					myself::SetMemo(talker,693);
					myself::SetMemoState(talker,693,1);
					myself::SetMemoStateEx(talker,693,1,1);
					myself::ShowQuestPage(talker,"manager_of_remnants_q0693_04.htm",693);
					myself::SetFlagJournal(talker,693,1);
					myself::ShowQuestMark(talker,693);
					myself::SoundEffect(talker,"ItemSound.quest_middle");
					gg::AddLog(1,talker,693);
				}
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,c0,c1,fhtml0,i0,i1,i2,i3,reply,talker) {
		if( ask == 693 ) {
			myself::SetCurrentQuestID(693);
			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 == 693 ) {
			if( reply == 1 ) {
				if( gg::HaveMemo(talker,693) == 0 && talker.level >= 75 ) {
					myself::ShowPage(talker,"manager_of_remnants_q0693_03a.htm");
				}
			}
			if( reply == 101 ) {
				if( gg::HaveMemo(talker,693) == 0 && talker.level >= 75 ) {
					myself::FHTML_SetFileName(fhtml0,"manager_of_remnants_q0693_03c.htm");
					myself::FHTML_SetInt(fhtml0,"quest_id",693);
					myself::ShowQuestFHTML(talker,fhtml0,693);
				}
			}
			if( reply == 2 ) {
				if( gg::HaveMemo(talker,693) == 1 && gg::GetMemoState(talker,693) == 1 ) {
					myself::ShowPage(talker,"manager_of_remnants_q0693_12.htm");
					myself::SetMemoStateEx(talker,693,1,2);
				}
			}
			if( reply == 3 ) {
				if( gg::HaveMemo(talker,693) == 1 && gg::GetMemoState(talker,693) == 1 ) {
					myself::ShowPage(talker,"manager_of_remnants_q0693_13.htm");
					myself::SetMemoStateEx(talker,693,1,3);
				}
			}
			if( reply == 4 ) {
				if( gg::HaveMemo(talker,693) == 1 && gg::GetMemoState(talker,693) == 1 ) {
					myself::ShowPage(talker,"manager_of_remnants_q0693_14.htm");
					myself::SetMemoStateEx(talker,693,1,4);
				}
			}
			if( reply == 5 ) {
				if( gg::HaveMemo(talker,693) == 1 && gg::GetMemoState(talker,693) == 1 ) {
					myself::ShowPage(talker,"manager_of_remnants_q0693_15.htm");
					myself::SetMemoStateEx(talker,693,1,5);
				}
			}
		}
		super;
	}

}
