//===== Hercules Script ======================================
//= Stylist
//===== By: ==================================================
//= Euphy
//===== Current Version: =====================================
//= 1.1
//===== Description: =========================================
//= Changes your hair style, hair color, and cloth color.
//===== Additional Comments: =================================
//= 1.1 Switched to 'getbattleflag', credits to Saithis. [Euphy]
//============================================================

office,228,26,4	script	Stylist#vip	4_F_BRZ_WOMAN,{
	cutin "lunain02",2;
	disable_items();
	.n$ = "[ ^ff0000Stylist^000000 ]";
	if ( #VIP == 3 || getgmlevel() >= 1 ) {	
		setarray .@styles[1],83,20,4;
	} else { 
		setarray .@styles[1],28,8,4;
	}
	mes .n$;
	mes "11... 12... Mmm... good. I think I'll be able to finish before tonight's party. Oh! I didn't notice you were here!";
	while(1){
	next;
	switch(select("- Dye Clothing","- Hair Style", "- Make Costume","- Restore Costume","^777777Cancel^000000")) {
	case 1:
		mes .n$;
		mes "Oh... you need my work? Well... okay, sounds good. Let's see if I can dye for "+jobname(Class)+".";
		cutin(sprintf("%s",Class), 3);
		next;
		mes .n$;
		mes "Please choose a pattern.";
		mes "that suits you.";
		next;
		setarray .@DyeName$[0],"Pattern 1","Pattern 2";
		setarray .@DyeItems[0],6046,6046;
		.@menu$ = "";
		for( set .@i,0; .@i<2; set .@i,.@i + 1)
			.@menu$ += "- "+.@DyeName$[(.@i)]+":";
		.@menu$ += "- ^777777Cancel^000000";
		.@s = select(.@menu$)+1;
		if (.@s == 4) callsub L_End;
		mes .n$;
		if (!countitem(Clothing_Dye_Coupon)) {
			mes "For me to dye your clothes, I'll need New Clothing Dye Coupon. You can purchase one from the Item Mall.";
			close2();
			cutin("", 255);
			close;
		}
		delitem Clothing_Dye_Coupon,1;
		setlook 7,.@s;
		mes "Your clothes have been dyed with Patter #"+(.@s-1)+".";
		close2();
		cutin("", 255);
		close;
	case 2:
		setarray .@Look[1],1,6;
		set .@s, select(" ~ Hairstyle: ~ Hair color");
		set .@Revert, getlook(.@Look[.@s]);
		set .@style,1;
		while(1) {
			setlook .@Look[.@s], .@style;
			message strcharinfo(0),"This is style #"+.@style+".";
			set .@menu$, " ~ Next (^0055FF"+((.@style!=.@styles[.@s])?.@style+1:1)+"^000000): ~ Previous (^0055FF"+((.@style!=1)?.@style-1:.@styles[.@s])+"^000000): ~ Jump to...: ~ Revert to original (^0055FF"+.@Revert+"^000000)";
			switch(select(.@menu$)) {
				case 1: set .@style, ((.@style!=.@styles[.@s])?.@style+1:1); break;
				case 2: set .@style, ((.@style!=1)?.@style-1:.@styles[.@s]); break;
				case 3: message strcharinfo(0),"Choose a style between 1 - "+.@styles[.@s]+".";
					input .@style,0,.@styles[.@s];
					if (!.@style) set .@style, rand(1,.@styles[.@s]);
					break;
				case 4: set .@style, .@Revert; setlook .@Look[.@s], .@Revert; break;
			}
		}
		close;
	case 3:
			mes "[ ^ff0000Stylist^000000 ]";
			mes "Please, select what to convert.";
			mes "Remember, I can't process rental headgears or with cards and refine.";
			next;
			.@check = getequipisequiped(EQI_HEAD_TOP)+getequipisequiped(EQI_HEAD_MID)+getequipisequiped(EQI_HEAD_LOW);
			if (!.@check) {
				mes "[ ^ff0000Stylist^000000 ]";
				cutin "lunain02",2;
				mes "Haha, you are not wearing any regular headgear.";
				break;
			}
			
			setarray .@Position$[1],"Top","Mid","Low";
			setarray .@Position[1],     1,    9,   10;
			set .@Menu$,"";
	
			for( set .@i, 1; .@i < 5; set .@i, .@i + 1 )
			{
				if( getequipisequiped(.@Position[.@i]) )
				set .@Menu$, .@Menu$ + .@Position$[.@i] + "-" + "[^ff0000" + getequipname(.@Position[.@i]) + "^000000]";
				set .@Menu$, .@Menu$ + ":";
			}
			set .@Part, .@Position[ select(.@Menu$) ];
			set .@id, getequipid(.@Part);
			set .@ref, getequiprefinerycnt(.@Part);
			if( !getequipisequiped(.@Part) )
			{
				cutin "lunain02",2;
				mes "[ ^ff0000Stylist^000000 ]";
				mes "Your not wearing anything there...";
				break;
			}
			mes "[ ^ff0000Stylist^000000 ]";
			mes "You want to Costume your ^ff0000" + getitemname(getequipid(.@Part)) + "^000000?";
			next;
			if( select("Yes, proceed:No, I am sorry.") == 2 )
			{	
				cutin "lunain03",2;
				mes "[ ^ff0000Stylist^000000 ]";
				mes "Need some time to think about it, huh? Alright, I can understand.";
				break;
			}
			for(set .@i,0; .@i<4; set .@i,.@i+1)
				set .@slot[.@i], getequipcardid(.@Part,.@i);
			if (.@slot[0]>4000 && .@slot[0]<5000) { // If it has card don't convert
				cutin "lunain02",2;
				mes "[ ^ff0000Stylist^000000 ]";
				mes "A card? Here?!";
				mes "As I said before, I don't convert headgear with cards.";
				emotion e_hmm;
				break;
			}
			getinventorylist;
			for(set .@i,0; .@i<@inventorylist_count; set .@i,.@i+1)
				if (@inventorylist_expire[.@i] != 0 && @inventorylist_equip[.@i] != 0) { // If rental don't convert
				cutin "lunain02",2;
				mes "[ ^ff0000Stylist^000000 ]";
				mes "Sorry, I don't convert a rental headgear!";
				emotion e_hmm;
				break;
				}
				if (.@ref > 0) { // If refine don't convert
				cutin "lunain02",2;
				mes "[ ^ff0000Stylist^000000 ]";
				mes "Sorry please keep in mind.";
				mes "I don't convert headgear with refine.";
				emotion e_hmm;
				break;
				}
			if (!countitem(.@id)) { 
				cutin "lunain02",2;
				mes "[ ^ff0000Stylist^000000 ]";
				mes "Where is ^ff0000"+getitemname(@id)+"^000000...?";
				npctalk "You're a snoozy cheater!";
				logmes "CHEATER: Tried to sign an item not having it: "+getitemname(@id);
				emotion e_wah;
				break;
			}
			costume .@Part; // Convert the Headgear
			cutin "lunain03",2;	
			mes "[ ^ff0000Stylist^000000 ]";
			mes "Done, enjoy your costume headgear.";
			break;

	case 4:
			mes "[ ^ff0000Stylist^000000 ]";
			mes "Please, select what to restore.";
			mes "Remember, I will only restore it back without refine and cards.";
			next;
			.@check = getequipisequiped(EQI_COSTUME_HEAD_TOP)+getequipisequiped(EQI_COSTUME_HEAD_MID)+getequipisequiped(EQI_COSTUME_HEAD_LOW);
			if (!.@check) {
				mes "[ ^ff0000Stylist^000000 ]";
				cutin "lunain02",2;
				mes "Haha, you are not wearing any costume headgear.";
				break;
			}

			setarray .@Position$[1],"Top","Mid","Low";
			setarray .@Position[1],     13,    12,   11;
			set .@Menu$,"";
			for( set .@i, 1; .@i < 5; set .@i, .@i + 1 )
			{
				if( getequipisequiped(.@Position[.@i]) )
				set .@Menu$, .@Menu$ + .@Position$[.@i] + "-" + "[^ff0000" + getequipname(.@Position[.@i]) + "^000000]";
				set .@Menu$, .@Menu$ + ":";
			}
			set .@Part, .@Position[ select(.@Menu$) ];
			if( !getequipisequiped(.@Part) )
			{
				cutin "lunain02",2;
				mes "[ ^ff0000Stylist^000000 ]";
				mes "Your not wearing anything there...";
				break;
			}
			mes "[ ^ff0000Stylist^000000 ]";
			mes "You want to restore your ^ff0000" + getitemname(getequipid(.@Part)) + "^000000?";
			next;
			if( select("Yes, proceed:No, I am sorry.") == 2 )
			{
				cutin "lunain02",2;
				mes "[ ^ff0000Stylist^000000 ]";
				mes "Need some time to think about it, huh?";
				mes "Alright, I can understand.";
				break;
			}
			uncostume .@Part;
			cutin "lunain03",2;
			mes "[ ^ff0000Stylist^000000 ]";
			mes "Done, enjoy your restored headgear.";
			break;

	default:
		close;
	}
	}
	close;
L_End:
	mes .n$;
	mes "Make yourself at home. Even though I don't have time for you.";
	close2();
	cutin("", 255);
	close;
}

