class 1 karakawei : citizen
{
handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,643) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Rise and Fall of the Elroki Tribe");
			}
			else
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Rise and Fall of the Elroki Tribe - In Progress");
			}
			if( myself::HaveMemo(talker,124) == 0 )
			{
				if( myself::GetOneTimeQuestFlag(talker,124) == 0 )
				{
					_choiceN = ( _choiceN + 1 );
					_code = 2;
					myself::AddChoice(2,"Meeting the Elroki");
				}
				else
				{
					_choiceN = ( _choiceN + 1 );
					_code = 3;
					myself::AddChoice(3,"Meeting the Elroki - Complete");
				}
			}
			else
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Meeting the Elroki - In Progress");
			}
			if( myself::HaveMemo(talker,125) == 1 && myself::GetMemoState(talker,125) == 2 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"In the Name of Evil Part 1 - In Progress");
			}
			if( myself::HaveMemo(talker,125) == 1 && myself::GetMemoState(talker,125) == 3 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"In the Name of Evil Part 1 - In Progress");
			}
			if( myself::HaveMemo(talker,125) == 1 && myself::GetMemoState(talker,125) == 4 && myself::OwnItemCount(talker,8779) < 2 && myself::OwnItemCount(talker,8780) < 2 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"In the Name of Evil Part 1 - In Progress");
			}
			if( myself::HaveMemo(talker,125) == 1 && myself::GetMemoState(talker,125) == 4 && myself::OwnItemCount(talker,8779) >= 2 && myself::OwnItemCount(talker,8780) >= 2 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 9;
				myself::AddChoice(9,"In the Name of Evil Part 1 - In Progress");
			}
			if( myself::HaveMemo(talker,125) == 1 && myself::GetMemoState(talker,125) == 5 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 7;
				myself::AddChoice(7,"In the Name of Evil Part 1 - In Progress");
			}
			if( myself::HaveMemo(talker,125) == 1 && myself::GetMemoState(talker,125) == 8 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 8;
				myself::AddChoice(8,"In the Name of Evil Part 1 - In Progress");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			switch(_code)
			{
				case 0:
				{
					myself::ShowPage(talker,"karakawei_q0643_001.htm");
					break;
				}
				case 1:
				{
					myself::SetCurrentQuestID(643);
					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,"karakawei_q0643_001.htm");
					break;
				}
				case 2:
				{
					myself::ShowPage(talker,"karakawei_q0124_003.htm");
					break;
				}
				case 3:
				{
					myself::SetCurrentQuestID(124);
					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 4:
				{
					myself::SetCurrentQuestID(124);
					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::GetMemoState(talker,124) < 4 )
					{
						myself::ShowPage(talker,"karakawei_q0124_003.htm");
						return;
					}
					if( myself::GetMemoState(talker,124) == 4 )
					{
						myself::ShowPage(talker,"karakawei_q0124_001.htm");
						return;
					}
					myself::ShowPage(talker,"karakawei_q0124_003.htm");
					break;
				}
				case 5:
				{
					myself::ShowPage(talker,"shaman_caracawe_q0125_01.htm");
					break;
				}
				case 6:
				{
					myself::ShowPage(talker,"shaman_caracawe_q0125_12.htm");
					break;
				}
				case 7:
				{
					myself::ShowPage(talker,"shaman_caracawe_q0125_19.htm");
					break;
				}
				case 8:
				{
					myself::ShowPage(talker,"shaman_caracawe_q0125_20.htm");
					break;
				}
				case 9:
				{
					myself::ShowPage(talker,"shaman_caracawe_q0125_11.htm");
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,i0,reply,talker)
	{
		if( ask == 643 )
		{
			myself::SetCurrentQuestID(643);
			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( reply == 1 )
			{
				if( myself::HaveMemo(talker,643) == 0 )
				{
					myself::ShowPage(talker,"karakawei_q0643_006.htm");
					return;
				}
				else
				{
					myself::ShowPage(talker,"karakawei_q0643_002.htm");
					return;
				}
			}
			if( reply == 2 )
			{
				if( myself::OwnItemCount(talker,8776) >= 300 )
				{
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
					{
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::DeleteItem1(talker,8776,300);
						switch(gg::Rand(11))
						{
							case 0:
							{
								myself::GiveItem1(talker,8712,5);
								break;
							}
							case 1:
							{
								myself::GiveItem1(talker,8713,5);
								break;
							}
							case 2:
							{
								myself::GiveItem1(talker,8714,5);
								break;
							}
							case 3:
							{
								myself::GiveItem1(talker,8715,5);
								break;
							}
							case 4:
							{
								myself::GiveItem1(talker,8716,5);
								break;
							}
							case 5:
							{
								myself::GiveItem1(talker,8717,5);
								break;
							}
							case 6:
							{
								myself::GiveItem1(talker,8718,5);
								break;
							}
							case 7:
							{
								myself::GiveItem1(talker,8719,5);
								break;
							}
							case 8:
							{
								myself::GiveItem1(talker,8720,5);
								break;
							}
							case 9:
							{
								myself::GiveItem1(talker,8721,5);
								break;
							}
							case 10:
							{
								myself::GiveItem1(talker,8722,5);
								break;
							}
						}
						myself::ShowPage(talker,"karakawei_q0643_003.htm");
						myself::SoundEffect(talker,"ItemSound.quest_itemget");
						return;
					}
				}
				else
				{
					myself::ShowPage(talker,"karakawei_q0643_005.htm");
					return;
				}
			}
			if( reply == 3 )
			{
				myself::ShowPage(talker,"karakawei_q0643_004.htm");
				return;
			}
		}
		if( ask == 124 )
		{
			myself::SetCurrentQuestID(124);
			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( reply == 1 )
			{
				myself::SetMemoState(talker,124,5);
				myself::SetFlagJournal(talker,124,5);
				myself::ShowPage(talker,"karakawei_q0124_003.htm");
				myself::SoundEffect(talker,"ItemSound.quest_middle");
				return;
			}
		}
		if( ask == 125 )
		{
			myself::SetCurrentQuestID(124);
			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( reply == 1 )
			{
				myself::SetMemoState(talker,125,3);
				myself::SetFlagJournal(talker,125,3);
				myself::ShowPage(talker,"shaman_caracawe_q0125_09.htm");
				myself::SoundEffect(talker,"ItemSound.quest_middle");
				return;
			}
			if( reply == 2 )
			{
				myself::SetMemoState(talker,125,5);
				myself::SetFlagJournal(talker,125,5);
				myself::ShowPage(talker,"shaman_caracawe_q0125_17.htm");
				myself::DeleteItem1(talker,8779,2);
				myself::DeleteItem1(talker,8780,2);
				myself::SoundEffect(talker,"ItemSound.quest_middle");
				return;
			}
		}
		super;
	}

}
