class 1 blueprint_seller_shaling : merchant
{
property:
	BuySellList SellList0 = {{"sb_summon_mechanic_golem1";20}};

handler:
	EventHandler TALK_SELECTED(fhtml0,talker)
	{
		if( _from_choice == 0 )
		{
			if( ( ( myself::HaveMemo(talker,27) == 1 && ( ( 1 == 1 && myself::OwnItemCount(talker,7625) >= 1 ) || 1 == 0 ) ) && myself::GetOneTimeQuestFlag(talker,27) == 0 ) && myself::GetMemoState(talker,27) == ( ( 2 * 10 ) + 1 ) )
			{
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Chest Caught by Bait of Wind (Continue)");
			}
			if( _choiceN > 1 )
			{
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 )
		{
			if( _code == 0 )
			{
				if( _from_choice == 0 || ( ( ( myself::HaveMemo(talker,27) == 1 && ( ( 1 == 1 && myself::OwnItemCount(talker,7625) >= 1 ) || 1 == 0 ) ) && myself::GetOneTimeQuestFlag(talker,27) == 0 ) && myself::GetMemoState(talker,27) == ( ( 2 * 10 ) + 1 ) ) )
				{
					myself::SetCurrentQuestID(27);
					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,27,2);
					myself::ShowPage(talker,"blueprint_seller_shaling_q0027_0201.htm");
				}
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,i0,i1,quest_id,reply,talker)
	{
		if( ask == 27 )
		{
			myself::SetCurrentQuestID(27);
			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 == 27 && myself::GetOneTimeQuestFlag(talker,27) == 0 )
		{
			i0 = myself::GetHTMLCookie(talker,27,( 3 - 1 ));
			if( i0 != -1 )
			{
				if( reply == 3 && myself::HaveMemo(talker,27) == 1 && myself::GetOneTimeQuestFlag(talker,27) == 0 )
				{
					if( ( ( ( 1 == 1 && myself::OwnItemCount(talker,7625) >= 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,7625,1);
							myself::DeleteItem1(talker,0,0);
							myself::DeleteItem1(talker,0,0);
							myself::GiveItem1(talker,880,1);
						}
						myself::AddLog(2,talker,27);
						myself::RemoveMemo(talker,27);
						myself::SetOneTimeQuestFlag(talker,27,1);
						myself::SoundEffect(talker,"ItemSound.quest_finish");
						myself::ShowPage(talker,"blueprint_seller_shaling_q0027_0301.htm");
					}
					else
					{
						myself::ShowPage(talker,"blueprint_seller_shaling_q0027_0302.htm");
					}
				}
			}
		}
		super;
	}

}
