//================= Hercules Script =======================================
//=       _   _                     _
//=      | | | |                   | |
//=      | |_| | ___ _ __ ___ _   _| | ___  ___
//=      |  _  |/ _ \ '__/ __| | | | |/ _ \/ __|
//=      | | | |  __/ | | (__| |_| | |  __/\__ \
//=      \_| |_/\___|_|  \___|\__,_|_|\___||___/
//================= License ===============================================
//= This file is part of Hercules.
//= http://herc.ws - http://github.com/HerculesWS/Hercules
//=
//= Copyright (C) 2012-2015  Hercules Dev Team
//= Copyright (C)  Euphy
//= Copyright (C)  Joseph
//= Copyright (C)  Gepard
//= Copyright (C)  L0ne_W0lf
//=
//= Hercules is free software: you can redistribute it and/or modify
//= it under the terms of the GNU General Public License as published by
//= the Free Software Foundation, either version 3 of the License, or
//= (at your option) any later version.
//=
//= This program is distributed in the hope that it will be useful,
//= but WITHOUT ANY WARRANTY; without even the implied warranty of
//= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//= GNU General Public License for more details.
//=
//= You should have received a copy of the GNU General Public License
//= along with this program.  If not, see <http://www.gnu.org/licenses/>.
//=========================================================================
//= Sealed Shrine
//================= Description ===========================================
//= Seal away the Great Demon Baphomet.
//================= Current Version =======================================
//= 2.3
//=========================================================================

//== Sealed Catacomb Entrance ==============================
monk_test,309,146,3	script	Friar Patrick#edq	4_M_OLDFRIAR,{
	cutin("ins_cata_pri_n", 2);
	mes("[Friar Patrick]");
	mes("The peace of this world cannot last forever... The hands of Evil are reaching into the world again...");
	next();
	mes("[Friar Patrick]");
	mes("What brought you to this place?");
	next();
	if (countitem(Bapho_Doll) > 0) {
		.@doll = 1;
		.@selection = select("What is this place?", "I want to enter.", "About the Cursed Baphomet Doll.", "Cancel.");
	} else {
		.@selection = select("What is this place?", "I want to enter.", "Cancel.");
	}
	switch (.@selection) {
	case 1:
		mes("[Friar Patrick]");
		mes("Huh... Don't you know? This is St. Capitolina Monastery where the Brothers who wish to become monks train and pray.");
		next();
		mes("[Friar Patrick]");
		mes("And this place is... What can I say... Yes. It's the grave of the Devil. Grave...");
		next();
		mes("[Friar Patrick]");
		mes("The very place where the great Devil who once demolished this world is sleeping.");
		next();
		switch (select("Tell me more.", "Stop talking.")) {
		case 1:
			cutin("ins_cata_pri_n", 2);
			mes("[Friar Patrick]");
			mes("Baphomet... is the name of the Devil... I think you have heard of his name.");
			next();
			mes("[Friar Patrick]");
			mes("Numerous brave men and brothers have trained in this monastery...");
			next();
			mes("[Friar Patrick]");
			mes("Under this gravestone in front of you... Baphomet is sealed.");
			next();
			mes("[Friar Patrick]");
			mes("But... As we speak Satan Morocc is marshalling his powerful magic in order to affect all life on this continent.");
			next();
			mes("[Friar Patrick]");
			mes("Baphomet also... has awakened and is preparing for his revival, into this world, by weakening the power of the seal through the power of Satan Morocc...");
			next();
			mes("[Friar Patrick]");
			mes("Now... I'm looking for someone brave enough to reseal Baphomet in its shrine... as we once did many years ago...");
			next();
			mes("[Friar Patrick]");
			mes("Anyone who fights for good will know, deep inside, that evil is threatening to conquer this world...");
			next();
			mes("[Friar Patrick]");
			mes("Train more and use your skills to protect the world from evil's looming presence...");
			break;
		case 2:
			cutin("ins_cata_pri_n", 2);
			mes("[Friar Patrick]");
			mes("Anyone who fights for good will know, deep inside, that evil is threatening to conquer this world...");
			next();
			mes("[Friar Patrick]");
			mes("Train more and use your skills to protect the world from evil's looming presence...");
			break;
		}
		break;
	case 2:
		if (BaseLevel >= 75) {

			.@party_id = getcharid(CHAR_ID_PARTY);

			mes("[Friar Patrick]");
			mes("Do you mean you'll go to the shrine and reseal Baphomet?");
			next();

			// 12 hour cooldown
			.@ins_bapho_check = questprogress(3040, PLAYTIME);
			// Two hour play limit
			//.@ins_bapho_check2 = questprogress(3045, PLAYTIME);

			if (!.@ins_bapho_check) {
				if (getpartyleader(.@party_id, 2) == getcharid(CHAR_ID_CHAR) && instance_check_party(.@party_id, 2, 75)) {
					mes("[Friar Patrick]");
					mesf("Party name is %s...", getpartyname(.@party_id));
					mesf("Name of the leader is %s...", strcharinfo(PC_NAME));
					.@instance = instance_create(_("Sealed Catacomb"), .@party_id);
					if (.@instance >= 0) {
						for (.@i = 1; .@i <= 2; .@i++) {
							if (instance_attachmap(.@i + "@cata", .@instance) == "") {
								mes("Umm... But it seems that there is a problem here... I'll check quickly. Please wait.");
								instance_destroy(.@instance);
								close();
							}
						}
						instance_set_timeout(7200, 300, .@instance);
						instance_init(.@instance);
					}
					mes("Okay... I'll adjust the shrine's seal so that you and your group can enter.");
					next();
					mes("[Friar Patrick]");
					mes("You will see a sign when the seal has broken. Please wait until the sign appears...");
					next();
					mes("[Friar Patrick]");
					mes("When you see the sign, put your hands on the gravestone... Then you can move inside.");
					next();
					mes("[Friar Patrick]");
					mes("One thing that you should remember is... Anyone who enters this shrine will be cursed by Baphomet and cannot enter or leave while they are cursed.");
					next();
					mes("[Friar Patrick]");
					mes("And one more thing... In this cursed area, some skills, which are protected by outer physical power are prohibited by the effect of the seal.");
					next();
					mes("[Friar Patrick]");
					mes("For example, the skills like ^0000FFSafety Wall and Assumptio^000000... So you'd better prepare before entering the shrine.");
				} else {
					mes("[Friar Patrick]");
					mes("Umm... I recognize your courage, but... I can't permit anyone to enter this place. I can only permit the leader of a party to enter first.");
					next();
					mes("[Friar Patrick]");
					mes("Once the party leader is permitted, the rest of the party can enter. This is a rule of this monastery, so please understand.");
				}
			} else if (.@ins_bapho_check == 1) {
				mes("[Friar Patrick]");
				mes("It seems you have entered this shrine recently... You cannot reenter because Baphomet's Curse still remains. Baphomet's Curse disappears only after a certain amount of time has passed.");
			} else if (.@ins_bapho_check == 2) {
				mes("[Friar Patrick]");
				mes("Umm... It seems that Baphomet's Curse has weakened. I can remove it now.");
				next();
				mes("[Friar Patrick]");
				mes("Haaaaaaap... Hocus Pocus Wingardium Abracadabra!!!!!");
				next();
				erasequest(3040);
				if (questprogress(3041))
					erasequest(3041);
				if (questprogress(3045))
					erasequest(3045);
				mes("[Friar Patrick]");
				mes("Huu... It's over. Now that I've released Baphomet's Curse, you can enter again.");
			}
		} else {
			mes("[Friar Patrick]");
			mes("Umm... You should train more to enter this dangerous place... You should reach at least Lv 75 to enter here.");
			next();
			mes("[Friar Patrick]");
			mes("Please train more and come again.");
		}
		break;
	case 3:
		if (.@doll == 1) {
			mes("[Friar Patrick]");
			mes("That is... the villainous doll that you are holding... Let me see it.");
			next();
			mes("[Friar Patrick]");
			mes("... ... ...");
			next();
			mes("[Friar Patrick]");
			mes("That's correct... I can feel Baphomet's evil inside... So, what will you do with the doll?");
			next();
			mes("[Friar Patrick]");
			mes("It is just a dangerous and useless thing if you do nothing with it... I'll introduce someone who can help you... Do you want to see him?");
			next();
			mes("[Friar Patrick]");
			mes("Go to see ^0000FFRust Blackhand^000000 who is near the main building of the monastery... He will make this doll helpful to you.");
			setquest(3042);
			break;
		}
	case 4:
		mes("[Friar Patrick]");
		mes("Anyone who fights for good will know, deep inside, that evil is threatening to conquer this world...");
		next();
		mes("[Friar Patrick]");
		mes("Train more and use your skills to protect the world from evil's looming presence...");
		break;
	}
	close2();
	cutin("", 255);
	end;
}

monk_test,306,151,3	script	Grave of Baphomet#edq	HIDDEN_NPC,{
	if (countitem(Token_Of_Apostle))
		delitem(Token_Of_Apostle, countitem(Token_Of_Apostle));
	mes("This gravestone has a carving of a wicked devil with large horns. It arouses an ominous feeling.");
	next();
	if (select("Touch the stone.", "Step back.") == 2)
		close();

	// 12 hour cooldown
	.@ins_bapho_check = questprogress(3040, PLAYTIME);
	// Two hour play limit
	//.@ins_bapho_check2 = questprogress(3045, PLAYTIME);

	if (!.@ins_bapho_check) {
		if (has_instance("1@cata") == "") {
			mes("It's cold to the touch. It doesn't respond.");
			close();
		} else {
			mapannounce("monk_test", sprintf(_$("[%s] member of the [%s] party has entered the Sealed Shrine."), strcharinfo(PC_NAME), getpartyname(.@party_id)), bc_map, C_SPRINGGREEN);
			setquest(3040);
			warp("1@cata", 100, 224);
			end;
		}
	} else if (.@ins_bapho_check == 1) {
		mes("[Friar Patrick]");
		mes("It seems you have entered this shrine recently... You cannot reenter because the curse of Baphomet still remains.");
		mes("The curse of Baphomet disappears after a certain amount of time after you entered.");
		close();
	} else if (.@ins_bapho_check == 2) {
		mes("[Friar Patrick]");
		mes("Umm... It seems the curse of Baphomet weakened. I'll clear the bad curse.");
		next();
		mes("[Friar Patrick]");
		mes("Haaaaaaap... Wingardium Leviosa Expecto Patronum !!!!!");
		specialeffect(EF_HOLYHIT, AREA, playerattached());
		erasequest(3040);
		if (questprogress(3041))
			erasequest(3041);
		if (questprogress(3045))
			erasequest(3045);
		next();
		mes("[Friar Patrick]");
		mes("Huu... It's over. Now I released all of the curses on you. You can enter again.");
		close();
	}
}

prt_monk,261,91,3	script	Rust Blackhand#edq	4_M_DWARF,{
	.@new_maje = questprogress(3043);
	mes("[Rust Blackhand]");
	mes("Who are you? What do you want me for?");
	next();
	mes("[Rust Blackhand]");
	mes("You're not a monk, then what do you want?");
	next();
	if (.@new_maje == 1) {
		mes("[Rust Blackhand]");
		mes("Did you bring all of the ingredients?");
		next();
		if (countitem(Bapho_Doll) && countitem(Magestic_Goat) && countitem(Dark_Crystal) > 29 && countitem(Dark_Debris) > 49 && Zeny >= 990000) {
			mes("[Rust Blackhand]");
			mes("kkk... You prepared the ingredients well. Why don't you leave it there and wait?");
			next();
			mes("[Rust Blackhand]");
			mes("Hmm... It's been such a long time since I last saw these wicked horns... kkk... Let me start...");
			next();
			mes("...");
			next();
			mes("... ...");
			next();
			mes("... ... ...");
			next();
			delitem(Bapho_Doll, 1);
			delitem(Magestic_Goat, 1);
			delitem(Dark_Crystal, 30);
			delitem(Dark_Debris, 50);
			Zeny -= 990000;
			completequest(3043);
			getitem(L_Magestic_Goat, 1);
			mes("[Rust Blackhand]");
			mes("It's done. You may be excited, of course. I understand...");
			next();
			mes("[Rust Blackhand]");
			mes("I don't accept complaints or A/S requests, so use it with care. I must go...");
			close();
		} else {
			mes("[Rust Blackhand]");
			mes("Huu... You don't understand what I said. You cannot make anything with these ingredients.");
			next();
			mes("[Rust Blackhand]");
			mes("I'll tell you the ingredients one more time, so please gather them correctly.");
			next();
			mes("[Rust Blackhand]");
			mes("^0000FFCursed Baphomet Doll, Magestic Goat, 30 Crystal of Darkness, 50 Fragment of Darkness^000000, and the most important, production cost is ^0000FF990000^000000 Zeny.");
			close();
		}
	} else if (!.@new_maje && countitem(Bapho_Doll) > 0) {
		switch (select("About the Cursed Baphomet Doll", "Stop talking.")) {
		case 1:
			mes("[Rust Blackhand]");
			mes("What?... Hmmm... Did you get the doll? You're pretty good, unlike your appearance...");
			next();
			mes("[Rust Blackhand]");
			mes("Let me see... Needless to say, Patric must have sent you here to deal with the doll, right?");
			next();
			mes("[Rust Blackhand]");
			mes("Cool... I'll help you make the evil doll useful. What? What can I do?");
			next();
			mes("[Rust Blackhand]");
			mes("I can make the strong and large horns of the wicked devil Baphomet for you. A helm that has his immense power.");
			next();
			mes("[Rust Blackhand]");
			mes("It is called the ^4d4dffGigantic Magestic Goat^000000. You'll realize that the Magestic Goat you're familiar with is nothing in comparison.");
			next();
			mes("[Rust Blackhand]");
			mes("The Cursed Baphomet Doll is the most important ingredient... I'll make you if you want. What would you like to do?");
			next();
			switch (select("I want to make one!", "I don't need one.")) {
			case 1:
				mes("[Rust Blackhand]");
				mes("kkk... Yes, wise men take their chances when the opportunity comes. I'll tell you the ingredients. Don't forget, and bring them all.");
				next();
				mes("[Rust Blackhand]");
				mes("^0000FFCursed Baphomet Doll, Magestic Goat, 30 Crystal of Darkness, 50 Fragment of Darkness^000000, and the most important, production cost is ^0000FF990000^000000 Zeny.");
				next();
				mes("[Rust Blackhand]");
				mes("You can get the Magestic Goat from the weak Baphomet in the Labyrinth Forest. Crystal of Darkness and Fragment of Darkness are from the Incarnation of Morocc.");
				next();
				mes("[Rust Blackhand]");
				mes("I'm sure that you can get the ingredients because you sealed the real Baphomet. Can't you? kkk...");
				next();
				mes("[Rust Blackhand]");
				mes("You'll never know how great this hat is until you get one. If you understood, go and get the ingredients.");
				if (questprogress(3042))
					erasequest(3042);
				setquest(3043);
				close();
			case 2:
				mes("[Rust Blackhand]");
				mes("Huh... Do you? Do whatever you want... Do you really want to let this opportunity go to waste?");
				next();
				mes("[Rust Blackhand]");
				mes("Tut, tut... I don't care if the wicked doll threatens your life all the time!");
				close();
			}
		case 2:
			mes("[Rust Blackhand]");
			mes("What a dull boy he is... huh...");
			close();
		}
	} else if (!.@new_maje && !countitem(Bapho_Doll)) {
		mes("[Rust Blackhand]");
		mes("If you don't have business with me, go away! As you see, I make equipment for the Brothers at the monastery, not for adventurers like you. Do you understand?");
		close();
	} else if (.@new_maje == 2 && countitem(Bapho_Doll)) {
		switch (select("About the Cursed Baphomet Doll", "Stop talking.")) {
		case 1:
			mes("[Rust Blackhand]");
			mes("What?... You again? What do you want this time?");
			next();
			mes("[Rust Blackhand]");
			mes("What? You got another doll from the wicked devil? Umm... You're much better than I thought...");
			next();
			mes("[Rust Blackhand]");
			mes("Alright... I'll help you again.");
			next();
			mes("[Rust Blackhand]");
			mes("If you want to make the doll into a ^4d4dffGigantic Magestic Goat^000000 again, I can make you another.");
			next();
			mes("[Rust Blackhand]");
			mes("I'll tell you the ingredients again. So, do you want to make?");
			next();
			switch (select("I want.", "No, I don't want.")) {
			case 1:
				mes("[Rust Blackhand]");
				mes("kkk... Yes, wise men take their chances when the opportunity comes. I'll tell you the ingredients. Don't forget, and bring them all.");
				next();
				mes("[Rust Blackhand]");
				mes("^0000FFCursed Baphomet Doll, Magestic Goat, 30 Crystal of Darkness, 50 Fragment of Darkness^000000, and the most important, production cost is ^0000FF990000^000000 Zeny.");
				next();
				mes("[Rust Blackhand]");
				mes("You can get the Magestic Goat from the weak Baphomet in the Labyrinth Forest. Crystal of Darkness and Fragment of Darkness are from the Incarnation of Morocc.");
				next();
				mes("[Rust Blackhand]");
				mes("I'm sure that you can get the ingredients because you sealed the real Baphomet. Can't you? kkk...");
				next();
				mes("[Rust Blackhand]");
				mes("You'll never know how great this hat is until you get one. If you understood, go and get the ingredients.");
				if (questprogress(3042))
					erasequest(3042);
				erasequest(3043);
				setquest(3043);
				close();
			case 2:
				mes("[Rust Blackhand]");
				mes("Huh... Do you? Do whatever you want... Do you really want to let this opportunity go to waste?");
				next();
				mes("[Rust Blackhand]");
				mes("Tut, tut... I don't care if the wicked doll threatens your life all the time!");
				close();
			}
		case 2:
			mes("[Rust Blackhand]");
			mes("What a dull boy he is... huh...");
			close();
		}
	} else if (.@new_maje == 2 && !countitem(Bapho_Doll)) {
		mes("[Rust Blackhand]");
		mes("Why are you hanging around here? If you don't want a ^4d4dffGigantic Magestic Goat^000000, go away.");
		close();
	}
}

//== Sealed Shrine Interior ================================
1@cata,1,2,0	script	ins_baphomet_lotto	FAKE_NPC,{
OnInstanceInit:
	// Pick one "true" Gravestone and 12 "false" Gravestones.
	.@true = rand(1, 13);
	for (.@i = 1; .@i <= 13; ++.@i)
		disablenpc(instance_npcname("Gravestone#1F_"+.@i+((.@i == .@true)?"T":"F")));
	disablenpc(instance_npcname("ins_baphomet_lotto"));
	end;
}

1@cata,3,2,0	script	ins_baphomet_lotto2	FAKE_NPC,{
OnEnable:
	for (.@i = 1; .@i <= 12; ++.@i)
		enablenpc(instance_npcname("Bobbing Torch#"+.@i));
	end;
}

1@cata,4,2,0	script	ins_baphomet_lotto3	FAKE_NPC,{
OnEnable:
	.@label$ = instance_npcname("ins_baphomet_lotto3")+"::OnMyMobDead";
	.@map$ = instance_mapname("1@cata");
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), FLAME_SKULL, 1, .@label$);
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), WRAITH_DEAD, 1, .@label$);
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), FLAME_SKULL, 1, .@label$);
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), WRAITH_DEAD, 1, .@label$);
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), FLAME_SKULL, 1, .@label$);
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), WRAITH_DEAD, 1, .@label$);
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), FLAME_SKULL, 1, .@label$);
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), KHALITZBURG, 1, .@label$);
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), EVIL_DRUID, 1, .@label$);
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), KHALITZBURG, 1, .@label$);
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), EVIL_DRUID, 1, .@label$);
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), KHALITZBURG, 1, .@label$);
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), WRAITH_DEAD, 1, .@label$);
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), EVIL_DRUID, 1, .@label$);
	monster(.@map$, 0, 0, _("Apostle of Baphomet"), FLAME_SKULL, 1, .@label$);
	end;

OnDisable:
	killmonster(instance_mapname("1@cata"), instance_npcname("ins_baphomet_lotto3")+"::OnMyMobDead");
	end;

OnMyMobDead:
	.@map$ = instance_mapname("1@cata");
	if (mobcount(.@map$, instance_npcname("ins_baphomet_lotto3")+"::OnMyMobDead") < 1)
		mapannounce(.@map$, _("All apostles of Baphomet are dead!"), bc_map, C_SPRINGGREEN);
	getitem(Token_Of_Apostle, 1);
	end;
}

//== Soul of hero near the north grave =====================
1@cata,141,221,0	script	Gravestone#	CLEAR_NPC,3,3,{
	.@party_id = getcharid(CHAR_ID_PARTY);
	if ('ins_baphomet == 0) {
		mes("The gravestone is trembling...");
		next();
		mes("When touching the gravestone, I hear a voice.");
		next();
		specialeffect(EF_CONE, AREA, playerattached());
		mes("[Voice of the Gravestone]");
		mes("I have waited and waited for a brave adventurer like you who will come back here again...");
		next();
		while (true) {
			switch (select("Who are you?", "Waited for me?", "Cancel.")) {
			case 1:
				mes("[Voice of the Gravestone]");
				mes("I was one of the warriors to stop Baphomet like you. Now, I'm dead and only my soul remains...");
				next();
				mes("[Voice of the Gravestone]");
				mes("As you know... We don't have much time. You can't stop Baphomet by yourselves. The power of the devil has strengthened over the years.");
				next();
				mes("[Voice of the Gravestone]");
				mes("In the past, my companions and I sealed Baphomet at the altar located on the 2nd basement and blocked the entrance.");
				next();
				mes("[Voice of the Gravestone]");
				mes("I moved my soul's essence to my pendant, so that I could remain in this world. That's when I became this grave's guardian.");
				next();
				break;
			case 2:
				mes("[Voice of the Gravestone]");
				mes("Baphomet's power is about to break the seal that we made. If you don't reactivate them... Baphomet's revival will only be a matter of time.");
				next();
				mes("[Voice of the Gravestone]");
				mes("To open the entrance, you must substantialize my soul. I'll open the entrance and reactivate the weakened seals after I am substantilized.");
				next();
				mes("[Voice of the Gravestone]");
				mes("To substantialize my soul, you should find my pendant. You can find my body near a grave here.");
				next();
				mes("[Voice of the Gravestone]");
				mes("If your ^0000FFparty leader^000000 brings me the pendant, my soul can be substantialized. So, hurry up.");
				'ins_baphomet = 1;
				close();
			case 3:
				mes("I can feel the voice becoming faint.");
				close();
			}
		}
	} else if ('ins_baphomet == 1) {
		mes("[Voice of the Gravestone]");
		mes("To open the entrance, you must substantialize my soul. I'll open the entrance and reactivate the weakened seals after I am substantilized.");
		next();
		mes("[Voice of the Gravestone]");
		mes("To substantialize my soul, you should find my pendant. You can find my body near a grave here.");
		next();
		mes("[Voice of the Gravestone]");
		mes("If your ^0000FFparty leader^000000 brings me the pendant, my soul can be substantialized. So, hurry up.");
		close();
	} else if ('ins_baphomet == 2 && getpartyleader(.@party_id, 2) == getcharid(CHAR_ID_CHAR)) {
		mes("[Voice of the Gravestone]");
		mes("Did you find the pendant?");
		next();
		if (countitem(Soul_Pendant) > 0) {
			specialeffect(EF_MAPPILLAR);
			mes("[Voice of the Gravestone]");
			mes("Yes... This is... My pendant...");
			next();
			delitem(Soul_Pendant, 1);
			enablenpc(instance_npcname("Ancient Hero's Soul#1F"));
			disablenpc(instance_npcname("Gravestone#"));
			mes("[Voice of the Gravestone]");
			mes("Now I can substantialize my soul. I'll wait for you in front of the altar of fire located at the center of this grave. Let's meet there.");
			next();
			mapannounce(instance_mapname("1@cata"), _("Ancient Hero's Soul : I'll wait for you in front of the altar of fire located at the center"), bc_map, C_YELLOW);
			mes("I can feel the voice becoming faint.");
			close();
		} else {
			mes("[Voice of the Gravestone]");
			mes("Are you still there? Bring back my pendant as soon as possible.");
			next();
			mes("[Voice of the Gravestone]");
			mes("You can find my body near a grave here. Go and get my pendant there.");
			close();
		}
	} else {
		mes("[Voice of the Gravestone]");
		mes("I want to talk to ^0000FFa representative among your party^000000. Everyone else, wait here.");
		close();
	}
	end;

OnTouch:
	if ('ins_baphomet == 0) {
		mes("'Krrrr... Krrrr...'");
		next();
		mes("I can feel something odd at the grave. It's like someone is calling out silently...");
		close();
	}
	end;

OnInstanceInit: // Temporary fix for @reloadscript.
	'ins_baphomet = 0;
	end;
}

1@cata,176,119,4	script	Ancient Hero's Soul#1F	4_M_CHAMPSOUL,{
	.@party_id = getcharid(CHAR_ID_PARTY);
	cutin("ins_cata_champ_n", 2);
	if ('ins_baphomet == 2) {
		mes("[Ancient Hero's Soul]");
		mes("With your help, my soul can be substantialized. I want to talk more, but we do not have enough time...");
		next();
		mes("[Ancient Hero's Soul]");
		mes("I must be substantialized within the next hour. To reach the Main Altar underground, you must help me perform the ceremony for opening each seal.");
		next();
		mes("[Ancient Hero's Soul]");
		mes("Now I'll tell you what should you do. First, collect ^0000FFEssence of Fire^000000 from the torches on the graves...");
		next();
		mes("[Ancient Hero's Soul]");
		mes("Second, all members who will enter the underground must carry a symbol, called the Token of Apostle.");
		next();
		while (true) {
			cutin("ins_cata_champ_n", 2);
			switch (select("What is Essence of Fire?", "What is a Token of Apostle?", "What should I do?", "I am ready.")) {
			case 1:
				++.@ins_baphomet_1f_1;
				mes("[Ancient Hero's Soul]");
				mes("You can see the torches here and there. These torches are the essence of Thor, the god of Thunder. They are inherited from our predecessors to stop the darkness of Baphomet...");
				next();
				mes("[Ancient Hero's Soul]");
				mes("To open the sealed underground gate, I must be purified by the ^0000FFEssence of Fire^000000 which has the power of Thor. Collect ^0000FF10 Essence of Fire^000000 from the torches.");
				next();
				mes("[Ancient Hero's Soul]");
				mes("One thing you must remember is... ^0000FFEssence of Fire^000000 can only be collected by the Inheritor of Faith.");
				next();
				mes("[Ancient Hero's Soul]");
				mes("I'll give the token of the Inheritor of Faith to the party leader. Only the party leader can collect the ^0000FFEssence of Fire^000000.");
				next();
				break;
			case 2:
				++.@ins_baphomet_1f_2;
				mes("[Ancient Hero's Soul]");
				mes("At that time, it was impossible to get rid of Devil Baphomet by ourselves. After numerous heroes sacrificed their lives, we could barely seal him under this Abbey.");
				next();
				mes("[Ancient Hero's Soul]");
				mes("However, Baphomet never gave up. He continuously strengthened his power. And his power has brought new life to this shrine.");
				next();
				mes("[Ancient Hero's Soul]");
				mes("Some of these monsters have magical powers. Baphomet calls them his 'Apostles'.");
				next();
				mes("[Ancient Hero's Soul]");
				mes("The apostles are cloning themselves to fill the shrine with their evil energy. They are the monsters here in this catacomb.");
				next();
				mes("[Ancient Hero's Soul]");
				mes("Kill the Apostles. They can only be distinguished from their clones because they will possess a ^0000FFToken of Apostle^000000...");
				next();
				mes("[Ancient Hero's Soul]");
				mes("If each party member possesses a ^0000FFToken of Apostle^000000, Baphomet will not be able to perceive your entrance to the Main Altar underground.");
				next();
				mes("[Ancient Hero's Soul]");
				mes("If Baphomet perceives you when you pass through the sealed gate, he may release his tremendous magical power. Then, this abbey will be demolished.");
				next();
				mes("[Ancient Hero's Soul]");
				mes("Kill the apostles and get the ^0000FFToken of Apostle^000000.");
				next();
				break;
			case 3:
				++.@ins_baphomet_1f_3;
				if (getpartyleader(.@party_id, 2) == getcharid(CHAR_ID_CHAR)) {
					mes("[Ancient Hero's Soul]");
					mes("You look like the leader of this party. You need to go and get ^0000FF10 Essence of Fire^000000 from the torches.");
					next();
					mes("[Ancient Hero's Soul]");
					mes("Now I'll carve you the symbol which shows you're a inheritor of faith. Be aware that no one in your party but you can collect the Essence of Fire.");
					next();
					specialeffect(EF_HOLYHIT, AREA, playerattached());
					mes("[Ancient Hero's Soul]");
					mes("You should also carry a ^0000FFToken of Apostle^000000, so find one for yourself too.");
					next();
					mes("[Ancient Hero's Soul]");
					mes("When all of you are ready to go, let me know. I'll open the sealed gate when you're ready.");
					next();
				} else {
					mes("[Ancient Hero's Soul]");
					mes("Make sure that your party leader has listened to my explanation of what you and your companions must do.");
					next();
					mes("[Ancient Hero's Soul]");
					mes("Kill the Apostles of Baphomet and find their ^0000FFToken of Apostle^000000.");
					next();
					mes("[Ancient Hero's Soul]");
					mes("It might be better to kill all of them because there is no way to differentiate them from their clones.");
					next();
					mes("[Ancient Hero's Soul]");
					mes("Are you ready?");
					mes("Make sure that you have listened to all that I have to say before saying that you are ready.");
					next();
				}
				break;
			case 4:
				if (.@ins_baphomet_1f_1 > 0 && .@ins_baphomet_1f_2 > 0 && .@ins_baphomet_1f_3 > 0) {
					cutin("ins_cata_champ_n", 2);
					mes("[Ancient Hero's Soul]");
					mes("Are you ready to go? Then I'll open this sealed gate now.");
					next();
					.@exitloop = 1;
				} else {
					cutin("ins_cata_champ_a", 2);
					mes("[Ancient Hero's Soul]");
					mes("It may be difficult but I wish you luck braving the perils of this catacomb.");
					next();
					mes("[Ancient Hero's Soul]");
					mes("Remember, you need to collect ^0000FF10 Essence of Fire^000000 from the torches and the ^0000FFToken of Apostle^000000 from the Apostles of Baphomet.");
					next();
				}
				break;
			}
			if (.@exitloop)
				break;
		}
		if (getpartyleader(.@party_id, 2) == getcharid(CHAR_ID_CHAR)) {
			mes("[Ancient Hero's Soul]");
			mes("To remind you again, I must be substantialized within the next hour. So everyone, finish your work within that time!");
			'ins_baphomet = 3;
			donpcevent(instance_npcname("ins_baphomet_1f_timer")+"::OnEnable");
			donpcevent(instance_npcname("ins_baphomet_lotto2")+"::OnEnable");
			donpcevent(instance_npcname("ins_baphomet_lotto3")+"::OnEnable");
		} else {
			mes("[Ancient Hero's Soul]");
			mes("To remind you again, I can be substantialized for the next hour. So everyone, finish your work within that time.");
			//'ins_baphomet = 3;
		}
		close2();
		cutin("", 255);
		end;
	} else if ('ins_baphomet == 3 && getpartyleader(.@party_id, 2) == getcharid(CHAR_ID_CHAR)) {
		cutin("ins_cata_champ_n", 2);
		mes("[Ancient Hero's Soul]");
		mes("Did you get 10 ^0000FFEssence of Fire^000000 and ^0000FFToken of Apostle^000000?");
		next();
		if (countitem(Essence_Of_Fire) > 9 && countitem(Token_Of_Apostle) > 0) {
			delitem(Essence_Of_Fire, countitem(Essence_Of_Fire));
			'ins_baphomet = 4;
			mes("[Ancient Hero's Soul]");
			mes("Okay. You've done your work. Now check your companions and tell me when everyone has finished their work.");
		} else {
			mes("[Ancient Hero's Soul]");
			mes("Not ready yet? You should prepare 10 ^0000FFEssence of Fire^000000 and ^0000FFToken of Apostle^000000.");
		}
		close2();
		cutin("", 255);
		end;
	} else if ('ins_baphomet == 3) {
		cutin("ins_cata_champ_n", 2);
		mes("[Ancient Hero's Soul]");
		mes("Do you have a ^0000FFToken of Apostle^000000?");
		next();
		if (countitem(Token_Of_Apostle) > 0) {
			'ins_baphomet = 4;
			mes("[Ancient Hero's Soul]");
			mes("Okay. You've done your work. Tell your representative to check your companions and come to me when everyone has finished their work.");
		} else {
			mes("[Ancient Hero's Soul]");
			mes("Not ready yet? You should prepare ^0000FFToken of Apostle^000000.");
		}
		close2();
		cutin("", 255);
		end;
	} else if ('ins_baphomet == 4 && getpartyleader(.@party_id, 2) == getcharid(CHAR_ID_CHAR)) {
		cutin("ins_cata_champ_n", 2);
		mes("[Ancient Hero's Soul]");
		mes("Are you ready? I opened the sealed gate. To pass the gate, you should carry a ^0000FFToken of Apostle^000000.");
		next();
		'ins_baphomet = 5;
		specialeffect(EF_TELEPORTATION);
		enablenpc(instance_npcname("ins_bapho_to_2f"));
		mes("[Ancient Hero's Soul]");
		mes("Now you can go to the main altar. It is located in the bottom right corner of this floor.");
		next();
		mes("[Ancient Hero's Soul]");
		mes("Your real battle will begin... I'll follow you soon and find a way to help you.");
		next();
		mes("[Ancient Hero's Soul]");
		mes("Go ahead, warriors.");
		cutin("", 255);
		mapannounce(instance_mapname("1@cata"), _("Ancient Hero's Soul : Now you can go to the Main Altar's gate. It is located in the Southeast"), bc_map, C_YELLOW);
		close();
	} else if ('ins_baphomet == 4) {
		cutin("ins_cata_champ_n", 2);
		mes("[Ancient Hero's Soul]");
		mes("Are you ready? I opened the sealed gate. To pass the gate, you should carry a ^0000FFToken of Apostle^000000.");
		next();
		mes("[Ancient Hero's Soul]");
		mes("I'll complete opening the sealed gate when your representative tells me that you're ready.");
		cutin("", 255);
		close();
	} else if ('ins_baphomet == 5) {
		cutin("ins_cata_champ_n", 2);
		mes("[Ancient Hero's Soul]");
		mes("What are you doing? The entrance of the main altar is opened now, go and fight! The entrance is near the bottom right side of this floor.");
		cutin("", 255);
		close();
	} else {
		cutin("ins_cata_champ_n", 2);
		mes("[Ancient Hero's Soul]");
		mes("I have nothing to say to you...");
		cutin("", 255);
		close();
	}

OnInstanceInit:
	disablenpc(instance_npcname("Ancient Hero's Soul#1F"));
	end;
}

//== To 2F Warp ============================================
1@cata,281,12,0	script	ins_bapho_to_2f	WARPNPC,1,1,{
OnTouch:
	if (countitem(Token_Of_Apostle) > 0) {
		delitem(Token_Of_Apostle, countitem(Token_Of_Apostle));
		'ins_baphomet = 5;
		warp(instance_mapname("2@cata"), 80, 144);
		end;
	} else {
		mes("[Ancient Hero's Soul]");
		mes("Where is your Token of Apostle? I said you should carry the Token of Apostle to pass this gate.");
		close();
	}

OnInstanceInit:
	disablenpc(instance_npcname("ins_bapho_to_2f"));
	end;
}

//== Gravestones ===========================================
-	script	Gravestone#SS1	FAKE_NPC,{
	if ('ins_baphomet == 1) {
		getitem(Soul_Pendant, 1);
		'ins_baphomet = 2;
		mes("A small object is shining under a leaning grave.");
		next();
		mesf("[%s]", strcharinfo(PC_NAME));
		mes("I think this is the pendant...");
		close();
	} else {
		mes("I can only feel gloom from this Gravestone.");
		close();
	}
}

1@cata,86,214,0	duplicate(Gravestone#SS1)	Gravestone#1F_1T	CLEAR_NPC
1@cata,200,209,0	duplicate(Gravestone#SS1)	Gravestone#1F_2T	CLEAR_NPC
1@cata,230,195,0	duplicate(Gravestone#SS1)	Gravestone#1F_3T	CLEAR_NPC
1@cata,118,182,0	duplicate(Gravestone#SS1)	Gravestone#1F_4T	CLEAR_NPC
1@cata,193,182,0	duplicate(Gravestone#SS1)	Gravestone#1F_5T	CLEAR_NPC
1@cata,253,156,0	duplicate(Gravestone#SS1)	Gravestone#1F_6T	CLEAR_NPC
1@cata,88,154,0	duplicate(Gravestone#SS1)	Gravestone#1F_7T	CLEAR_NPC
1@cata,127,116,0	duplicate(Gravestone#SS1)	Gravestone#1F_8T	CLEAR_NPC
1@cata,90,98,0	duplicate(Gravestone#SS1)	Gravestone#1F_9T	CLEAR_NPC
1@cata,188,84,0	duplicate(Gravestone#SS1)	Gravestone#1F_10T	CLEAR_NPC
1@cata,244,42,0	duplicate(Gravestone#SS1)	Gravestone#1F_11T	CLEAR_NPC
1@cata,127,32,0	duplicate(Gravestone#SS1)	Gravestone#1F_12T	CLEAR_NPC
1@cata,267,30,0	duplicate(Gravestone#SS1)	Gravestone#1F_13T	CLEAR_NPC

-	script	Gravestone#SS2	FAKE_NPC,{
	mes("I can only feel gloom from this Gravestone.");
	close();
}

1@cata,86,214,0	duplicate(Gravestone#SS2)	Gravestone#1F_1F	CLEAR_NPC
1@cata,200,209,0	duplicate(Gravestone#SS2)	Gravestone#1F_2F	CLEAR_NPC
1@cata,230,195,0	duplicate(Gravestone#SS2)	Gravestone#1F_3F	CLEAR_NPC
1@cata,118,182,0	duplicate(Gravestone#SS2)	Gravestone#1F_4F	CLEAR_NPC
1@cata,193,182,0	duplicate(Gravestone#SS2)	Gravestone#1F_5F	CLEAR_NPC
1@cata,253,156,0	duplicate(Gravestone#SS2)	Gravestone#1F_6F	CLEAR_NPC
1@cata,88,154,0	duplicate(Gravestone#SS2)	Gravestone#1F_7F	CLEAR_NPC
1@cata,127,116,0	duplicate(Gravestone#SS2)	Gravestone#1F_8F	CLEAR_NPC
1@cata,90,98,0	duplicate(Gravestone#SS2)	Gravestone#1F_9F	CLEAR_NPC
1@cata,188,84,0	duplicate(Gravestone#SS2)	Gravestone#1F_10F	CLEAR_NPC
1@cata,244,42,0	duplicate(Gravestone#SS2)	Gravestone#1F_11F	CLEAR_NPC
1@cata,127,32,0	duplicate(Gravestone#SS2)	Gravestone#1F_12F	CLEAR_NPC
1@cata,267,30,0	duplicate(Gravestone#SS2)	Gravestone#1F_13F	CLEAR_NPC

//== Bobbing Torches =======================================
-	script	Bobbing Torch#SS	FAKE_NPC,{
	.@party_id = getcharid(CHAR_ID_PARTY);
	if (getpartyleader(.@party_id, 2) == getcharid(CHAR_ID_CHAR)) {
		if ('ins_baphomet == 3 && countitem(Essence_Of_Fire) < 11) {
			mes("A huge torch appearing as if it can burn everything is bobbing up and down in front of me.");
			next();
			mes("The grand appearance and heat of the fire makes me step back... But I pluck up my courage and reach out to pick up the torch.");
			next();
			specialeffect(EF_HOLYHIT, AREA, playerattached());
			getitem(Essence_Of_Fire, 1);
			mes("The symbol of inheritor shines. Then a small crystal falls into my hand from the torch.");
			disablenpc(instance_npcname(strnpcinfo(NPC_NAME)));
			close();
		} else if ('ins_baphomet == 3 && countitem(Essence_Of_Fire) > 10) {
			mes("You have 10 Essence of Fire already, so you don't need to collect any more.");
			close();
		} else {
			mes("You don't need to collect Essence of Fire anymore.");
			close();
		}
	} else {
		mes("A huge torch appearing as if it can burn everything is bobbing up and down in front of me..");
		next();
		mes("[Unknown Voice]");
		mes("You are not a inheritor of faith. Do not desecrate the Essence of Fire with your disrespectful hands.");
		specialeffect(EF_FIRESPLASHHIT, AREA, playerattached());
		percentheal(-50, 0);
		close();
	}

OnInstanceInit:
	disablenpc(instance_npcname(strnpcinfo(NPC_NAME)));
	end;
}

1@cata,267,210,0	duplicate(Bobbing Torch#SS)	Bobbing Torch#1	CLEAR_NPC
1@cata,85,182,0	duplicate(Bobbing Torch#SS)	Bobbing Torch#2	CLEAR_NPC
1@cata,267,154,0	duplicate(Bobbing Torch#SS)	Bobbing Torch#3	CLEAR_NPC
1@cata,157,139,0	duplicate(Bobbing Torch#SS)	Bobbing Torch#4	CLEAR_NPC
1@cata,193,138,0	duplicate(Bobbing Torch#SS)	Bobbing Torch#5	CLEAR_NPC
1@cata,193,102,0	duplicate(Bobbing Torch#SS)	Bobbing Torch#6	CLEAR_NPC
1@cata,157,102,0	duplicate(Bobbing Torch#SS)	Bobbing Torch#7	CLEAR_NPC
1@cata,113,112,0	duplicate(Bobbing Torch#SS)	Bobbing Torch#8	CLEAR_NPC
1@cata,253,56,0	duplicate(Bobbing Torch#SS)	Bobbing Torch#9	CLEAR_NPC
1@cata,239,56,0	duplicate(Bobbing Torch#SS)	Bobbing Torch#10	CLEAR_NPC
1@cata,71,42,0	duplicate(Bobbing Torch#SS)	Bobbing Torch#11	CLEAR_NPC
1@cata,155,14,0	duplicate(Bobbing Torch#SS)	Bobbing Torch#12	CLEAR_NPC

1@cata,1,1,0	script	ins_baphomet_1f_timer	FAKE_NPC,{
OnInstanceInit:
	disablenpc(instance_npcname("ins_baphomet_1f_timer"));
	end;

OnEnable:
	enablenpc(instance_npcname("ins_baphomet_1f_timer"));
	initnpctimer();
	end;

OnDisable:
	disablenpc(instance_npcname("ins_baphomet_1f_timer"));
	stopnpctimer();
	end;

OnTimer1800000:
	mapannounce(instance_mapname("1@cata"), _("Ancient Hero's Soul : We don't have enough time! Hurry up!"), bc_map, C_YELLOW);
	end;

OnTimer2400000:
	mapannounce(instance_mapname("1@cata"), _("Ancient Hero's Soul : My body is disappearing... Hurry up!"), bc_map, C_YELLOW);
	end;

OnTimer3000000:
	mapannounce(instance_mapname("1@cata"), _("Ancient Hero's Soul : Everything is over... There is no other way but to wait for the next chance..."), bc_map, C_YELLOW);
	end;

OnTimer3050000:
	mapannounce(instance_mapname("1@cata"), _("Ancient Hero's Soul : We failed... However... We still have a chance. I hope you will train yourselves until the time comes."), bc_map, C_YELLOW);
	end;

OnTimer3100000:
	mapannounce(instance_mapname("1@cata"), _("You've failed to open the seal of main altar."), bc_map, C_YELLOW);
	end;

OnTimer3500000:
	instance_warpall("monk_test", 310, 150);
	stopnpctimer();
	end;
}

2@cata,80,144,0	script	ins_2f_enter	FAKE_NPC,3,3,{
OnTouch:
	donpcevent(instance_npcname("ins_2f_enter_broad")+"::OnEnable");
	disablenpc(instance_npcname("ins_2f_enter"));
	end;
}

2@cata,1,1,0	script	ins_2f_enter_broad	FAKE_NPC,{
OnInstanceInit:
OnDisable:
	disablenpc(instance_npcname("ins_2f_enter_broad"));
	end;

OnEnable:
	enablenpc(instance_npcname("ins_2f_enter_broad"));
	initnpctimer();
	end;

OnTimer10000:
	mapannounce(instance_mapname("2@cata"), _("Baphomet : Humans... interfering again..."), bc_map, "0xdb7093");
	end;

OnTimer13000:
	mapannounce(instance_mapname("2@cata"), _("Apostle of Baphomet : Humans! Humans have invaded our sanctum!"), bc_map, C_YELLOW);
	end;

OnTimer16000:
	mapannounce(instance_mapname("2@cata"), _("Apostle of Baphomet : Kill the humans! Do not stop the revival of our Master!"), bc_map, C_YELLOW);
	end;

OnTimer18000:
	mapannounce(instance_mapname("2@cata"), _("Apostle of Baphomet : Hurry up and release the seals of the altars! Our Master's return is upon us!"), bc_map, C_YELLOW);
	stopnpctimer();
	disablenpc(instance_npcname("ins_2f_enter_broad"));
	end;
}

2@cata,50,67,0	script	slave_left	FAKE_NPC,5,5,{
OnTouch:
	.@map$ = instance_mapname("2@cata");
	mapannounce(.@map$, _("Apostle of Baphomet : Kill the humans! Don't let them interrupt the revival of our Master!"), bc_map, C_YELLOW);
	monster(.@map$, 55, 67, _("Apostle of Baphomet"), FLAME_SKULL, 1);
	monster(.@map$, 51, 67, _("Apostle of Baphomet"), WRAITH_DEAD, 1);
	monster(.@map$, 58, 67, _("Apostle of Baphomet"), MINI_DEMON, 1);
	monster(.@map$, 53, 67, _("Apostle of Baphomet"), WRAITH_DEAD, 1);
	monster(.@map$, 54, 67, _("Apostle of Baphomet"), FLAME_SKULL, 1);
	monster(.@map$, 55, 67, _("Apostle of Baphomet"), WRAITH_DEAD, 1);
	monster(.@map$, 56, 67, _("Apostle of Baphomet"), EVIL_DRUID, 1);
	monster(.@map$, 58, 66, _("Apostle of Baphomet"), FLAME_SKULL, 1);
	monster(.@map$, 56, 66, _("Apostle of Baphomet"), EVIL_DRUID, 1);
	monster(.@map$, 60, 66, _("Apostle of Baphomet"), KHALITZBURG, 1);
	monster(.@map$, 59, 66, _("Apostle of Baphomet"), EVIL_DRUID, 1);
	monster(.@map$, 54, 66, _("Apostle of Baphomet"), KHALITZBURG, 1);
	monster(.@map$, 55, 66, _("Apostle of Baphomet"), MINI_DEMON, 1);
	monster(.@map$, 56, 66, _("Apostle of Baphomet"), KHALITZBURG, 1);
	monster(.@map$, 50, 65, _("Apostle of Baphomet"), BANSHEE, 1);
	monster(.@map$, 61, 65, _("Apostle of Baphomet"), MINI_DEMON, 1);
	disablenpc(instance_npcname("slave_left"));
	end;
}

2@cata,109,67,0	script	slave_right	FAKE_NPC,5,5,{
OnTouch:
	.@map$ = instance_mapname("2@cata");
	mapannounce(.@map$, _("Apostle of Baphomet : Kill the humans! Don't let them interrupt the revival of our Master!"), bc_map, C_YELLOW);
	monster(.@map$, 105, 67, _("Apostle of Baphomet"), FLAME_SKULL, 1);
	monster(.@map$, 104, 67, _("Apostle of Baphomet"), WRAITH_DEAD, 1);
	monster(.@map$, 107, 67, _("Apostle of Baphomet"), FLAME_SKULL, 1);
	monster(.@map$, 106, 67, _("Apostle of Baphomet"), WRAITH_DEAD, 1);
	monster(.@map$, 102, 67, _("Apostle of Baphomet"), FLAME_SKULL, 1);
	monster(.@map$, 103, 67, _("Apostle of Baphomet"), WRAITH_DEAD, 1);
	monster(.@map$, 103, 67, _("Apostle of Baphomet"), EVIL_DRUID, 1);
	monster(.@map$, 109, 66, _("Apostle of Baphomet"), EVIL_DRUID, 1);
	monster(.@map$, 108, 66, _("Apostle of Baphomet"), KHALITZBURG, 1);
	monster(.@map$, 101, 66, _("Apostle of Baphomet"), EVIL_DRUID, 1);
	monster(.@map$, 106, 66, _("Apostle of Baphomet"), MINI_DEMON, 1);
	monster(.@map$, 102, 66, _("Apostle of Baphomet"), KHALITZBURG, 1);
	monster(.@map$, 104, 66, _("Apostle of Baphomet"), MINI_DEMON, 1);
	monster(.@map$, 103, 66, _("Apostle of Baphomet"), KHALITZBURG, 1);
	monster(.@map$, 109, 65, _("Apostle of Baphomet"), BANSHEE, 1);
	monster(.@map$, 108, 65, _("Apostle of Baphomet"), MINI_DEMON, 1);
	disablenpc(instance_npcname("slave_right"));
	end;
}

2@cata,79,39,0	script	slave_down	FAKE_NPC,5,5,{
OnTouch:
	.@map$ = instance_mapname("2@cata");
	mapannounce(.@map$, _("Apostle of Baphomet : Kill the humans! Don't let them interrupt the revival of our Master!"), bc_map, C_YELLOW);
	monster(.@map$, 78, 41, _("Apostle of Baphomet"), FLAME_SKULL, 1);
	monster(.@map$, 79, 42, _("Apostle of Baphomet"), WRAITH_DEAD, 1);
	monster(.@map$, 78, 46, _("Apostle of Baphomet"), FLAME_SKULL, 1);
	monster(.@map$, 81, 41, _("Apostle of Baphomet"), WRAITH_DEAD, 1);
	monster(.@map$, 81, 42, _("Apostle of Baphomet"), FLAME_SKULL, 1);
	monster(.@map$, 79, 43, _("Apostle of Baphomet"), WRAITH_DEAD, 1);
	monster(.@map$, 77, 40, _("Apostle of Baphomet"), EVIL_DRUID, 1);
	monster(.@map$, 79, 41, _("Apostle of Baphomet"), KHALITZBURG, 1);
	monster(.@map$, 79, 42, _("Apostle of Baphomet"), EVIL_DRUID, 1);
	monster(.@map$, 79, 43, _("Apostle of Baphomet"), KHALITZBURG, 1);
	monster(.@map$, 79, 48, _("Apostle of Baphomet"), EVIL_DRUID, 1);
	monster(.@map$, 78, 49, _("Apostle of Baphomet"), KHALITZBURG, 1);
	monster(.@map$, 78, 41, _("Apostle of Baphomet"), MINI_DEMON, 1);
	monster(.@map$, 74, 42, _("Apostle of Baphomet"), MINI_DEMON, 1);
	monster(.@map$, 72, 48, _("Apostle of Baphomet"), BANSHEE, 1);
	monster(.@map$, 72, 38, _("Apostle of Baphomet"), MINI_DEMON, 1);
	disablenpc(instance_npcname("slave_down"));
	end;
}

//== Magical Seals =========================================
-	script	Magical Seal#SS	FAKE_NPC,{
	.@seal_check = questprogress(3041, PLAYTIME);
	if (.@seal_check == 1) {
		specialeffect(EF_SILENCEATTACK, AREA, playerattached());
		percentheal(-50, 0);
		sc_start(Eff_Stone, 30000, 0);
		mes("Your SP has not recovered yet. You lost your SP on the altar, but it seems the power of the seal has returned.");
		close();
	}
	if (.@seal_check == 2)
		erasequest(3041);
	specialeffect(EF_LEXDIVINA);
	disablenpc(instance_npcname(strnpcinfo(NPC_NAME)));
	.@map$ = instance_mapname("2@cata");
	if (strnpcinfo(NPC_NAME_HIDDEN) == "0")
		areamobuseskill(.@map$, 79, 81, 10, BAPHOMET_I, "NPC_INVINCIBLEOFF", 1, 0, 0, e_hlp, 0);
	else if (strnpcinfo(NPC_NAME_HIDDEN) == "2")
		areamobuseskill(.@map$, 123, 109, 10, BAPHOMET_I, "NPC_INVINCIBLEOFF", 1, 0, 0, e_hlp, 0);
	else if (strnpcinfo(NPC_NAME_HIDDEN) == "4")
		areamobuseskill(.@map$, 123, 22, 10, BAPHOMET_I, "NPC_INVINCIBLEOFF", 1, 0, 0, e_hlp, 0);
	else if (strnpcinfo(NPC_NAME_HIDDEN) == "8")
		areamobuseskill(.@map$, 35, 21, 10, BAPHOMET_I, "NPC_INVINCIBLEOFF", 1, 0, 0, e_hlp, 0);
	else if (strnpcinfo(NPC_NAME_HIDDEN) == "10")
		areamobuseskill(.@map$, 35, 109, 10, BAPHOMET_I, "NPC_INVINCIBLEOFF", 1, 0, 0, e_hlp, 0);
	percentheal(-50, 0);
	sc_start(Eff_Stone, 20000, 0);
	setquest(3041);
	mapannounce(.@map$, _("The seal activated by putting magical power into the altar."), bc_map, "0x87ceeb");
	mes("I can feel the power of the altar came back by adding magical power.");
	next();
	mes("But you can't use your magic for 3 minutes because you used your SP on the altar.");
	close();

OnInstanceInit:
	disablenpc(instance_npcname(strnpcinfo(NPC_NAME)));
	end;
}

2@cata,79,81,0	duplicate(Magical Seal#SS)	Magical Seal#0	CLEAR_NPC
2@cata,123,109,0	duplicate(Magical Seal#SS)	Magical Seal#2	CLEAR_NPC
2@cata,123,22,0	duplicate(Magical Seal#SS)	Magical Seal#4	CLEAR_NPC
2@cata,35,21,0	duplicate(Magical Seal#SS)	Magical Seal#8	CLEAR_NPC
2@cata,35,109,0	duplicate(Magical Seal#SS)	Magical Seal#10	CLEAR_NPC

2@cata,79,65,0	script	The Main Altar#ss	CLEAR_NPC,{
	.@party_id = getcharid(CHAR_ID_PARTY);
	if ('ins_baphomet == 5 && getpartyleader(.@party_id, 2) == getcharid(CHAR_ID_CHAR)) {
		mes("An evil power, too terrible to describe, lies under the great altar radiating a violet color.");
		next();
		mes("Complicated Magical Rune letters blink rapidly, attempting to suppress the dreadful power within.");
		next();
		mes("The bottom of the Main Altar trembles furiously.");
		next();
		specialeffect(EF_METEORSTORM);
		specialeffect(EF_METEORSTORM);
		mesf("[%s]", strcharinfo(PC_NAME));
		mes("Watch out! Something... Something is coming.");
		'ins_baphomet = 6;
		donpcevent(instance_npcname("ins_2f_hero_broad")+"::OnEnable");
		disablenpc(instance_npcname("The Main Altar#ss"));
		close();
	} else {
		mes("An evil power, too terrible to describe, lies under the great altar radiating a violet color.");
		next();
		mes("Complicated Magical Rune letters blink rapidly, attempting to suppress the dreadful power within.");
		close();
	}
	end;
}

2@cata,80,63,4	script	Ancient Hero's Soul#2F	4_M_CHAMPSOUL,{
	cutin("ins_cata_champ_s", 2);
	if (questprogress(3041))
		erasequest(3041);
	mes("[Ancient Hero's Soul]");
	mes("Good job, my descendants... You've finished the long-cherished task that me and my bretheren could not complete.");
	next();
	mes("[Ancient Hero's Soul]");
	mes("I really appreciate your help.");
	mes("Our souls can finally rest in peace...");
	next();
	mes("[Ancient Hero's Soul]");
	mes("The struggle for peace on this world will never end. But... my role here is finally over because there are brave heroes like you.");
	next();
	switch (select("Let me leave the shrine.", "Stop talking.")) {
	case 1:
		mes("[Ancient Hero's Soul]");
		mes("Okay. I'll let you and your group leave here safely.");
		next();
		mes("[Ancient Hero's Soul]");
		mes("If you leave, please say hello to Patrick for me.");
		cutin("", 255);
		'ins_baphomet = 0;
		warp("monk_test", 310, 150);
		close();
	case 2:
		mes("[Ancient Hero's Soul]");
		mes("Do you still have something to do here? If you're done I'll let you leave safely...");
		cutin("", 255);
		close();
	}

OnInstanceInit:
	disablenpc(instance_npcname("Ancient Hero's Soul#2F"));
	end;
}

2@cata,1,2,0	script	ins_2f_hero_broad	FAKE_NPC,{
OnEnable:
	enablenpc(instance_npcname("ins_2f_hero_broad"));
	initnpctimer();
	end;

OnDisable:
	disablenpc(instance_npcname("ins_2f_hero_broad"));
	end;

OnTimer3000:
	mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : My God! The seal of the Main Altar is weakening!"), bc_map, C_YELLOW);
	end;

OnTimer6000:
	mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : My descendants... Listen carefully to what I'm going to say."), bc_map, C_YELLOW);
	end;

OnTimer9000:
	mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : The altars that control the Main Altar's power are located in the Northeast, Southeast, Southwest and Northwest corners of this room."), bc_map, C_YELLOW);
	end;

OnTimer12000:
	mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : Find these altars and activate their seals before Baphomet revives."), bc_map, C_YELLOW);
	end;

OnTimer15000:
	mapannounce(instance_mapname("2@cata"), _("Baphomet : It's too late, weaklings... Now, you'll feel the despair of death!"), bc_map, "0xdb7093");
	end;

OnTimer17000:
	mapannounce(instance_mapname("2@cata"), _("Baphomet : No one can harm me here. You will be my first sacrifice."), bc_map, "0xdb7093");
	donpcevent(instance_npcname("control_baphomet")+"::OnEnable");
	donpcevent(instance_npcname("ins_2f_hero_broad2")+"::OnEnable");
	stopnpctimer();
	disablenpc(instance_npcname("ins_2f_hero_broad"));
	end;
}

2@cata,3,3,0	script	control_baphomet	FAKE_NPC,{
OnInstanceInit:
OnDisable:
	disablenpc(instance_npcname("control_baphomet"));
	end;

OnEnable:
	enablenpc(instance_npcname("control_baphomet"));
	donpcevent(instance_npcname("2f_callmon_pattern_c")+"::OnEnable");
	monster(instance_mapname("2@cata"), 79, 64, "Baphomet#", BAPHOMET_I, 1, instance_npcname("control_baphomet")+"::OnMyMobDead");
	end;

OnMyMobDead:
	.@map$ = instance_mapname("2@cata");
	if (mobcount(.@map$, instance_npcname("control_baphomet")+"::OnMyMobDead") < 1) {
		'ins_baphomet = 7;
		erasequest(3041);
		mapannounce(.@map$, _("Baphomet : No! Nonono! How dare these weaklings defeat me!... No!!..."), bc_map, "0xdb7093");
		enablenpc(instance_npcname("Ancient Hero's Soul#2F"));
		disablenpc(instance_npcname("slave_down"));
		disablenpc(instance_npcname("slave_left"));
		disablenpc(instance_npcname("slave_right"));
		donpcevent(instance_npcname("ins_2f_hero_broad")+"::OnDisable");
		donpcevent(instance_npcname("ins_2f_hero_broad2")+"::OnDisable");
		donpcevent(instance_npcname("ins_2f_hero_pattern_c")+"::OnDisable");
		donpcevent(instance_npcname("2f_callmon_pattern_c")+"::OnDisable");
		donpcevent(instance_npcname("2f_callmon_pattern")+"::OnDisable");
		donpcevent(instance_npcname("ins_2f_hero_pattern")+"::OnDisable");
		donpcevent(instance_npcname("ins_2f_enter_broad")+"::OnDisable");
		donpcevent(instance_npcname("control_baphomet")+"::OnDisable");
		disablenpc(instance_npcname("control_baphomet"));
	}
	end;
}

2@cata,2,2,0	script	ins_2f_hero_broad2	FAKE_NPC,{
OnInstanceInit:
OnDisable:
	disablenpc(instance_npcname("ins_2f_hero_broad2"));
	end;

OnEnable:
	enablenpc(instance_npcname("ins_2f_hero_broad2"));
	initnpctimer();
	end;

OnTimer8000:
	mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : Don't be discouraged, Baphomet can still be defeated!"), bc_map, C_YELLOW);
	end;

OnTimer11000:
	mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : Go to the altars and activate their seals."), bc_map, C_YELLOW);
	end;

OnTimer13000:
	mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : Once the seals recover their power, Baphomet will be vulnerable."), bc_map, C_YELLOW);
	end;

OnTimer16000:
	mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : You should lure Baphomet to the unsealed Altars. Otherwise, your efforts will be futile."), bc_map, C_YELLOW);
	end;

OnTimer19000:
	mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : We have only 1 hour to stop Baphomet. If time runs out, the power of the seals will be useless."), bc_map, C_YELLOW);
	end;

OnTimer22000:
	mapannounce(instance_mapname("2@cata"), _("Baphomet : It's useless. Make more seals. I'll crush them all. None of you will survive!"), bc_map, "0xdb7093");
	end;

OnTimer26000:
	mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : The magical power of the central seal is running out. Go to the central seal and put the magical power."), bc_map, C_YELLOW);
	enablenpc(instance_npcname("Magical Seal#0"));
	disablenpc(instance_npcname("Magical Seal#2"));
	disablenpc(instance_npcname("Magical Seal#4"));
	disablenpc(instance_npcname("Magical Seal#8"));
	disablenpc(instance_npcname("Magical Seal#10"));
	donpcevent(instance_npcname("ins_2f_hero_pattern_c")+"::OnEnable");
	stopnpctimer();
	disablenpc(instance_npcname("ins_2f_hero_broad2"));
	end;
}

2@cata,4,1,0	script	2f_callmon_pattern_c	FAKE_NPC,{
OnInstanceInit:
	disablenpc(instance_npcname("2f_callmon_pattern_c"));
	end;

OnEnable:
	enablenpc(instance_npcname("2f_callmon_pattern_c"));
	initnpctimer();
	donpcevent(instance_npcname("2f_callmon_pattern_c")+"::OnGo");
	end;

OnDisable:
	stopnpctimer();
	disablenpc(instance_npcname("2f_callmon_pattern_c"));
	end;

OnGo:
	donpcevent(instance_npcname("2f_callmon_pattern")+"::OnEnable");
	end;

OnTimer3600000:
	donpcevent(instance_npcname("2f_callmon_pattern_c")+"::OnDisable");
	end;
}

2@cata,4,2,0	script	2f_callmon_pattern	FAKE_NPC,{
OnInstanceInit:
	disablenpc(instance_npcname("2f_callmon_pattern"));
	end;

OnEnable:
	enablenpc(instance_npcname("2f_callmon_pattern"));
	stopnpctimer();
	initnpctimer();
	end;

OnDisable:
	disablenpc(instance_npcname("2f_callmon_pattern"));
	stopnpctimer();
	end;

OnTimer300000:
	enablenpc(instance_npcname("slave_down"));
	enablenpc(instance_npcname("slave_left"));
	enablenpc(instance_npcname("slave_right"));
	donpcevent(instance_npcname("2f_callmon_pattern_c")+"::OnGo");
	end;
}

2@cata,3,1,0	script	ins_2f_hero_pattern_c	FAKE_NPC,{
OnInstanceInit:
	disablenpc(instance_npcname("ins_2f_hero_pattern_c"));
	end;

OnEnable:
	enablenpc(instance_npcname("ins_2f_hero_pattern_c"));
	initnpctimer();
	donpcevent(instance_npcname("ins_2f_hero_pattern_c")+"::OnGo");
	end;

OnGo:
	donpcevent(instance_npcname("ins_2f_hero_pattern")+"::OnEnable");
	end;

OnDisable:
	stopnpctimer();
	disablenpc(instance_npcname("Magical Seal#0"));
	disablenpc(instance_npcname("Magical Seal#2"));
	disablenpc(instance_npcname("Magical Seal#4"));
	disablenpc(instance_npcname("Magical Seal#8"));
	disablenpc(instance_npcname("Magical Seal#10"));
	donpcevent(instance_npcname("ins_2f_hero_pattern")+"::OnDisable");
	disablenpc(instance_npcname("ins_2f_hero_pattern_c"));
	end;

OnTimer3600000:
	mapannounce(instance_mapname("2@cata"), _("Baphomet : krrrr... Now you can't stop me with the seals. All you can do is wait for death!"), bc_map, "0xdb7093");
	end;

OnTimer3605000:
	mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : We can't stop Baphomet with the magical power of the seals anymore. Now everything depends on God..."), bc_map, C_YELLOW);
	donpcevent(instance_npcname("ins_2f_hero_pattern_c")+"::OnDisable");
	end;
}

2@cata,3,2,0	script	ins_2f_hero_pattern	FAKE_NPC,{
OnInstanceInit:
	disablenpc(instance_npcname("ins_2f_hero_pattern"));
	end;

OnEnable:
	enablenpc(instance_npcname("ins_2f_hero_pattern"));
	initnpctimer();
	end;

OnDisable:
	disablenpc(instance_npcname("ins_2f_hero_pattern"));
	stopnpctimer();
	end;

OnTimer70000:
	switch (rand(1, 5)) {
	case 1:
		mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : The seal of the Main Altar is running out. Strengthen the Main Altar's seal!"), bc_map, C_YELLOW);
		enablenpc(instance_npcname("Magical Seal#0"));
		disablenpc(instance_npcname("Magical Seal#2"));
		disablenpc(instance_npcname("Magical Seal#4"));
		disablenpc(instance_npcname("Magical Seal#8"));
		disablenpc(instance_npcname("Magical Seal#10"));
		break;
	case 2:
		mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : The magical power of the seal at 2 o'clock is running out. Go to 2 o'clock and put the magical power in the seal."), bc_map, C_YELLOW);
		disablenpc(instance_npcname("Magical Seal#0"));
		enablenpc(instance_npcname("Magical Seal#2"));
		disablenpc(instance_npcname("Magical Seal#4"));
		disablenpc(instance_npcname("Magical Seal#8"));
		disablenpc(instance_npcname("Magical Seal#10"));
		break;
	case 3:
		mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : The magical power of the seal at 4 o'clock is running out. Go to 4 o'clock and put the magical power in the seal."), bc_map, C_YELLOW);
		disablenpc(instance_npcname("Magical Seal#0"));
		disablenpc(instance_npcname("Magical Seal#2"));
		enablenpc(instance_npcname("Magical Seal#4"));
		disablenpc(instance_npcname("Magical Seal#8"));
		disablenpc(instance_npcname("Magical Seal#10"));
		break;
	case 4:
		mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : The magical power of the seal at 8 o'clock is running out. Go to 8 o'clock and put the magical power in the seal."), bc_map, C_YELLOW);
		disablenpc(instance_npcname("Magical Seal#0"));
		disablenpc(instance_npcname("Magical Seal#2"));
		disablenpc(instance_npcname("Magical Seal#4"));
		enablenpc(instance_npcname("Magical Seal#8"));
		disablenpc(instance_npcname("Magical Seal#10"));
		break;
	case 5:
		mapannounce(instance_mapname("2@cata"), _("Ancient Hero's Soul : The magical power of the seal at 10 o'clock is running out. Go to 10 o'clock and put the magical power in the seal."), bc_map, C_YELLOW);
		disablenpc(instance_npcname("Magical Seal#0"));
		disablenpc(instance_npcname("Magical Seal#2"));
		disablenpc(instance_npcname("Magical Seal#4"));
		disablenpc(instance_npcname("Magical Seal#8"));
		enablenpc(instance_npcname("Magical Seal#10"));
	}
	stopnpctimer();
	donpcevent(instance_npcname("ins_2f_hero_pattern_c")+"::OnGo");
	end;
}

1@cata,1,1,0	script	ins_1f_spawn_mobs	FAKE_NPC,{
OnInstanceInit:
	.@map$ = instance_mapname("1@cata");
	monster(.@map$, 0, 0, _("Zombie Master"), ZOMBIE_MASTER, 10);
	monster(.@map$, 0, 0, _("Wraith Dead"), WRAITH_DEAD, 10);
	//monster(.@map$, 0, 0, _("Ancient Mimic"), ANCIENT_MIMIC, 10);
	monster(.@map$, 0, 0, _("Flame Skull"), FLAME_SKULL, 10);
	monster(.@map$, 0, 0, _("Skeleton General"), SKELETON_GENERAL, 10);
	monster(.@map$, 0, 0, _("Zombie Master"), ZOMBIE_MASTER, 10);
	monster(.@map$, 0, 0, _("Skeleton General"), SKELETON_GENERAL, 10);
	monster(.@map$, 0, 0, _("Flame Skull"), FLAME_SKULL, 10);
	monster(.@map$, 0, 0, _("Wraith Dead"), WRAITH_DEAD, 10);
	monster(.@map$, 0, 0, _("Wraith Dead"), WRAITH_DEAD, 10);
	monster(.@map$, 0, 0, _("Khalitzburg"), KHALITZBURG, 10);
	monster(.@map$, 0, 0, _("Khalitzburg"), KHALITZBURG, 10);
	monster(.@map$, 0, 0, _("Flame Skull"), FLAME_SKULL, 10);
	monster(.@map$, 0, 0, _("Flame Skull"), FLAME_SKULL, 10);
	monster(.@map$, 0, 0, _("Ancient Mimic"), ANCIENT_MIMIC, 10);
	monster(.@map$, 0, 0, _("Zombie Master"), ZOMBIE_MASTER, 10);
	monster(.@map$, 0, 0, _("Ancient Mimic"), ANCIENT_MIMIC, 10);
	monster(.@map$, 0, 0, _("Zombie Master"), ZOMBIE_MASTER, 10);
	monster(.@map$, 0, 0, _("Wraith Dead"), WRAITH_DEAD, 10);
	monster(.@map$, 0, 0, _("Skeleton General"), SKELETON_GENERAL, 10);
	monster(.@map$, 0, 0, _("Skeleton General"), SKELETON_GENERAL, 10);
	monster(.@map$, 0, 0, _("Wind Ghost"), WIND_GHOST, 10);
	monster(.@map$, 0, 0, _("Wind Ghost"), WIND_GHOST, 10);
	monster(.@map$, 0, 0, _("Wind Ghost"), WIND_GHOST, 10);
	monster(.@map$, 0, 0, _("Lude"), LUDE, 10);
	monster(.@map$, 0, 0, _("Lude"), LUDE, 10);
	monster(.@map$, 0, 0, _("Evil Druid"), EVIL_DRUID, 10);
	monster(.@map$, 0, 0, _("Evil Druid"), EVIL_DRUID, 10);
	monster(.@map$, 0, 0, _("Evil Druid"), EVIL_DRUID, 10);
	monster(.@map$, 0, 0, _("Banshee"), BANSHEE, 10);
	monster(.@map$, 0, 0, _("Dark Illusion"), DARK_ILLUSION, 1);
	disablenpc(instance_npcname("ins_1f_spawn_mobs"));
	end;
}
