@LabelIndex 360659
@StringIndex 52131
class 0 verdure_sage_ellikia : citizen {
handler:
	EventHandler TALKED(fhtml0,talker) {
		if( _from_choice == 0 ) {
			if( gg::HaveMemo(talker,87) == 1 && talker.occupation == 30 && gg::GetMemoState(talker,87) == 13 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Saga of Eva's Saint (In Progress)");
			}
			if( gg::HaveMemo(talker,87) == 1 && talker.occupation == 30 && gg::GetMemoState(talker,87) == 14 && gg::OwnItemCount(talker,7440) == 0 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Saga of Eva's Saint (In Progress)");
			}
			if( gg::HaveMemo(talker,87) == 1 && talker.occupation == 30 && gg::GetMemoState(talker,87) == 14 && gg::OwnItemCount(talker,7440) >= 1 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Saga of Eva's Saint (In Progress)");
			}
			if( gg::HaveMemo(talker,87) == 0 || talker.occupation != 30 || ( gg::GetMemoState(talker,87) != 13 && gg::GetMemoState(talker,87) != 14 ) ) {
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Saga of Eva's Saint (In Progress)");
			}
			if( _choiceN > 1 ) {
				myself::ShowChoicePage(talker,0);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 ) {
			switch(_code) {
				case 0: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,87) == 1 && talker.occupation == 30 && gg::GetMemoState(talker,87) == 13 ) ) {
						myself::SetCurrentQuestID(87);
						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.i_quest0 == 0 && myself.sm.param2 == talker.dbid ) {
							myself::ShowPage(talker,"verdure_sage_ellikia_q0087_0101.htm");
						}
						if( myself.i_quest0 == 0 && myself.sm.param2 != talker.dbid ) {
							myself::ShowPage(talker,"verdure_sage_ellikia_q0087_0102.htm");
						}
						if( myself.i_quest0 == 1 ) {
							myself::ShowPage(talker,"verdure_sage_ellikia_q0087_0103.htm");
						}
					}
					break;
				}
				case 1: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,87) == 1 && talker.occupation == 30 && gg::GetMemoState(talker,87) == 14 && gg::OwnItemCount(talker,7440) == 0 ) ) {
						myself::SetCurrentQuestID(87);
						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.i_quest0 == 0 && myself.sm.param2 == talker.dbid ) {
							myself::ShowPage(talker,"verdure_sage_ellikia_q0087_0104.htm");
						}
						if( myself.i_quest0 == 0 && myself.sm.param2 != talker.dbid ) {
							myself::ShowPage(talker,"verdure_sage_ellikia_q0087_0105.htm");
						}
						if( myself.i_quest0 == 1 && myself.sm.param2 == talker.dbid ) {
							myself::ShowPage(talker,"verdure_sage_ellikia_q0087_0106.htm");
						}
						if( myself.i_quest0 == 1 && myself.sm.param2 != talker.dbid ) {
							myself::ShowPage(talker,"verdure_sage_ellikia_q0087_0107.htm");
						}
					}
					break;
				}
				case 2: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,87) == 1 && talker.occupation == 30 && gg::GetMemoState(talker,87) == 14 && gg::OwnItemCount(talker,7440) >= 1 ) ) {
						myself::SetCurrentQuestID(87);
						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.i_quest0 == 0 ) {
							myself::ShowPage(talker,"verdure_sage_ellikia_q0087_0108.htm");
						}
						if( myself.i_quest0 == 1 ) {
							myself::ShowPage(talker,"verdure_sage_ellikia_q0087_0109.htm");
						}
					}
					break;
				}
				case 3: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,87) == 0 || talker.occupation != 30 || ( gg::GetMemoState(talker,87) != 13 && gg::GetMemoState(talker,87) != 14 ) ) ) {
						myself::SetCurrentQuestID(87);
						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,"noquest.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler ATTACKED(attacker,c1) {
		myself::SetCurrentQuestID(87);
		c1 = attacker;
		if( c1.master ) {
			c1 = c1.master;
		}
		if( c1.is_pc == 0 ) {
			myself::AddAttackDesire(attacker,1,2000);
		}
		super;
	}

	EventHandler TIMER_FIRED_EX(c0,npc0,timer_id) {
		myself::SetCurrentQuestID(87);
		if( timer_id == 99903 ) {
			myself::Say(gg::MakeFString(8757,"","","","",""));
			myself::AddTimerEx(99904,1500);
		} else if( timer_id == 99904 ) {
			c0 = gg::GetCreatureFromIndex(myself.sm.param1);
			if( c0 ) {
				if( c0.is_pc == 1 ) {
					myself::Say(gg::MakeFString(8758,c0.name,"","","",""));
				}
			}
			myself::AddTimerEx(99909,10000);
		} else if( timer_id == 99905 ) {
			myself.i_quest1 = ( myself.i_quest1 + 1 );
			if( myself.i_quest0 == 1 || myself.i_quest0 == 2 || myself.i_quest1 > 3 ) {
				npc0 = gg::GetNPCFromID(myself.sm.param3);
				if( gg::IsNull(npc0) == 0 ) {
					npc0.i_quest0 = 0;
				}
				if( myself.i_quest0 == 1 ) {
					myself::Say(gg::MakeFString(8761,"","","","",""));
				} else {
					myself::Say(gg::MakeFString(8762,"","","","",""));
				}
				myself::Despawn();
			} else {
				myself::AddTimerEx(99905,1000);
			}
		} else if( timer_id == 99909 ) {
			if( myself.i_quest0 == 0 ) {
				if( gg::Rand(2) == 0 ) {
					c0 = gg::GetCreatureFromIndex(myself.sm.param1);
					if( c0 ) {
						if( c0.is_pc == 1 ) {
							myself::Say(gg::MakeFString(8759,c0.name,"","","",""));
						}
					}
				} else {
					c0 = gg::GetCreatureFromIndex(myself.sm.param1);
					if( c0 ) {
						if( c0.is_pc == 1 ) {
							myself::Say(gg::MakeFString(8760,c0.name,"","","",""));
						}
					}
				}
				myself::AddTimerEx(99909,13000);
			}
		}
		super;
	}

	EventHandler CREATED() {
		myself::SetCurrentQuestID(87);
		myself::AddTimerEx(99903,500);
		myself::AddTimerEx(99905,( 1000 * 60 ));
		myself.i_quest0 = 0;
		myself.i_quest1 = 0;
		super;
	}

	EventHandler MENU_SELECTED(ask,npc0,reply,talker) {
		if( ask == 87 ) {
			myself::SetCurrentQuestID(87);
			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 == 87 ) {
			if( reply == 1 ) {
				if( gg::HaveMemo(talker,87) == 1 && talker.occupation == 30 && gg::GetMemoState(talker,87) == 14 && gg::OwnItemCount(talker,7440) == 0 && myself.i_quest0 == 1 && myself.sm.param2 == talker.dbid ) {
					myself::ShowPage(talker,"verdure_sage_ellikia_q0087_0110.htm");
				}
			} else if( reply == 2 ) {
				if( gg::HaveMemo(talker,87) == 1 && talker.occupation == 30 && gg::GetMemoState(talker,87) == 14 && gg::OwnItemCount(talker,7440) == 0 && myself.i_quest0 == 1 && myself.sm.param2 != talker.dbid ) {
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 ) {
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::GiveItem1(talker,7440,1);
						myself::ShowPage(talker,"verdure_sage_ellikia_q0087_0111.htm");
						myself::SetFlagJournal(talker,87,18);
						myself::ShowQuestMark(talker,87);
						myself::SoundEffect(talker,"ItemSound.quest_middle");
					}
				}
			} else if( reply == 3 ) {
				if( gg::HaveMemo(talker,87) == 1 && talker.occupation == 30 && gg::GetMemoState(talker,87) == 14 && gg::OwnItemCount(talker,7440) == 0 && myself.i_quest0 == 1 && myself.sm.param2 == talker.dbid ) {
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 ) {
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::GiveItem1(talker,7440,1);
						myself::SetFlagJournal(talker,87,18);
						myself::ShowQuestMark(talker,87);
						myself::SoundEffect(talker,"ItemSound.quest_middle");
						myself::Say(gg::MakeFString(8763,"","","","",""));
						npc0 = gg::GetNPCFromID(myself.sm.param3);
						if( gg::IsNull(npc0) == 0 ) {
							npc0.i_quest0 = 0;
						}
						myself::Despawn();
					}
				}
			}
		}
		super;
	}

}
