//================= Hercules Script =======================================
//=       _   _                     _
//=      | | | |                   | |
//=      | |_| | ___ _ __ ___ _   _| | ___  ___
//=      |  _  |/ _ \ '__/ __| | | | |/ _ \/ __|
//=      | | | |  __/ | | (__| |_| | |  __/\__ \
//=      \_| |_/\___|_|  \___|\__,_|_|\___||___/
//================= License ===============================================
//= This file is part of Hercules.
//= http://herc.ws - http://github.com/HerculesWS/Hercules
//=
//= Copyright (C) 2012-2016  Hercules Dev Team
//= Copyright (C)  L0ne_W0lf
//=
//= 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/>.
//=========================================================================
// BattleGround System - KvM Item Dealer
//================= Description ===========================================
//= Kreiger Von Midgard Battleground Point redemption NPC
//================= Current Version =======================================
//= 1.0
//================= Additional Comments ===================================
//= KvM Does NOT use items, but a character variable to keep track of
//= points. This NPC when talked to will convert already-given tokens and
//= convert them to points under the player variable kvm_point.
//=========================================================================
//== Badges Exchange =======================================
prontera,137,94,6	script	Erundek	4_M_MANAGER,{
	if (checkweight(Knife,1) == 0) {
		mes("- Wait a minute !! -");
		mes("- Currently you're carrying -");
		mes("- too many items with you. -");
		mes("- Please try again -");
		mes("- after you loose some weight. -");
		close;
	}
	mes("[Erundek]");
	mes("Do you have the battlefield badges?");
	mes("I can exchange Bravery Badges and Valor Badges for reward items.");
	next;
	switch(select("Exchange Badges", "Check the Catalog")) {
	case 1:
		mes("[Erundek]");
		mes("Which type of items would you like to exchange?");
		mes("To check more information about the reward items, please use our ^3131FFCatalog^000000.");
		next;
		switch(select("Weapon", "Armor", "Accessory", "Consumable")) {
		case 1:
			mes("[Erundek]");
			mes("You chose ^3131FFWeapon^000000.");
			mes("The following weapons are available for exchange with the battlefield badges.");
			mes("Please note that items for ^3131FFBravery Badges are indicated as (BB)^000000, and ^3131FFValor Badges as (VB)^000000.");
			next;
			switch(select("Dagger/OneSword/TwoSword/TwoSpear", "Staff/Mace/TwoAxe/Shuriken", "Bow/Katar/Music/Whip", "Book/Knuckle", "Revolver/Rifle/Gatling/Shotgun/Launcher")) {
			case 1:
				mes("[Erundek]");
				mes("The following items are available in the ^3131FFDagger, One-Handed Sword, Two-Handed Sword, and Two-Handed Spear^000000 category.");
				next;
				setarray .@Weapons[0],13036,7828,13037,7829,13411,7828,13410,7829,1183,7828,1184,7829,1425,7828,1482,7829;
				break;
			case 2:
				mes("[Erundek]");
				mes("The following items are available in the ^3131FFStaff / Mace / Two-Handed Axe / Huuma Shuriken^000000 category.");
				next;
				setarray .@Weapons[0],1632,7828,1633,7829,1634,7828,1635,7829,1543,7828,1542,7829,1380,7828,1379,7829,13305,7828,13306,7829;
				break;
			case 3:
				mes("[Erundek]");
				mes("The following weapons are available in the ^3131FFBow / Katar / Musical Instrument / Whip^000000 category.");
				next;
				setarray .@Weapons[0],1739,7828,1738,7829,1279,7828,1280,7829,1924,7828,1923,7829,1978,7828,1977,7829;
				break;
			case 4:
				mes("[Erundek]");
				mes("The following weapons are available in the ^3131FFBook / Knuckle^000000 category.");
				next;
				setarray .@Weapons[0],1574,7828,1575,7829,1824,7828,1823,7829;
				break;
			case 5:
				mes("[Erundek]");
				mes("The following weapons are available in the ^3131FFRevolver / Rifle / Gatling Gun / Shotgun / Grenade Launcher^000000 category.");
				next;
				setarray .@Weapons[0],13108,7828,13171,7829,13172,7828,13173,7829,13174,7829;
				break;
			}
			.@menu$ = "";
			for (.@i = 0; .@i < getarraysize(.@Weapons); .@i += 2)
				.@menu$ += getitemname(.@Weapons[.@i]) + ((.@Weapons[.@i+1]==7828) ? _("(BB)") : _("(VB)")) + ":";
			.@i = (select(.@menu$)-1)*2;
			.@type$ = ((.@Weapons[.@i+1]==7828) ? _("(BB)") : _("(VB)"));
			mes("[Erundek]");
			mesf("You chose ^3131FF%s%s^000000.", getitemname(.@Weapons[.@i]), .@type$);
			mesf("You can exchange for this item with ^FF0000100 %s^000000.", getitemname(.@Weapons[.@i+1]));
			mes("Would you like to exchange?");
			next;
			switch(select("Do not exchange", "Exchange")) {
			case 1:
				break;
			case 2:
				mes("[Erundek]");
				mesf("Would you like to spend ^FF0000100 %s^000000 and receive a ^3131FF%s%s^000000?",
					getitemname(.@Weapons[.@i+1]), getitemname(.@Weapons[.@i]), .@type$);
				next;
				mes("[Erundek]");
				mes("Remember, Battleground Reward Items are ^FF0000Character Bound^000000. Are you sure you want this item?");
				next;
				switch(select("Yes", "No")) {
				case 1:
					mes("[Erundek]");
					if (countitem(.@Weapons[.@i+1]) >= 100) {
						mes("Thank you for exchanging.");
						delitem .@Weapons[.@i+1],100;
						getitem .@Weapons[.@i],1;
					}
					else mes("I'm sorry, but you don't have enough badges to exchange.");
					close;
				case 2:
					break;
				}
				break;
			}
			mes("[Erundek]");
			mes("Do you need more time to check the items?");
			close;
		case 2:
			mes("[Erundek]");
			mes("You chose ^3131FFArmor^000000.");
			mes("The following armors are available for exchange with the battlefield badges.");
			next;
			switch(select("Garments / Shoes", "Armor")) {
			case 1:
				setarray .@items[0],2538,50,2539,50,2540,50,2435,50,2436,50,2437,50;
				break;
			case 2:
				setarray .@items[0],2376,80,2377,80,2378,80,2379,80,2380,80,2381,80,2382,80;
				break;
			}
			break;
		case 3:
			mes("[Erundek]");
			mes("You chose ^3131FFAccessory^000000.");
			mes("You can exchange the Medal of Honors with your Badges according to the job classes, as follows:");
			next;
			setarray .@items[0],2733,500,2720,500,2721,500,2722,500,2723,500,2724,500,2725,500;
			.@menu1$ = sprintf("%s:%s/%s:%s:%s:%s:%s:%s",
					jobname(Job_Gunslinger), jobname(Job_Swordman), jobname(Job_Star_Gladiator), jobname(Job_Thief),
					jobname(Job_Acolyte), jobname(Job_Mage), jobname(Job_Archer), jobname(Job_Merchant));
			break;
		case 4:
			mes("[Erundek]");
			mes("You chose ^3131FFConsumable^000000.");
			mes("The following consumable items are available for exchange with the battlefield badges:");
			next;
			setarray .@items[0],12269,10,12270,10,12271,5,12272,10,12273,10;
			break;
		}
		break;
	case 2:
		mes("[Erundek]");
		mes("We have many items, so please take a look and purchase deliberately.");
		close2;
		readbook 11010,1;
		end;
	}
	.@menu$ = "";
	if (.@menu1$ != "") .@menu$ = .@menu1$;
	else for (.@i = 0; .@i < getarraysize(.@items); .@i += 2)
		.@menu$ += getitemname(.@items[.@i])+":";
	.@i = (select(.@menu$)-1)*2;
	mes("[Erundek]");
	mesf("You chose ^3131FF%s^000000.", getitemname(.@items[.@i]));
	switch(.@items[.@i]) {
		case 2720: mes("This item is for Swordman and Taekwon Master Class only."); break;
		case 2721: mes("This item is for Thief Class only."); break;
		case 2722: mes("This item is for Acolyte Class only."); break;
		case 2723: mes("This item is for Magician Class only."); break;
		case 2724: mes("This item is for Archer Class only."); break;
		case 2725: mes("This item is for Merchant Class only."); break;
		case 2733: mes("This item is for Gunslinger only."); break;
		default: break;
	}
	mesf("You can exchange for this item with ^FF0000%d %s or %d %s^000000.", .@items[.@i+1], getitemname(7828), .@items[.@i+1], getitemname(7829));
	mes("Would you like to exchange?");
	next;
	switch(select("Do not exchange", "Exchange")) {
	case 1:
		mes("[Erundek]");
		mes("Do you need more time to check the items?");
		break;
	case 2:
		mes("[Erundek]");
		mes("Which Badge do you want to exchange?");
		mesf("You need ^3131FF%d Badges^000000 to exchange.", .@items[.@i+1]);
		next;
		if (.@item[0] < 12269 || .@item[0] > 12273 ) {
			mes("[Erundek]");
			mes("Remember, Battleground Reward Items are ^FF0000Character Bound^000000. Are you sure you want this item?");
			next;
		}
		.@j = select("Bravery Badge", "Valor Badge", "Cancel");
		mes("[Erundek]");
		if (.@j == 3) {
			mes("You cancelled the exchange.");
			break;
		}
		.@cost = ((.@j==1)?7828:7829);
		if (countitem(.@cost) >= .@items[.@i+1]) {
			mes("Thank you for exchanging.");
			delitem .@cost, .@items[.@i+1];
			getitem .@items[.@i],1;
		}
		else mesf("You do not have enough %ss.", getitemname(.@cost));
		break;
	}
	close;
}

prontera,135,92,6	script	KVM Logistic Officer#a	4_M_JOB_KNIGHT2,{
	if (countitem(War_Badge)) {
		.@pointstoadd = countitem(War_Badge);
		delitem 7773,.@pointstoadd;
		kvm_point += .@pointstoadd;
		mes("[Logistics]");
		mesf("Are those %ss I see?", getitemname(7773));
		mes("We no longer accept that currency,\r"
			"but I can exchange those for you.");
		mesf("So you have %d %ss?", .@pointstoadd, getitemname(7773));
		mesf("Alright, all set, you now have ^580080%d^000000 KVM Points.", kvm_point);
		next;
	}
	if (checkweight(Knife,1) == 0) {
		mes("- Wait a minute !! -");
		mes("- Currently you're carrying -");
		mes("- too many items with you. -");
		mes("- Please try again -");
		mes("- after you loose some weight. -");
		close;
	}
	mes("[Logistics]");
	mes("Hello?");
	mes("I am in charge of distributing\r"
		"reward items for KVM points. Any\r"
		"wrong selection of items will not\r"
		"be reversed. Please be carefull.");
	mes("Select the next step please.");
	next;
	.@name$ = strcharinfo(PC_NAME);
	switch(select("Purchase KVM Items.", "Confirm KVM Points.", "Explanation of KVM Rewards.", "Explanation of KVM Points.")) {
	case 1:
		mes("[Logistics]");
		mes("Wich items do you want to see? As\r"
			"for the detailed specification of\r"
			"the items, please refer to the\r"
			"^3131FFCatalogue^000000.");
		next;
		switch(select("Weapon", "Armor/Accessory", "Mass-Production Armor/Accessory", "Popularized Armor/Accessory")) {
		case 1:
			mes("[Logistics]");
			mes("You have selected the Weapon Category.");
			mes("Please select a sub-category.");
			next;
			switch(select("Dagger/Sword/Spear", "Staff/Mace/Axe/Shuriken", "Bow/Katar/Instrument/Whip", "Book/Knuckle", "Revolver/Rifle/Gun/Grenade Launcher")) {
			case 1:
				openshop("weapon1"); // Dagger/Sword/Spear
				end;
			case 2:
				openshop("weapon2"); // Staff/Mace/Axe/Shuriken
				end;
			case 3:
				openshop("weapon3"); // Bow/Katar/Instrument/Whip
				end;
			case 4:
				openshop("weapon4"); // Book/Knuckle
				end;
			case 5:
				openshop("weapon5"); // Revolver/Rifle/Gun/Grenade Launcher
				end;
			}
		case 2:
			openshop("armor1"); // Armor/Accessory
			end;
		case 3:
			openshop("armor2"); // Mass-Production Armor/Accessory
			end;
		case 4:
			openshop("armor3"); // Popularized Armor/Accessory
			end;
		}
	case 2:
		mes("[Logistics]");
		mesf("%s, your current points are ^580080%d^000000 KVM Points.", .@name$, kvm_point);
		close;
	case 3:
		mes("[Logistics]");
		mes("There are 3 categories in KVM Rewards: Weapon/Armor.Accessory.");
		next;
		mes("[Logistics]");
		mes("Weapon rewards require 2,000 KVM points for each.");
		mes("There are 3 types of Armor rewards and they require 840/630/580 KVM points fo each.");
		mes("Accessory rewards require 1,200 KVM points for each.");
		next;
		mes("[Logistics]");
		mes("Kreiger Weapons are LV 4 Weapons, they can be upgraded and will have special effects: Slaughter, Destruction and Blessing.");
		next;
		mes("[Logistics]");
		mes("When you can wear all 3 armors, you can have a special set of options.");
		mes("Also, when Kreiger Accessory rewards are worn with medalsm it will bring you special set rewards.");
		next;
		mes("[Logistics]");
		mes("Finally, there are Mass-Production Armor and Accessory rewards.");
		mes("Players whose Lvl is higher than 60 can equip Mass-Production Armors and there is a Lvl limit for Popularized Armor as well.");
		close;
	case 4:
		mes("[Logistics]");
		mes("KVM Points are rewarded when you win, lose or draw in Tierra - Triple Infierno.");
		mes("You can have special Rewards by using these points.");
		close;
	}
	end;
}

-	trader	weapon1	-,{
	OnInit:
	tradertype(NST_CUSTOM);
	sellitem 13042,2000;
	sellitem 13416,2000;
	sellitem 13417,2000;
	sellitem 13418,2000;
	sellitem 1187,2000;
	sellitem 1426,2000;
	sellitem 1486,2000;
	end;

	OnPayFunds:
		if( kvm_point < @price-@points ) end;
		kvm_point -= @price-@points;
		purchaseok();
		end;

	OnCountFunds:
		setcurrency(kvm_point);
		end;
}
-	trader	weapon2	-,{
	OnInit:
	tradertype(NST_CUSTOM);
	sellitem 2002,2000;
	sellitem 1640,2000;
	sellitem 1641,2000;
	sellitem 1546,2000;
	sellitem 1310,2000;
	sellitem 1382,2000;
	sellitem 13307,2000;
	end;

	OnPayFunds:
		if( kvm_point < @price-@points ) end;
		kvm_point -= @price-@points;
		purchaseok();
		end;

	OnCountFunds:
		setcurrency(kvm_point);
		end;
}
-	trader	weapon3	-,{
	OnInit:
	tradertype(NST_CUSTOM);
	sellitem 1743,2000;
	sellitem 1281,2000;
	sellitem 1282,2000;
	sellitem 1927,2000;
	sellitem 1981,2000;
	end;

	OnPayFunds:
		if( kvm_point < @price-@points ) end;
		kvm_point -= @price-@points;
		purchaseok();
		end;

	OnCountFunds:
		setcurrency(kvm_point);
		end;
}
-	trader	weapon4	-,{
	OnInit:
	tradertype(NST_CUSTOM);
	sellitem 1576,2000;
	sellitem 1577,2000;
	sellitem 1826,2000;
	sellitem 1827,2000;
	end;

	OnPayFunds:
		if( kvm_point < @price-@points ) end;
		kvm_point -= @price-@points;
		purchaseok();
		end;

	OnCountFunds:
		setcurrency(kvm_point);
		end;
}
-	trader	weapon5	-,{
	OnInit:
	tradertype(NST_CUSTOM);
	sellitem 13110,2000;
	sellitem 13176,2000;
	sellitem 13177,2000;
	sellitem 13178,2000;
	sellitem 13179,2000;
	end;

	OnPayFunds:
		if( kvm_point < @price-@points ) end;
		kvm_point -= @price-@points;
		purchaseok();
		end;

	OnCountFunds:
		setcurrency(kvm_point);
		end;
}
-	trader	armor1	-,{
	OnInit:
	tradertype(NST_CUSTOM);
	sellitem 2394,840;
	sellitem 2549,630;
	sellitem 2444,580;
	sellitem 2772,1200;
	end;

	OnPayFunds:
		if( kvm_point < @price-@points ) end;
		kvm_point -= @price-@points;
		purchaseok();
		end;

	OnCountFunds:
		setcurrency(kvm_point);
		end;
}
-	trader	armor2	-,{
	OnInit:
	tradertype(NST_CUSTOM);
	sellitem 2395,120;
	sellitem 2445,70;
	sellitem 2773,200;
	end;

	OnPayFunds:
		if( kvm_point < @price-@points ) end;
		kvm_point -= @price-@points;
		purchaseok();
		end;

	OnCountFunds:
		setcurrency(kvm_point);
		end;
}
-	trader	armor3	-,{
	OnInit:
	tradertype(NST_CUSTOM);
	sellitem 2396,15;
	sellitem 2446,10;
	sellitem 2774,30;
	end;

	OnPayFunds:
		if( kvm_point < @price-@points ) end;
		kvm_point -= @price-@points;
		purchaseok();
		end;

	OnCountFunds:
		setcurrency(kvm_point);
		end;
}
