//================= Hercules Script =======================================
//=       _   _                     _
//=      | | | |                   | |
//=      | |_| | ___ _ __ ___ _   _| | ___  ___
//=      |  _  |/ _ \ '__/ __| | | | |/ _ \/ __|
//=      | | | |  __/ | | (__| |_| | |  __/\__ \
//=      \_| |_/\___|_|  \___|\__,_|_|\___||___/
//================= License ===============================================
//= This file is part of Hercules.
//= http://herc.ws - http://github.com/HerculesWS/Hercules
//=
//= Copyright (C) 2012-2015  Hercules Dev Team
//= Copyright (C)  rAthena Dev Team
//= Copyright (C)  Euphy
//= Copyright (C)  eAthena Dev Team
//= Copyright (C)  Masao
//= Copyright (C)  L0ne_W0lf
//= Copyright (C)  SinSloth
//= Copyright (C)  Lupus
//= Copyright (C)  MasterOfMuppets
//=
//= Hercules is free software: you can redistribute it and/or modify
//= it under the terms of the GNU General Public License as published by
//= the Free Software Foundation, either version 3 of the License, or
//= (at your option) any later version.
//=
//= This program is distributed in the hope that it will be useful,
//= but WITHOUT ANY WARRANTY; without even the implied warranty of
//= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//= GNU General Public License for more details.
//=
//= You should have received a copy of the GNU General Public License
//= along with this program.  If not, see <http://www.gnu.org/licenses/>.
//=========================================================================
//= Alchemist Shop
//================= Description ===========================================
//= Merchants for Alchemist Materials and Manuals.
//================= Current Version =======================================
//= 1.9
//=========================================================================

alde_alche,24,188,3	script	Guild Dealer	2_M_ALCHE,{
	if (checkweight(Knife,1) == 0) {
		mes "- Wait a minute! -";
		mes "- Currently you are carrying -";
		mes "- too many items with you. -";
		mes "- Please come back again -";
		mes "- after you store some items into kafra storage. -";
		close;
	}
	mes "[Gever Al Sharp]";
	mes "Welcome to the";
	mes "Alchemist Union.";
	mes "How can I assist you today?";
	next;
	switch (select("Purchase materials.", "Purchase a production manual.", "Quit.")) {
	case 1:
		mes "[Gever Al Sharp]";
		mes "What would you like?";
		next;
		if (select("Medicine Bowl - " + (RENEWAL ? "250z" : "8 Zeny"), "Cancel.") == 1) {
			mes "[Gever Al Sharp]";
			mes "How many do you want?";
			mes "Enter '0' if you want to quit.";
			next;
			while(1) {
				input .@input, 0, 2001;
				if (.@input == 0) {
					mes "[Gever Al Sharp]";
					mes "The deal was cancelled.";
					mes "Come again next time.";
					close;
				}
				else if (.@input < 1 || .@input > 2000) {
					mes "[Gever Al Sharp]";
					mes "The number must";
					mes "be less than 2000.";
					next;
				}
				else {
					break;
				}
			}
			if (RENEWAL) {
				.@sell = .@input * 250;
			} else {
				.@sell = .@input * 8;
			}
			.@item_weight = .@input * 10;
			if (Zeny < .@sell) {
				mes "[Gever Al Sharp]";
				mes "You don't";
				mes "have enough zeny.";
				mes "Check how much zeny";
				mes "you have first.";
				close;
			}
			if ((MaxWeight - Weight) < .@item_weight) {
				mes "[Gever Al Sharp]";
				mes "It doesn't seem like";
				mes "you can carry everything.";
				mes "Please check the space";
				mes "in your inventory.";
				close;
			}
			Zeny -= .@sell;
			getitem Medicine_Bowl,.@input;
			mes "[Gever Al Sharp]";
			mes "Thank you.";
			mes "Come again.";
			close;
		}
		mes "[Gever Al Sharp]";
		mes "Well then,";
		mes "come again when";
		mes "you need to purchase";
		mes "materials related to";
		mes "Alchemy, alright?";
		close;
	case 2:
		mes "[Gever Al Sharp]";
		mes "What do you need?";
		mes "Manuals are generally 100,000 zeny. But there are a couple of special manuals that will cost more.";
		next;
		switch (select("Potion Creation Guide", "Alcohol Creation Guide", "Bottle Grenade Creation Guide", "Acid Bottle Creation Guide", "Plant Bottle Creation Guide", "Marine Sphere Bottle Creation Guide", "Glistening Coat Creation Guide", "Condensed Potion Creation Guide", "Cancel Deal.")) {
		case 1:
			callsub S_SellManual, Normal_Potion_Book, 100000;
			break;
		case 2:
			callsub S_SellManual, Alcol_Create_Book, 100000;
			break;
		case 3:
			callsub S_SellManual, FireBottle_Create_Book, 100000;
			break;
		case 4:
			callsub S_SellManual, Acid_Create_Book, 100000;
			break;
		case 5:
			callsub S_SellManual, Plant_Create_Book, 100000;
			break;
		case 6:
			callsub S_SellManual, Mine_Create_Book, 100000;
			break;
		case 7:
			callsub S_SellManual, Coating_Create_Book, 100000;
			break;
		case 8:
			callsub S_SellManual, Slim_Potion_Create_Book, 240000;
			break;
		case 9:
			mes "[Gever Al Sharp]";
			mes "Well then...";
			mes "Come back if you";
			mes "ever need to buy";
			mes "a production manual.";
			close;
		}
	case 3:
		mes "[Gever Al Sharp]";
		mes "Alright then,";
		mes "have a good day.";
		close;
	}

S_SellManual:
	if (Zeny < getarg(1)) {
		mes "[Gever Al Sharp]";
		mes "You don't";
		mes "have enough zeny.";
		mes "Check how much zeny";
		mes "you have first.";
		close;
	}
	mes "[Gever Al Sharp]";
	mes ""+ getitemname(getarg(0)) +"?";
	mes "That'll be "+ getarg(1) +" zeny.";
	next;
	if (select("Purchase.", "Quit.") == 1) {
		Zeny -= getarg(1);
		getitem getarg(0),1;
		mes "[Gever Al Sharp]";
		mes "Thank you for";
		mes "your patronage.";
		close;
	}
	mes "[Gever Al Sharp]";
	mes "Come again";
	mes "next time.";
	close;
}
