//===== 15-3athena Script ====================================
//= Magic Book Seller
//===== By: ================================================== 
//= Masao, Muad_Dib (translation)
//===== Current Version: ===================================== 
//= 1.1c
//===== Compatible With: ===================================== 
//= 15-3athena Project
//===== Description: ========================================= 
//= [Official Conversion]
//= An NPC which sells you different kinds of Magic Books.
//===== Additional Comments: ================================= 
//= 1.0 First Version. [Masao]
//= 1.1 Optimized. [Euphy]
//= 1.1a Updated NPC name to "Master Velofos". [Euphy]
//= 1.1b Fixed the rand part in "Mysterious Documents" to match
//=	 Aegis & fixed a bracket issue. [Capuche]
//= 1.1c Ported from rAthena to 15-3athena. [15peaces]
//============================================================ 

// Main Quest :: war_book
//============================================================
geffen_in,176,105,4	script	Master Velofos	64,{
	if (checkweight(1201,1) == 0) {
		mes "You're carrying too many items. Please make some room in your bag first.";
		close;
	}
	if ((MaxWeight - Weight) < 1000) {
		mes "You're overweight with items. Please lose some item weight first.";
		close;
	}
	if ((Upper == 2) && (Class != Job_Baby_Warlock)) {
		mes "[Master Velofos]";
		mes "What are you, a baby?";
		mes "I'm not here to babysit. Get lost!";
		close;
	}
	if ((Class != Job_Warlock) && (Class != Job_Warlock_T) && (Class != Job_Baby_Warlock)) {
		mes "[Master Velofos]";
		mes "Ha ha, are you also seeking new knowledge?";
		next;
		mes "[Master Velofos]";
		mes "I'm sorry, but my knowledge doesn't concern you.";
		close;
	}
	if (getskilllv(2230) < 1) {
		mes "[Master Velofos]";
		mes "Well, you've met all the qualifications except one: you need the Release spell.";
		next;
		mes "[Master Velofos]";
		mes "Learn the spell first. I've got so many things to tell you.";
		close;
	}
	mes "[Master Velofos]";
	mes "Welcome, my friend.";
	mes "Congratulations on entering a brand new world of magic.";
	next;
	mes "[Master Velofos]";
	mes "We magic practitioners are always thirsty for new knowledge and power.";
	next;
	mes "[Master Velofos]";
	mes "We endure great hardship and pain to achieve what we want. When we finally do, the sense of accomplishment defies description. That's why both you and I have chosen the way of magic.";
	next;
	mes "[Master Velofos]";
	mes "By the way, what brings you to me today?";
	next;
	switch (select("Nothing.:Do you know the Reading Spell Book?:What's the Freezing Spell?:Can I have a Magic Book?:Can I use the Reading Spell Book without the Freezing Spell?:About the Ultimate Magic Book")) {
	case 1:
		mes "[Master Velofos]";
		mes "Hah! You're silly.";
		close;
	case 2:
		mes "[Master Velofos]";
		mes "Reading Spell Book literally means 'read a spell book.' Do you know how to use Magic Books?";
		next;
		switch (select("Yes, I do.:No, I don't.")) {
		case 1:
			mes "[Master Velofos]";
			mes "Well then, you don't need an additional lecture.";
			close;
		case 2:
			mes "[Master Velofos]";
			mes "Magic Books are an advanced type of magic scroll. While spells on scrolls disappear after one use, the ones in Magic Books can be cast multiple times.";
			next;
			mes "[Master Velofos]";
			mes "Let's compare a spell on a scroll to a wire. When the wire is used to open a door or do something else, it's bent and crushed, losing its original shape. A spell from a Magic Book is more like a shape memory alloy.";
			next;
			mes "[Master Velofos]";
			mes "Huh, don't you now what shape memory alloy is? Eh, just remember this: a wire made from shape memory alloy restores its shape over time.";
			next;
			mes "[Master Velofos]";
			mes "Like the alloy, a spell on a Magic Book remains after a use, although reusing the spell has a downtime for its restoration.";
			next;
			mes "[Master Velofos]";
			mes "...Oh, I didn't mean to talk for too long. Anyways, you can use Magic Books to cast spells that you've learned. Its concept is different from normal spells.";
			next;
			select("What's the difference?");
			mes "[Master Velofos]";
			mes "Why do you have to write your existing spells in Magic Books, you asked?";
			next;
			mes "[Master Velofos]";
			mes "That's a good question. It's related to Magic Binding.";
			next;
			mes "[Master Velofos]";
			mes "You already learned Release, which allows you to hold the energy of the four different elements before the actual casting. Magic Binding is similar to Release.";
			next;
			mes "[Master Velofos]";
			mes "Since you've learned Release, you're capable of using Magic Binding as well. Well, let's talk about that later.";
			next;
			mes "[Master Velofos]";
			mes "You know how to hold an existing spell, and then cast it at a desired timing via Release.";
			next;
			mes "[Master Velofos]";
			mes "Carrying the globes of the four elements is also related to Magic Binding.";
			next;
			mes "[Master Velofos]";
			mes "As you know, the four elements are Fire, Water, Wind, and Earth. Being able to employ them freely is the essential principle of magic.";
			next;
			mes "[Master Velofos]";
			mes "We Humans use torches to keep fire, fans to blow wind, and bowls to hold water. We also use clay to make earthenware.";
			next;
			mes "[Master Velofos]";
			mes "Those activities may differ from magic, but both are the same in the sense of employing the four elements.";
			next;
			mes "[Master Velofos]";
			mes "When you use complex magic spells to summon a storm, drop lightning, or burn an area, that consumes a lot of your energy, both physically and mentally.";
			next;
			mes "[Master Velofos]";
			mes "When you fail to bind such powerful magic spells or fail to control them, you can receive irreparable damage to your mind and body.";
			next;
			mes "[Master Velofos]";
			mes "That's why we use Magic Books to reduce that burden. It helps summon pre-cast spells while you're focusing on binding their magic power.";
			next;
			mes "[Master Velofos]";
			mes "There's one downside though: Magic Books cannot be used for spells that you haven't learned.";
			next;
			mes "[Master Velofos]";
			mes "As I said earlier, spells in Magic Books tend to go back to what they are.";
			next;
			mes "[Master Velofos]";
			mes "That said, as a Circler, you cannot change or create spells in Magic Books.";
			next;
			mes "[Master Velofos]";
			mes "Even if you create one, its power will be beyond your capacity.";
			next;
			mes "[Master Velofos]";
			mes "In order to use the Reading Spell Book, you must learn the Freezing Spell to bind magic.";
			close;
		}
	case 3:
		mes "[Master Velofos]";
		mes "The Freezing Spell is used for Magic Binding. It helps you to insert a magic spell to a circle.";
		next;
		mes "[Master Velofos]";
		mes "Circles of magic work organically with each other. When you use the Freezing Spell to bind a spell, the spell won't activate until you cast the release spell.";
		next;
		mes "[Master Velofos]";
		mes "Of course, binding a spell continuously consumes your mana, but it consumes less mana than conventional magic spells.";
		next;
		mes "[Master Velofos]";
		mes "Magic Binding becomes more difficult when you use more powerful magic spells.";
		next;
		mes "[Master Velofos]";
		mes "For weak spells, you can bind two to three of them with your circle. For more powerful spells, maybe one or two is possible.";
		next;
		mes "[Master Velofos]";
		mes "That all depends on your ability to control your spells. You'll have to try and experience Magic Binding after you first learn it to really understand.";
		close;
	case 4:
		mes "[Master Velofos]";
		mes "I'm sorry, but I only have Magic Books for beginners, but they're obviously not suitable for you. Do you still want one?";
		next;
		switch (select("Sure thing.:Where can I find advanced books?")) {
		case 1:
			mes "[Master Velofos]";
			mes "Please go talk to [Lea] in the Archive. Tell her that you need one of the Magic Books that I've stored in there.";
			next;
			mes "[Master Velofos]";
			mes "For your information, she won't give it to you without anything in return. Expect her to ask you for something!";
			if (wm_book < 1) set wm_book, 1;
			close;
		case 2:
			mes "[Master Velofos]";
			mes "I'm sorry, but our management has recently decided to limit the availability of Magic Books for Multi Circlers. It's because their numbers are increasing more quickly than we expected.";
			next;
			mes "[Master Velofos]";
			mes "You could find one if you try hard, but I don't have any with me.";
			next;
			mes "[Master Velofos]";
			mes "If our management releases the restriction, you'll be the first one to know. Don't worry.";
			close;
		}
	case 5:
		mes "[Master Velofos]";
		mes "Nothing will happen when you try to bind magic without using Magic Binding because you have nothing to hold magic.";
		next;
		mes "[Master Velofos]";
		mes "It's like water that needs a bowl to stay in place.";
		next;
		mes "[Master Velofos]";
		mes "The problem is when you try to forcefully cast a spell that you haven't learned. It'll definately backfire on you.";
		next;
		mes "[Master Velofos]";
		mes "Of course, the damage won't be severe: you'll fall asleep or be thrown into confusion. This is all because there's a conflict between your Magic Book and the force of Magic Binding when you're trying to summon and hold a unlearned spell.";
		next;
		mes "[Master Velofos]";
		mes "Don't try it out just to see what happens for yourself! Falling asleep while casting a spell? There's nothing more humiliating than that to magic practitioners like us.";
		close;
	case 6:
		if ((BaseLevel > 139) && (getskilllv(2217) > 0 || getskilllv(2213) > 0)) {
			if (mac_book < 1) {
				mes "[Master Velofos]";
				mes "I'm sorry, but could you ask someone else? I'm kind of busy right now.";
				close;
			}
			if (mac_book == 1) {
				mes "[Master Velofos]";
				mes "Huh, are you looking for the Ultimate Magic Book? Who sent you?";
				next;
				select("Ms. Lea.");
				mes "[Master Velofos]";
				mes "I'm sorry, but there's not much information left about the Ultimate Magic Book.";
				next;
				mes "[Master Velofos]";
				mes "A few scholars in the Midgard Continent once tried to collect ancient Magic Books and reproduce that book, but...";
				next;
				select("But what?");
				mes "[Master Velofos]";
				mes "Oh yes, perhaps he might know something.";
				next;
				select("Yes, I knew this was coming!");
				mes "[Master Velofos]";
				mes "My brother is just like you. He's very interested in recreating the Ultimate Magic Book.";
				next;
				mes "[Master Velofos]";
				mes "His name is Galfos.";
				mes "He's been taking a great interest in the ancient Magic Books.";
				next;
				mes "[Master Velofos]";
				mes "I didn't support him or give him any advice for his research since I thought he'd give on it pretty quickly, but...";
				next;
				mes "[Master Velofos]";
				mes "If he's discovered anything useful, maybe it can helpful to you.";
				next;
				select("Where's Galfos now?");
				mes "[Master Velofos]";
				mes "I've heard that he's near the Expedition Camp beyond the Dimensional Rift to seek information about the ancient Magic Books.";
				next;
				mes "[Master Velofos]";
				mes "If you want to see him, you should prepare for a long journey.";
				set mac_book,2;
				close;
			}
			if (mac_book > 1) {
				mes "[Master Velofos]";
				mes "Galfos is near the Expedition Camp beyond the Dimensional Rift.";
				next;
				mes "[Master Velofos]";
				mes "If you want to see him, you should prepare for a long journey.";
				close;
			}
		}
		mes "[Master Velofos]";
		mes "Ha ha, I'm sorry, but you should focus on strengthening your body rather than creating Magic Books.";
		close;
	}
}

geffen_in,175,112,4	script	Lea	123,{
	if (checkweight(1201,1) == 0) {
		mes "You're carrying too many items. Please make some room in your bag first.";
		close;
	}
	if ((MaxWeight - Weight) < 1000) {
		mes "You're overweight with items. Please lose some item weight first.";
		close;
	}
	if (wm_book > 0 && (Class == Job_Warlock || Class == Job_Warlock_T || Class == Job_Baby_Warlock)) {
		mes "[Lea]";
		mes "You can only read books here. If you'd like to borrow any books, please receive an approval from 1 manager and 1 High Mage.";
		next;
		mes "[Lea]";
		mes "How may I help you?";
		next;
		select("Master Velofos asked me to bring his Magic Book.");
		mes "[Lea]";
		mes "Are you borrowing a book?";
		next;
		switch (select("Let me think.:I want the Beginner's Magic Books.:I want the Intermediate Magic Books.:I want the Superior Magic Books.:I want the Ultimate Magic Book.")) {
		case 1:
			mes "[Lea]";
			mes "No problem.";
			close;
		case 2:
			mes "[Lea]";
			mes "We're in trouble because so many people want to borrow our Magic Books.";
			next;
			mes "[Lea]";
			mes "Unfortunately, many of our lent books aren't returned on time. That's why we've decided to charge a security deposit.";
			next;
			select("A security deposit?");
			mes "[Lea]";
			mes "Yes. You may pay a minimum of 10,000 Rune-Midgarts zeny. Alternatively, you can bring 2 Old Magic Books or 50 Old Pages. Once you pay the deposit, I'll let you borrow some Magic Books.";
			next;
			set .@Payment, select("Where can I find Old Magic Books and Old Pages?:I'll pay with zeny.:I'll pay with Old Magic Books.:I'll pay with Old Pages.")-1;
			mes "[Lea]";
			if (!.@Payment) {
				mes "I heard that you can find them from Ride Words, Death Words, Bathorys, and other monsters. I ask that you please don't strain yourself to find those items.";
				next;
				mes "[Lea]";
				mes "Your life is more important than anything else, you know?";
				close;
			}
			if ((.@Payment == 1 && Zeny > 10000) || (.@Payment == 2 && countitem(1006) > 1) || (.@Payment == 3 && countitem(1097) > 49)) {
				mes "What kind of Magic Book do you want?";
				next;
				set .@i, select("Let me think.:Magic Book (Fire Bolt):Magic Book (Cold Bolt):Magic Book (Lightning Bolt)")-1;
				mes "[Lea]";
				if (!.@i) {
					mes "No problem.";
					close;
				}
				if (countitem(6188+.@i)) {
					mes "You already have that Magic Book. You can't borrow a new book until you return the current one.";
					next;
					mes "[Lea]";
					mes "Don't you know how many others would want the book you already have? It's a bit selfish to want more than one, you know.";
					close;
				}
				if ((.@Payment == 1 && Zeny > 10000) || (.@Payment == 2 && countitem(1006) > 1) || (.@Payment == 3 && countitem(1097) > 49)) {
					mes "The book's return date is written on the lending card on the back cover of the book.";
					next;
					mes "[Lea]";
					mes "Please try not to lose or damage the book to avoid paying any extra charges.";
					if (.@Payment == 1) set Zeny, Zeny - 10000;
					else if (.@Payment == 2) delitem 1006,2; //Old_Magic_Book
					else delitem 1097,50; //Worn_Out_Page
					getitem 6188+.@i,1; //Magic_Book_FB, Magic_Book_CB, Magic_Book_LB
					close;
				}
			}
			mes "I'm sorry, but you don't have enough funds.";
			close;
		case 3:
			mes "[Lea]";
			mes "Ah, so you want the Intermediate Magic Books. Please pay 50,000 Rune-Midgartian zeny, or you can bring me 2 Old Blue Boxes or 9 Eluniums to borrow the Intermediate Magic Books.";
			next;
			set .@Payment, select("Where can I find Old Blue Boxes and Eluniums?:I'll pay 50,000 zeny.:I'll pay with Old Blue Boxes.:I'll pay with Eluniums.")-1;
			mes "[Lea]";
			if (!.@Payment) {
				mes "Old Blue Boxes are quite rare to find, but they can be obtained from monsters everywhere in the world, including Myst Cases, Megalogons, Mimics, Nightmares, Krabens, Requiems, Nine Tails, Noxiouses, and Byorgues.";
				mes "If you have sufficient funds, you may buy the boxes from street vendors.";
				next;
				mes "[Lea]";
				mes "Eluniums can be obtained from Hyeguns, Zombie Prisoners, Teddy Bears, Obsedians, and Loli Ruris. Or you can refine Rough Eluniums to Eluniums at the Forge in town, and that may be easier.";
				close;
			}
			if ((.@Payment == 1 && Zeny > 50000) || (.@Payment == 2 && countitem(603) > 1) || (.@Payment == 3 && countitem(985) > 8)) {
				mes "What kind of Magic Book do you want?";
				next;
				set .@i, select("Let me think.:Magic Book (Storm Gust):Magic Book (Lord of Vermillion):Magic Book (Meteor Storm):Magic Book (Thunderstorm):Magic Book (Jupitel Thunder):Magic Book (Water Ball):Magic Book (Heaven's Drive):Magic Book (Earth Spike)")-1;
				setarray .@Books[0],6192,6193,6194,6197,6198,6199,6200,6201;
				mes "[Lea]";
				if (!.@i) {
					mes "No problem.";
					close;
				}
				if (countitem(.@Books[.@i-1])) {
					mes "You already have that Magic Book. You can't borrow a new book until you return the current one.";
					next;
					mes "[Lea]";
					mes "Don't you know how many others would want the book you already have? It's a bit selfish to want more than one, you know.";
					close;
				}
				if ((.@Payment == 1 && Zeny > 50000) || (.@Payment == 2 && countitem(603) > 1) || (.@Payment == 3 && countitem(985) > 8)) {
					mes "Thank you for your deposit. The book's return date is written on the lending card on the back cover of the book. Please try not to lose or damage the book and avoid paying compensation.";
					next;
					mes "[Lea]";
					mes "The Intermediate and Superior Magic Books must be returned upon borrowing the Ultimate Magic Book. Remember that you're just borrowing them, so make sure you take good care of those books.";
					if (.@Payment == 1) set Zeny, Zeny - 50000;
					else if (.@Payment == 2) delitem 603,2; //Old_Blue_Box
					else delitem 985,9; //Elunium
					getitem .@Books[.@i-1],1; //Magic_Book_SG, Magic_Book_LOV, Magic_Book_MS, Magic_Book_TS, Magic_Book_JT, Magic_Book_WB, Magic_Book_HD, Magic_Book_ES
					close;
				}
			}
			mes "I'm sorry, but you don't have enough funds.";
			close;
		case 4:
			mes "[Lea]";
			mes "Oh, do you want the Superior Magic Books? For your information, borrowing those Magic Books requires many conditions and restrictions. Are you sure that you want it?";
			next;
			select("Yes.");
			mes "[Lea]";
			mes "I see. If you're determined to borrow the Superior Magic Books, please choose one of the following tyes of payment for the security deposit.";
			next;
			mes "[Lea]";
			mes "[12 Mystery Pieces and 100,000 zeny], [7 Oridecons and 100,000 zeny], or [1 Old Violet Box and 100,000 zeny]. Now how would you like to pay your deposit?";
			next;
			set .@Payment, select("Where can I find those items?:Let me think.:I'll pay with 12 Mystery Pieces and 100,000 zeny.:I'll pay with 7 Oridecons and 100,000 zeny.:I'll pay with 1 Old Violet Box and 100,000 zeny.")-1;
			mes "[Lea]";
			if (!.@Payment) {
				mes "Mystery Pieces can be obtained from machine creatures in the Juperos Dungeon, and they're the fountain of knowledge from the ancient civilization. Ah, I get excited thinking about those artifacts.";
				next;
				mes "[Lea]";
				mes "Oridecons can be obtained from Executioners, Gryphons, Jokers, and Abysmal Knights, but it'll be easier to collect Rough Oridecons than Oridecons.";
				next;
				mes "[Lea]";
				mes "You can refine Rough Oridecons to Oridecons at the Forge in town.";
				next;
				mes "[Lea]";
				mes "Old Violet Boxes can be obtained from Mimics, Megaliths, Orc Lords, Stormy Knights, and Osirises.";
				next;
				mes "[Lea]";
				mes "The boxes are a subject worthy of serious study since they're used to test Schrodinger's pet cat.";
				close;
			}
			if (.@Payment == 1) {
				mes "If you're unable to collect the items for the security deposit, I can offer you an alternate payment method.";
				next;
				mes "[Lea]";
				mes "How does 200,000 Rune-Midgartian zeny sound?";
				next;
				if(select("I'm sorry, but I can't pay that much.:Sounds good.") == 1) {
					mes "[Lea]";
					mes "I see.";
					close;
				}
				mes "[Lea]";
			}
			if ((.@Payment == 1 && Zeny > 199999) || (Zeny > 99999 && ((.@Payment == 2 && countitem(7094) > 11) || (.@Payment == 3 && countitem(984) > 6) || (.@Payment == 4 && countitem(617))))) {
				mes "What kind of Magic Book do you want?";
				next;
				set .@i, select("Let me think.:Magic Book (Earth Strain):Magic Book (Chain Lightning):Magic Book (Crimson Rock):Magic Book (Drain Life)")-1;
				mes "[Lea]";
				if (!.@i) {
					mes "No problem.";
					close;
				}
				if (countitem(6201+.@i)) {
					mes "You already have that Magic Book. You can't borrow a new book until you return the current one.";
					next;
					mes "[Lea]";
					mes "Don't you know how many others would want the book you already have? It's a bit selfish to want more than one, you know.";
					close;
				}
				if ((.@Payment == 1 && Zeny > 199999) || (Zeny > 99999 && ((.@Payment == 2 && countitem(7094) > 11) || (.@Payment == 3 && countitem(984) > 6) || (.@Payment == 4 && countitem(617))))) {
					mes "Thank you for your deposit. The book's return date is written on the lending card on the back cover of the book. Please try not to lose or damage the book and avoid paying compensation.";
					next;
					mes "[Lea]";
					mes "The Intermediate and Superior Magic Books must be returned upon borrowing the Ultimate Magic Book. Remember that you're just borrowing them, so make sure you take good care of those books.";
					if (.@Payment == 1) set Zeny, Zeny - 200000;
					else if (.@Payment == 2) delitem 7094,12; //Mystery_Piece
					else if (.@Payment == 3) delitem 984,7; //Oridecon
					else delitem 617,1; //Old_Violet_Box
					if (.@Payment > 1) set Zeny, Zeny - 100000;
					getitem 6201+.@i,1; //Magic_Book_ES_, Magic_Book_CL, Magic_Book_CR, Magic_Book_DL
					close;
				}
			}
			mes "I'm sorry, but you don't have enough funds.";
			close;
		case 5:
			if ((BaseLevel > 139) && (mac_book < 1) && ((getskilllv(2217) > 0) || (getskilllv(2213) > 0))) {
				mes "[Lea]";
				mes "Did... Did you just say the Ultimate Magic Book?";
				next;
				mes "[Lea]";
				mes "Oh, my....";
				mes "I can't believe someone actually wants that book.";
				next;
				select("Please don't say that you don't have it.");
				mes "[Lea]";
				mes "Frankly, I've never even seen the Ultimate Magic Book.";
				next;
				mes "[Lea]";
				mes "You should ask Master Velofos if you want to know more about that book.";
				next;
				mes "[Lea]";
				mes "I'm sorry that I can't help you more than that.";
				set mac_book,1;
				close;
			}
			if ((BaseLevel > 139) && (mac_book > 0) && ((getskilllv(2217) > 0) || (getskilllv(2213) > 0))) {
				mes "[Lea]";
				mes "You should ask Master Velofos for some information about that book.";
				close;
			}
			mes "[Lea]";
			mes "How about practicing your magic spells for now?";
			next;
			mes "[Lea]";
			mes "In order to obtain the Ultimate Magic Book, you must reach Level 140 and learn Tetera Bolt and Comet.";
			next;
			mes "[Lea]";
			mes "That book can't be used by just anyone, you know?";
			close;
		}
	}
	mes "[Lea]";
	mes "Welcome to the Magic Archive. You can read and borrow books from here under certain conditions.";
	close;
}

mid_camp,255,244,4	script	Galfos	735,{
	if (checkweight(1201,1) == 0) {
		mes "You're carrying too many items. Please make some room in your bag first.";
		close;
	}
	if ((MaxWeight - Weight) < 1000) {
		mes "You're overweight with items. Please lose some item weight first.";
		close;
	}
	if ((Upper == 2) && (Class != Job_Baby_Warlock)) {
		mes "[Galfos]";
		mes "What are you, a baby?";
		mes "I'm not here to babysit. Get lost!";
		close;
	}
	if ((Class != Job_Warlock) && (Class != Job_Warlock_T) && (Class != Job_Baby_Warlock)) {
		mes "[Galfos]";
		mes "My right arm feels hot while my left arm feels cold. I can never get used to this weird weather!";
		close;
	}
	if (getskilllv(2230) < 1) {
		mes "[Galfos]";
		mes "Ah, I'll get myself in trouble if I stay here any longer. Maybe I'm already in...";
		close;
	}
	if (BaseLevel < 140 || (getskilllv(2217) < 1 && getskilllv(2213) < 1)) {
		mes "[Galfos]";
		mes "I'm sorry, but I don't talk to people that aren't even ready for this.";
		close;
	}
	if (mac_book < 2) {
		mes "[Galfos]";
		mes "You look strong, but you don't seem to have any business with me.";
		close;
	}
	if (mac_book == 2) {
		mes "[Galfos]";
		mes "What brings you to me?";
		next;
		select("I heard that you've studied the Ultimate Magic Book.");
		mes "[Galfos]";
		mes "Why, are you interested too?";
		mes "I didn't know someone would actually take an interest in that book. Yes, I'm studying that magic book. How did you find that out?";
		next;
		select("You're Velof's brother, right?");
		mes "[Galfos]";
		mes "Yes, I'm Galfos, and Velofos is my brother.";
		next;
		mes "[Galfos]";
		mes "Wait a minute,";
		mes "did the old man recommend me to you?";
		next;
		select("That's right.");
		mes "[Galfos]";
		mes "Wow!";
		mes "This is surprising. He never took my research very seriously. I'm glad that he finally changed his mind.";
		next;
		mes "[Galfos]";
		mes "Heh! Your timing couldn't be better: I was looking for a test object.";
		next;
		select("A test object?");
		mes "[Galfos]";
		mes "Frankly, I'm only interested in creating the Ultimate Magic Book.";
		next;
		mes "[Galfos]";
		mes "I'm not good at using magic, not to mention that I prefer fists in fighting. Nevertheless, I find Magic Books to be incredibly intriguing.";
		next;
		mes "[Galfos]";
		mes "The problem is that I can't use the Ultimate Magic Book, even if I made one. That's why I can't really test it on my own.";
		next;
		mes "[Galfos]";
		mes "That's why I've been waiting for a true magic practitioner like you that can help me test my Ultimate Magic Book.";
		next;
		select("(What is he talking about?)");
		mes "[Galfos]";
		mes "My research is almost done,";
		mes "and I need to solve one last problem to create the Magic Book.";
		next;
		mes "[Galfos]";
		mes "To make the ancient Ultimate Magic Book, I need an artifact and some spells to fuse into it.";
		next;
		mes "[Galfos]";
		mes "I've perfectly restored the spells based on the ancient documents, but I still have no information about the necessary artifact.";
		next;
		mes "[Galfos]";
		mes "Ah, but there's a silver lining!";
		next;
		select("(Now we're getting somewhere!)");
		mes "[Galfos]";
		mes "Ha ha...";
		mes "There's a great archive in El Dicastes, the Capital City of the Evil Giants, where all knowledge in this world is stored.";
		next;
		mes "[Galfos]";
		mes "Maybe that's the place to find some information about the artifact for this Ultimate Magic Book.";
		next;
		mes "[Galfos]";
		mes "You know what to do, don't you? Find information about the artifact in the El Dicastes archive, using everything in your power.";
		next;
		mes "[Galfos]";
		mes "Afterwards, create and bring me the artifact. We'll talk about creating the Magic Book afterwards.";
		set mac_book,3;
		close;
	}
	if (mac_book == 3) {
		mes "[Galfos]";
		mes "You know what to do, don't you? Find information about the artifact in the El Dicastes archive, using everything in your power.";
		next;
		mes "[Galfos]";
		mes "Afterwards, create and bring me the artifact. We'll talk about creating the Magic Book afterwards.";
		close;
	}
	if (mac_book == 4) {
		mes "[Galfos]";
		mes "Oh, did you find";
		mes "anything useful?";
		next;
		set .@i, select("I've discovered everything about Comet.:I've mastered the zenith of Tetra Vortex.");
		mes "[Galfos]";
		if ((.@i == 1 && countitem(6195)) || (.@i == 2 && countitem(6196))) {
			mes "Are you kidding me? You already have the book!";
			close;
		}
		if ((.@i == 1 && checkquest(12218) == 2) || (.@i == 2 && checkquest(12219) == 2 && checkquest(12220) == 2 && checkquest(12221) == 2 && checkquest(12222) == 2)) {
			mes "Oh my, I sense incredible energy coming from you. This is great! Now we're ready to make the Ultimate Magic Book.";
			next;
			mes "[Galfos]";
			mes "There's one problem, though: I'm so broke that I don't even have enough money to buy the tools to make the book.";
			next;
			mes "[Galfos]";
			mes "I need at least ^0000aa1,000,000 zeny^000000 to buy all the necessary tools. Do you have the money?";
			next;
			if(select("Wh-what? No!:Sure.") == 1) {
				mes "[Galfos]";
				mes "Aw, you don't? It's disappointing, but there's nothing I can do. Come back when you have enough money, okay?";
				close;
			}
			mes "[Galfos]";
			if (Zeny >= 1000000) {
				mes "Alright then, let's get started!";
				next;
				specialeffect2 EF_DISPELL;
				progressbar "ffff00",4;
				specialeffect2 EF_LORD;
				set Zeny, Zeny - 1000000;
				getitem 6194+.@i,1; //Magic_Book_CM, Magic_Book_TV
				mes "[Galfos]";
				mes "Man, I almost lost my control to the incredible magic energy! Here's your Magic Book.";
				next;
				mes "[Galfos]";
				mes "Thank you for making my dream come true. Feel free to come back if you need another one of these books.";
				close;
			}
			mes "Hey, what did I tell you? I can't buy the tools to make the book without money!";
			close;
		}
		mes "Are you sure that you've found something? It doesn't seem like you've learned what we need...";
		close;
	}
	mes "[Galfos]";
	mes "Is there anything else you need?";
	close;
}

dic_in01,25,190,0	script	Mysterious Documents	844,{
	if (isequipped(2782) < 1) {
		mes "I better not forget to equip my ring.";
		close;
	}
	if (ep13_3_invite < 5) {
		mes "When you approach the documents, an Evil Giant that looks like the archive manager tries to call Guard Galton. You should get out of here quickly.";
		close;
	}
	if (checkquest(12165,"PLAYTIME") == 1) {
		mes "The documents are making you feel nauseous. You should come back later after your stomach settles.";
		close;
	}
	if (checkquest(12165,"PLAYTIME") == 2) {
		mes "You don't feel as nauseous anymore. It should be safe to proceed now.";
		erasequest 12165;
		close;
	}
	if ((BaseLevel < 140) || (getskilllv(2217) < 1) && (getskilllv(2213) < 1)) {
		mes "The documents in this container aren't legible. It's no use trying to read them.";
		close;
	}
	specialeffect2 EF_DISPELL;
	progressbar "ffff00",4;
	if (mac_book < 3) {
		mes "You have discovered records about magic, acceleration, and particle waves.";
		close;
	}
	if (mac_book == 3) {
		mes "You have discovered records about magic, acceleration, and particle waves. These documents must be the ones that Galfos is looking for.";
		set mac_book, 4;
		close;
	}
	if (mac_book == 4) {
		set .@r, rand(1,10);
		if (.@r == 1) {
			if (getskilllv(2213) > 0) {
				if (checkquest(12218) == 1) {
					mes "You already own this document.";
					close;
				}
				mes "^660066In order to create the essence of lava, you must refine 40 Burning Hearts at the hottest place on the 2nd floor of the Thor's Volcano Dungeon.^000000";
				mes "^660066You must do this by using the greatest power in that place. The Humans have used this method to study the acceleration of magic particles since ancient times.^000000";
				next;
				mes "You have discovered the ^990099Lava Essence Creation Method^000000. Please check your Quest window for more details.";
				specialeffect2 EF_STEAL;
				close2;
				setquest 12218;
				end;
			}
			mes "Nothing in this document looks useful.";
			close;
		}
		if (.@r == 2) {
			if (getskilllv(2217) > 0) {
				if (checkquest(12219) == 1) {
					mes "You already own this document.";
					close;
				}
				mes "^660066The essence of flame can be refined on stable ground on the 1st floor of the Thor's Volcano Dungeon. 10 Love Coals are necessary to refine the essence.^000000";
				mes "^660066According to Humans' information, this essence constitutes one of the four natural elements.^000000";
				next;
				mes "You have discovered the ^990099Flame Essence Creation Method^000000. Please check your Quest window for more details.";
				specialeffect2 EF_STEAL;
				close2;
				setquest 12219;
				end;
			}
			mes "Nothing in this document looks useful.";
			close;
		}
		if (.@r == 3) {
			if (getskilllv(2217) > 0) {
				if (checkquest(12220) == 1) {
					mes "You already own this document.";
					close;
				}
				mes "^660066I succeeded in refining the essence of glacier deep inside the 3rd floor of the Ice Cave. If you'd like to try, prepare 10 Ice Hearts and go to the following location.^000000";
				next;
				mes "You have discovered the ^990099Glacier Essence Creation Method^000000. Please check your Quest window for more details.";
				specialeffect2 EF_STEAL;
				close2;
				setquest 12220;
				end;
			}
			mes "Nothing in this document looks useful.";
			close;
		}
		if (.@r == 4) {
			if (getskilllv(2217) > 0) {
				if (checkquest(12221) == 1) {
					mes "You already own this document.";
					close;
				}
				mes "^660066I was able to refine the essence of fossil from old rocks on the 2nd floor of the Mine Dungeon. So far, that place is the most stable among all the testing grounds.";
				mes "If you'd like to try, prepare 10 Jubilees and go to the dungeon. Good luck.^000000";
				next;
				mes "You have discovered the ^990099Fossil Essence Creation Method^000000. Please check your Quest window for more details.";
				specialeffect2 EF_STEAL;
				close2;
				setquest 12221;
				end;
			}
			mes "Nothing in this document looks useful.";
			close;
		}
		if (.@r == 5) {
			if (getskilllv(2217) > 0) {
				if (checkquest(12222) == 1) {
					mes "You already own this document.";
					close;
				}
				mes "^660066In order to refine the essence of storm, I visited the Hermit's Checkerboard in Kunlun where the spirit of the wind resides.";
				mes "The refining process was easy, but I had a hard time finding the catalyst, Dragon Teeth.^000000";
				next;
				mes "You have discovered the ^990099Storm Essence Creation Method^000000. Please check your Quest window for more details.";
				specialeffect2 EF_STEAL;
				close2;
				setquest 12222;
				end;
			}
			mes "Nothing in this document looks useful.";
			close;
		}
		if (.@r == 10) {
			mes "You suddenly feel sick, and this nausea won't go away easily. You should try finding the documents you need later.";
			setquest 12165;
			close;
		}
		mes "Nothing here looks special.";
		close;
	}
	mes "You no longer need to search this place.";
	close;
}

function	script	Magic_Book_Essence	{
	if (MaxWeight - Weight < 1000) {
		mes "Please lighten your bag.";
		close;
	}
	if (checkquest(getarg(0)) == 1 && countitem(getarg(1)) >= getarg(2)) {
		specialeffect2 EF_BLIND;
		specialeffect2 EF_BEGINSPELL;
		progressbar "ffff00",4;
		delitem getarg(1),getarg(2);
		if (rand(2)) {
			mes "You have used "+callfunc("F_InsertPlural",getarg(2),getitemname(getarg(1)))+" to create ^999900"+getarg(3)+" Essence^000000.";
			next;
			mes "^008800The "+getarg(3)+" Essence will last permanently, unless there's a problem.^000000";
			completequest getarg(0);
			specialeffect2 EF_LORD;
			close;
		}
		mes "^008888You have failed to refine the essence using "+callfunc("F_InsertPlural",getarg(2),getitemname(getarg(1)))+".^000000";
		close;
	}
	if (checkquest(getarg(0)) == 2) {
		mes "You've already created "+getarg(3)+" Essence in this area.";
		close;
	}
	mes "Someone already used this area.";
	close;
}
thor_v02,163,104,0	script	Powerful Lava Energy#33	844,{ callfunc "Magic_Book_Essence",12218,7097,40,"Lava"; end; }
thor_v01,185,91,0	script	Powerful Flame Energy#33	844,{ callfunc "Magic_Book_Essence",12219,7098,10,"Flame"; end; }
ice_dun03,137,148,0	script	Powerful Glacier Energy	844,{ callfunc "Magic_Book_Essence",12220,7561,10,"Glacier"; end; }
ein_dun02,181,124,0	script	Powerful Fossil Energy	844,{ callfunc "Magic_Book_Essence",12221,7312,10,"Fossil"; end; }
gon_dun02,252,198,0	script	Powerful Storm Energy#33	844,{ callfunc "Magic_Book_Essence",12222,7266,10,"Storm"; end; }
