@LabelIndex 405356
@StringIndex 60878
class 0 chamberlain_frederick : chamberlain {
property:
	TelPosList Position1 = {{"Front of the Rune Castle"; 27400; -49180; -1320; 0; 0 };{"Rune Town Square"; 43889; -49101; -792; 0; 0 };{"Front of the Swamp Fortress"; 71814; -57054; -3088; 0; 0 }};
	TelPosList Position2 = {{"Front of the Rune Castle"; 27400; -49180; -1320; 0; 0 };{"Rune Town Square"; 43889; -49101; -792; 0; 0 };{"Front of the Swamp Fortress"; 71814; -57054; -3088; 0; 0 };{"Forest of the Dead"; 52107; -54328; -3158; 500; 0 };{"Wild Beast Pastures"; 43805; -88010; -2780; 500; 0 };{"Swamp of Screams"; 69340; -50203; -3314; 500; 0 };{"Valley of Saints"; 65307; -71445; -3696; 500; 0 };{"Monastery of Silence"; 106414; -87799; -2949; 500; 0 }};
	BuySellList SellList0 = {{"advdeluxe_food_for_strider";10};{"pledge_shield_castle";10};{"circlet_of_rune";10};{"agathion_seal_bracelet_rune";10};{"13686";10}};

handler:
	EventHandler TALK_SELECTED(c0,fhtml0,i0,i1,talker) {
		if( _from_choice == 0 ) {
			if( gg::HaveMemo(talker,716) == 0 && myself::IsMyLord(talker) == 1 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Path to Becoming a Lord - Rune");
			}
			if( gg::HaveMemo(talker,716) == 1 && gg::GetMemoState(talker,716) == 1 && myself::IsMyLord(talker) == 1 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Path to Becoming a Lord - Rune (in progress)");
			}
			if( gg::HaveMemo(talker,716) == 1 && gg::GetMemoState(talker,716) == 2 && myself::IsMyLord(talker) == 1 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Path to Becoming a Lord - Rune (in progress)");
			}
			if( gg::HaveMemo(talker,716) == 1 && gg::GetMemoState(talker,716) == 3 && myself::IsMyLord(talker) == 1 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Path to Becoming a Lord - Rune (in progress)");
			}
			if( gg::HaveMemo(talker,716) == 1 && gg::GetMemoState(talker,716) == 4 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Path to Becoming a Lord - Rune (in progress)");
			}
			if( myself::IsMyLord(talker) == 0 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Path to Becoming a Lord - Rune (in progress)");
			}
			if( gg::HaveMemo(talker,716) == 1 && gg::GetMemoState(talker,716) == 5 && myself::IsMyLord(talker) == 1 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"Path to Becoming a Lord - Rune (in progress)");
			}
			if( gg::HaveMemo(talker,716) == 1 && gg::GetMemoState(talker,716) == 6 && myself::IsMyLord(talker) == 1 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 7;
				myself::AddChoice(7,"Path to Becoming a Lord - Rune (in progress)");
			}
			if( gg::HaveMemo(talker,716) == 1 && ( gg::GetMemoState(talker,716) / 10 ) == 1 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 8;
				myself::AddChoice(8,"Path to Becoming a Lord - Rune (in progress)");
			}
			if( gg::HaveMemo(talker,716) == 1 && ( gg::GetMemoState(talker,716) / 10 ) == 2 && myself::IsMyLord(talker) == 1 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 9;
				myself::AddChoice(9,"Path to Becoming a Lord - Rune (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,716) == 0 && myself::IsMyLord(talker) == 1 ) ) {
						myself::SetCurrentQuestID(716);
						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::IsDominionOfLord(88) == 0 ) {
								myself::ShowQuestPage(talker,"chamberlain_frederick_q0716_01.htm",716);
							} else {
								myself::ShowQuestPage(talker,"chamberlain_frederick_q0716_03.htm",716);
							}
						} else {
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,716) == 1 && gg::GetMemoState(talker,716) == 1 && myself::IsMyLord(talker) == 1 ) ) {
						myself::SetCurrentQuestID(716);
						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::GetOneTimeQuestFlag(talker,25) == 0 ) {
							myself::ShowPage(talker,"chamberlain_frederick_q0716_06.htm");
						} else {
							myself::SetMemoState(talker,716,2);
							myself::SetMemoStateEx(talker,716,1,0);
							myself::ShowPage(talker,"chamberlain_frederick_q0716_07.htm");
							myself::SetFlagJournal(talker,716,2);
							myself::ShowQuestMark(talker,716);
							myself::SoundEffect(talker,"ItemSound.quest_middle");
						}
					}
					break;
				}
				case 2: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,716) == 1 && gg::GetMemoState(talker,716) == 2 && myself::IsMyLord(talker) == 1 ) ) {
						myself::SetCurrentQuestID(716);
						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,"chamberlain_frederick_q0716_08.htm");
					}
					break;
				}
				case 3: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,716) == 1 && gg::GetMemoState(talker,716) == 3 && myself::IsMyLord(talker) == 1 ) ) {
						myself::SetCurrentQuestID(716);
						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::SetMemoState(talker,716,4);
						myself::ShowPage(talker,"chamberlain_frederick_q0716_09.htm");
						myself::SetFlagJournal(talker,716,4);
						myself::ShowQuestMark(talker,716);
						myself::SoundEffect(talker,"ItemSound.quest_middle");
					}
					break;
				}
				case 4: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,716) == 1 && gg::GetMemoState(talker,716) == 4 ) ) {
						myself::SetCurrentQuestID(716);
						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,"chamberlain_frederick_q0716_10.htm");
					}
					break;
				}
				case 5: {
					if( _from_choice == 0 || myself::IsMyLord(talker) == 0 ) {
						myself::SetCurrentQuestID(716);
						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::Castle_GetPledgeId() == talker.pledge_id && talker.pledge_id != 0 ) {
							c0 = myself::Pledge_GetLeader(talker);
							if( myself::IsNullCreature(c0) == 0 ) {
								if( gg::HaveMemo(c0,716) == 1 && gg::GetMemoState(c0,716) == 4 ) {
									if( myself::DistFromMe(c0) <= 1500 ) {
										myself::ShowPage(talker,"chamberlain_frederick_q0716_16.htm");
									} else {
										myself::ShowPage(talker,"chamberlain_frederick_q0716_15.htm");
									}
								} else {
									myself::ShowPage(talker,"chamberlain_frederick_q0716_13.htm");
								}
							} else {
								myself::ShowPage(talker,"chamberlain_frederick_q0716_12.htm");
							}
						} else if( myself::Castle_GetPledgeId() != talker.pledge_id ) {
							myself::ShowPage(talker,"chamberlain_frederick_q0716_11.htm");
						}
					}
					break;
				}
				case 6: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,716) == 1 && gg::GetMemoState(talker,716) == 5 && myself::IsMyLord(talker) == 1 ) ) {
						myself::SetCurrentQuestID(716);
						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,"chamberlain_frederick_q0716_19.htm");
					}
					break;
				}
				case 7: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,716) == 1 && gg::GetMemoState(talker,716) == 6 && myself::IsMyLord(talker) == 1 ) ) {
						myself::SetCurrentQuestID(716);
						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;
						}
						i0 = gg::GetMemoState(talker,716);
						myself::SetMemoState(talker,716,( i0 + 10 ));
						myself::ShowPage(talker,"chamberlain_frederick_q0716_20.htm");
						myself::SetFlagJournal(talker,716,7);
						myself::ShowQuestMark(talker,716);
						myself::SoundEffect(talker,"ItemSound.quest_middle");
					}
					break;
				}
				case 8: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,716) == 1 && ( gg::GetMemoState(talker,716) / 10 ) == 1 ) ) {
						myself::SetCurrentQuestID(716);
						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,"chamberlain_frederick_q0716_21.htm");
					}
					break;
				}
				case 9: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,716) == 1 && ( gg::GetMemoState(talker,716) / 10 ) == 2 && myself::IsMyLord(talker) == 1 ) ) {
						myself::SetCurrentQuestID(716);
						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::GetDominionWarState(88) == 5 || myself::Castle_IsUnderSiege() ) {
							myself::ShowPage(talker,"chamberlain_frederick_q0716_22a.htm");
						} else if( gg::Fortress_GetContractStatus(110) == -1 ) {
							myself::ShowPage(talker,"chamberlain_frederick_q0716_22b.htm");
						} else {
							myself::Say(gg::MakeFString(71659,talker.name,"","","",""));
							myself::DeclareLord(88,talker);
							myself::RemoveMemo(talker,716);
							myself::SoundEffect(talker,"ItemSound.quest_finish");
							gg::AddLog(2,talker,716);
							myself::ShowPage(talker,"chamberlain_frederick_q0716_22.htm");
						}
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(i0,quest_id,talker) {
		if( quest_id == 716 ) {
			myself::SetCurrentQuestID(716);
			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,716) == 0 && myself::IsMyLord(talker) == 1 && myself::IsDominionOfLord(88) == 0 ) {
					if( myself::GetOneTimeQuestFlag(talker,25) == 0 ) {
						myself::SetMemoState(talker,716,1);
						myself::SetMemo(talker,quest_id);
						myself::SoundEffect(talker,"ItemSound.quest_accept");
						myself::ShowQuestPage(talker,"chamberlain_frederick_q0716_04.htm",716);
						myself::SetFlagJournal(talker,716,1);
						myself::ShowQuestMark(talker,716);
					} else {
						myself::SetMemo(talker,quest_id);
						myself::SetMemoState(talker,716,2);
						myself::ShowQuestPage(talker,"chamberlain_frederick_q0716_05.htm",716);
						myself::SetFlagJournal(talker,716,2);
						myself::ShowQuestMark(talker,716);
						myself::SoundEffect(talker,"ItemSound.quest_middle");
					}
				}
				gg::AddLog(1,talker,quest_id);
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,c0,fhtml0,i0,i1,reply,talker) {
		if( ask == 716 ) {
			myself::SetCurrentQuestID(716);
			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 == 716 ) {
			if( reply == 1 ) {
				if( gg::HaveMemo(talker,716) == 0 && myself::IsMyLord(talker) == 1 && myself::IsDominionOfLord(88) == 0 ) {
					myself::FHTML_SetFileName(fhtml0,"chamberlain_frederick_q0716_02.htm");
					myself::FHTML_SetInt(fhtml0,"quest_id",716);
					myself::ShowQuestFHTML(talker,fhtml0,716);
				}
			}
			if( reply == 3 ) {
				i0 = talker.dbid;
				if( myself::IsMyLord(talker) == 0 ) {
					if( myself::Castle_GetPledgeId() == talker.pledge_id && talker.pledge_id != 0 ) {
						c0 = myself::Pledge_GetLeader(talker);
						if( myself::IsNullCreature(c0) == 0 ) {
							if( gg::HaveMemo(c0,716) == 1 && gg::GetMemoState(c0,716) == 4 ) {
								if( myself::DistFromMe(c0) <= 1500 ) {
									myself::FHTML_SetFileName(fhtml0,"chamberlain_frederick_q0716_17.htm");
									myself::FHTML_SetStr(fhtml0,"name",talker.name);
									myself::ShowFHTML(talker,fhtml0);
									myself::Say(gg::MakeFString(71652,talker.name,"","","",""));
									myself::SetMemoState(c0,716,5);
									myself::SetFlagJournal(c0,716,5);
									myself::ShowQuestMark(c0,716);
									myself::SoundEffect(c0,"ItemSound.quest_middle");
									myself::SetMemoStateEx(c0,716,1,i0);
								} else {
									myself::ShowPage(talker,"chamberlain_frederick_q0716_18.htm");
								}
							}
						}
					}
				}
			}
		}
		super;
	}

}
