class 1 trader_chali : merchant_for_newbie
{
property:
	BuySellList SellList0 = {{"pants";15};{"shirt";15};{"leather_pants";15};{"leather_shirt";15};{"hard_leather_pants";15};{"wooden_gaiters";15};{"wooden_breastplate";15};{"tights_pants";15};{"tights_shirt";15};{"bone_breastplate";15};{"bone_gaiters";15};{"leather_shield";15};{"small_shield";15};{"buckler";15};{"round_shield";15};{"short_gloves";15};{"short_leather_gloves";15};{"gloves";15};{"leather_gloves";15};{"apprentice_s_shoes";15};{"cloth_shoes";15};{"leather_sandals";15};{"crude_leather_shoes";15};{"cotton_shoes";15};{"leather_shoes";15};{"low_boots";15};{"cloth_cap";15};{"leather_cap";15};{"wooden_helmet";15};{"leather_helmet";15};{"cotton_shirt";15};{"striped_cotton_shirt";15}};
	BuySellList SellList1 = {{"hose";15};{"tunic";15};{"cotton_hose";15};{"cotton_tunic";15};{"feriotic_hose";15};{"feriotic_tunic";15};{"leather_hose";15};{"leather_tunic";15};{"hose_of_devotion";15};{"tunic_of_devotion";15};{"leather_shield";15};{"small_shield";15};{"buckler";15};{"round_shield";15};{"short_gloves";15};{"short_leather_gloves";15};{"gloves";15};{"leather_gloves";15};{"apprentice_s_shoes";15};{"cloth_shoes";15};{"leather_sandals";15};{"crude_leather_shoes";15};{"cotton_shoes";15};{"leather_shoes";15};{"low_boots";15};{"cloth_cap";15};{"leather_cap";15};{"wooden_helmet";15};{"leather_helmet";15};{"cotton_shirt";15};{"striped_cotton_shirt";15}};

handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,417) == 1 && myself::OwnItemCount(talker,1648) == 1 && myself::GetMemoStateEx(talker,417,1) < 20 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Path to become a Scavenger");
			}
			if( myself::HaveMemo(talker,417) == 1 && myself::OwnItemCount(talker,1648) == 1 && myself::GetMemoStateEx(talker,417,1) >= 20 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Path to become a Scavenger");
			}
			if( myself::HaveMemo(talker,417) == 1 && myself::OwnItemCount(talker,1651) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Path to become a Scavenger");
			}
			if( myself::HaveMemo(talker,5) && myself::OwnItemCount(talker,1547) && myself::OwnItemCount(talker,1550) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Miner's Favor");
			}
			if( myself::HaveMemo(talker,5) && myself::OwnItemCount(talker,1547) && myself::OwnItemCount(talker,1550) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Miner's Favor");
			}
			if( myself::HaveMemo(talker,221) == 1 && myself::OwnItemCount(talker,3258) == 0 && myself::OwnItemCount(talker,3252) == 0 && myself::OwnItemCount(talker,3247) == 0 && myself::OwnItemCount(talker,3239) >= 1 && myself::OwnItemCount(talker,3246) >= 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 5;
				myself::AddChoice(5,"Testimony of Prosperity");
			}
			if( myself::HaveMemo(talker,221) == 1 && myself::OwnItemCount(talker,3239) >= 1 && myself::OwnItemCount(talker,3246) >= 1 && myself::OwnItemCount(talker,3252) >= 1 && myself::OwnItemCount(talker,3247) == 0 && myself::OwnItemCount(talker,3258) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 6;
				myself::AddChoice(6,"Testimony of Prosperity");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			switch(_code)
			{
				case 0:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,417) == 1 && myself::OwnItemCount(talker,1648) == 1 && myself::GetMemoStateEx(talker,417,1) < 20 ) )
					{
						myself::SetCurrentQuestID(417);
						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,"trader_chali_q0417_01.htm");
							myself::DeleteItem1(talker,1648,1);
							myself::GiveItem1(talker,1651,1);
							myself::SetMemoStateEx(talker,417,1,( myself::GetMemoStateEx(talker,417,1) + 10 ));
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,417) == 1 && myself::OwnItemCount(talker,1648) == 1 && myself::GetMemoStateEx(talker,417,1) >= 20 ) )
					{
						myself::SetCurrentQuestID(417);
						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::SetMemoState(talker,417,1);
							myself::ShowPage(talker,"trader_chali_q0417_02.htm");
							myself::DeleteItem1(talker,1648,1);
							myself::GiveItem1(talker,1651,1);
							myself::SetMemoStateEx(talker,417,1,( myself::GetMemoStateEx(talker,417,1) + 10 ));
							myself::SetFlagJournal(talker,417,3);
						}
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,417) == 1 && myself::OwnItemCount(talker,1651) == 1 ) )
					{
						myself::SetCurrentQuestID(417);
						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,"trader_chali_q0417_03.htm");
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,5) && myself::OwnItemCount(talker,1547) && myself::OwnItemCount(talker,1550) == 0 ) )
					{
						myself::SetCurrentQuestID(5);
						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,"trader_chali_q0005_01.htm");
							myself::GiveItem1(talker,1550,1);
							if( ( ( ( myself::OwnItemCount(talker,1548) + myself::OwnItemCount(talker,1549) ) + myself::OwnItemCount(talker,1550) ) + myself::OwnItemCount(talker,1551) ) >= 3 )
							{
								myself::SetFlagJournal(talker,5,2);
							}
						}
					}
					break;
				}
				case 4:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,5) && myself::OwnItemCount(talker,1547) && myself::OwnItemCount(talker,1550) ) )
					{
						myself::SetCurrentQuestID(5);
						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,"trader_chali_q0005_02.htm");
					}
					break;
				}
				case 5:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,221) == 1 && myself::OwnItemCount(talker,3258) == 0 && myself::OwnItemCount(talker,3252) == 0 && myself::OwnItemCount(talker,3247) == 0 && myself::OwnItemCount(talker,3239) >= 1 && myself::OwnItemCount(talker,3246) >= 1 ) )
					{
						myself::SetCurrentQuestID(221);
						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,"trader_chali_q0221_01.htm");
							myself::GiveItem1(talker,3252,1);
						}
					}
					break;
				}
				case 6:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,221) == 1 && myself::OwnItemCount(talker,3239) >= 1 && myself::OwnItemCount(talker,3246) >= 1 && myself::OwnItemCount(talker,3252) >= 1 && myself::OwnItemCount(talker,3247) == 0 && myself::OwnItemCount(talker,3258) == 0 ) )
					{
						myself::SetCurrentQuestID(221);
						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,"trader_chali_q0221_02.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

}
