//===== eAthena Script ======================================= 
//= Quest NPCs related to Niflheim
//===== By: ================================================== 
//= The eAthena Dev Team
//===== Current Version: ===================================== 
//= 1.1
//===== Compatible With: ===================================== 
//= eAthena 7.15 +
//===== Description: ========================================= 
//= Book of Devil		(MISC_QUEST | 256)
//= Piano Key Ouest		(MISC_QUEST | 32)
//===== Additional Comments: ================================= 
//= 1.0 Initial release, moved Book of Devil and Piano quest
//=	from npc/cities/niflheim.txt [Evera]
//= 1.1 Optimized Book of Devil quest. used bit-wise var,
//=	Optimized Piano Quest - now uses 1 variable [Lupus]
//============================================================ 

//=============================================================
//Quest for Book of Devil
//=============================================================
niflheim,184,199,5	script	Little Girl#02	793,{
	mes "[Sairin]";
	if(MISC_QUEST & 256){
		mes "Thanks again!";
		close;
	}
	if(@niflheimlost == 2){
		mes "You found him?";
		mes "Oh thank you!";
		mes "Please, take this as a token of my appreciation.";
		getitem 642,1;//Items: Book of Devil,
		set MISC_QUEST,MISC_QUEST | 256;
		set @niflheimlost,0;
		close;
	}
	if(@niflheimlost == 1){
M_YES:
		set @niflheimlost,1;
		mes "Please find him and tell him where I am! I saw him last in Niflheim Field, the first one...";
		close;
	}
	mes "Sir, will you please help me?";
	if(BaseJob==Job_Novice){
		mes "Oh... you are lost, too...";
		close;
	}
	next;
	menu "Yes",-, "No",M_NO;

	mes "[Sairin]";
	mes "My friend and I went for a hike and ended up wandering into a strange field.";
	next;
	mes "[Sairin]";
	mes "Suddenly, I found a doll. I picked it up, and it turned into a ghost!";
	next;
	mes "[Sairin]";
	mes "I screamed and ran as fast as I could. When I stopped running, I ended up in this strange town..";
	next;
	mes "[Sairin]";
	mes "No one here will help me, and there are ghosts everywhere! Could you help me find my friend?";
	next;
	menu "Sure",M_YES, "No",M_NO;
M_NO:
	close;
}

nif_fild01,213,268,5	script	Little Boy	797,{
	if(MISC_QUEST & 256){
L_DONE:
		set @niflheimlost,2;
		mes "[Marius]";
		mes "Thank you for helping us!";
		close;
	}
	if(@niflheimlost == 2) goto L_PART2;
	if(@niflheimlost == 1){
		mes "[Marius]";
		mes "Who are you?";
		mes "...";
		mes "You found Sairin?";
		mes "She ran to Niflheim?";
		next;
L_PART2:
		mes "[Marius]";
		mes "Could you tell her that I am on my way?";
		mes "I am a little slow, and its very important that she knows.";
		next;
		menu "Yes",L_DONE, "No",-;
		close;	
	}
	mes "[Marius]";
	mes "Sairin... where are you?";
	close;
}

//=============================================================
//Piano Quest
//=============================================================
niflheim,224,243,3	script	Alager	795,{
	mes "[Alager]";
	mes "Muahaha, I love to eat meat...";
	mes "You look... delicious!";
	next;
	mes "[Alager]";
	mes "I'm going to eat you...";
	next;
	mes "-Chomp bite slurp-";
	if(nif_piano&1 || (MISC_QUEST & 32)) goto L_end;
	percentheal -60,0;
	next;
	mes "[Alager]";
	mes "Ahhh, it's been some time since I had such delicious meat!";
	// 50% made up, not the slightest idea how to translate these ^^;
	mes "as an ex-barbeque chef, my favourite meat";
	mes "would be like preparing beef fillet,";
	mes "crossed and grilled to perfection";
	mes "that would be really delicious... ";
	next;
	mes "[Alager]";
	mes "Ah, let me thank you with this,";
	mes "I found it on the ground, hoho~";
	getitem 7184,1;//Items: Piano Key,
	set nif_piano, nif_piano|1;
	close;
L_end:
	percentheal -30,0;
 	close;
}

nif_in,105,81,3	script	Crayu	794,{
	mes "[Crayu]";
	mes "Ah, there was this poem...";
	mes "in which author and time of writing was unknown,";
	mes "and has been circulating since long ago...";
	next;
	mes "[Crayu]";
	mes "^FF0000When the sun sets in the western hills,^000000";
	mes "^FF0000Where points the velvet gloom of dawn,^000000";
	mes "^FF0000The beautiful melody surrounding thy soul,^000000";
	mes "^FF0000Is the key from Lord Death's wrath.^000000";
	next;
	mes "[Crayu]";
	if(nif_piano&2 || (MISC_QUEST & 32)){
		mes "I wonder what does it mean...";
		mes "If you read it carefully,";
		mes "it seems to have a deep meaning,";
		mes "as if there is a mysterious secret";
		mes "hidden within these words...";
		close;
	}
	set @nif_random,rand(1,4);
	mes "Heh, let me give you a little exam!";
	mes "Repeat line no. " + @nif_random + " of the poem";
	mes "that you have just heard to me!";
	next;
	input @inputstr1$;
	switch(@nif_random){
	case 1:
		set @str1$,"When the sun sets in the western hills,";
		break;
	case 2:
		set @str1$,"Where points the velvet gloom of dawn,";
		break;
	case 3:
		set @str1$,"The beautiful melody surrounding thy soul,";
		break;
	case 4:
		set @str1$,"Is the key from Lord Death's wrath.";
		break;
	}
	mes "[Crayu]";
	if(@inputstr1$ == @str1$){
		mes "Hoho... I see you have paid attention!";
		mes "I am Grey, a wandering poet of yore,";
		mes "you are the best audience I have had so far,";
		mes "here, take this as a reward.";
		getitem 7184,1;//Items: Piano Key,
		set nif_piano, nif_piano|2;
		next;
		mes "[Crayu]";
		mes "I hope you will treat other poets";
		mes "as well as you treated me, farewell.";
		close;
	}
	mes "Aih... If you had paid more attention,";
	mes "you would have known the correct answer!";
	mes "Come back for the challenge again,";
	mes "when you have thought over it!";
	close;
}

nif_in,31,20,3	script	Kurtz	794,{
	mes "[Kurtz]";
	mes "Business nowadays is really bad...";
	mes "Back when I used to be alive,";
	mes "my business was this bad too~!";
	if(nif_piano&4 || (MISC_QUEST & 32)) close;
	next;
	mes "[Kurtz]";
	mes "Hey! You there! Dump this for me";
	mes "on the way out will you!";
	getitem 7184,1;//Items: Piano Key,
	set nif_piano, nif_piano|4;
	next;
	mes "[Kurtz]";
	mes "Why is business so bad lately...";
	mes "(mumble mumble)";
	close;
}

niflheim,169,71,5	script	#1	111,2,2{
	if(MISC_QUEST & 32 || nif_piano&8) end;

	mes "- In the nearby tombs -";
	mes "- you see something -";
	mes "- half buried in the ground -";
	mes "- What is it? -";
	mes "- Looks like it broke off something -";
	next;
	mes "- Pick it up? -";
	menu "Yes",-,"No",L_end;
	getitem 7184,1;//Items: Piano Key,
	set nif_piano, nif_piano|8;
L_end:
	close;
}

niflheim,208,103,5	script	#2	111,2,2{
	if(MISC_QUEST & 32 || nif_piano&32) end;
	if(nif_piano&16){
		mes "- In the hole you have dug -";
		mes "- there is something else -";
		mes "- buried deep in the ground -";
		mes "- Looks like its another fragment -";
		next;
		mes "- Pick it up? -";
		menu "Yes",-,"No",L_end;
		getitem 7184,1;//Items: Piano Key,
		set nif_piano, nif_piano|32;
	L_end:
		close;
	}
	mes "- In the nearby tombs -";
	mes "- you see something -";
	mes "- half buried in the ground -";
	mes "- What is it? -";
	mes "- Looks like it broke off something -";
	next;
	mes "- Pick it up? -";
	menu "Yes",-,"No",L_end;
	getitem 7184,1;//Items: Piano Key,
	set nif_piano, nif_piano|16;
	close;
}

nif_in,115,181,5	script	#4	111,3,3{
	mes "- You see a huge old piano -";
	if((MISC_QUEST & 32)==0) mes "- with a few keys missing  -";
	if(MISC_QUEST & 32) mes "- with one key missing -";
	if(MISC_QUEST & 32 || countitem(7184) < 6) close;

	delitem 7184,countitem(7184);//Items: Piano Key,
	set MISC_QUEST,MISC_QUEST | 32;
	set nif_piano, 0;
	mes "- You slide the 6 piano keys one -";
	mes "- by one into the missing slots  -";
	mes "- on the piano, but you realize  -";
	mes "- the left-most side seems to be -";
	mes "- missing one more key. -";
	close;
}

nif_in,118,151,5	script	#5	111,3,3{
	if((MISC_QUEST & 32)==0) end;
	mes "- The very moment the long shadow -";
	mes "- of your body falls on the piano -";
	next;
	mes "- You suddenly seem to feel lighter -";
	mes "- and your vision starts to blur... -";
	next;
	warp "nif_in",179,163;
	close;
}

nif_in,188,168,3	script	Witch	792,{
	mes "[Kirkena]";
	mes "Hmm?... Aren't you a living human?";
	mes "Must have took you some effort";
	mes "to get to this place...";
	mes "Whatever reason though, this is not a place";
	mes "the living shall belong...";
	next;
	mes "[Kirkena]";
	mes "I shall use my powers to send you back";
	mes "but you should not return in the future.";
	close2;
	warp "umbala",138,208;
	end;
}