//================= 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 Team
//= Copyright (C)  eAthena Team
//= Copyright (C)  L0ne_W0lf
//= Copyright (C)  KarLaeda
//= Copyright (C)  Lupus
//=
//= 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/>.
//=========================================================================
//= Novice Goods Exchanger
//================= Description ===========================================
//= Exchanges your Basic Monster drops for Red Potions.
//================= Current Version =======================================
//= 1.4
//=========================================================================

prontera,123,102,5	script	Merchant#pron	4_M_03,{
	if (MaxWeight - Weight < 6301 || checkweight(Knife,1) == 0) {
		mes "[Merchant]";
		mes "Haha!";
		mes "What are you, superhuman?";
		mes "You're carrying so much stuff!";
		mes "You better put some of that";
		mes "into Kafra Storage~";
		close;
	}
	mes "[Merchant]";
	mes "Good day!";
	mes "Have you collected any";
	mes "items like Shells or Fluff?";
	mes "What about Jellopies? Oh yeah,";
	mes "I need those for something.";
	next;
	mes "[Merchant]";
	mes "Of course, I won't ask you";
	mes "to give me that stuff for free. What about if I trade a Red Potion for 5 Shells, 10 Fluff,";
	mes "or 10 Jellopies?";
	next;
	switch(select("Sure!", "I think it's a rip-off!", "No, thanks.")) {
	case 1:
		mes "[Merchant]";
		mes "So which item do";
		mes "you want to bring me?";
		mes "Shells, Fluffs, or Jellopies?";
		next;
		switch(select("Shells", "Jellopies", "Fluff", "Cancel")) {
		case 1: callfunc "F_PotExchange",935,5;
		case 2: callfunc "F_PotExchange",909,10;
		case 3: callfunc "F_PotExchange",914,10;
		case 4:
			mes "[Merchant]";
			mes "Sure~";
			mes "No problem.";
			close;
		}
	case 2:
		mes "[Merchant]";
		mes "A rip-off...?";
		mes "If you check the market value";
		mes "of the items being traded, I'm actually the one getting";
		mes "ripped off here.";
		close;
	case 3:
		mes "[Merchant]";
		mes "Alright,";
		mes "no problem.";
		mes "But come back to me";
		mes "if you change your mind.";
		close;
	}
}

morocc,180,259,3	script	Merchant#morroc	4_M_03,{
	if (MaxWeight - Weight < 6301 || checkweight(Knife,1) == 0) {
		mes "[Merchant]";
		mes "Haha!";
		mes "What are you, superhuman?";
		mes "You're carrying so much stuff!";
		mes "You better put some of that";
		mes "into Kafra Storage~";
		close;
	}
	mes "[Merchant]";
	mes "Good day!";
	mes "Have you collected any";
	mes "Shells or Feathers of Bird?";
	mes "What about Jellopies? Oh yeah,";
	mes "I need those for something.";
	next;
	mes "[Merchant]";
	mes "Of course, I won't ask you";
	mes "to give me that stuff for free. What about if I trade a Red Potion for 5 Shells, 7 Feathers of Bird";
	mes "or 10 Jellopies?";
	next;
	switch(select("Sure!", "I think it's a rip-off!", "No, thanks.")) {
	case 1:
		mes "[Merchant]";
		mes "So which item do";
		mes "you want to bring me?";
		mes "Shells, Feathers of Birds,";
		mes "or Jellopies?";
		next;
		switch(select("Shells", "Feathers of Birds", "Jellopies", "Cancel")) {
		case 1: callfunc "F_PotExchange",935,5;
		case 2: callfunc "F_PotExchange",916,7;
		case 3: callfunc "F_PotExchange",909,10;
		case 4:
			mes "[Merchant]";
			mes "Sure~";
			mes "No problem.";
			close;
		}
	case 2:
		mes "[Merchant]";
		mes "A rip-off...?";
		mes "If you check the market value";
		mes "of the items being traded, I'm actually the one getting";
		mes "ripped off here.";
		close;
	case 3:
		mes "[Merchant]";
		mes "Alright,";
		mes "no problem.";
		mes "But come back to me";
		mes "if you change your mind.";
		close;
	}
}

payon,200,134,5	script	Merchant#pay	4_M_03,{
	if (MaxWeight - Weight < 6301 || checkweight(Knife,1) == 0) {
		mes "[Merchant]";
		mes "Haha!";
		mes "What are you, superhuman?";
		mes "You're carrying so much stuff!";
		mes "You better put some of that";
		mes "into Kafra Storage~";
		close;
	}
	mes "[Merchant]";
	mes "Good day!";
	mes "Have you collected";
	mes "items like Tree Roots?";
	mes "What about Jellopies? Oh yeah,";
	mes "I need those for something.";
	next;
	mes "[Merchant]";
	mes "Of course, I won't ask you";
	mes "to give me that stuff for free. What about if I trade a Red Potion for 6 Tree Roots or 10 Jellopies?";
	next;
	switch(select("Sure!", "I think it's a rip-off!", "No, thanks.")) {
	case 1:
		mes "[Merchant]";
		mes "So which item do";
		mes "you want to bring me?";
		mes "Tree Roots, or Jellopies?";
		next;
		switch(select("Tree Roots", "Jellopies", "Cancel")) {
		case 1: callfunc "F_PotExchange",902,6;
		case 2: callfunc "F_PotExchange",909,10;
		case 3:
			mes "[Merchant]";
			mes "Sure~";
			mes "No problem.";
			close;
		}
	case 2:
		mes "[Merchant]";
		mes "A rip-off...?";
		mes "If you check the market value";
		mes "of the items being traded, I'm actually the one getting";
		mes "ripped off here.";
		close;
	case 3:
		mes "[Merchant]";
		mes "Alright,";
		mes "no problem.";
		mes "But come back to me";
		mes "if you change your mind.";
		close;
	}
}

aldebaran,152,63,5	script	Merchant#alde	4_M_03,{
	if (MaxWeight - Weight < 6301 || checkweight(Knife,1) == 0) {
		mes "[Merchant]";
		mes "Haha!";
		mes "What are you, superhuman?";
		mes "You're carrying so much stuff!";
		mes "You better put some of that";
		mes "into Kafra Storage~";
		close;
	}
	mes "[Merchant]";
	mes "Good day!";
	mes "Have you collected any";
	mes "Worm Peelings or Feather of Birds?";
	mes "How about Jellopies? Oh yeah,";
	mes "I need those for something.";
	next;
	mes "[Merchant]";
	mes "Of course, I won't ask you";
	mes "to give me that stuff for free. What about if I trade a Red Potion for 1 Worm Peeling, 7 Feather of Birds, or 10 Jellopies?";
	next;
	switch(select("Sure!", "I think it's a rip-off!", "No, thanks.")) {
	case 1:
		mes "[Merchant]";
		mes "So which item do";
		mes "you want to bring me?";
		mes "Feathers of Birds?";
		mes "Worm Peelings?";
		mes "Or Jellopies?";
		next;
		switch(select("Worm Peelings", "Feathers of Birds", "Jellopies", "Cancel")) {
		case 1: callfunc "F_PotExchange",955,1;
		case 2: callfunc "F_PotExchange",916,7;
		case 3: callfunc "F_PotExchange",909,10;
		case 4:
			mes "[Merchant]";
			mes "Sure~";
			mes "No problem.";
			close;
		}
	case 2:
		mes "[Merchant]";
		mes "A rip-off...?";
		mes "If you check the market value";
		mes "of the items being traded, I'm actually the one getting";
		mes "ripped off here.";
		close;
	case 3:
		mes "[Merchant]";
		mes "Alright,";
		mes "no problem.";
		mes "But come back to me";
		mes "if you change your mind.";
		close;
	}
}

geffen,173,88,5	script	Merchant#geff	4_M_03,{
	if (MaxWeight - Weight < 6301 || checkweight(Knife,1) == 0) {
		mes "[Merchant]";
		mes "Haha!";
		mes "What are you, superhuman?";
		mes "You're carrying so much stuff!";
		mes "You better put some of that";
		mes "into Kafra Storage~";
		close;
	}
	mes "[Merchant]";
	mes "Good day!";
	mes "Have you collected any";
	mes "items like Shells or Chrysalises?";
	mes "What about Jellopies? Oh yeah,";
	mes "I need those for something.";
	next;
	mes "[Merchant]";
	mes "Of course, I won't ask you";
	mes "to give me that stuff for free. What about if I trade a Red Potion for 5 Shells or 6 Chrysalises, or 10 Jellopies?";
	next;
	switch(select("Sure!", "I think it's a rip-off!", "No, thanks.")) {
	case 1:
		mes "[Merchant]";
		mes "So which item do";
		mes "you want to bring me?";
		mes "Shells, Chrysalises, or Jellopies?";
		next;
		switch(select("Shells", "Chrysalises", "Jellopies", "Cancel")) {
		case 1: callfunc "F_PotExchange",935,5;
		case 2: callfunc "F_PotExchange",915,6;
		case 3: callfunc "F_PotExchange",909,10;
		case 4:
			mes "[Merchant]";
			mes "Sure~";
			mes "No problem.";
			close;
		}
	case 2:
		mes "[Merchant]";
		mes "A rip-off...?";
		mes "If you check the market value";
		mes "of the items being traded, I'm actually the one getting";
		mes "ripped off here.";
		close;
	case 3:
		mes "[Merchant]";
		mes "Alright,";
		mes "no problem.";
		mes "But come back to me";
		mes "if you change your mind.";
		close;
	}
}

function	script	F_PotExchange	{
	if (countitem(getarg(0)) < getarg(1)) {
		mes "[Merchant]";
		mes "Hey, where are";
		mes "all those "+getitemname(getarg(0))+"";
		mes "that you promised?";
		mes "Give me "+getitemname(getarg(0))+"!";
		close;
	}
	else {
		mes "[Merchant]";
		mes "Okay, let me check";
		mes "how many "+getitemname(getarg(0))+" you";
		mes "have on you. Hmm...";
		next;
		mes "[Merchant]";
		mes "You have";
		mes "a total of " + countitem(getarg(0)) + " "+getitemname(getarg(0))+".";
		mes "I can give you a total";
		mes "of " + (countitem(getarg(0))/getarg(1)) + " Red Potions for those.";
		next;
		mes "[Merchant]";
		mes "What do you say?";
		mes "Do we have a deal?";
		next;
		if (select("Deal.", "No deal.") == 1) {
			mes "[Merchant]";
			mes "You know the exact";
			mes "number of Red Potions";
			mes "you want to receive for";
			mes "those "+getitemname(getarg(0))+", don't you?";
			next;
			mes "[Merchant]";
			mes "Now, I can trade you";
			mes "a minimum of 1 Red Potion";
			mes "and a maximum of 100 Red Potions";
			mes "at one time. If you change your";
			mes "mind, just enter '0' to cancel.";
			next;
			while(1) {
				input .@input,0,101;
				if (.@input == 0) {
					mes "[Merchant]";
					mes "What...?";
					mes "Why the hell do you";
					mes "even bother to talk to me?";
					mes "Pretty indecisive, aren't you?";
					close;
				}
				else if (.@input > 100) {
					mes "[Merchant]";
					mes "I can't give you more";
					mes "than 100 Red Potions";
					mes "at once. Let's try";
					mes "this again.";
					next;
				}
				else {
					break;
				}
			}
			.@put_out_item = .@input * getarg(1);
			if (countitem(getarg(0)) < .@put_out_item) {
				mes "[Merchant]";
				mes "Uh oh, the number you entered doesn't seem right. You better check the number of Red Potions that you can trade for again.";
				close;
			}
			mes "[Merchant]";
			mes "There you go!";
			mes "Check how many Red Potions";
			mes "I've given you, it should be good. Thanks, that was a good deal~";
			delitem getarg(0),.@put_out_item; //Shell
			getitem Red_Potion,.@input;
			close;
		}
		mes "[Merchant]";
		mes "Huh~";
		mes "Alright.";
		mes "Though aren't";
		mes "Red Potions more useful";
		mes "to an adventurer like you?";
		close;
	}
}
