//===== rAthena Script =======================================
//= BattleGround System - KvM Item Dealer
//===== Description: =========================================
//= [Official Conversion]
//= Kreiger Von Midgard Battleground Point redemption NPC
//= * NOTE * 
//= 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.
//===== Changelogs: ==========================================
//= 1.0 First Version. [L0ne_W0lf]
//============================================================

bat_room,151,144,3	script	KVM Logistic Officer#a	734,{
	if (countitem(6376)) {// KVM_Badge
		set .@pointstoadd,countitem(6376);
		delitem 6376,.@pointstoadd;
		set kvm_point,kvm_point+.@pointstoadd;
		mes "[Logistics]";
		mes "Are those "+getitemname(6376)+"s I see?";
		mes "We no longer accept that currency,";
		mes "but I can exchange those for you,";
		mes "So you have "+.@pointstoadd+" "+getitemname(6376)+"s?";
		mes "Alright, all set, you now have ^580080"+ kvm_point +"^000000 KVM Points.";
		next;
	}
	if (checkweight(1201,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";
	mes "reward items for KVM points. Any";
	mes "wrong selection of items will not";
	mes "be reversed. Please be carefull.";
	mes "Select the next step please.";
	next;
	set .@name$,strcharinfo(0);
	switch(select("Read the KVM Catalogue.:Purchase KVM Items.:Confirm KVM Points.:Explanation of KVM Rewards.:Explanation of KVM Points.")) {
	case 1:
		mes "[Logistics]";
		mes "Here is the catalogue of KVM items.";
		mes "Each weapon requires 2,000 points";
		mes "and each armor from 10 to 1,200";
		mes "points. So, be carefull when";
		mes "selecting a reward.";
		close2;
		readbook 11017,1;
		end;
	case 2:
		mes "[Logistics]";
		mes "Wich items do you want to see? As";
		mes "for the detailed specification of";
		mes "the items, please refer to the";
		mes "^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:
				mes "[Logistics]";
				mes "You have selected the Dagger/Sword/Spear category.";
				mes "Please select a sub-category.";
				next;
				switch(select("Dagger:One-handed Sword:Two-handed Sword:One-handed Spear:Two-handed Spear")) {
				case 1: callsub PurchaseItem,13042,0,1; //Krieger_Dagger1 
				case 2:
					mes "[Logistics]";
					mes "You have selected the 'One-handed Sword' category.";
					mes "There are 3 One-handed Swords: Glorious Flamberge, Glorious Rapier and Glorious Holy Avenger.";
					mes "If you want their details, please refer to the KVM Catalogue.";
					mes "Please select one of them.";
					next;
					switch(select("Glorious Flamberge:Glorious Rapier:Glorious Holy Avenger")) {
					case 1: callsub PurchaseItem,13416,0,0; //Krieger_Onehand_Sword1
					case 2: callsub PurchaseItem,13417,0,0; //Krieger_Onehand_Sword2
					case 3: callsub PurchaseItem,13418,0,0; //Krieger_Onehand_Sword3
					}
				case 3: callsub PurchaseItem,1187,0,1; //Krieger_Twohand_Sword1
				case 4: callsub PurchaseItem,1426,0,1; //Krieger_Onehand_Spear1
				case 5: callsub PurchaseItem,1486,0,1; //Krieger_Twohand_Spear1
				}
			case 2:
				mes "[Logistics]";
				mes "You have selected the 'Staff/Mace/Axe/Shuriken' category.";
				mes "Please select a sub-category.";
				next;
				switch(select("Staff:Mace:One-handed Axe:Two-handed Axe:Shuriken")) {
				case 1:
					mes "[Logistics]";
					mes "You have selected the 'Staff' category.";
					mes "There are 3 Staffs: a Two-handed Weapon Glorious Destruction Staff, a One-handed Glorious Arc Wand and a Glorious Healing Staff.";
					mes "If you want their details, please refer to the KVM Catalogue.";
					mes "Please select one of them.";
					next;
					switch(select("Glorious Destruction Staff:Glorious Arc Wand:Glorious Healing Staff")) {
					case 1: callsub PurchaseItem,2002,0,0; //Krieger_Twohand_Staff1
					case 2: callsub PurchaseItem,1640,0,0; //Krieger_Onehand_Staff1
					case 3: callsub PurchaseItem,1641,0,0; //Krieger_Onehand_Staff2
					}
				case 2: callsub PurchaseItem,1546,0,1; //Krieger_Onehand_Mace1
				case 3: callsub PurchaseItem,1310,0,1; //Krieger_Onehand_Axe1
				case 4: callsub PurchaseItem,1382,0,1; //Krieger_Twohand_Axe1
				case 5: callsub PurchaseItem,13307,0,1; //Krieger_Huuma_Shuriken1
				}
			case 3:
				mes "[Logistics]";
				mes "You have selected the Bow/Katar/Instrument/Whip category.";
				mes "Please select a sub-category.";
				next;
				switch(select("Bow:Katar:Instrument:Whip")) {
				case 1: callsub PurchaseItem,1743,0,1; //Krieger_Bow1
				case 2:
					mes "[Logistics]";
					mes "You have selected the 'Katar' category.";
					mes "There are 2 Katars: Glorious Bloody Roar and Glorious Jamadhar.";
					mes "If you want their details, please refer to the KVM Catalogue.";
					mes "Please select one of them.";
					next;
					switch(select("Glorious Bloody Roar:Glorious Jamadhar")) {
					case 1: callsub PurchaseItem,1281,0,0; //Krieger_Katar1
					case 2: callsub PurchaseItem,1282,0,0; //Krieger_Katar2
					}
				case 3: callsub PurchaseItem,1927,0,1; //Krieger_Instrument1
				case 4: callsub PurchaseItem,1981,0,1; //Krieger_Whip1
				}
			case 4:
				mes "[Logistics]";
				mes "You have selected the Book/Knuckle category.";
				mes "Please select a sub-category.";
				next;
				switch(select("Book:Knuckle")) {
				case 1:
					mes "[Logistics]";
					mes "You have selected 'Book'.";
					mes "There are 2 Books: Glorious Tablet and Glorious Apocalypse.";
					mes "If you want their details, please refer to the KVM Catalogue.";
					mes "Please select one of them.";
					next;
					switch(select("Glorious Tablet:Glorious Apocalypse")) {
					case 1: callsub PurchaseItem,1576,0,0; //Krieger_Book1
					case 2: callsub PurchaseItem,1577,0,0; //Krieger_Book2
					}
				case 2:
					mes "[Logistics]";
					mes "You have selected the 'Knuckle' category.";
					mes "There are 2 Knuckles: Glorious Claw and Glorious Fist.";
					mes "If you want their details, please refer to the KVM Catalogue.";
					mes "Please select one of them.";
					next;
					switch(select("Glorious Claw:Glorious Fist")) {
					case 1: callsub PurchaseItem,1826,0,0; //Krieger_Knuckle1
					case 2: callsub PurchaseItem,1827,0,0; //Krieger_Knuckle2
					}
				}
			case 5:
				mes "[Logistics]";
				mes "You have selected the 'Revolver/Rifle/Gun/Grenade Launcher' category.";
				mes "Please select a sub-category.";
				next;
				switch(select("Revolver:Rifle:Gatling Gun:Shotgun:Grenade Launcher")) {
				case 1: callsub PurchaseItem,13110,0,1; //Krieger_Pistol1
				case 2: callsub PurchaseItem,13176,0,1; //Krieger_Rifle1
				case 3: callsub PurchaseItem,13177,0,1; //Krieger_Gatling1
				case 4: callsub PurchaseItem,13178,0,1; //Krieger_Shotgun1
				case 5: callsub PurchaseItem,13179,0,1; //Krieger_Launcher1
				}
			}
		case 2:
			mes "[Logistics]";
			mes "You have selected the 'Armor/Accessory' category.";
			mes "Please select a sub-category.";
			next;
			switch(select("Armor:Cloak:Shoes:Accessory")) {
			case 1: callsub PurchaseItem,2394,1,2; //Krieger_Suit1
			case 2: callsub PurchaseItem,2549,2,2; //Krieger_Muffler1
			case 3: callsub PurchaseItem,2444,3,2; //Krieger_Shoes1
			case 4: callsub PurchaseItem,2772,4,2; //Krieger_Ring1
			}
		case 3:
			mes "[Logistics]";
			mes "You have selected the 'Mass-Production Armor/Accessory' category.";
			mes "Please select a sub-category.";
			next;
			switch(select("Mass-Production Armor:Mass-Production Shoes:Mass-Production Accessory")) {
			case 1: callsub PurchaseItem,2395,5,3; //Krieger_Suit2
			case 2: callsub PurchaseItem,2445,6,3; //Krieger_Shoes2
			case 3: callsub PurchaseItem,2773,7,3; //Krieger_Ring2
			}
		case 4:
			mes "[Logistics]";
			mes "You have selected the 'Popularized Armor/Accessory' category.";
			mes "Please select a sub-category.";
			next;
			switch(select("Popularized Armor:Popularized Shoes:Popularized Accessory")) {
			case 1: callsub PurchaseItem,2396,8,4; //Krieger_Suit3
			case 2: callsub PurchaseItem,2446,9,4; //Krieger_Shoes3
			case 3: callsub PurchaseItem,2774,10,4; //Krieger_Ring3
			}
		}
	case 3:
		mes "[Logistics]";
		mes ""+ .@name$ +", your current points are ^580080"+ kvm_point +"^000000 KVM Points.";
		close;
	case 4:
		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 5:
		mes "[Logistics]";
		mes "KVM Points are rewarded when you win, lose or draw in Kreiger Von Midgard (KVM).";
		mes "You can have special Rewards by using these points.";
		close;
	}

PurchaseItem:
	// Pricing for Weapon, Suit1, Muffler1, Shoes1, Ring1m Suit2, Shoes2, Ring2, Suit3, Shoes3, Ring3
	setarray .@prices[0],2000,840,630,580,1200,120,70,200,15,10,30;

	.@item_id = getarg(0);
	.@req_setting = getarg(1);
	.@item_type = getarg(2);

	mes "[Logistics]";

	if (!.@item_type)
		mes "You have selected ^ff0000"+ getitemname(.@item_id) +"^000000.";
	else if (.@item_type == 1)
		mes "There is only one "+ callfunc("F_GetWeaponType",.@item_id) +": "+ getitemname(.@item_id) +".";
	else if (.@item_type == 2) {
		mes "You have selected '"+ callfunc("F_GetArmorType",.@item_id) +"'.";
		mes "The armor for one whose Lvl is more than 80 is: ^ff0000"+ getitemname(.@item_id) +"^000000.";
	}
	else if (.@item_type == 3) {
		mes "You have selected 'Mass-Production "+ callfunc("F_GetArmorType",.@item_id) +"'.";
		mes "There is only one Mass-Production "+ callfunc("F_GetArmorType",.@item_id) +": ^ff0000"+ getitemname(.@item_id) +"^000000.";
	}
	else if (.@item_type == 4) {
		mes "You have selected 'Popularized "+ callfunc("F_GetArmorType",.@item_id) +"'.";
		mes "There is only one Popularized "+ callfunc("F_GetArmorType",.@item_id) +": ^ff0000"+ getitemname(.@item_id) +"^000000.";
	}

	if (!.@req_setting)
		mes "It requires ^0000ff2,000^000000 KVM Points, and "+ .@name$ +", your points are: ^580080"+ kvm_point +"^000000.";
	else if (.@req_setting == 4)
		mes "It requires ^0000ff1,200^000000 KVM Points, and "+ .@name$ +", your points are: ^580080"+ kvm_point +"^000000.";
	else
		mes "It requires ^0000ff"+ .@prices[.@req_setting] +"^000000 KVM Points, and "+ .@name$ +", your points are: ^580080"+ kvm_point +"^000000.";

	mes "Are you sure you want this item?";
	next;
	switch(select("No, I won't purchase it.:Yes, I will purchase it.")) {
	case 1:
		mes "[Logistics]";
		mes "You have selected 'I won't purchase it'.";
		mes "When purchasing an item, please be careful there are no refunds.";
		break;
	case 2:
		if (kvm_point >= .@prices[.@req_setting]) {
			kvm_point = kvm_point -.@prices[.@req_setting];
			getitem .@item_id,1;
			mes "[Logistics]";
			mes "You have purchased a "+ getitemname(.@item_id) +".";
			if (!.@req_setting)
				mes "Your KVM Points are reduced by ^0000ff"+ .@req_setting +"^000000 points, your KVM Points are now ^580080"+kvm_point+"^000000.";
			if (.@req_setting == 4)
				mes "Your KVM Points are reduced by ^0000ff1,200^000000 points, your KVM Points are now ^580080"+kvm_point+"^000000.";
			else
				mes "Your KVM Points are reduced by ^0000ff"+ .@prices[.@req_setting] +"^000000 points, your KVM Points are now ^580080"+kvm_point+"^000000.";
		}
		else {
			mes "[Logistics]";
			if (!.@req_setting)
				mes "You need ^0000ff2,000^000000 KVM Points to purchase this item.";
			else if (.@req_setting == 4)
				mes "You need ^0000ff1,200^000000 KVM Points to purchase this item.";
			else
				mes "You need ^0000ff"+ .@prices[.@req_setting] +"^000000 KVM Points to purchase this item.";
			mes "However, your KVM Points are now ^580080"+ kvm_point +"^000000.";
			mes "Which are not enough to buy it.";
			mes "When you get enough points, please come back again.";
		}
	}
	close;
}
