//===== rAthena Script ======================================= 
//= Valhallen Items Quests NPC
//===== By: ================================================== 
//= Avaji
//===== Current Version: ===================================== 
//= 2.0
//===== Compatible With: ===================================== 
//= rAthena Project
//===== Description: ========================================= 
//= All-in-one: Mjolnir,Sleipnir,Brisingamen,Gleipnir,Megingjard
//= Custom quest, ingredients based on official RO FAQ
//===== Additional Comments: ================================= 
//= 1.1 Optimized. [Euphy]
//= 2.0 Adds SE and TE Godlikes. Fixed Mixing Itemlist. [Jey]
//= Sources for the mixing lists 2016-08-15:
//= http://irowiki.org/wiki/God_Items_Quest
//= http://irowiki.org/wiki/God_Items_Quest_2
//= http://irowiki.org/wiki/God_Items_Quest_3
//============================================================ 

prontera,147,171,5	script	Lenneth	811,{
	mes "[Lenneth]";
	mes "I come from Valhalla to aid you.";
	mes "I can transmute for you many of the Valhallen items,";
	mes "although they require many rare elements to make.";
	next;
	switch(select("Mjolnir:Sleipnir:Brisingamen:Gleipnir:Megingjard:Asprika:Brynhild:Hervor:Jormungand:Muspellium:Essence Of Rune:Close")) {
		case 1:
			mes "[Lenneth]";
			mes "^3355FFMjolnir^000000 is the mighty Hammer of Thor.";
			setarray .@Items[0],1530,1522,2,984,20,985,5,969,40,7074,2,7075,4,7078,5,7091,5,7089,5;
			break;
		case 2:
			mes "[Lenneth]";
			mes "^3355FFSleipnir^000000 are boots made after Odin's War Horse.";
			setarray .@Items[0],2410,2406,2,969,20,985,10,7076,3,7079,5,7083,3,7086,4,7087,3;
			break;
		case 3:
			mes "[Lenneth]";
			mes "^3355FFBrisingammen^000000 is the magical Necklace of Freyja, goddess of Beauty.";
			setarray .@Items[0],2630,2603,1,726,2,722,3,727,10,724,5,969,20,7073,4,7077,4,7088,3,7090,3,7092,3;
			break;
		case 4:
			mes "[Lenneth]";
			mes "The ^3355FFGleipnir^000000 is a light yet strong rope required to make ^3355FFMegingjard^000000";
			setarray .@Items[0],7058,7080,4,7081,5,7082,4,7084,3,7085,3;
			break;
		case 5:
			mes "[Lenneth]";
			mes "The ^3355FFMegingjard^000000 is the powerful Belt of Thor.";
			setarray .@Items[0],2629,7058,1,2627,1,969,20,726,10,984,10;
			break;
		case 6:
			mes "[Lenneth]";
			mes "The ^3355FFAsprika^000000 is the light of gods.";
			setarray .@Items[0],2541,7835,1,7836,1,7837,1,7838,1,2513,1,7063,100,7291,10,7293,10,985,20;
			break;
		case 7:
			mes "[Lenneth]";
			mes "The ^3355FFBrynhild^000000 is the warrior's armor.";
			setarray .@Items[0],2383,7830,1,7831,1,7832,1,7833,1,7834,1,7510,100,2357,1,969,10,985,20;
			break;
		case 8:
			mes "[Lenneth]";
			mes "The ^3355FFHervor^000000 is named after the valkyrie who ensures victory for her warriors.";
			setarray .@Items[0],2181,6595,2,6596,1,6594,4,6597,3,6602,1,6604,1,6605,1,2115,1;
			break;
		case 9:
			mes "[Lenneth]";
			mes "The ^3355FFJormungand^000000 is famous for its ability to poison the enemy.";
			setarray .@Items[0],2020,6603,4,6599,1,6598,1,6601,4,6600,1,6604,1,6605,1,1473,1;
			break;
		case 10:
			mes "[Lenneth]";
			mes "The ^3355FFMuspellium^000000 is required to make ^3355FFJormungand^000000 and ^3355FFHervor^000000.";
			setarray .@Items[0],6605,984,50,985,50;
			break;
		case 11:
			mes "[Lenneth]";
			mes "The ^3355FFEssence Of Rune^000000 is required to make ^3355FFJormungand^000000 and ^3355FFHervor^000000.";
			setarray .@Items[0],6604,12735,200,12736,100;
			break;
		default:
			close;
	}
	
	mes "^FF0000The items I need are as follows:^000000";
	set .@itemmissing,0;
	for(set .@i,1; .@i<getarraysize(.@Items); set .@i,.@i+2) {
		set .@amount,.@Items[.@i+1];
		set .@id,.@Items[.@i];
		mes " ~ "+.@amount+"x "+((countitem(.@id)<.@amount)?("^dd3355"):("^33dd55"))+getitemname(.@id)+((getitemslots(.@id)>0)?" ["+getitemslots(.@id)+"]":"")+"^000000";
		if (countitem(.@id) < .@amount) 
			set .@itemmissing,1;
	}
	if (.@itemmissing) {
		next;
		mes "[Lenneth]";
		mes "Go on and find all these items.";
		mes "I will wait here to aid you.";
		close;
	}
	next;
	mes "[Lenneth]";
	mes "Do you desire ^3355FF"+getitemname(.@Items[0])+"^000000?";
	next;
	if(select("No","Yes")==1) {
		mes "[Lenneth]";
		mes "Please return if you change your mind.";
		close;
	}
	mes "[Lenneth]";
	mes "Here is your ^3355FF"+getitemname(.@Items[0])+"^000000.";
	mes "May it serve you well.";
	//second check if the player tries to bypass the first
	for(set .@i,1; .@i<getarraysize(.@Items); set .@i,.@i+2) {
		set .@amount,.@Items[.@i+1];
		set .@id,.@Items[.@i];
		if (countitem(.@id) < .@amount) 
			close;
	}
	// Delete the items _after_ the second check
	for(set .@i,1; .@i<getarraysize(.@Items); set .@i,.@i+2) {
		set .@amount,.@Items[.@i+1];
		set .@id,.@Items[.@i];
		delitem .@id, .@amount;
	}
	getitem .@Items[0],1;
	close;
}
