//================= 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)  Xantara
//= Copyright (C)  Maud_Dib
//=
//= 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/>.
//=========================================================================
//= Headgear Dyer (Cash)
//================= Description ===========================================
//= Change headgear's color. Cost is a Mysterious Dyestuff
//================= Current Version =======================================
//= 1.0
//=========================================================================

prt_in,253,168,4	script	Alora	4_F_LGTGIRL,{
	// Mysterious Dyestuff
	.@dyeID = 6220;
	// Headgear Choices
	setarray .@hgn$[1], "Mage Hat","Beanie","Drooping Cat","Deviruchi Hat","Wig","Ribbon","Magestic Goat";
	// Mage Hats - Normal, Yellow, Blue, Brown, Gray, Red
	setarray .@hg_1[1], 5027, 5242, 5241, 5240, 5239, 5238;
	// Beanies - Normal, Pink, Blue, Brown
	setarray .@hg_2[1], 5076, 5237, 5236, 5235;
	// Drooping Cats - Normal, Blue, Brown, Gray, Pink, Yellow
	setarray .@hg_3[1], 5058, 5233, 5231, 5230, 5232, 5234;
	// Deviruchi Hats - Normal, Red, Gray, Brown
	setarray .@hg_4[1], 5038, 5227, 5228, 5229;
	// Wigs - Happy, Shiny, Marvelous, Fantastic
	setarray .@hg_5[1], 5273, 5274, 5275, 5276;
	// Ribbons - Normal, Black, Yellow, Green, Pink, Red, Orange, White
	setarray .@hg_6[1], 2208, 5191, 5192, 5193, 5194, 5195, 5196, 5197;
	// Magestic Goats - Normal, Evolved
	setarray .@hg_7[1], 2256, 5217;

	mes "[Alora]";
	mes "Hello, I can change your headgear's color if you bring me a Mysterious Dyestuff.";
	next;
	mes "[Alora]";
	mes "Do you have a headgear that you would like to dye?";
	next;
	for(.@i = 1; .@i < getarraysize(.@hgn$); ++.@i) {
		if(.@i == 1)    .@menu$ = .@hgn$[.@i];
		else            .@menu$ += ":"+ .@hgn$[.@i];
	}
	.@menu$ += ":Cancel";
	.@t = select(.@menu$);
	if(.@t == getarraysize(.@hgn$)) {
		mes "[Alora]";
		mes "Have a good journey adventurer!";
		mes "If you ever are curious to try a new color on your Kafra headgear or the ones you found on your adventures please come to me!";
		close;
	}
	mes "[Alora]";
	mes "Okay, what color do you want to change it to?";
	next;
	for(.@i = 1; .@i < getarraysize(getd(".@hg_"+.@t+"")); ++.@i) {
		if(.@i == 1 && .@t != 5)
			.@menu$ = "Normal";
		else if(.@i == 1 && .@t == 5)
			.@menu$ = getitemname(getd(".@hg_"+.@t+"["+.@i+"]"));
		else {
			sscanf(getitemname(getd(".@hg_"+.@t+"["+.@i+"]")),"%s "+ .@hgn$[.@t],.@colour$);
			.@menu$ += ":"+ .@colour$;
		}
	}
	.@menu$ += ":Cancel";
	.@c = select(.@menu$);
	if(.@c == getarraysize(getd(".@hg_"+.@t+""))) {
		mes "[Alora]";
		mes "Oh, okay no problem!";
		close;
	}
	.@dyHG = getd(".@hg_"+.@t+"["+.@c+"]");
	mes "[Alora]";
	mes "Oh I'm so excited aren't you?";
	mes "And just to be sure, what color is the "+ .@hgn$[.@t] +" you want me to use?";
	next;
	mes "[Alora]";
	mes "Please understand that I'm going to use the ^FF00001st "+ .@hgn$[.@t] +" of that color in your inventory!^000000";
	next;
	mes "[Alora]";
	mes "Any upgrades and cards will be dissolved by the mysterious dye, so be sure you are ok with having a ^0000FF+0 "+ getitemname(.@dyHG) +" without any cards.^000000";
	next;
	mes "["+ strcharinfo(PC_NAME) +"]";
	mes "Ok, thanks for the warning, I think I'll give you my";
	next;
	.@menu$ = "Nevermind";
	for(.@i = 1; .@i < getarraysize(getd(".@hg_"+.@t+"")); ++.@i) {
		if(.@i == 1)    .@menu$ += ":Normal "+ getitemname(getd(".@hg_"+.@t+"["+.@i+"]"));
		else            .@menu$ += ":"+ getitemname(getd(".@hg_"+.@t+"["+.@i+"]"));
	}
	.@mine = select(.@menu$) - 1;
	if(!.@mine) {
		mes "[Alora]";
		mes "It's best to be very sure, have a safe journey.";
		close;
	}
	.@myHG = getd(".@hg_"+.@t+"["+.@mine+"]");
	if(.@dyHG == .@myHG) {
		mes "[Alora]";
		mes "Woah what happened?";
		close;
	}
	if(!countitem(.@dyeID) || !countitem(.@myHG)) {
		mes "[Alora]";
		mes "Oh my, you seem to be missing something.";
		close;
	}
	mes "[Alora]";
	mes "Looks great doesn't it?!";
	mes "I hope you'll come back to dye more pretty headgears!";
	delitem .@dyeID,1; // Dyestuff
	delitem .@myHG,1;  // Your headgear
	getitem .@dyHG,1;  // Dyed headgear
	close;
}
