//================= 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)  Masao
//= Copyright (C)  eAthena Dev Team
//= Copyright (C)  Kisuka
//= Copyright (C)  Lupus
//= Copyright (C)  ultramage
//= Copyright (C)  SinSloth
//=
//= 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/>.
//=========================================================================
//= Magazine Dealers
//================= Description ===========================================
//= Turns bullets into magazines/packs.
//================= Current Version =======================================
//= 1.5
//=========================================================================

alberta,118,157,3	script	Magazine Dealer Kenny::mdk	4_M_01,{
	if (BaseJob == Job_Gunslinger) {
		mes "[Kenny]";
		mes "Welcome to my Magazine Shop.";
		mes "As you may know, large numbers";
		mes "of bullets can be carried more";
		mes "easily when they're in Magazines. Now, can I interest you in";
		mes "anything in particular?";
		next;
		switch(select("Wind Sphere Pack", "Shadow Sphere Pack", "Poison Sphere Pack", "Water Sphere Pack", "Fire Sphere Pack", "Cartridge", "Blood Cartridge", "Silver Cartridge", "Cancel")) {
		case 1: callfunc "Func_Casing",13204,12144; break;
		case 2: callfunc "Func_Casing",13206,12145; break;
		case 3: callfunc "Func_Casing",13205,12146; break;
		case 4: callfunc "Func_Casing",13207,12147; break;
		case 5: callfunc "Func_Casing",13203,12148; break;
		case 6: callfunc "Func_Casing",13200,12149; break;
		case 7: callfunc "Func_Casing",13202,12150; break;
		case 8: callfunc "Func_Casing",13201,12151; break;
		case 9:
			mes "[Kenny]";
			mes "Well, if you ever find";
			mes "that you have too many";
			mes "bullets, come and see me.";
			mes "It's a smart idea to store";
			mes "bullets with my Magazines.";
			close;
		}
	}
	mes "[Kenny]";
	mes "Welcome to my shop.";
	mes "Here, I provide Magazines";
	mes "and Cartridges for Gunslingers.";
	mes "Sorry, but it doesn't look like";
	mes "my services would be of any";
	mes "use to you, adventurer.";
	next;
	mes "[Kenny]";
	mes "Eh, but if you happen to";
	mes "know any Gunslingers, send";
	mes "them my way. You can never";
	mes "have too many bullets.";
	close;
}

function	script	Func_Casing	{
	mes "[Kenny]";
	mes "Now, you can trade";
	mes "500 "+getitemname(getarg(0))+"s";
	mes "and 500 zeny for 1 "+getitemname(getarg(1))+", so make sure";
	mes "you have sufficient bullets";
	mes "and zeny for this exchange.";
	next;
	mes "[Kenny]";
	mes "You can exchange 500 "+getitemname(getarg(0))+"s and 500 zeny";
	mes "with 1 "+getitemname(getarg(1))+".";
	next;
	mes "[Kenny]";
	mes "Remember that I can't give";
	mes "you more than 50 Magazines";
	mes "at a time. Now please enter";
	mes "the number of Magazines you";
	mes "want to receive. If you want to cancel, then just enter ''0.''";
	next;
	input .@amount;
	if (.@amount > 50 || .@amount == 0) {
		mes "[Kenny]";
		mes "Hey, I can't give you";
		mes "that many Magazines.";
		mes "Please try again, and";
		mes "enter a number no";
		mes "greater than 50.";
		close;
	}
	if (countitem(getarg(0)) >= (500*.@amount)) {
		if (Zeny >= (500*.@amount)) {
			if (checkweight(getarg(1),.@amount) == 0) {
				mes "[Kenny]";
				mes "Hey, you've got a lot";
				mes "of junk crammed in your";
				mes "Inventory. Free up some";
				mes "space, and then come back";
				mes "and trade your bullets for";
				mes "some Magazines later, okay?";
				close;
			}else{
				mes "[Kenny]";
				mes "Alright, here are";
				mes "your Magazines. Thanks";
				mes "for visiting my shop, and";
				mes "I hope that you use all";
				mes "of your ammo wisely.";
				Zeny -= 500*.@amount;
				delitem getarg(0),500*.@amount;
				getitem getarg(1),.@amount;
				close;
			}
		} else {
			mes "[Kenny]";
			mes "Sorry, but you don't";
			mes "have enough zeny for";
			mes "this Magazine exchange.";
			mes "Come back to my shop";
			mes "after you've saved up";
			mes "some more money.";
			close;
		}
	} else {
		mes "[Kenny]";
		mes "Sorry, but you don't";
		mes "have enough bullets for";
		mes "this Magazine exchange.";
		mes "Maybe you should double";
		mes "check your Inventory, and";
		mes "then come back to me later.";
		close;
	}
}
