//================= 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)  Playtester
//= Copyright (C)  Nexon
//= Copyright (C)  L0ne_W0lf
//= Copyright (C)  Muad_Dib (Prometheus Project)
//=
//= 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/>.
//=========================================================================
//= Arrow Quiver Event
//================= Description ===========================================
//= Turns arrows into Arrow Quivers.
//================= Current Version =======================================
//= 1.2
//=========================================================================

payon_in01,5,134,5	script	Inventor Jaax	4_M_ORIENT02,{
	if (checkweight(Knife,1) == 0 || MaxWeight - Weight < 2000) {
		mes "[Inventor Jaax]";
		mes "Hey, you're carrying";
		mes "way too much stuff. Why don't you stash it away in Kafra Storage? We can talk after you do that, right?";
		close;
	}
	mes "[Inventor Jaax]";
	mes "My name is Jaax.";
	mes "Without ego, I can";
	mes "say that I am perhaps the";
	mes "^663300greatest inventor of our time^000000.";
	next;
	mes "[Inventor Jaax]";
	mes "This time, I've";
	mes "created something";
	mes "truly extraordinary. I call them... ^663300Magic Quivers^000000 !! This will be remembered in history as an";
	mes "arrow revolution!";
	emotion e_no1;
	next;
	mes "[Inventor Jaax]";
	mes "I've studied magic and quivers for years, working night and day until I finally figured how to condense arrows with magic! With magic quivers, you'll be carrying more arrows, but with less weight!";
	next;
	mes "[Inventor Jaax]";
	mes "Would you like to try using one of my arrow quivers? I have no doubt that someone like you can appreciate my genius!";
	next;
	switch(select("Quiver", "Iron Arrow Quiver", "Steel Arrow Quiver", "Oridecon Arrow Quiver", "Fire Arrow Quiver", "Silver Arrow Quiver", "Wind Arrow Quiver", "Stone Arrow Quiver", "Crystal Arrow Quiver", "Shadow Arrow Quiver", "Immaterial Arrow Quiver", "Rusty Arrow Quiver")) {
	case 1: callsub S_BuyQuiver,1750,500,500,12004;
	case 2: callsub S_BuyQuiver,1770,500,500,12005;
	case 3: callsub S_BuyQuiver,1753,500,500,12006;
	case 4: callsub S_BuyQuiver,1765,500,500,12007;
	case 5: callsub S_BuyQuiver,1752,500,500,12008;
	case 6: callsub S_BuyQuiver,1751,500,500,12009;
	case 7: callsub S_BuyQuiver,1755,500,500,12010;
	case 8: callsub S_BuyQuiver,1756,500,500,12011;
	case 9: callsub S_BuyQuiver,1754,500,500,12012;
	case 10: callsub S_BuyQuiver,1767,500,500,12013;
	case 11: callsub S_BuyQuiver,1757,500,500,12014;
	case 12: callsub S_BuyQuiver,1762,500,500,12015;
	}
	//This doesn't seem to be accessable...
	//mes "[Inventor Jaax]";
	//mes "Is there";
	//mes "anything you want?";
	//close;

// Arguments:
// -0: Type of Arrow to be packaged (item ID).
// -1: How many of each 'getarg(0)' arrow per quiver.
// -2: The cost of making a 'getarg(0)' quiver.
// -3: The quiver given by the NPC (item ID).
S_BuyQuiver:
	if (countitem(getarg(0)) >= getarg(1)) {
		mes "[Inventor Jaax]";
		mes "Excellent!";
		mes "Are you carrying any Arrows with you? I'll provide you with a quiver that can carry "+getarg(1)+" of your "+getitemname(getarg(0))+"s for only ^FF3131"+getarg(2)+" Zeny^000000.";
		next;
		switch(select("Store as many Arrows in quivers as possible", "Purchase 1 quiver", "Cancel")) {
		case 1:
			.@arrows = countitem(getarg(0));
			.@quiver = .@arrows / getarg(1);
			.@arrows_used = .@quiver * getarg(1);
			.@arrow_zeny01 = .@quiver * getarg(2);
			mes "Number of";
			mes "Arrows: ^3131FF"+.@arrows+" ^000000";
			mes "Maximum Number";
			mes "of Purchasable";
			mes "Quivers: ^3131FF"+.@quiver+" ^000000";
			mes "Zeny required: ^3131FF"+.@arrow_zeny01+" Zeny^000000";
			next;
			mes "[Inventor Jaax]";
			mes "Would you like to";
			mes "buy as many Quivers";
			mes "as you can for the Arrows";
			mes "you are currently carrying?";
			next;
			if (select("Yes", "Cancel") == 1) {
				if (.@arrow_zeny01 < Zeny) {
					mes "[Inventor Jaax]";
					mes "There you go!";
					mes "Just remember, ^FF0000you won't be able to use the Quiver when your carried weight is 90% of your maximum weight limit^000000.";
					Zeny -= .@arrow_zeny01;
					delitem getarg(0),.@arrows_used; //Arrow
					getitem getarg(3),.@quiver; //Quiver
					next;
					mes "[Inventor Jaax]";
					mes "So...";
					mes "Just keep track";
					mes "of how much you're";
					mes "carrying from time";
					mes "to time and you should";
					mes "be alright.";
					close;
				}
				else {
					mes "[Inventor Jaax]";
					mes "I'm sorry, but you don't have enough Zeny. I can't just give these away after working years";
					mes "to develop this revolutionary technology!";
					close;
				}
			}
			mes "[Inventor Jaax]";
			mes "You changed your mind?";
			mes "When the glory of owning";
			mes "a quiver is so close?";
			close;
		case 2:
			if (Zeny > getarg(2)) {
				mes "[Inventor Jaax]";
				mes "There you go!";
				mes "Just remember, ^FF0000you won't be able to use the Quiver when your carried weight is 90% of your maximum weight limit^000000.";
				Zeny -= getarg(2);
				delitem getarg(0),getarg(1); //Arrow
				getitem getarg(3),1; //Quiver
				next;
				mes "[Inventor Jaax]";
				mes "So...";
				mes "Just keep track";
				mes "of how much you're";
				mes "carrying from time";
				mes "to time and you should";
				mes "be alright.";
				close;
			}
			else {
				mes "[Inventor Jaax]";
				mes "You don't even";
				mes "have "+getarg(2)+" Zeny?";
				mes "I'm so sorry. I had no";
				mes "idea that you were so...";
				mes "^333333Destitute^000000.";
				close;
			}
		case 3:
			mes "[Inventor Jaax]";
			mes "What...?";
			mes "Do you not see that this invention can forever change the way Arrows are carried?! The future is now!";
			close;
		}
	}
	else {
		mes "[Inventor Jaax]";
		mes "You can carry a maximum of "+getarg(1)+" Arrows within this quiver. It was made using my secret method,";
		mes "so the total weight of the Arrows and Quiver is less than carrying the Arrows alone.";
		next;
		mes "[Inventor Jaax]";
		mes "It's a miracle of science! One that you can experience for yourself if you bring me at least "+getarg(1)+" Arrows and "+getarg(2)+" Zeny for each Quiver.";
		close;
	}
}
