class 1 trader_salient : merchant_for_chaotic
{
property:
	BuySellList SellList0 = {{"soulshot_none";50};{"spiritshot_none";50};{"blessed_spiritshot_none";50};{"comp_bspiritshot_none";50};{"comp_spiritshot_none";50};{"comp_soulshot_none";50};{"adv_comp_bspiritshot_none";50};{"adv_comp_spiritshot_none";50};{"adv_comp_soulshot_none";50};{"wooden_arrow";50};{"bone_arrow";50};{"fine_steel_arrow";50};{"lesser_healing_potion";50};{"healing_potion";50};{"antidote";50};{"advanced_antidote";50};{"bandage";50};{"emergency_dressing";50};{"quick_step_potion";50};{"swift_attack_potion";50};{"potion_of_acumen2";50};{"scroll_of_awake";50};{"scroll_of_escape";50};{"scroll_of_resurrection";50};{"scroll_of_escape_to_agit";50};{"spirit_ore";50};{"soul_ore";50};{"energy_stone";50};{"key_of_thief";50};{"rope_of_magic_d";50};{"rope_of_magic_c";50};{"rope_of_magic_b";50};{"gemstone_d";50};{"dice_heart";50};{"dice_spade";50};{"dice_clover";50};{"dice_diamond";50}};

handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( myself::HaveMemo(talker,328) == 0 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Sense for Business");
			}
			if( myself::HaveMemo(talker,328) == 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Sense for Business");
			}
			if( myself::HaveMemo(talker,233) == 1 && myself::OwnItemCount(talker,2904) == 0 && myself::OwnItemCount(talker,2902) >= 1 && myself::OwnItemCount(talker,2903) >= 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Test of the War Spirit");
			}
			if( myself::HaveMemo(talker,233) == 1 && myself::OwnItemCount(talker,2903) == 0 && myself::OwnItemCount(talker,2902) >= 1 && myself::OwnItemCount(talker,2904) >= 1 )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 3;
				myself::AddChoice(3,"Test of the War Spirit");
			}
			if( myself::HaveMemo(talker,233) == 1 && myself::OwnItemCount(talker,2902) == 0 && ( myself::OwnItemCount(talker,2910) >= 1 || myself::OwnItemCount(talker,2914) >= 1 || myself::OwnItemCount(talker,2880) >= 1 ) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 4;
				myself::AddChoice(4,"Test of the War Spirit");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			switch(_code)
			{
				case 0:
				{
					if( _from_choice == 0 || myself::HaveMemo(talker,328) == 0 )
					{
						myself::SetCurrentQuestID(328);
						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.level >= 21 )
							{
								myself::FHTML_SetFileName(fhtml0,"trader_salient_q0328_02.htm");
								myself::FHTML_SetInt(fhtml0,"quest_id",328);
								myself::ShowFHTML(talker,fhtml0);
							}
							else
							{
								myself::ShowPage(talker,"trader_salient_q0328_01.htm");
							}
						}
						else
						{
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1:
				{
					if( _from_choice == 0 || myself::HaveMemo(talker,328) == 1 )
					{
						myself::SetCurrentQuestID(328);
						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,1347) + myself::OwnItemCount(talker,1366) ) + myself::OwnItemCount(talker,1348) ) > 0 )
						{
							if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
							{
								talker.quest_last_reward_time = myself::GetCurrentTick();
								if( ( ( myself::OwnItemCount(talker,1347) + myself::OwnItemCount(talker,1366) ) + myself::OwnItemCount(talker,1348) ) >= 10 )
								{
									myself::GiveItem1(talker,57,( ( ( 618 + ( 25 * myself::OwnItemCount(talker,1347) ) ) + ( 1000 * myself::OwnItemCount(talker,1366) ) ) + ( 60 * myself::OwnItemCount(talker,1348) ) ));
								}
								else
								{
									myself::GiveItem1(talker,57,( ( ( 25 * myself::OwnItemCount(talker,1347) ) + ( 1000 * myself::OwnItemCount(talker,1366) ) ) + ( 60 * myself::OwnItemCount(talker,1348) ) ));
								}
								myself::DeleteItem1(talker,1347,myself::OwnItemCount(talker,1347));
								myself::DeleteItem1(talker,1366,myself::OwnItemCount(talker,1366));
								myself::DeleteItem1(talker,1348,myself::OwnItemCount(talker,1348));
								myself::ShowPage(talker,"trader_salient_q0328_05.htm");
								myself::AddLog(3,talker,328);
							}
						}
						else
						{
							myself::ShowPage(talker,"trader_salient_q0328_04.htm");
						}
					}
					break;
				}
				case 2:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,233) == 1 && myself::OwnItemCount(talker,2904) == 0 && myself::OwnItemCount(talker,2902) >= 1 && myself::OwnItemCount(talker,2903) >= 1 ) )
					{
						myself::SetCurrentQuestID(233);
						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_salient_q0233_01.htm");
							myself::DeleteItem1(talker,2903,1);
							myself::GiveItem1(talker,2904,1);
						}
					}
					break;
				}
				case 3:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,233) == 1 && myself::OwnItemCount(talker,2903) == 0 && myself::OwnItemCount(talker,2902) >= 1 && myself::OwnItemCount(talker,2904) >= 1 ) )
					{
						myself::SetCurrentQuestID(233);
						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_salient_q0233_02.htm");
					}
					break;
				}
				case 4:
				{
					if( _from_choice == 0 || ( myself::HaveMemo(talker,233) == 1 && myself::OwnItemCount(talker,2902) == 0 && ( myself::OwnItemCount(talker,2910) >= 1 || myself::OwnItemCount(talker,2914) >= 1 || myself::OwnItemCount(talker,2880) >= 1 ) ) )
					{
						myself::SetCurrentQuestID(233);
						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_salient_q0233_03.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(quest_id,talker)
	{
		if( quest_id == 328 )
		{
			myself::SetCurrentQuestID(328);
			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::AddLog(1,talker,328);
				myself::SoundEffect(talker,"ItemSound.quest_accept");
				myself::ShowPage(talker,"trader_salient_q0328_03.htm");
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,reply,talker)
	{
		if( ask == 328 )
		{
			myself::SetCurrentQuestID(328);
			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 == 328 )
		{
			if( reply == 1 )
			{
				myself::ShowPage(talker,"trader_salient_q0328_06.htm");
				myself::RemoveMemo(talker,328);
				myself::AddLog(2,talker,328);
				myself::SoundEffect(talker,"ItemSound.quest_finish");
			}
			else if( reply == 2 )
			{
				myself::ShowPage(talker,"trader_salient_q0328_07.htm");
			}
		}
		super;
	}

}
