//@unloadnpc Tailoring Master
//@loadnpc npc/thor/crafting/tailoring/tailoring_main.txt


office,120,28,0	script	Tailoring Master	4_F_JPNOBA,{
	dispbottom "Your tailoring skill is " + tailoring_skill;
	if ( handicrafting_skill == 40 ) {
		mes .npc$;
		mes "You cannot take any work orders anymore. You handicrafting skill is already at max";
		close;
	}
	mes .npc$;
	mes "We have several ongoing projects that you can participate in based on your skill level.  These can help you fine tune your handicrafting skills.";	
	next;
	mes .npc$;
	mes "You can only have 1 work order accepted from any guild at any time, so if you are currently working on one, you must complete it before I can give you another.";
	next;
	switch( handicrafting_skill ) {
		case 0: case 1: case 2: case 3: case 4:
			.@work$="Bandage"; 
			.@craft_item = 30135;
			.@denarius_earned = 1;
			setarray .@ingredients[ 0 ], 930, 1, 504, 1;
			break;
		case 5: case 6: case 7: case 8: case 9:
			.@work$="Clothes";
			.@craft_item = 30136;
			.@denarius_earned = 2;
			setarray .@ingredients[ 0 ], 7071, 1, 504, 1; 
			break;
		case 10: case 11: case 12: case 13: case 14: 
			.@work$="Prison Uniform"; 
			.@craft_item = 30137;
			.@denarius_earned = 3;
			setarray .@ingredients[ 0 ], 1099, 1, 504, 1; 
			break;
		case 15: case 16: case 17: case 18: case 19:
			.@work$="White Cloth"; 
			.@craft_item = 30138;
			.@denarius_earned = 4;
			setarray .@ingredients[ 0 ], 7069, 1, 504, 1; 
			break;
		case 20: case 21: case 22: case 23: case 24: 
			.@work$="Kimono";
			.@craft_item = 30139;
			.@denarius_earned = 5;
			setarray .@ingredients[ 0 ], 7153, 1, 504, 1; 
			break;
		case 25: case 26: case 27: case 28: case 29:
			.@work$="Sea Otter Fleece";
			.@craft_item = 30140;
			.@denarius_earned = 6;
			setarray .@ingredients[ 0 ], 7065, 1, 504, 1; 
			break;
		case 30: case 31: case 32: case 33: case 34:
			.@work$="Course Black Fabric";
			.@craft_item = 30141;
			.@denarius_earned = 7;
			setarray .@ingredients[ 0 ], 1020, 1, 504, 1; 
			break;
		case 35: case 36: case 37: case 38: case 39: case 40:
			.@work$="Tiger Skin Rug";
			.@craft_item = 30142;
			.@denarius_earned = 8;
			setarray .@ingredients[ 0 ], 1029, 1, 504, 1; 
			break;
		default: break;
	}

	if ( invited ) {
		mes .npc$;
		mes "You accepted the work order for Repairing and Cleaning Dirty "+.@work$+".";
		next;
		if (countitem (.@craft_item) == 0) {
			close;
		} else if (countitem (.@craft_item) == 2 ) {
			mes .npc$;
			mes "Good work!!!";
			.@a = rand( 1, 5 ); // Random 1% - 5% experience points
			delitem .@craft_item,countitem (.@craft_item);
			handicrafting_exp += .@a;
			dispbottom "Your handicrafting experience is now "+handicrafting_exp+". Your handcrafting skill is "+handicrafting_skill;
			/* Earn handicrafting skill if experience is still greather than 100 */
			while ( 1 ) {
				if ( handicrafting_exp >= 100 ) {
					handicrafting_exp -= 100; // deduct 100 experience points since we will add one handicrafting skill level
					handicrafting_skill++; // every 100 handicrafting experience is equal to 1 handicrafting skill level
				} else break;
			}
			work_order_done = 0;
			invited = 0;
		} else {
			mes .npc$;
			mes "It seems you've made more items than the we ordered.";
			mes "Would you like to turn those in now? We can't pay as much as we would if we'd known you were making more item than requested, however.";
			next;
			if (select("No, Thanks", "Yes, Please") == 1) {
				mes .npc$;
				mes "Let me know if you change your mind.";
				close;
			}
			.@a = rand( 1, 5 ); // Random 1% - 5% experience points
			delitem .@craft_item,countitem (.@craft_item);
			handicrafting_exp += .@a;
			dispbottom "Your handicrafting experience is now "+handicrafting_exp+". Your handcrafting skill is "+handicrafting_skill;
			/* Earn handicrafting skill if experience is still greather than 100 */
			while ( 1 ) {
				if ( handicrafting_exp >= 100 ) {
					handicrafting_exp -= 100; // deduct 100 experience points since we will add one handicrafting skill level
					handicrafting_skill++; // every 100 handicrafting experience is equal to 1 handicrafting skill level
				} else break;
			}
			work_order_done = 0;
			invited = 0;
			close;
		}
		close;

	} else {

		if (countitem (.@craft_item) > 0 ) {
			mes .npc$;
			mes "It seems you've made some items that could be of use but haven't accepted any workorders.";
			mes "Would you like to turn those in now? We can't pay as much as we would if we'd known you were making item, however.";
			next;
			if (select("No, Thanks", "Yes, Please") == 1) {
				mes .npc$;
				mes "Let me know if you change your mind.";
				close;
			}
			.@a = rand( 1, 5 ); // Random 1% - 5% experience points
			delitem .@craft_item,countitem (.@craft_item);
			denarius_earned = 0;
			handicrafting_exp += .@a;
			dispbottom "Your handicrafting experience is now "+handicrafting_exp+". Your handcrafting skill is "+handicrafting_skill;
			/* Earn handicrafting skill if experience is still greather than 100 */
			while ( 1 ) {
				if ( handicrafting_exp >= 100 ) {
					handicrafting_exp -= 100; // deduct 100 experience points since we will add one handicrafting skill level
					handicrafting_skill++; // every 100 handicrafting experience is equal to 1 handicrafting skill level
				} else break;
			}
			work_order_done = 0;
			invited = 0;
			close;
		}
	
		mes .npc$;
		mes "Hmm, let's see here. It seems we have order to Repair and Clean Dirty "+.@work$+".";
		next;
		mes .npc$;
		mes "To make it, you will need to take "+ .@ingredients[ 1 ] + " " + getitemname( .@ingredients[ 0 ] ) + " " +.@ingredients[ 3 ] + " " + getitemname( .@ingredients[ 2 ] )+". Use the "+getitemname( .@ingredients[ 2 ] )+"  to repair and clean the "+.@work$+" then bring it back to me. For each one you bring, I give you "+.@denarius_earned+" Denarius."  ; 
		next;
		mes .npc$;	
		mes "Would you like to accept this workorder now?";
		next;
		if (select("No, Thanks", "Yes, Please") == 1) {
			mes .npc$;
			mes "Let me know if you change your mind";
			invited = 0;
			close;
		}
		mes .npc$;	
		mes "Let me know once you complete the work.";		
		invited = 1;			
		close;
	}


	OnInit:
		.npc$ = "[ ^000099" + strnpcinfo( 1 ) + "^000000 ]";
		end;
}

