class 1 bard_rukal : citizen
{
handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,228) == 0 && myself::GetOneTimeQuestFlag(talker,228) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Test of Magus");
			}
			if( myself::HaveMemo(talker,228) == 0 && myself::GetOneTimeQuestFlag(talker,228) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Test of Magus (Complete)");
			}
			if( myself::HaveMemo(talker,228) == 1 && myself::OwnItemCount(talker,2841) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Test of Magus (Continue)");
			}
			if( myself::HaveMemo(talker,228) == 1 && myself::OwnItemCount(talker,2842) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Test of Magus (Continue)");
			}
			if( myself::HaveMemo(talker,228) == 1 && myself::OwnItemCount(talker,2843) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Test of Magus (Continue)");
			}
			if( myself::HaveMemo(talker,228) == 1 && myself::OwnItemCount(talker,2847) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Test of Magus (Continue)");
			}
			if( ( ( myself::HaveMemo(talker,30) == 1 && ( ( 1 == 1 && myself::OwnItemCount(talker,7628) >= 1 ) || 1 == 0 ) ) && myself::GetOneTimeQuestFlag(talker,30) == 0 ) && myself::GetMemoState(talker,30) == ( ( 2 * 10 ) + 1 ) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"Chest Caught by Bait of Fire (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,228) == 0 && myself::GetOneTimeQuestFlag(talker,228) == 0 ) )
					{
						myself::SetCurrentQuestID(228);
						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.occupation == 11 || talker.occupation == 26 || talker.occupation == 39 )
							{
								if( talker.level < 39 )
								{
									myself::ShowPage(talker,"bard_rukal_q0228_02.htm");
								}
								else
								{
									myself::FHTML_SetFileName(fhtml0,"bard_rukal_q0228_03.htm");
									myself::FHTML_SetInt(fhtml0,"quest_id",228);
									myself::ShowFHTML(talker,fhtml0);
								}
							}
							else
							{
								myself::ShowPage(talker,"bard_rukal_q0228_01.htm");
							}
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,228) == 0 && myself::GetOneTimeQuestFlag(talker,228) == 1 ) )
					{
						myself::SetCurrentQuestID(228);
						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,228) == 1 && myself::OwnItemCount(talker,2841) == 1 ) )
					{
						myself::SetCurrentQuestID(228);
						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,"bard_rukal_q0228_05.htm");
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,228) == 1 && myself::OwnItemCount(talker,2842) == 1 ) )
					{
						myself::SetCurrentQuestID(228);
						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,"bard_rukal_q0228_06.htm");
					}
					break;
				}
				case 4:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,228) == 1 && myself::OwnItemCount(talker,2843) == 1 ) )
					{
						myself::SetCurrentQuestID(228);
						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::OwnItemCount(talker,2844) >= 1 && myself::OwnItemCount(talker,2845) >= 1 && myself::OwnItemCount(talker,2846) >= 1 )
						{
							myself::ShowPage(talker,"bard_rukal_q0228_08.htm");
						}
						else
						{
							myself::ShowPage(talker,"bard_rukal_q0228_07.htm");
						}
					}
					break;
				}
				case 5:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,228) == 1 && myself::OwnItemCount(talker,2847) == 1 ) )
					{
						myself::SetCurrentQuestID(228);
						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::OwnItemCount(talker,2856) >= 1 && myself::OwnItemCount(talker,2857) >= 1 && myself::OwnItemCount(talker,2858) >= 1 && myself::OwnItemCount(talker,2859) >= 1 )
						{
							if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
							{
								talker.quest_last_reward_time = myself::GetCurrentTick();
								myself::DeleteItem1(talker,2847,myself::OwnItemCount(talker,2847));
								myself::DeleteItem1(talker,2856,myself::OwnItemCount(talker,2856));
								myself::DeleteItem1(talker,2857,myself::OwnItemCount(talker,2857));
								myself::DeleteItem1(talker,2858,myself::OwnItemCount(talker,2858));
								myself::DeleteItem1(talker,2859,myself::OwnItemCount(talker,2859));
								myself::GiveItem1(talker,2840,1);
								myself::IncrementParam(talker,0,139039);
								myself::IncrementParam(talker,1,40000);
								myself::ShowPage(talker,"bard_rukal_q0228_12.htm");
								myself::RemoveMemo(talker,228);
								myself::SoundEffect(talker,"ItemSound.quest_finish");
								myself::SetOneTimeQuestFlag(talker,228,1);
							}
						}
						else
						{
							myself::ShowPage(talker,"bard_rukal_q0228_11.htm");
						}
					}
					break;
				}
				case 6:
				{
					if( _from_choice == 0 || ( ( ( myself::HaveMemo(talker,30) == 1 && ( ( 1 == 1 && myself::OwnItemCount(talker,7628) >= 1 ) || 1 == 0 ) ) && myself::GetOneTimeQuestFlag(talker,30) == 0 ) && myself::GetMemoState(talker,30) == ( ( 2 * 10 ) + 1 ) ) )
					{
						myself::SetCurrentQuestID(30);
						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::SetHTMLCookie(talker,30,2);
						myself::ShowPage(talker,"bard_rukal_q0030_0201.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(quest_id,talker)
	{
		if( quest_id == 228 )
		{
			myself::SetCurrentQuestID(228);
			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");
				if( myself::OwnItemCount(talker,2841) == 0 )
				{
					myself::GiveItem1(talker,2841,1);
				}
				myself::ShowPage(talker,"bard_rukal_q0228_04.htm");
				myself::SetFlagJournal(talker,228,1);
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,i0,i1,quest_id,reply,talker)
	{
		if( ask == 228 )
		{
			myself::SetCurrentQuestID(228);
			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 == 228 )
		{
			if( reply == 1 )
			{
				myself::ShowPage(talker,"bard_rukal_q0228_09.htm");
			}
			if( reply == 2 )
			{
				if( myself::OwnItemCount(talker,2846) >= 1 )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::ShowPage(talker,"bard_rukal_q0228_10.htm");
						myself::SetFlagJournal(talker,228,5);
						myself::DeleteItem1(talker,2843,myself::OwnItemCount(talker,2843));
						myself::DeleteItem1(talker,2844,myself::OwnItemCount(talker,2844));
						myself::DeleteItem1(talker,2845,myself::OwnItemCount(talker,2845));
						myself::DeleteItem1(talker,2846,1);
						myself::GiveItem1(talker,2847,1);
					}
				}
			}
		}
		if( ask == 30 )
		{
			myself::SetCurrentQuestID(30);
			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 == 30 && myself::GetOneTimeQuestFlag(talker,30) == 0 )
		{
			i0 = myself::GetHTMLCookie(talker,30,( 3 - 1 ));
			if( i0 != -1 )
			{
				if( reply == 3 && myself::HaveMemo(talker,30) == 1 && myself::GetOneTimeQuestFlag(talker,30) == 0 )
				{
					if( ( ( ( 1 == 1 && myself::OwnItemCount(talker,7628) >= 1 ) || 1 == 0 ) && ( ( 0 == 1 && myself::OwnItemCount(talker,0) >= 0 ) || 0 == 0 ) ) && ( ( 0 == 1 && myself::OwnItemCount(talker,0) >= 0 ) || 0 == 0 ) )
					{
						if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
						{
							talker.quest_last_reward_time = myself::GetCurrentTick();
							myself::DeleteItem1(talker,7628,1);
							myself::DeleteItem1(talker,0,0);
							myself::DeleteItem1(talker,0,0);
							myself::GiveItem1(talker,916,1);
						}
						myself::AddLog(2,talker,30);
						myself::RemoveMemo(talker,30);
						myself::SetOneTimeQuestFlag(talker,30,1);
						myself::SoundEffect(talker,"ItemSound.quest_finish");
						myself::ShowPage(talker,"bard_rukal_q0030_0301.htm");
					}
					else
					{
						myself::ShowPage(talker,"bard_rukal_q0030_0302.htm");
					}
				}
			}
		}
		super;
	}

}
