//Robo Eye Quest
//@unloadnpc Guild Master
//@loadnpc npc/thor/rise.txt

prt_gld,159,97,2	script	Guild Master	1_M_KNIGHTMASTER,{
	disable_items;
	if(!wcrown) {
		set .@guild_id,strcharinfo(2);
		if ( getcharid(0) != getguildmasterid(getcharid(2)) || countitem(CRO_Woe_Crown) > 0 ) {
			mes "[ "+CStr("Guild Leader","GREEN")+" ]";
			mes "...";
			close;
		}
		query_sql "SELECT guild_lv FROM guild WHERE guild_id = "+getcharid(2), .@guild_lv;
		if (.@guild_lv <= 9) {
			mes "[ "+CStr("Guild Leader","GREEN")+" ]";
			mes "...";
			close;
		}
		mes "[ "+CStr("Guild Leader","GREEN")+" ]";
		mes "Hello, "+CStr(strcharinfo(PC_NAME),"BLUE")+"!";
		mes "Have you heard about that "+Itemlink(CRO_Woe_Crown);
		next;
		mes "[ "+CStr("Guild Leader","GREEN")+" ]";
		mes "This "+CStr("WoE Crown","RED")+" is very hard to craft, I need to go to Geffenia to find that legendary blacksmith but I don't have that "+Itemlink(Lucifers_Lament);
		mes "But, you can give me your "+Itemlink(Lucifers_Lament)+" so that I can start to organize my troop for my expedition.";
		setquest 30010;
		next;
		if(select("Sure, I have that item. Let's do it.", "No, I'm not interested") == 2) {
			mes "[ "+CStr("Guild Leader","GREEN")+" ]";
			mes "Very well. Return at once if you change your mind.";
			close;
		}
		if(countitem(Lucifers_Lament) > 0) {	
			mes "[ "+CStr("Guild Leader","GREEN")+" ]";
			mes "Okay, let me organize the troop for this expedition.";
			delitem Lucifers_Lament,1;
			changequest 30010,30011;
			set wcrown,1;
			close;
		}else{
			mes "[ "+CStr("Guild Leader","GREEN")+" ]";
			mes "Hmmm, I don't see "+Itemlink(Lucifers_Lament)+" in your inventory.";
			close;
		}
	}
	else if(wcrown==1){
		if (questprogress(30011,HUNTING) == 1) {
			mes "[ "+CStr("Guild Leader","GREEN")+" ]";
			mes "Yes, yes, the  troop was sent and found the Legendary Blacksmith at Geffenia. But, he was busy looking for other materials at Lighhalzen.  You can help him by";
			mes "killing ^FF0000500 Engiem Cenia^000000 at Bio Labs.";
			mes "Go and report to me when done.";
 			close;
		}
		else if (questprogress(30011,HUNTING) == 2) {
			mes "[ "+CStr("Guild Leader","GREEN")+" ]";
			mes "Yes you did it!!!";
			completequest 30011;
			setquest 30012;
			set wcrown,2;
			close;
		}
	}
	else if(wcrown==2){
		if (countitem(Emperium) > 24 && countitem(Holy_Water) > 99 && countitem(Zweihander) > 0) {
			mes "[ "+CStr("Guild Leader","GREEN")+" ]";	
			mes "Very well..";
			delitem Emperium,25;
			delitem Holy_Water,100;
			delitem Zweihander,1;
			completequest 30012;
			setquest 30013;
			set wcrown,3;	
			close;	
		} else {
			mes "[ "+CStr("Guild Leader","GREEN")+" ]";	
			mes "Now bring me these other materials:";
			mes "25x  "+Itemlink(Emperium);
			mes "100x "+Itemlink(Holy_Water);
			mes "1x   "+Itemlink(Zweihander);	
			mes "Go and report to me when done.";
			close;
		} 
	}
	else if(wcrown==3){	
		if (questprogress(30013,HUNTING) == 1) {
			mes "[ "+CStr("Guild Leader","GREEN")+" ]";
			mes "Organize an expedition to Payon Field and kill 1 "+CStr("Eddga","RED");
 			close;
		}
		else if (questprogress(30013,HUNTING) == 2) {
			if (checkweight(CRO_Woe_Crown,1) == 0) {
				mes "[ "+CStr("Guild Leader","GREEN")+" ]";
				mes "If you want the reward, empty your bag, first!";
				 close;
			}
			mes "[ "+CStr("Guild Leader","GREEN")+" ]";
			mes "Congratulations!!!, I shall give you now the "+CStr("Legendary WoE Crown","RED");
			set wcrown,4;
			completequest 30013;
			getitem CRO_Woe_Crown,1;
 			close;
		}

	}
	else if(wcrown>=4){
		mes "[ "+CStr("Guild Leader","GREEN")+" ]";
		mes "How is your "+CStr("Legendary WoE Crown","RED")+"?";
		mes "Congratulations on having that.";
		close;
	}

}
