//===== eAthena Script ======================================= 
//= Dye Maker
//===== By: ================================================== 
//= eAthena Dev Team
//===== Current Version: ===================================== 
//= 1.4
//===== Compatible With: ===================================== 
//= eAthena SVN
//===== Description: ========================================= 
//= [Aegis Conversion]
//===== Additional Comments: ================================= 
//= 1.0 Fully working [kobra_k88]
//= 1.1 Spell Checked [Nexon] 
//= 1.2 Rescripted to Aegis 10.3 standard. [L0ne_W0lf]
//= 1.2b Fixed typos in variable names [ultramage]
//= 1.3 Made the checks more dynamic [ultramage]
//= 1.3b Fixed incorrect checking loop structure [ultramage]
//= 1.4 Added a checkweight. [L0ne_W0lf]
//============================================================ 

morocc_in,146,99,3	script	Java Dullihan	58,{
	if ((MaxWeight-Weight) < 200 || checkweight(1201,1) == 0) {
		mes "- Wait a moment! -";
		mes "- Currently you're carrying -";
		mes "- too many items with you. -";
		mes "- Please come back later -";
		mes "- after you put some items into kafra storage. -";
		close;
	}
	mes "[Dye Maker Java Dullihan]";
	mes "Wow...";
	mes "Such a nice day. Days like this are perfect to make dyes.";
	next;
	switch(select("Talk:Make Dyestuffs:Cancel")) {
	case 1:
		mes "[Dye Maker Java Dullihan]";
		mes "Erm, I don't really have much to say to you. But, if you would like me to tell you about my life, I can do that. It's a little long and boring, but would you like to listen?";
		next;
		if (select("Listen:Don't Listen") == 1) {
			mes "[Dye Maker Java Dullihan]";
			mes "As long as I can remember, my father has been making dyes. He used to spend countless hours making dyes of different colors. Even when my mother passed away, he never stopped.";
			next;
			mes "[Dye Maker Java Dullihan]";
			mes "At one point in my life, I became rebellious and ran away from home. I didn't want to be stuck to the family business and wanted to try other things.";
			next;
			mes "[Dye Maker Java Dullihan]";
			mes "Anyways...";
			mes "I eventually wound up back home to carry on the family tradition, making dyes for 15 years already. I guess it was really in my blood.";
			next;
			mes "[Dye Maker Java Dullihan]";
			mes "Something I realized these days is that now I can understand my father. Why my father devoted everything to making dyes...";
			next;
			mes "[Dye Maker Java Dullihan]";
			mes "In the middle of all that tedious and hard work, he probably felt the magic of those colors passing on so many dreams for other people.";
			next;
			mes "[Dye Maker Java Dullihan]";
			mes "It was probably for those dreams that he tried so hard to make dyes for his customers...";
			next;
			mes "[Dye Maker Java Dullihan]";
			mes "Heh... How do I know this? Well, that's the way I feel right now. Since a couple years ago, I've been able to hear what the colors were saying...";
			next;
			mes "[Dye Maker Java Dullian]";
			mes "Just watch. Someday, I'm going to succeed in making the color my father wanted to, but never got the chance to make.";
			close;
		}
		mes "[Dye Maker Java Dullihan]";
		mes "Ahahahaha...";
		mes "Well, I guess no one would want to listen to a measly dyemaker's story anyway. Hahaha....";
		close;

	case 2:
		mes "[Dye Maker Java Dullihan]";
		mes "Great! If you want it, I'll make it for you. I promise I'll make you the color you want. But what color dye would you like to make? The fee is different depending on the color.";
		next;
		mes "[Dye Maker Java Dullihan]";
		mes "Why, do you ask? Just remember that there are colors that are easy to make, and those that require more effort and work. Please don't think the fee is too expensive.";
		next;
		mes "[Dye Maker Java Dullihan]";
		mes "The color of the dye is special, made with all my heart and soul.";
		next;
		switch(select("Scarlet Dyestuffs:Lemon Dyestuffs:Cobaltblue Dyestuffs:Darkgreen Dyestuffs:Orange Dyestuffs:Violet Dyestuffs:White Dyestuffs:Black Dyestuffs:Cancel")) {
		case 1: callsub S_MakeDye,1,1; break;
		case 2: callsub S_MakeDye,2,1; break;
		case 3: callsub S_MakeDye,3,2; break;
		case 4: callsub S_MakeDye,4,3; break;
		case 5: callsub S_MakeDye,5,4; break;
		case 6: callsub S_MakeDye,6,4; break;
		case 7: callsub S_MakeDye,7,4; break;
		case 8: callsub S_MakeDye,8,4; break;
		case 9:
			mes "[Dye Maker Java Dullihan]";
			mes "Eeeehhhh!! What's this? You change your mind now!? So disappointing...";
			close;
		}

	case 3:
		mes "[Dye Maker Java Dullihan]";
		mes "I'm not bragging or anything. But I have the skills to make dyestuff. If you ever need dyestuff, please come to me. I'll make them for you at a reasonable price.";
		close;
	}

S_MakeDye:
	mes "[Dye Maker Java Dullihan]";
	switch(getarg(0)) {
	case 1:
		mes "Mmm... I need 30 Red Herbs, 1 Counteragent, and 1 Empty Bottle to make Red Dyestuffs. The fee is only 3000 zeny to make it.";
		setarray .@item[0], 507, 973, 713;
		setarray .@count[0], 30,   1,   1;
		set .@cost,3000;
		set .@dyestuff,975;
		break;
	case 2:
		mes "Mmm... I need 30 Yellow Herbs, 1 Couneragent, and 1 Empty Bottle to make Lemon Dyestuffs. The fee is only 3000 zeny to make it.";
		setarray .@item[0], 508, 973, 713;
		setarray .@count[0], 30,   1,   1;
		set .@cost,3000;
		set .@dyestuff,976;
		break;
	case 3:
		mes "Mmm... I need 20 Blue Herbs, 1 Counteragent, and 1 Empty Bottle to make Cobaltblue Dyestuff. It's hard to use the Blue Herb, so the fee is going to be 3500 zeny.";
		setarray .@item[0], 510, 973, 713;
		setarray .@count[0], 20,   1,   1;
		set .@cost,3500;
		set .@dyestuff,978;
		break;
	case 4:
		mes "Mmm... I need 5 Blue Herbs, 20 Green Herbs, 20 Yellow Herbs, 1 Counteragent, 1 Mixture, and 1 Empty Bottle to make Darkgreen Dyestuffs. Don't get all of the materials confused. The fee is only 5000 zeny.";
		setarray .@item[0], 510, 511, 508, 974, 973, 713;
		setarray .@count[0],  5,  20,  20,   1,   1,   1;
		set .@cost,5000;
		set .@dyestuff,979;
		break;
	case 5:
		mes "Mmm... I need 20 Red Herbs, 20 Yellow Herbs, 1 Counteragent, 1 Mixture, and 1 Empty Bottle to make Orange Dyestuff. The fee is going to be 5000 zeny.";
		setarray .@item[0], 507, 508, 974, 973, 713;
		setarray .@count[0], 20,  20,   1,   1,   1;
		set .@cost,5000;
		set .@dyestuff,980;
		break;
	case 6:
		mes "Mmm... I need 10 Blue Herbs, 30 Red Herbs, 1 Counteragent, 1 Mixture, and 1 Empty Bottle to make Violet Dyestuffs. The fee will be 5000 zeny.";
		setarray .@item[0], 510, 507, 974, 973, 713;
		setarray .@count[0], 10,  30,   1,   1,   1;
		set .@cost,5000;
		set .@dyestuff,981;
		break;
	case 7:
		mes "Mmm... I need 30 White Herbs, 1 Counteragent, and 1 Empty bottle to make White Dyestuffs. The fee will be 3000 zeny.";
		setarray .@item[0], 509, 973, 713;
		setarray .@count[0], 30,   1,   1; 
		set .@cost,3000;
		set .@dyestuff,982;
		break;
	case 8:
		mes "Mmm... I need 30 of each Red, Yellow, and Green Herb, 5 Blue Herbs, 1 Counteragent, 1 Mixture, and 1 Empty Bottle. The process takes longer and more effort than the others, so it is going to be 7000 zeny.";
		setarray .@item[0], 507, 508, 511, 510, 974, 973, 713;
		setarray .@count[0], 30,  30,  30,   5,   1,   1,   1;
		set .@cost,7000;
		set .@dyestuff,983;
		break;
	}
	next;
	mes "[Dye Maker Java Dullihan]";
	switch(getarg(1)) {
	case 1: mes "Ah! I think you would have everything ready. Would you like to start the process?"; break;
	case 2: mes "Okay! I believe you would have everything ready. Would you like to start the process?"; break;
	case 3: mes "Okay! I believe you would have everything ready. Shall we begin the process?"; break;
	case 4: mes "Okay! I believe you would have everything prepared. Would you like to start the process?"; break;
	}
	next;
	if (select("Make Dyestuffs:Cancel") == 1) {
		set .@size, getarraysize(.@item);
		// check requirements
		for( set .@i,0 ; .@i < .@size ; set .@i,.@i+1 )
			if( countitem(.@item[.@i]) < .@count[.@i] )
				break;
		if( .@i < .@size || Zeny < .@cost ) {
			mes "[Dye Maker Java Dullihan]";
			mes "Hmmm. Not enough...";
			mes "I don't think I'll be able to make the color you want with those materials. Why don't you go get some more materials...?";
			close;
		}
		// delete items
		for (set .@i, 0; .@i < .@size ; set .@i, .@i+1)
			delitem .@item[.@i], .@count[.@i];
		set zeny,zeny-.@cost;
		// get dyestuff
		getitem .@dyestuff,1;
		
		mes "[Dye Maker Java Dullihan]";
		mes "Hmm... It came out pretty well. A very rich color. Of course I'll be trying harder to make a more charming color...";
		next;
		mes "[Dye Maker Java Dullihan]";
		mes "Well, then. Stop by whenever you need more dyes.";
		close;
	}
	mes "[Dye Maker Java Dullihan]";
	mes "Eeeehhhh!! What's this?";
	mes "You change your mind now!? So disappointing...";
	return;
}
