@LabelIndex 404055
@StringIndex 60546
class 0 chamberlain_saius : chamberlain {
property:
	TelPosList Position1 = {{"Front of the Gludio Castle"; -15043; 116596; -3208; 0; 0 };{"Gludio Town Square"; -14393; 123671; -3144; 0; 0 };{"Front of the Shanty Fortress"; -58761; 154663; -2701; 0; 0 };{"Front of the Southern Fortress"; -29856; 214275; -3680; 0; 0 }};
	TelPosList Position2 = {{"Front of the Gludio Castle"; -15043; 116596; -3208; 0; 0 };{"Gludio Town Square"; -14393; 123671; -3144; 0; 0 };{"Front of the Shanty Fortress"; -58761; 154663; -2701; 0; 0 };{"Front of the Southern Fortress"; -29856; 214275; -3680; 0; 0 };{"Ruins of Agony"; -41248; 122848; -2912; 500; 0 };{"Ruins of Despair"; -19120; 136816; -3762; 500; 0 };{"The Ant Nest"; -9959; 176184; -4160; 500; 0 };{"Windawood Manor"; -28327; 155125; -3496; 500; 0 }};
	BuySellList SellList0 = {{"advdeluxe_food_for_strider";10};{"pledge_shield_castle";10};{"circlet_of_gludio";10};{"agathion_seal_bracelet_gludio";10};{"13686";10}};

handler:
	EventHandler TALK_SELECTED(c0,fhtml0,i0,i1,talker) {
		if( _from_choice == 0 ) {
			if( gg::HaveMemo(talker,708) == 0 && myself::IsMyLord(talker) == 1 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Path to Becoming a Lord - Gludio");
			}
			if( gg::HaveMemo(talker,708) == 1 && gg::GetMemoState(talker,708) == 1 && myself::IsMyLord(talker) == 1 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Path to Becoming a Lord - Gludio (in progress)");
			}
			if( gg::HaveMemo(talker,708) == 1 && gg::GetMemoState(talker,708) == 2 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Path to Becoming a Lord - Gludio (in progress)");
			}
			if( myself::IsMyLord(talker) == 0 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Path to Becoming a Lord - Gludio (in progress)");
			}
			if( gg::HaveMemo(talker,708) == 1 && gg::GetMemoState(talker,708) == 3 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Path to Becoming a Lord - Gludio (in progress)");
			}
			if( gg::HaveMemo(talker,708) == 1 && gg::GetMemoState(talker,708) == 4 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Path to Becoming a Lord - Gludio (in progress)");
			}
			if( gg::HaveMemo(talker,708) == 1 && gg::GetMemoState(talker,708) == 5 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"Path to Becoming a Lord - Gludio (in progress)");
			}
			if( gg::HaveMemo(talker,708) == 1 && ( gg::GetMemoState(talker,708) / 10 ) <= 1 && ( gg::GetMemoState(talker,708) % 10 ) == 9 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 7;
				myself::AddChoice(7,"Path to Becoming a Lord - Gludio (in progress)");
			}
			if( gg::HaveMemo(talker,708) == 1 && ( gg::GetMemoState(talker,708) / 10 ) == 1 && ( gg::GetMemoState(talker,708) % 10 ) != 9 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 8;
				myself::AddChoice(8,"Path to Becoming a Lord - Gludio (in progress)");
			}
			if( ( gg::HaveMemo(talker,708) == 1 && ( ( gg::GetMemoState(talker,708) / 10 ) == 2 || ( gg::GetMemoState(talker,708) / 10 ) == 3 ) ) && ( gg::GetMemoState(talker,708) % 10 ) == 9 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 9;
				myself::AddChoice(9,"Path to Becoming a Lord - Gludio (in progress)");
			}
			if( ( gg::HaveMemo(talker,708) == 1 && ( ( gg::GetMemoState(talker,708) / 10 ) == 2 || ( gg::GetMemoState(talker,708) / 10 ) == 3 ) ) && ( gg::GetMemoState(talker,708) % 10 ) == 9 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 10;
				myself::AddChoice(10,"Path to Becoming a Lord - Gludio (in progress)");
			}
			if( gg::HaveMemo(talker,708) == 1 && ( gg::GetMemoState(talker,708) / 10 ) == 4 && ( gg::GetMemoState(talker,708) % 10 ) != 9 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 11;
				myself::AddChoice(11,"Path to Becoming a Lord - Gludio (in progress)");
			}
			if( gg::HaveMemo(talker,708) == 1 && ( gg::GetMemoState(talker,708) / 10 ) == 4 && ( gg::GetMemoState(talker,708) % 10 ) == 9 && myself::IsMyLord(talker) == 1 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 12;
				myself::AddChoice(12,"Path to Becoming a Lord - Gludio (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,708) == 0 && myself::IsMyLord(talker) == 1 ) ) {
						myself::SetCurrentQuestID(708);
						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(81) == 0 ) {
								myself::ShowQuestPage(talker,"chamberlain_saius_q0708_01.htm",708);
							} else {
								myself::ShowQuestPage(talker,"chamberlain_saius_q0708_03.htm",708);
							}
						} else {
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,708) == 1 && gg::GetMemoState(talker,708) == 1 && myself::IsMyLord(talker) == 1 ) ) {
						myself::SetCurrentQuestID(708);
						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() - gg::GetMemoStateEx(talker,708,1) ) < 60 ) {
							myself::ShowPage(talker,"chamberlain_saius_q0708_05.htm");
						} else {
							myself::SetMemoState(talker,708,2);
							myself::SetMemoStateEx(talker,708,1,0);
							myself::ShowPage(talker,"chamberlain_saius_q0708_06.htm");
						}
					}
					break;
				}
				case 2: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,708) == 1 && gg::GetMemoState(talker,708) == 2 ) ) {
						myself::SetCurrentQuestID(708);
						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_saius_q0708_07.htm");
					}
					break;
				}
				case 3: {
					if( _from_choice == 0 || myself::IsMyLord(talker) == 0 ) {
						myself::SetCurrentQuestID(708);
						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,708) == 1 && gg::GetMemoState(c0,708) == 3 ) {
									if( myself::DistFromMe(c0) <= 1500 ) {
										myself::ShowPage(talker,"chamberlain_saius_q0708_11.htm");
									} else {
										myself::ShowPage(talker,"chamberlain_saius_q0708_10.htm");
									}
								} else if( gg::HaveMemo(c0,708) == 1 && gg::GetMemoState(c0,708) == 4 ) {
									myself::ShowPage(talker,"chamberlain_saius_q0708_13a.htm");
								} else {
									myself::ShowPage(talker,"chamberlain_saius_q0708_09.htm");
								}
							} else {
								myself::ShowPage(talker,"chamberlain_saius_q0708_09.htm");
							}
						} else if( myself::Castle_GetPledgeId() != talker.pledge_id ) {
							myself::ShowPage(talker,"chamberlain_saius_q0708_09.htm");
						}
					}
					break;
				}
				case 4: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,708) == 1 && gg::GetMemoState(talker,708) == 3 ) ) {
						myself::SetCurrentQuestID(708);
						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_saius_q0708_14.htm");
					}
					break;
				}
				case 5: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,708) == 1 && gg::GetMemoState(talker,708) == 4 ) ) {
						myself::SetCurrentQuestID(708);
						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_saius_q0708_15.htm");
					}
					break;
				}
				case 6: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,708) == 1 && gg::GetMemoState(talker,708) == 5 ) ) {
						myself::SetCurrentQuestID(708);
						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,708);
						myself::SetMemoState(talker,708,( i0 + 10 ));
						myself::ShowPage(talker,"chamberlain_saius_q0708_16.htm");
						myself::SetFlagJournal(talker,708,5);
						myself::ShowQuestMark(talker,708);
						myself::SoundEffect(talker,"ItemSound.quest_middle");
					}
					break;
				}
				case 7: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,708) == 1 && ( gg::GetMemoState(talker,708) / 10 ) <= 1 && ( gg::GetMemoState(talker,708) % 10 ) == 9 ) ) {
						myself::SetCurrentQuestID(708);
						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,708) / 10 );
						i1 = gg::GetMemoState(talker,708);
						if( i0 == 0 ) {
							myself::SetMemoState(talker,708,( i1 + 10 ));
							myself::SetFlagJournal(talker,708,5);
							myself::ShowQuestMark(talker,708);
							myself::SoundEffect(talker,"ItemSound.quest_middle");
						}
						myself::ShowPage(talker,"chamberlain_saius_q0708_17.htm");
					}
					break;
				}
				case 8: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,708) == 1 && ( gg::GetMemoState(talker,708) / 10 ) == 1 && ( gg::GetMemoState(talker,708) % 10 ) != 9 ) ) {
						myself::SetCurrentQuestID(708);
						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_saius_q0708_18.htm");
					}
					break;
				}
				case 9: {
					if( _from_choice == 0 || ( ( gg::HaveMemo(talker,708) == 1 && ( ( gg::GetMemoState(talker,708) / 10 ) == 2 || ( gg::GetMemoState(talker,708) / 10 ) == 3 ) ) && ( gg::GetMemoState(talker,708) % 10 ) == 9 ) ) {
						myself::SetCurrentQuestID(708);
						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_saius_q0708_19.htm");
					}
					break;
				}
				case 10: {
					if( _from_choice == 0 || ( ( gg::HaveMemo(talker,708) == 1 && ( ( gg::GetMemoState(talker,708) / 10 ) == 2 || ( gg::GetMemoState(talker,708) / 10 ) == 3 ) ) && ( gg::GetMemoState(talker,708) % 10 ) == 9 ) ) {
						myself::SetCurrentQuestID(708);
						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_saius_q0708_20.htm");
					}
					break;
				}
				case 11: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,708) == 1 && ( gg::GetMemoState(talker,708) / 10 ) == 4 && ( gg::GetMemoState(talker,708) % 10 ) != 9 ) ) {
						myself::SetCurrentQuestID(708);
						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_saius_q0708_21.htm");
					}
					break;
				}
				case 12: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,708) == 1 && ( gg::GetMemoState(talker,708) / 10 ) == 4 && ( gg::GetMemoState(talker,708) % 10 ) == 9 && myself::IsMyLord(talker) == 1 ) ) {
						myself::SetCurrentQuestID(708);
						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(81) == 5 || myself::Castle_IsUnderSiege() ) {
							myself::ShowPage(talker,"chamberlain_saius_q0708_22a.htm");
						} else if( gg::Fortress_GetContractStatus(101) == -1 || gg::Fortress_GetContractStatus(102) == -1 ) {
							myself::ShowPage(talker,"chamberlain_saius_q0708_22b.htm");
						} else {
							myself::ShowPage(talker,"chamberlain_saius_q0708_22.htm");
						}
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(i0,quest_id,talker) {
		if( quest_id == 708 ) {
			myself::SetCurrentQuestID(708);
			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,708) == 0 && myself::IsMyLord(talker) == 1 && myself::IsDominionOfLord(81) == 0 ) {
					i0 = myself::GetCurrentTick();
					myself::SetMemo(talker,quest_id);
					myself::SetMemoState(talker,708,1);
					myself::SetMemoStateEx(talker,708,1,i0);
					myself::ShowQuestPage(talker,"chamberlain_saius_q0708_04.htm",708);
					myself::SetFlagJournal(talker,708,1);
					myself::ShowQuestMark(talker,708);
					myself::SoundEffect(talker,"ItemSound.quest_middle");
					myself::AddTimerEx(70801,( 1000 * 60 ));
				}
				gg::AddLog(1,talker,quest_id);
			}
			return;
		}
		super;
	}

	EventHandler TIMER_FIRED_EX(i0,talker,timer_id) {
		myself::SetCurrentQuestID(708);
		if( timer_id == 70801 ) {
			myself::Say(gg::MakeFString(70851,"","","","",""));
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,c0,fhtml0,i0,i1,reply,talker) {
		if( ask == 708 ) {
			myself::SetCurrentQuestID(708);
			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 == 708 ) {
			if( reply == 1 ) {
				if( gg::HaveMemo(talker,708) == 0 && myself::IsMyLord(talker) == 1 && myself::IsDominionOfLord(81) == 0 ) {
					myself::FHTML_SetFileName(fhtml0,"chamberlain_saius_q0708_02.htm");
					myself::FHTML_SetInt(fhtml0,"quest_id",708);
					myself::ShowQuestFHTML(talker,fhtml0,708);
				}
			}
			if( reply == 2 ) {
				if( gg::HaveMemo(talker,708) == 1 && gg::GetMemoState(talker,708) == 2 && myself::IsDominionOfLord(81) == 0 ) {
					myself::SetMemoState(talker,708,3);
					myself::ShowPage(talker,"chamberlain_saius_q0708_08.htm");
					myself::SetFlagJournal(talker,708,2);
					myself::ShowQuestMark(talker,708);
					myself::SoundEffect(talker,"ItemSound.quest_middle");
				}
			}
			if( reply == 3 ) {
				c0 = myself::Pledge_GetLeader(talker);
				i0 = talker.dbid;
				if( myself::IsNullCreature(c0) == 0 && myself::DistFromMe(c0) <= 1500 && gg::HaveMemo(c0,708) == 1 && gg::GetMemoState(c0,708) == 3 && myself::Castle_GetPledgeId() == talker.pledge_id && talker.pledge_id != 0 ) {
					myself::FHTML_SetFileName(fhtml0,"chamberlain_saius_q0708_12.htm");
					myself::FHTML_SetStr(fhtml0,"name",talker.name);
					myself::ShowFHTML(talker,fhtml0);
					myself::Say(gg::MakeFString(70852,talker.name,"","","",""));
					myself::SetMemoState(c0,708,4);
					myself::SetFlagJournal(c0,708,3);
					myself::ShowQuestMark(c0,708);
					myself::SoundEffect(c0,"ItemSound.quest_middle");
					myself::SetMemoStateEx(c0,708,1,i0);
				} else {
					myself::ShowQuestPage(talker,"chamberlain_saius_q0708_13.htm",708);
				}
			}
			if( reply == 4 ) {
				if( gg::HaveMemo(talker,708) == 1 && gg::GetMemoState(talker,708) == 49 ) {
					if( gg::GetDominionWarState(81) != 5 && myself::IsMyLord(talker) == 1 ) {
						myself::Say(gg::MakeFString(70859,talker.name,"","","",""));
						myself::DeclareLord(81,talker);
						myself::RemoveMemo(talker,708);
						myself::SoundEffect(talker,"ItemSound.quest_finish");
						gg::AddLog(2,talker,708);
						myself::ShowPage(talker,"chamberlain_saius_q0708_23.htm");
					}
				}
			}
		}
		super;
	}

}
