class 1 magister_kaira : mage_coach
{
handler:
	EventHandler TALK_SELECTED(talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,219) == 0 && myself::GetOneTimeQuestFlag(talker,219) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Testimony of Fate");
			}
			if( myself::HaveMemo(talker,219) == 0 && myself::GetOneTimeQuestFlag(talker,219) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Testimony of Fate (Complete)");
			}
			if( myself::HaveMemo(talker,219) == 1 && myself::OwnItemCount(talker,3173) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Testimony of Fate (Continue)");
			}
			if( myself::HaveMemo(talker,219) == 1 && ( myself::OwnItemCount(talker,3174) || myself::OwnItemCount(talker,3175) ) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Testimony of Fate (Continue)");
			}
			if( myself::HaveMemo(talker,219) == 1 && ( myself::OwnItemCount(talker,3176) || myself::OwnItemCount(talker,3177) ) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Testimony of Fate (Continue)");
			}
			if( myself::HaveMemo(talker,219) == 1 && myself::OwnItemCount(talker,3184) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Testimony of Fate (Continue)");
			}
			if( myself::HaveMemo(talker,219) == 1 && ( myself::OwnItemCount(talker,3185) || myself::OwnItemCount(talker,3186) ) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"Testimony of Fate (Continue)");
			}
			if( myself::HaveMemo(talker,219) == 1 && myself::OwnItemCount(talker,3187) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 7;
				myself::AddChoice(7,"Testimony of Fate (Continue)");
			}
			if( myself::HaveMemo(talker,219) == 1 && myself::OwnItemCount(talker,3188) && talker.level < 38 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 8;
				myself::AddChoice(8,"Testimony of Fate (Continue)");
			}
			if( myself::HaveMemo(talker,219) == 1 && myself::OwnItemCount(talker,3188) && talker.level >= 38 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 9;
				myself::AddChoice(9,"Testimony of Fate (Continue)");
			}
			if( myself::HaveMemo(talker,219) == 1 && myself::OwnItemCount(talker,3189) && talker.level >= 38 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 10;
				myself::AddChoice(10,"Testimony of Fate (Continue)");
			}
			if( myself::HaveMemo(talker,219) == 1 && myself::OwnItemCount(talker,3190) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 11;
				myself::AddChoice(11,"Testimony of Fate (Continue)");
			}
			if( myself::HaveMemo(talker,229) == 1 && myself::OwnItemCount(talker,3309) == 1 && myself::OwnItemCount(talker,3318) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 12;
				myself::AddChoice(12,"Test of Witchcraft (Continue)");
			}
			if( myself::HaveMemo(talker,229) == 1 && myself::OwnItemCount(talker,3318) == 1 && myself::OwnItemCount(talker,3309) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 13;
				myself::AddChoice(13,"Test of Witchcraft (Continue)");
			}
			if( myself::HaveMemo(talker,229) == 1 && ( myself::OwnItemCount(talker,3323) >= 1 || myself::OwnItemCount(talker,3324) >= 1 ) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 14;
				myself::AddChoice(14,"Test of Witchcraft (Continue)");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			switch(_code)
			{
				case 0:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,219) == 0 && myself::GetOneTimeQuestFlag(talker,219) == 0 ) )
					{
						myself::SetCurrentQuestID(219);
						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( talker.race == 2 && talker.level >= 37 && myself::IsInCategory(19,talker.occupation) )
							{
								myself::ShowPage(talker,"magister_kaira_q0219_03.htm");
							}
							else if( talker.race == 2 && talker.level >= 37 )
							{
								myself::ShowPage(talker,"magister_kaira_q0219_01a.htm");
							}
							else if( talker.race == 2 )
							{
								myself::ShowPage(talker,"magister_kaira_q0219_02.htm");
							}
							else
							{
								myself::ShowPage(talker,"magister_kaira_q0219_01.htm");
							}
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,219) == 0 && myself::GetOneTimeQuestFlag(talker,219) == 1 ) )
					{
						myself::SetCurrentQuestID(219);
						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,"finishedquest.htm");
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,219) == 1 && myself::OwnItemCount(talker,3173) ) )
					{
						myself::SetCurrentQuestID(219);
						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,"magister_kaira_q0219_06.htm");
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,219) == 1 && ( myself::OwnItemCount(talker,3174) || myself::OwnItemCount(talker,3175) ) ) )
					{
						myself::SetCurrentQuestID(219);
						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,"magister_kaira_q0219_07.htm");
					}
					break;
				}
				case 4:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,219) == 1 && ( myself::OwnItemCount(talker,3176) || myself::OwnItemCount(talker,3177) ) ) )
					{
						myself::SetCurrentQuestID(219);
						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,"magister_kaira_q0219_08.htm");
						myself::SetFlagJournal(talker,219,5);
					}
					break;
				}
				case 5:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,219) == 1 && myself::OwnItemCount(talker,3184) ) )
					{
						myself::SetCurrentQuestID(219);
						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();
							myself::ShowPage(talker,"magister_kaira_q0219_09.htm");
							myself::GiveItem1(talker,3185,1);
							myself::DeleteItem1(talker,3184,1);
							myself::CreateOnePrivateEx(1030613,"alders_spirit",0,0,78977,149036,-3597,0,0,0,0);
							myself::SetFlagJournal(talker,219,10);
						}
					}
					break;
				}
				case 6:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,219) == 1 && ( myself::OwnItemCount(talker,3185) || myself::OwnItemCount(talker,3186) ) ) )
					{
						myself::SetCurrentQuestID(219);
						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,"magister_kaira_q0219_10.htm");
						myself::SetFlagJournal(talker,219,11);
					}
					break;
				}
				case 7:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,219) == 1 && myself::OwnItemCount(talker,3187) ) )
					{
						myself::SetCurrentQuestID(219);
						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,"magister_kaira_q0219_11.htm");
					}
					break;
				}
				case 8:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,219) == 1 && myself::OwnItemCount(talker,3188) && talker.level < 38 ) )
					{
						myself::SetCurrentQuestID(219);
						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,"magister_kaira_q0219_14.htm");
					}
					break;
				}
				case 9:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,219) == 1 && myself::OwnItemCount(talker,3188) && talker.level >= 38 ) )
					{
						myself::SetCurrentQuestID(219);
						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();
							myself::ShowPage(talker,"magister_kaira_q0219_15.htm");
							myself::GiveItem1(talker,3189,1);
							myself::DeleteItem1(talker,3188,1);
							myself::SetFlagJournal(talker,219,15);
						}
					}
					break;
				}
				case 10:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,219) == 1 && myself::OwnItemCount(talker,3189) && talker.level >= 38 ) )
					{
						myself::SetCurrentQuestID(219);
						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,"magister_kaira_q0219_16.htm");
					}
					break;
				}
				case 11:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,219) == 1 && myself::OwnItemCount(talker,3190) ) )
					{
						myself::SetCurrentQuestID(219);
						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,"magister_kaira_q0219_17.htm");
					}
					break;
				}
				case 12:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,229) == 1 && myself::OwnItemCount(talker,3309) == 1 && myself::OwnItemCount(talker,3318) == 0 ) )
					{
						myself::SetCurrentQuestID(229);
						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,"magister_kaira_q0229_01.htm");
					}
					break;
				}
				case 13:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,229) == 1 && myself::OwnItemCount(talker,3318) == 1 && myself::OwnItemCount(talker,3309) == 1 ) )
					{
						myself::SetCurrentQuestID(229);
						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,"magister_kaira_q0229_03.htm");
					}
					break;
				}
				case 14:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,229) == 1 && ( myself::OwnItemCount(talker,3323) >= 1 || myself::OwnItemCount(talker,3324) >= 1 ) ) )
					{
						myself::SetCurrentQuestID(229);
						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,"magister_kaira_q0229_04.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(quest_id,talker)
	{
		if( quest_id == 219 )
		{
			myself::SetCurrentQuestID(219);
			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();
				myself::SetMemo(talker,quest_id);
				myself::SoundEffect(talker,"ItemSound.quest_accept");
				myself::ShowPage(talker,"magister_kaira_q0219_05.htm");
				myself::SetFlagJournal(talker,219,1);
				myself::AddLog(1,talker,219);
				myself::GiveItem1(talker,3173,1);
				talker.flag = 0;
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,fhtml0,reply,talker)
	{
		if( ask == 219 )
		{
			myself::SetCurrentQuestID(219);
			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 == 219 )
		{
			if( reply == 1 )
			{
				myself::FHTML_SetFileName(fhtml0,"magister_kaira_q0219_04.htm");
				myself::FHTML_SetInt(fhtml0,"quest_id",219);
				myself::ShowFHTML(talker,fhtml0);
			}
			else if( reply == 2 && myself::OwnItemCount(talker,3187) > 0 )
			{
				if( talker.level >= 38 )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::ShowPage(talker,"magister_kaira_q0219_12.htm");
						myself::GiveItem1(talker,3189,1);
						myself::DeleteItem1(talker,3187,1);
						myself::SetFlagJournal(talker,219,15);
					}
				}
				else if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::ShowPage(talker,"magister_kaira_q0219_13.htm");
					myself::GiveItem1(talker,3188,1);
					myself::DeleteItem1(talker,3187,1);
					myself::SetFlagJournal(talker,219,14);
				}
			}
		}
		if( ask == 229 )
		{
			myself::SetCurrentQuestID(229);
			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 == 229 )
		{
			if( reply == 1 )
			{
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::ShowPage(talker,"magister_kaira_q0229_02.htm");
					myself::GiveItem1(talker,3318,1);
					if( myself::OwnItemCount(talker,3317) >= 1 && myself::OwnItemCount(talker,3319) >= 1 && myself::OwnItemCount(talker,3320) >= 1 && myself::OwnItemCount(talker,3321) >= 1 && myself::OwnItemCount(talker,3322) >= 1 )
					{
						myself::SetFlagJournal(talker,229,3);
					}
				}
			}
		}
		super;
	}

}
