code:
package classes.Scenes.Dungeons
{
	import classes.*;
	import classes.GlobalFlags.kFLAGS;
	import classes.GlobalFlags.kGAMECLASS;
	import classes.BaseContent;
	import classes.Scenes.Dungeons.DungeonAbstractContent;
	import classes.Scenes.Dungeons.DungeonCore;
	import classes.Scenes.Dungeons.WizardTower.ArchInquisitorVilkus;
	import classes.Scenes.Dungeons.WizardTower.ArchitectJeremiah;
	import classes.Scenes.Dungeons.WizardTower.AspectOfLaurentius;
	import classes.Scenes.Dungeons.WizardTower.ImpStatue;
	import classes.Scenes.Dungeons.WizardTower.IncubusStatue;
	import classes.Scenes.Dungeons.WizardTower.SentinelOfApostasy;
	import classes.Scenes.Dungeons.WizardTower.SentinelOfBlasphemy;
	import classes.Scenes.Dungeons.WizardTower.SentinelOfHeresy;
	import classes.Scenes.Dungeons.WizardTower.SuccubusStatue;
	import classes.GlobalFlags.kACHIEVEMENTS;
import classes.Scenes.Places.CorruptedCoven;
import classes.display.SpriteDb;

public class WizardTower extends DungeonAbstractContent
	{

		public function WizardTower()
		{
		}

		public function get map():DungeonMap{
			return game.dungeons.map;
		}

		public function get playerLoc():int{
			return game.dungeons.playerLoc;
		}

		public var floor:int = 0;
		public var puzzleSolved:Boolean = false;

		public var puzzleLayout:Array = new Array(81);
		public var mirrorLayout:Array = new Array(81);
		public var puzzleplayerLoc:int = 41;
		public var mirrorLoc:int = 41;
		public const DUNGEON_DEFEATED_SENTINELS:int = 1;
		public const DUNGEON_SOLVED_GATEPUZZLE:int = 2;
		public const DUNGEON_SOLVED_MIRRORPUZZLE:int = 4;
		public const DUNGEON_MET_JEREMIAH:int = 8;
		public const DUNGEON_DESTROYED_JEREMIAH:int = 16;
		public const DUNGEON_FOUND_LOCKEDDOOR:int = 32;
		public const DUNGEON_ALLOWED_EXIT:int = 64;
		public const DUNGEON_LEARNED_KEY:int = 128;
		public const DUNGEON_DEFEATED_VILKUS:int = 256;
		public const DUNGEON_JEREMIAH_REFORMED:int = 512;
		public const DUNGEON_LAURENTIUS_FOUND:int = 1024;
		public const DUNGEON_LAURENTIUS_DEFEATED:int = 2048;
		public const DUNGEON_TOWER_AWOKEN:int = 4096;

		override public function initRooms():void {
			dungeonRooms = new Object();
            dungeonRooms[58] = roomEntrance;
            dungeonRooms[50] = roomEntrance2;
            dungeonRooms[42] = corridor;
            dungeonRooms[41] = pillar;
            dungeonRooms[43] = pillar;
            dungeonRooms[33] = pillar2;
            dungeonRooms[35] = pillar2;
            dungeonRooms[25] = staircase;
            dungeonRooms[27] = staircase;
            dungeonRooms[26] = studyRoom;
            dungeonRooms[18] = upperCorridor;
            dungeonRooms[10] = finalDoor;
            dungeonRooms[2] = theChamber;
        }

		override public function initMap():void{
            if(!onPillar){
                this.dungeonMap = 		   [1,1,0,1,1,-1,-1,-1, //7
											1,1,2,1,1,-1,-1,-1, //15
											1,1,0,1,1,-1,-1,-1, //23
											1,0,0,0,1,-1,-1,-1, //31
											1,0,1,0,1,-1,-1,-1, //39
											1,0,0,0,1,-1,-1,-1, //47
											1,1,0,1,1,-1,-1,-1, //55
											1,1,0,1,1,-1,-1,-1]; //63
                if (flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_DESTROYED_JEREMIAH) this.dungeonMap[10] = 0;
            }else{
                this.dungeonMap = 		   [1,1,1,1,1,-1,-1,-1, //7
											1,1,0,1,1,-1,-1,-1, //15
											1,1,0,1,1,-1,-1,-1, //23
											1,1,0,1,1,-1,-1,-1, //31
											1,1,0,1,1,-1,-1,-1, //39
											1,1,0,1,1,-1,-1,-1, //47
											1,1,0,1,1,-1,-1,-1, //55
											1,1,0,1,1,-1,-1,-1]; //63
            }
		}

		public function roomEntrance2():void{
            outputText("Despite the sourceless light that allows you to move forward, this section of the corridor still puts you on edge. Blood and scorch marks adorn the walls and floor in great amounts. A few mummified bodies are strewn across the floor, some of them scorched. It seems this sterile environment has prevented any decomposition from taking place.");
            if (player.inte > 85) outputText("\nFrom a cursory examination, you'd wager these bodies are a decade old, maybe more.");
            else outputText("\nYou're not really sure how old these are. What happened here?");
		}

		public function corridor():void{
            if (!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_SOLVED_MIRRORPUZZLE)) mirrorPuzzle();
            else{
                outputText("The corridor leads to a much more open area, opening up on both sides and the ceiling to reveal a massive circular room that absolutely dwarfs you."
                        + "You cannot see the ceiling when you look skywards. A massive pillar of the same smooth obsidian sits on its center, stretching towards the sky. The light pulses continue to emerge from the corridor, climbing the pillar and alighting several thousand runes along its height.");
                outputText("\n\nNow freed from the maze, you're able to proceed.");
            }
		}

		public function pillar():void{
            outputText("Going around the massive pillar just makes more evident that this tower does not conform to regular conventions of space. It was sizable on the outside, but the scale of your surroundings and the pillar defies ordinary expectation. This is a marvel of engineering, magical or otherwise.");
		}

		public function pillar2():void{
            outputText("While you saw plenty of corpses in the corridor, what you see here is less gruesome, reminding you instead of the sentinels guarding the entrance to the tower. Several statues--and statue pieces--are littered throughout the area. They all depict demons: Incubi, Succubi, Omnibi and Imps.");
            outputText("\n\nTheir poses vary; some of them are cowering in horror, others are laughing, others apparently are in the middle of climax with other demons. The craftsmanship is superb, and the marble truly looks like flesh, each muscle and tendon sculpted to a level of skill you didn't imagine possible.");
            outputText("\n\nAhead lies a massive, steep staircase, that winds towards a higher level at the back of the colossal pillar.");
		}

		public function staircase():void{
            outputText("Having reached the end of the width of the pillar, you climb the staircase. More statues rest on the steps, some broken, some intact.");
            outputText("\n\nThe steps are incredibly numerous. You look back and notice that you're a lot higher than what you previously thought possible when you first began climbing; it seems this Tower is once again defying space.");
            outputText("\nRegardless, you seem to be making progress, and haven't fallen into another trap. You spot the end of the stairs ahead. Just in time, you think. Your [legs] are burning from all this climbing.");
		}

		public function upperCorridor():void{
            outputText("You are in a corridor in the upper levels of the Tower. It is much more narrow than the one that led you to the massive room with the pillar, but it is otherwise similar, made of polished obsidian, adorned with glowing runes. In contrast with the other rooms, it is devoid of signs of battle, statues or corpses.");
            if (!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_FOUND_LOCKEDDOOR)){
                outputText("\nYou make little progress before finding another thing stopping you. This time, it is a stone door, sealed shut and protected by some kind of energy field. A cursory examination of the gate reveals its sturdiness is too high for anything short of an army of wizards, minotaurs, or both, to have any chance of destroying. You'll have to find a key.");
                flags[kFLAGS.WIZARD_TOWER_PROGRESS] += DUNGEON_FOUND_LOCKEDDOOR;
            }
		}

		public function finalDoor():void{
            outputText("With Jeremiah's seal undone, the door that once blocked this corridor is now unlocked, though it is still hard to push open due to its sheer heft."
                    + "\nTo the north, there's another set of stairs, similar in length to the one that led you to the study room.");
            if (flags[kFLAGS.VILKUS_DEFEAT_DAY] + 2 <= game.time.days && flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_DEFEATED_VILKUS){
                outputText("\nWhile this section of the tower was silent before, it now hums and pulses with light, much like the rest of the building. The pulses of light move upstairs, beckoning you to visit Vilkus' grave once again.");
            }else{
                outputText("\nThe silence here is deafening, and you can no longer hear the humming of the magical pulses that exist in the rest of the Tower.");
                if(!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_DEFEATED_VILKUS)) outputText(" There is a distinct sense of foreboding as you look to the darkness above. You should be ready for a long, grueling fight.");

            }
		}

		public function theChamber():void{
            if (!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_DEFEATED_VILKUS)) encounterVilkus();
            else{
                outputText("The chamber Vilkus resided in is now silent, the lethicite crystals turned gray and powerless. Vilkus' ashes have been carried by the winds and spread throughout Mareth; perhaps his intended way of departing life.");
                if (flags[kFLAGS.VILKUS_DEFEAT_DAY] + 2 <= game.time.days && !(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_LAURENTIUS_FOUND)){
                    outputText("\n\nA pillar of light sits at the center of the room, of obvious magical source.");
                    addButton(0, "Light", meetLaurentius).hint("Walk into the light. Something within you tells that you should prepare yourself for anything.");
                }
            }
		}
		override public function runFunc():void{
			clearOutput();
			if (onPillar){
				runFuncPillar();
				return;
			}
			dungeons.setDungeonButtons();
			if(game.dungeons.map.walkedLayout.indexOf(dungeons.playerLoc) == -1) game.dungeons.map.walkedLayout.push(dungeons.playerLoc);
			dungeonRooms[dungeons.playerLoc]();
		output.flush();
		}

		public function runFuncPillar():void{
			clearOutput();
			dungeons.setDungeonButtons();
			switch(dungeons.playerLoc){
				case 58:
					outputText("You are light. Pure energy.");
					dungeons.setDungeonButtons();
					break;
				case 50:
					outputText("Rise through the Pillar. Though your mind cannot comprehend it, your soul Knows it.");
					dungeons.mapLayout[58] = 1;
					dungeons.setDungeonButtons();
					break;
				case 42:
					outputText("We are all just wishes of greater beings, stardust taken will and form. But as they have Ascended us, we can Ascend ourselves.");
					dungeons.mapLayout[50] = 1;
					dungeons.setDungeonButtons();
					break;
				case 34:
					outputText("You have gone through much, to be here. What your body Endures, your soul Learns. And what the soul Learns, it can make material.");
					dungeons.mapLayout[42] = 1;
					dungeons.setDungeonButtons();
					break;
				case 26:
					outputText("There is one lesson your body has yet to Endure.");
					dungeons.mapLayout[34] = 1;
					dungeons.setDungeonButtons();
					break;
				case 18:
					outputText("How to forget itself, and let the soul rise forth.");
					dungeons.mapLayout[26] = 1;
					dungeons.setDungeonButtons();
					break;
				case 10:
					outputText("Welcome, [name].");
					dungeons.mapLayout[12] = 1;
					dungeons.setDungeonButtons();
					menu();
					doNext(meetLaurentius2);
					break;

			}
		output.flush();
		}

		public function enterDungeon():void {
			clearOutput();
			game.inDungeon = true;
			//game.dungeonLoc = 80;
			outputText("Your arduous travels along the Volcanic Crag finally bear fruit. You reach the top of a cliff, and are amazed by what you see; On the horizon, in the middle of a cracked and scorched plain, lies a massive, half-toppled tower."
			+ "\n\nIt is easily 600 feet tall. Its obsidian surface gleams even in the scarce light that manages to pierce the volcanic dust and ash that clouds the area. Along its trapezoidal length, several cracks and missing pieces scar the otherwise mirror-polished surface of the tower. You notice a massive embossed circle at its top, though you can’t make out details from the distance you’re at."
			+ "\n\nYou move ahead, carefully hiking down the jagged cliff. Travelling through the Crag is always a complex task, but the rocks are especially treacherous here, the hill obscenely steep."
			+ "\nAfter a few difficult minutes, you’re at the base of the cliff, and the sheer scale of the tower becomes more apparent to you. It is one of the most impressive things you’ve seen in Mareth yet, even in its decrepit state.You continue your approach.\n\nAs you get closer, the fire-hot wind becomes stronger, lifting volcanic ash in great waves that makes it difficult to both see and breathe. Unbidden, you narrow your eyes and soldier on.");
			doNext(enterDungeonpt2);
		}

		public function enterDungeonpt2(fromEnterDungeon:Boolean = true):void{
			//Generic text
			clearOutput();
			if (fromEnterDungeon) cheatTime(0.16);
			else cheatTime(1);
			outputText(fromEnterDungeon ? "Ten minutes have passed" : "An hour has past" + " by the time you’ve reached the base of the tower. Its gate is apropos to the rest of the structure: 63 feet tall and 36 feet wide, it is massive, although almost unnoticeable, its existence only signalized by thin cuts into the base of the tower.");
			if(!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_DEFEATED_SENTINELS))outputText("\n\nStanding in front of the gate are three stone statues. One depicts a warrior, armored in exquisite plate armor, wielding a spear. The second depicts a wizard, clad in robes, holding a book in one hand, staff in another. The third, is of a naked man, wielding a shield. They show a curious scene; the Warrior points his spear at the naked man, his gaze clearly one of rage and anger. The Wizard holds her staff aloft, towards the sky, eyes closed and book held tightly against her chest. The Naked Man cowers, protecting himself with his shield while standing in a fetal position."
			+ "\n\nThe statues are cracked and covered with volcanic ash. It stands curiously distinct from the rest of the landscape. You’re unsure what it is supposed to represent.");
			outputText("\n\nDo you enter the tower or leave?");
			if (flags[kFLAGS.FOUND_WIZARD_TOWER] < 1) {
				outputText("\n\nThe Tower of Deception is now accessible from the 'Dungeons' submenu inside 'Places' menu.");
				flags[kFLAGS.FOUND_WIZARD_TOWER] = 1;
			}
			menu();
			addButton(0, "Enter", enterForReal).hint("Enter the Tower of Deception.");
			addButton(14, "Leave", exitDungeon);
		}

		public function exitDungeon():void{
			clearOutput();
			outputText("You turn your back on the Tower and head back to camp.");
			game.inDungeon = false;
			dungeons.usingAlternative = false;
			doNext(camp.returnToCampUseTwoHours);
		}
		public function enterForReal():void{
			menu();
			clearOutput();
			if(!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_DEFEATED_SENTINELS)){
				outputText("You move towards the gate, ignoring the statues."
				+ "\n\nWhen you touch the smooth surface of the gate, you hear rumbling and the sound of stone rubbing against stone behind you, even through the howling of the volcanic dust storms."
				+ "\nYou turn around and behold the three statues once again. They have shifted from their still scene, and are now all staring at you, their emotionless gaze sending you warnings of danger."
				+ "\nThe Warrior is the first one to move again, pointing its spear defiantly at you. The Wizard follows by brandishing her staff, and the Naked Man weakly raises his shield."
				+ "\n\nYou have a fight on your hands!");
				var desc:String = "You are fighting a trio of living statues, enchanted by some unknown force. One statue depicts a Warrior, clad in exquisite plate armor and wielding a soldier's spear, in a perpetual gaze of rage and anger. The second depicts a Wizard, clad in robes, holding a book in one hand, staff in another. Her face is one of melancholy, of one who can barely contain her suffering. The third is a Naked Man, cowering behind his hefty circular shield. They are all exquisitely crafted, although the ravages of time and the merciless storms of the Volcanic Crag have worn some of the beauty of the craftsmanship away.";
				startCombatMultiple(new SentinelOfApostasy, new SentinelOfBlasphemy, new SentinelOfHeresy, null, victoryAgainstSentinels, defeatedBySentinels, victoryAgainstSentinels, defeatedBySentinels, desc);
			}else{
				outputText("You stand at the gate of the obsidian Tower. The statues are destroyed and inert, barely visible now that the dust storms have buried them. The uncomfortable heat and tearing wind force you to make a decision: Will you enter the mysterious tower or leave?");
				if (!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_SOLVED_GATEPUZZLE)) addButton(0, "Enter Tower", toGatePuzzle).hint("Advance towards the gate and attempt to find a way to open it.");
				else addButton(0, "Enter Tower", enterTower).hint("Enter the Tower proper.");
				addButton(14, "Leave", exitDungeon).hint("Leave and return to camp.");
			}
		}

		public function defeatedBySentinels():void{
			clearOutput();
			outputText("You fall, overwhelmed by your enemies."
			+ "The Warrior and the Naked Man approach you to confirm their victory, while the Wizard kneels in a prayer. You stare at them, their marble eyes piercing you and filling you with fear for your fate."
			+ "\nWith one last twitch, you attempt a half-hearted attack, which sends the Naked Man running back in horror. The Warrior stands still, and your attack bounces harmlessly on the enchanted stone."
			+ " He raises his spear and points it down, towards your heart. You cringe, preparing for the upcoming attack."
			+ "\n\nHe plunges his weapon down, easily piercing through your [armor] and skin, wounding your heart. You feel pain, the taste of blood, and then cold. Absolute cold."
			+ "\n\nHis victory confirmed, the Warrior returns to the other two statues, and they soon revert to their previous, immortal scene.");
			game.gameOver();
			combat.cleanupAfterCombat();
		}

		public function victoryAgainstSentinels():void{
			clearOutput();
			outputText("With one decisive strike, the final living statue falls."
			+"\n\nYou move towards the gate once again, moving past the Naked Man, cracked in half, and the Wizard, her remaining hand clutching her stone book tightly. You touch the smooth surface of the gate, looking for some switch to open it."
			+"\n\nYou heard the sound of stone once again, and ready your [weapon] as you turn around. To your surprise, the Warrior is back up, holding his spear with a single hand. He dashes to your direction and fiercely throws his weapon at you!"
			+"\nFortunately, his weakened condition impaired his aim, and the spear crashes onto the tower, making a small scratch on its surface as the weapon is obliterated into several pieces. The Warrior falls to the ground, shattering, and definitely ending the fight."
			+"\n\nYou don’t understand what magic enchanted these statues, or why they stand guard here, but you know that the answer must lie inside.");
			flags[kFLAGS.WIZARD_TOWER_PROGRESS] += DUNGEON_DEFEATED_SENTINELS;
			combat.cleanupAfterCombat();
			addButton(0, "Continue", toGatePuzzle).hint("Advance towards the gate and attempt to find a way to open it.");
		}

		public function toGatePuzzle(retry:Boolean = false):void{
			clearOutput();
			if (!retry){
				outputText("You touch the surface of the tower once again, attempting to find a way to open the gate."
				+ "\n\nAfter several minutes of frustrating search, you spot a small magical circle etched between the lines that separate each door of the gate. Upon placing your hand there for a few seconds, several glowing words appear on the surface of the gate, as if written by an invisible hand carrying a red-hot pen.\n\n");
			}
			outputText("[say: Three Wizards congregated to built this tower. Althanos, Laurentius, Garland. One of them is the First.]"
			+ "\n[say: Althanos claims he is the First.]"
			+ "\n[say: Laurentius claims Garland is not the First.]"
			+ "\n[say: Garland claims he is not the First.]"
			+ "\n[say: At least one of them is telling the truth. At least one of them is lying. Who is the First?]");
			menu();
			addButton(0, "Althanos", answerPuzzle, 0).hint("Althanos is the First.");
			addButton(1, "Laurentius", answerPuzzle, 1).hint("Laurentius is the First.");
			addButton(2, "Garland", answerPuzzle, 2).hint("Garland is the First.");
			addButton(14, "Leave", leave).hint("Leave the gate and its puzzle.");
		}

		public function answerPuzzle(answer:int):void{
			clearOutput();
			menu();
			if (answer != 1){
				outputText("The words disappear, and soon after a new sentence is written on the gate."
				+"\n[say: You are not welcome here. Pay for your ignorance, and fuel apotheosis.]"
				+"\n\nThe magic circle lights up, runes rotating along its center axis. Suddenly, a bright flash emerges from it, leaving you blinded!"
				+"\nBefore you can run or react, you feel the unmistakable sensation of being hit with magic. You tremble as you feel drained and fatigued, your spirit and body withering and rotting!");
				dynStats("str", -5, "tou", -5, "spe", -5, "int", -5);
				outputText(" (-5 to all combat stats!)");
				outputText("\nWould you like to try again?");
				addButton(0, "Try again", toGatePuzzle, true).hint("Try another answer.");
			}else{
				outputText("The words disappear, and soon after a new sentence is written on the gate."
				+"[say: Welcome, Wizard. May apotheosis reach us all soon.]"
				+"\nThe lines delineating the gate glow, and before your eyes, the massive obsidian slab of stone disappears, revealing the entrance!"
				+"\nWhatever is inside will probably not be happy about your intrusion. It is best to be prepared. You may not be able to immediately return to your camp afterwards.");
				flags[kFLAGS.WIZARD_TOWER_PROGRESS] += DUNGEON_SOLVED_GATEPUZZLE;
				addButton(0, "Enter Tower", enterTower).hint("Enter the Tower proper.");
			}
			addButton(14, "Leave", leave).hint("Leave the gate and its puzzle.");

		}

		public function enterTowerDimensionalShift():void{
			clearOutput();
			outputText("You step inside the obsidian tower, moving into a pitch black corridor, weapons at the ready for any ambush."
            + "The sweltering heat of the landscape behind you is soon replaced by a rather noticeable coolness. You move forward slowly, stepping ever more carefully as the natural light from the exterior dims."
			+ "\n\nAfter minutes of walking, all you see is pitch black. The corridor is unnaturally long; you’re sure you have walked the width of the tower by now. You turn around, but there’s not even a glint of the exterior’s light. Your stomach sinks as you realize you may have been lured into a trap."
			+ "\n\nSuddenly, a pulse of light irradiates from the floor beneath you, several glowing lines dashing from your position and moving towards the darkness, crawling between the divisions of the mirror-polished obsidian slabs. The light converges into one point in the distance, almost too far to see."
			+ "\nIn a flash, the entire corridor lights up, and you’re thrown to the ground by an unseen force. You get up, dazed, feeling as if you’re being pushed to every direction at once, the corridor spinning and rotating, falling and being raised. You nearly hurl on the spot as the corridor itself stretches, widening, heightening and shortening in random amounts. You look at your hands and panic as they too begin morphing, bending in impossible dimensions!");
			doNext(dimensionalShift2);
		}

		public function dimensionalShift2():void{
			clearOutput();
			outputText("Almost as suddenly as it started, it ends, and you find yourself in a sufficiently well lit room. Breathing rapidly, you get up and begin analyzing your surroundings.");
			doNext(enterTower);
		}

		public function roomEntrance():void{
			clearOutput();
			outputText("You’re standing in an extremely spacious corridor, made completely out of some sort of obsidian stone, polished to a mirror shine."
			+ " Magical runes adorn much of the walls and ceiling. Every once in a while, a pulse of light crawls through the corridor with an audible hum, like a high pitched glass harp, causing the runes to glow intensely for a few moments.");
			if (flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_ALLOWED_EXIT) addButton(0, "Leave", leave).hint("Leave the Tower.");
			else addButtonDisabled(0, "Leave", "Some type of magic is warping space behind you, impeding your escape!");
		}

		public function studyRoom():void{
			clearOutput();
			outputText("The stairs lead to what appears to be a study room, of scale proportional to the rest of the tower. Several statue pieces are strewn across the place, and the many bookshelves are destroyed, their books burned to the point of unreadability."
			+ "The alchemy tables are also destroyed, their fluids dried and stuck to the floor. Various weapons, from swords to spears and riding crops are also on the floor, destroyed.");
			outputText("\nAn archway on the back of the room leads to another corridor.");
			if(flags[kFLAGS.CORR_WITCH_COVEN] & CorruptedCoven.TALKED_JEREMIAH_WEAPONS && !(flags[kFLAGS.CORR_WITCH_COVEN] & CorruptedCoven.BROUGHT_JEREMIAH_BACK)){
				outputText("\n\nYou're partially surprised to see Circe sitting on a chair, chatting with Jeremiah over a glass of wine. Two glasses of wine, in fact, although Jeremiah has trouble" +
						" sipping from his, the goblet itself being further than two feet away from him. He looks at you and smiles in his usual kind but confused manner." +
						"\n[say: Why, hello, [name]. This old lady showed up here just now and started talking to me with several strange and difficult words. You can join in too!]" +
						"\nYou look at Circe. She bows her head slightly to greet you, her face evidently angered over being called an old lady. [say: Yes, [name], join us. You can take Jeremiah's" +
						" wine, I'm sure the old man wouldn't mind.]" +
						"\n\nYou take the goblet and sit on a large block of marble. You ask them what they're chatting about." +
						"\n[say: We're talking about whatever happens to go through Jeremiah's mind. There's plenty in there that can't be found anywhere else, especially now that Vilkus burned" +
						" everything to ash. He's... difficult to understand sometimes, though.]" +
						"\nJeremiah seem unfazed by her remark. [say: The old lady asked for my knowledge on the creation of golems and the Inquisitor's techniques for arcane smithing. Says it's" +
						" for \"the good of Mareth\", \"the future of magic\", \"to get a new perspective\" and other big-brained bromides. Oh my, she's a wizard alright.]" +
						"\nCirce lifts her hand towards the statue, as if to say [say: See?]" +
						"\n\nYou ask Jeremiah why he's unwilling to part with his knowledge. He strokes his stone beard." +
						"\n[say: Well, if there's one thing that I learned from living here for decades, is that no one should ever trust a solitary sorcerer without drilling into their minds a" +
						" bit. They quite often go insane, and have powers beyond comprehension! A dangerous combination.]" +
						"\nYou point out that, for all intents and purposes, he is a solitary wizard." +
						"\n[say: Oh, don't I know it!] He says, chuckling. [say: And I tried to kill you twice!]" +
						"\nCirce sighs." +
						"\n\n[say: So, Jeremiah here decided to test me on my merits first, and he's just rambling about his past, for the most part. I can tell he's incredibly wise, but his time" +
						" here has certainly torn holes in his mind.]" +
						"\nYou tell her that that's a certainty, considering what transpired here, but he may also just be testing your patience." +
						"\n\n[say: Certainly a possibility. Well, if that's the case...] Circe gets up from her chair, finishing her glass of wine with a long gulp." +
						"\n[say: We're going to have this discussion somewhere more comfortable.]" +
						"\n\nShe waves her hands, creating a circle of pure energy around herself and Jeremiah. You look at him, and he raises and lowers his brow repeatedly, probably interpreting" +
						" her sentence in a completely different way. " +
						"\n[say: Don't be a stranger, [name].] Circe says, clutching her fist." +
						"\nJeremiah smiles to you, and, in a flash, both of them vanish." +
						"\n\nSounds like neither Circe or Jeremiah are solitary wizards anymore.");
				flags[kFLAGS.CORR_WITCH_COVEN] += CorruptedCoven.BROUGHT_JEREMIAH_BACK;
				return;
			}
			if(flags[kFLAGS.CORR_WITCH_COVEN] & CorruptedCoven.BROUGHT_JEREMIAH_BACK){
				outputText("You see a square on the floor on the other end of the room that is particularly lacking in dust and ash. Just the place where Jeremiah used to rest.");
				return;
			}

			if (!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_MET_JEREMIAH)){
				outputText("\n\nA peculiar work in progress lies on the other end of the room. It is a massive slab of marble, about 12 feet fall. A bearded, bald old man is half sculpted out of the slab; his upper body has been carved with the same quality as the other statues, but its lower half is just unsculpted marble.");
				addButton(0, "Approach Statue", meetJeremiah).hint("Approach the half-done statue.");
			}else{
				if (flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_DESTROYED_JEREMIAH && !(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_DEFEATED_VILKUS)) outputText("\n\nThe remains of Jeremiah stand at the end of the room.");
				else if (!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_JEREMIAH_REFORMED) && flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_DEFEATED_VILKUS){
					clearOutput();
					menu();
					outputText("You reach the study room again, and your eyes widen when you look to the end of the room. Jeremiah is there, completely reformed!");
					outputText("\nYou brandish your [weapon] and look at him menacingly, waiting to see what his reaction will be.");
					outputText("\nHe stares at you. [say: Hello, [name]. That is your name, right? Nice pose.]");
					outputText("\n\nYou narrow your eyes and look at his marble face. He seems just as oblivious as before.");
					outputText("\n\n[say: Ah, it's about the whole \"pummelling me into tiny pieces\" thing, right? I got better. No hard feelings. In fact, I feel better than ever! My mind is... clear, for the first time in ages!]");
					outputText("\n\nYou lower your weapon. He seems honest, after all.");
					outputText("\nJeremiah may have better answers for some questions now.");
					flags[kFLAGS.WIZARD_TOWER_PROGRESS] += DUNGEON_JEREMIAH_REFORMED;
					doNext(runFunc);
				}else{
					outputText("\n\nJeremiah stands at the end of the room, as he always does.");
					addButton(0, "Jeremiah", meetJeremiah).hint("Approach the curious statue.");
				}

			}

		}

		public function meetJeremiah():void{
			clearOutput();
			menu();
			if(!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_MET_JEREMIAH)){
				outputText("You carefully approach the statue, wary of any more extra-dimensional traps.");
				outputText("\n\nWhat has been sculpted out of the marble is exquisite; the old man's face and beard are crafted to perfection. His upper body is clad in beautiful hooded robes, and the sword heraldry emblazoned within is elegant, too.");
				if (flags[kFLAGS.GOTTEN_INQUISITOR_ARMOR] > 0 || flags[kFLAGS.GOTTEN_INQUISITOR_CORSET] > 0 || flags[kFLAGS.GOTTEN_INQUISITOR_ROBES] > 0) outputText(" You've seen it before; it's the Inquisitor heraldry!");
				outputText("\n\nYou move back to analyze the whole sculpture. Well crafted, but nothing necessarily unique about it.");
				outputText("\nThat is, until it turns its head and starts speaking.");
				outputText("\n\n[say: Well, hello there. You seem to be pretty interested in me! That's fine, I'm interested in your too, hehe- erh, not in the way you'd expect. You're real, aren't you?]");
				outputText("\n\nAfter your initial recoil, you turn your head slightly and answer that yes, you are real.");
				outputText("\n\n[say: That is exactly what a hallucination would say! Or maybe the hallucinations want me to think that they would say that, so that I wouldn't pay attention to real people. Well, I'll just have to go with Faith here. IIIIt's what we do.]");
				outputText("\n\nSomething in that voice is familiar. You ponder it for a few moments and it becomes clear; this is the same voice you heard when you were sent to the maze!\n You confront him with that information.");
				outputText("\n\n[say: I did Maze you, didn't I? Did I? I don't know, really. My memory isn't very good nowadays... when I begin remembering stuff, it just clears up again!]");
				outputText("\n\nYou ask your question again.");
				outputText("\n\n[say: Oh, hoho, sorry. Well, if I mazed you, then that's because you are an invader. That is one of my jobs, you know. Send anything that enters this tower to that extradimensional maze, so they won't bother Vilkus. Hah, curious is the trap maker's art, isn't it? Its efficacy unwitnessed by its own eyes.]");
				outputText("\n\nYou raise a brow.");
				outputText("\n\n[say: Or I guess, in this case, the inefficacy was witnessed by my eyes. Good to see you're alive, though. If you are alive. Vilkus didn't tell me to kill anything that left the maze, so I guess I won't. IIII'm Jeremiah, person that did a thing in the past. Nice to meet you.]");
				outputText("\n\nThe statue smiles at you. It appears genuinely unaware of how dire your situation was just minutes ago. You tell him your name and think about what to do next.");
				flags[kFLAGS.WIZARD_TOWER_PROGRESS] += DUNGEON_MET_JEREMIAH;
			}else{
				outputText("You approach the half-sculpted Inquisitor. It immediately turns its face towards you, with the usual gaze of someone who is lost, but happy.");
				outputText("\n\n[say: Heeey, person I have met before. Good to see you again.]");
			}
			addButton(0, "Past", askQuestion, 0).hint("Ask him about his past.");
			if (flags[kFLAGS.GOTTEN_INQUISITOR_ARMOR] > 0 || flags[kFLAGS.GOTTEN_INQUISITOR_CORSET] > 0 || flags[kFLAGS.GOTTEN_INQUISITOR_ROBES] > 0) addButton(1, "Heraldry", askQuestion, 1).hint("Ask him about the Inquisitor heraldry carved on his body.");
			else addButtonDisabled(1, "Heraldry", "You could talk about the heraldry on his body, if you recognized it.");
			if (!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_ALLOWED_EXIT)) addButton(2, "Leave Tower", askQuestion, 2).hint("Ask him if he knows how to leave the tower.");
			else addButtonDisabled(2, "Leave Tower", "You're already capable of leaving the tower.");
			addButton(3, "Vilkus", askQuestion, 3).hint("Ask him who Vilkus is.");
			addButton(4, "Tower", askQuestion, 4).hint("Ask him about the Tower.");
			addButton(5, "Sentinels", askQuestion, 5).hint("Ask him about the stone statues.");
			if (flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_FOUND_LOCKEDDOOR && !(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_DESTROYED_JEREMIAH)) addButton(6, "Locked Room", askQuestion, 6).hint("Ask him if he knows a way to open the locked room in the nearby corridor.");
			else if (player.hasKeyItem("Talisman of the Flame")) addButton(6, "Talisman", askQuestion, 7).hint("Ask him about the talisman you found on Vilkus' corpse.");
			if (flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_JEREMIAH_REFORMED) addButton(8, "Maze", askQuestion, 8).hint("Ask him about the bizarre maze he attempted to banish you to.");
			if (flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_LEARNED_KEY && !(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_DESTROYED_JEREMIAH)) addButton(7, "Attack", attackJeremiah).hint("Attack Jeremiah.");
			addButton(14, "Leave", runFunc).hint("Leave the statue and return to the room.");
		}
		public function askQuestion(question:int):void{
			clearOutput();
			switch(question){
				case 0:
					outputText("You ask him about his past as a \"person that did a thing\". He contorts for a few moments, visibly uncomfortable with his current position, before answering.");
					if (flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_JEREMIAH_REFORMED){
						outputText("\n\n[say: I was an Inquisitor, back when the order still existed. All who took refuge here were. The Inquisition was a group of warriors and wizards that joined together to fight corruption, no matter the source, and no matter how overwhelming.]");
						outputText("\n[say: We were partially successful, but they proved too strong, too numerous to fight back through regular means. We took refuge here. We were ambushed, and here we met our untimely end, most of us turning into the very essence of what we were trying to fight: Lethicite.]");
						break;

					}
					outputText("\n\n[say: Well, yes. I do remember that I did a thing in the past. It was very important for the fate of the world, and I was very important too. I can't remember it right now, though. I can't remember much aside from the fact I have to guard Vilkus so he can continue with his work.]");
					outputText("\n\nYou scratch your head. This statue truly appears to be addled beyond reason.");
					break;
				case 1:
					outputText("You ask him about the heraldry on his body, or what's been carved of it. It's the same heraldry you found in Inquisitor clothing.");
					if (flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_JEREMIAH_REFORMED){
						outputText("\n\n[say: You recognize it? Does that mean... does the Inquisition still act in Mareth?]");
						outputText("\n\nYou shake your head, and tell him that you found the clothes in an old tomb.");
						outputText("\n\n[say: Oh.] He says, visibly disappointed. [say: That is very sad indeed. Yes, we were all Inquisitors here. Some of us preferred more practical armor, but many wore the heraldry with great pride. Though there isn't much point to it now. Oh well.]");
						outputText("\n\nWell, there's little left to say about it.");
						break;
					}
					outputText("\n\n[say: Oh?] The statue clumsily turns to face his own chest as best he can. [say: Inquisitor... that brings me memories.]\n\nHe raises his stony brow.\n\n[say: Oh! Hoho, nope, gone. How interesting.]");
					outputText("\n\nWell, it was worth a try.");
					break;
				case 2:
					outputText("You ask him if he knows how to leave the tower.");
					outputText("\n\n[say: Yes, I imagine that would be hard indeed, if you are not capable of teleportation. Hmrhgh. Vilkus told me that allowing anyone inside is FORBIDDEN. So I guess that allowing you to leave is the most un-FORBIDDEN thing I could possibly do!]");
					outputText("\n\nYou shrug.");
					outputText("\n\n[say: Ah, shrugging, the best way to agree with someone. Very well, I'll use some of my magic to break the spell sealing the entrance. Just be careful and don't let volcanic dust in the tower. It makes it quite dirty indeed.]");
					flags[kFLAGS.WIZARD_TOWER_PROGRESS] += DUNGEON_ALLOWED_EXIT;
					break;
				case 3:
					outputText("You ask him who Vilkus is supposed to be. He shifts a bit, evidently uncomfortable about the topic.");
					if (flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_JEREMIAH_REFORMED){
						outputText("\n\n[say: Vilkus was Arch Inquisitor, the highest rank awarded to any of us. We all followed him, no matter how dire the situation, or how hopeless our prospects. He was the prime example of what an Inquisitor should be, and how the Demon threat should be fought.]");
						outputText("\n\nYou sigh, and tell him that you had no choice but to kill Vilkus when he attacked you.");
						outputText("\n\n[say: I understand. After several years here... Vilkus changed. Perhaps living near so much lethicite eventually corrupted his soul and corroded his sanity. Or perhaps his faith finally met its match, and he despaired over the silence of dear old Marae. Regardless, it was high time for him to rest.]");
						outputText("\n\nYou nod in understanding.");
						break;
					}
					outputText("\n\n[say: Vilkus is the person that sets the rules. He told me not to allow anyone inside, so his work isn't disturbed. Disturbing his work is very forbidden. I took an oath not to do it, I think.]");
					outputText("\n\nYou ask him what he's working on.");
					outputText("\n\n[say: I don't know. I think I knew, once. But that memory is very out of my reach, much like anything more than two feet away from me. I'd tell you to go ask that to him personally, but that is forbidden.]");
					outputText("\n\nHe smiles, convinced he told you everything you need to know. Not even close to the truth, but it's hard to get anything out of him.");
					break;
				case 4:
					outputText("You ask him if he knows who built the Tower, or what its purpose is.");
					if (flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_JEREMIAH_REFORMED){
						outputText("[say: \"Laurentius is the First\". The story of this tower was lost to time, even when civilization wasn't ravaged by the demon menace. I imagine information about it is even harder to find now, since demons are not exactly good at keeping knowledge.]");
						outputText("\n[say: From what our scholars discovered, Laurentius was an uniquely powerful wizard. He differed from other wizards in his time in that he did not want to return to his home world. He wanted to reshape this one to match his ideals. How megalomaniacal!]");
						outputText("\n\nYou nod. Quite interesting.");
						outputText("\n\n[say: Yes, well, from scraps of written history, it seems he built this tower and lived a solitary life of research and pursue of knowledge. He was quite fond of making golems and living statues--adding life where there was none. I learned much from his writings here, before Vilkus determined we burned all of it to ash. I'm afraid it is all lost now.]");
						outputText("\n\nShame. You thank him for the information.");
						break;
					}
					outputText("\n\n[say: Well, the little puzzle outside said Laurentius was the First, so I'll assume he built this. I meant to change that puzzle to be harder, but you'd be amazed how hard it is to make a good puzzle. Much harder than solving one, that's for sure!]");
					outputText("\n\nYou sigh and ask him to focus on the question.");
					outputText("\n\n[say: Yes, yes, focus. As for the Tower's purpose, I truly cannot say. It doesn't seem to be a regular wizard's tower. Those usually have all kinds of amenities, libraries, kitchens, sex dungeons and the like. Ooh, how sinful. The magic runes probably mean something, but I have no idea. My final guess: This tower was built because it could be built. Sometimes that's all the reason you need to do something!]");
					outputText("\n\nThat's probably all you can get out of him.");
					break;
				case 5:
					outputText("You ask him who made these living and unliving statues.");
					if (flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_JEREMIAH_REFORMED){
						outputText("\n\n[say: Well. I did. I am, or was, Chief Architect for the Inquisition. I built many things. Armor, weapons, jewelry, and I had the knowledge to transfer someone's essence into an inanimate object, to imbue it with life and hold it under my command.]");
						outputText("\n\nYou ask him about the sentinels, and himself.");
						outputText("\n\n[say: The sentinels outside are... old friends, partners, if you'd like. After the demons ambushed this tower, Vilkus grew increasingly distrustful of the few remaining members of our order, believing that the attack was brought by a betrayer that was still among us. One by one, I turned them into servant statues, at Vilkus' behest.]");
						outputText("\n[say: Some of them accepted the opportunity to serve the Inquisition with honor. Some others... not so much.]");
						outputText("\n\nYou ask him why he turned himself into a statue, and not a complete one.");
						outputText("\n\n[say: Hrmph. When the inevitable time came where Vilkus ordered me to turn myself into an eternal sentinel, I accepted the task, both to prove my loyalty and to defend him eternally. However, in the middle of the process, he sabotaged it, and cast a spell to warp my mind, imbuing it with only a few basic directives.]");
						outputText("\n\nYou speculate if it was to prevent anyone from disturbing him.");
						outputText("\n\n[say: Yes, precisely. Maybe he believed I wouldn't serve him eternally if I had full control of myself. I wonder what brought that doubt upon him. Regardless, as time passed I crafted more statues, using whatever prisoners we happened to have captured for interrogation as material. And sometimes I destroyed them, since I saw them as invaders as well. And because it was fun.]");
						outputText("\n\nYou then ask him why he hasn't finished the job or reversed the spell, now that he has his sanity back.");
						outputText("\n\n[say: The process is rather, uhh, one-way. And although it doesn't look like it, the spell did work fully; it's just that, when I attempted it, I really did think this form was good enough for me. So I guess I'll stay here forever. Might rebuild a few of the statues again, order them to unlock the secrets of this tower. It's a hobby, at least.]");
						outputText("\n\nJeremiah sighs, and looks sad for the first time since you met him. Best to leave it alone for now.");
						break;
					}
					outputText("\n\n[say: Heheh, I don't like to brag, but I did. A bit of magic on a weak target, then poof, marble! Or maybe I make the statue and then use magic to transfer its soul. Or maybe it's none of these things. Who knows, really?]");
					outputText("\n\nInteresting. You push the issue and ask him about the statues' purpose.");
					outputText("\n\n[say: Whatever you want! The three statues outside are set up for defensive purposes, another layer of measures to prevent Vilkus from being bothered. Though if you are here, I'm guessing they're quite destroyed right now.]");
					outputText("\n\nYou nod and confirm.");
					outputText("\n\n[say: Oooh, bother. Not a lot of material left to make statues out of, both in marble and souls. Unless you want to help?]");
					outputText("\n\nYou narrow your eyes.");
					outputText("\n\n[say: Hey, it was only a question.]");
					break;
				case 6:
					outputText("You ask him about the locked door in the nearby corridor.");
					outputText("\n\n[say: Yes, it is very well locked. What about it?]");
					outputText("\n\nYou ask him if he has a key, or knows what a key might be.");
					outputText("\n\n[say: Well, I am the key. I am powering that door's lock with my essence, or soul, or some similar magical nonsense. I could let you inside, but I won't. It's the most FORBIDDEN thing I could imagine! It would be best if you left this matter rest." + (!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_ALLOWED_EXIT) ? " Here, I will open the entrance of the dungeon for you, so you can leave." : "") + "]");
					outputText("\n\nLooks like you're not opening that door. Not in a friendly manner, anyway.");
					if (!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_ALLOWED_EXIT)){
						flags[kFLAGS.WIZARD_TOWER_PROGRESS] += DUNGEON_ALLOWED_EXIT;
						dungeons.mapLayout[10] = 0;
					}
					if(!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_LEARNED_KEY)) flags[kFLAGS.WIZARD_TOWER_PROGRESS] += DUNGEON_LEARNED_KEY;
					break;
				case 7:
					outputText("You ask him about the talisman you found in Vilkus' body.");
					outputText("\n\n[say: Oooh, interesting. I thought these were lost to time. Those talismans were a token of trust given to honored Inquisitors for feats of strength and faith. They contain great magical potential, and I can't help but wonder why Vilkus did not make use of it. Maybe he didn't feel worthy? Hm, worth a thought.]");
					outputText("\n\nYou ask him if there's anything you could do with it.");
					outputText("\n\n[say: You? Nothing. Me? I can shape that talisman into one item of fearsome power! It is supposed to only be given to Inquisitors, but considering the circumstance, I'll let it slide. Now, what are you thinking about?]");
					menu();
					addButton(0, "Spear", craftWeapon, 0).hint("Craft the Flameheart Spear, which has high armor penetration and deals more damage the lower the user's health.");
					addButton(1, "Shield", craftWeapon, 1).hint("Craft the Flamegrit Shield, which has high defense rating and regenerates the user's health based on the number of lovers and companions.");
					addButton(2, "Ring", craftWeapon, 2).hint("Craft the Flamespirit Ring, which massively boosts the power of spells, but also increases spell costs.");
					addButton(14, "Nope", meetJeremiah).hint("Don't craft anything right now.");
					return;
				case 8:
					outputText("You ask him about the extra-dimensional maze he banished you to.");
					outputText("\n\n[say: Quite the amazing thing, isn't it? I wish I could claim ownership of it, but no. That's Laurentius' doing. I merely discovered it and reset the trap, like an unwashed wizard that learns spells from books.]");
					outputText("\n\nYou glare at him.");
					outputText("\n\n[say: *cough* Weeell, the thing that amazes me is that you actually managed to leave it. I was very careful to recklessly destroy as much of the magical matrix surrounding the corridor as possible, to turn a fun puzzle into a nightmare realm of certain death. How did you do that?]");
					outputText("\n\nYou tell him that another maze materialized beneath yours, one with a clone of yourself and an exit.");
					outputText("\n\n[say: Really?] The statue attempts to stroke its stony beard. [say: Now that is interesting. Since I screwed the spell so skillfully, the only remaining possibility is that someone helped you, like a guardian angel. Or someone that has fun watching you stumble around places. It is probably pretty funny!]");
					outputText("\n\nQuite the mystery. You nod, and think about what he said.");
					break;

			}
		doNext(meetJeremiah);
		}

		public function craftWeapon(which:int):void{
			clearOutput();
			switch(which){
				case 0:
					outputText("You give him the talisman and tell him you want the Flameheart Spear.");
					outputText("\n\n[say: Marvelous, marvelous. Now, let me work.]");
					outputText("\n\nJeremiah holds the circular talisman with its single available hand. It glows as he utters words of power, and before your eyes, it morphs into a beautiful black and gold spear, which appears to gleam and shine even in complete absence of light. It is truly a marvelous weapon, worthy of the most honored of Inquisitors.");
					outputText("\n\n[say: I missed doing that, really. Here you go, have fun with it. I'd tell you to only slay demons and corrupted foes, but I'm willing to guess there's not many pure beings left, after all these years.]");
					inventory.takeItem(weapons.FLMHRTSPEAR, confirmAcquired, notAcquired);
					break;
				case 1:
					outputText("You give him the talisman and tell him you want the Flamegrit Shield.");
					outputText("\n\n[say: Marvelous, marvelous. Now, let me work.]");
					outputText("\n\nJeremiah holds the circular talisman with its single available hand. It glows as he utters words of power, and before your eyes, it morphs into an exquisite black and gold shield which appears to gleam and shine even in complete absence of light. It is truly a marvelous shield, worthy of the most honored of Inquisitors.");
					outputText("\n\n[say: I missed doing that, really. Here you go, have fun with it. I'd tell you to only slay demons and corrupted foes, but I'm willing to guess there's not many pure beings left, after all these years.]");
					inventory.takeItem(shields.FLMGRIT_SH, confirmAcquired, notAcquired);
					break;
				case 2:
					outputText("You give him the talisman and tell him you want the Flamespirit Ring.");
					outputText("\n\n[say: Marvelous, marvelous. Now, let me work.]");
					outputText("\n\nJeremiah holds the circular talisman with its single available hand. It glows as he utters words of power, and before your eyes, it morphs into an exquisite black and gold ring which appears to gleam and shine even in complete absence of light. It is truly a marvelous piece of jewelry, worthy of the most honored of Inquisitors.");
					outputText("\n\n[say: I missed doing that, really. Here you go, have fun with it. I'd tell you to only slay demons and corrupted foes, but I'm willing to guess there's not many pure beings left, after all these years.]");
					inventory.takeItem(jewelries.FLMSPRTRNG, confirmAcquired, notAcquired);
			}

		}

		public function confirmAcquired():void{
			clearOutput();
			outputText("You take your reward. Just touching it fills you with power and determination. You thank Jeremiah for the item.");
			outputText("\n\n[say: Don't mention it. Seriously, don't mention it. I don't want more demons to ambush this place.]");
			player.removeKeyItem("Talisman of the Flame");
			doNext(meetJeremiah);
		}

		public function notAcquired():void{
			clearOutput();
			outputText("You tell Jeremiah you're not really capable of carrying the item right now.");
			outputText("\n\n[say: Can't you make an effort?]");
			outputText("\n\nAbsolutely not.");
			outputText("\n\n[say: Very well. Return when you're able to actually get it, then.]");
			doNext(meetJeremiah);
		}

		public function attackJeremiah():void{
			clearOutput();
			outputText("You ready your [weapon] and position yourself to destroy the marble statue and open the locked door.");
			outputText("\n\n[say: Oh, I wouldn't do that if I were you. But if I were you, I wouldn't be me, so I wouldn't die if you succeeded. So maybe I would!]");
			outputText("\n\nYou sigh, and strike the statue with all your might. To your surprise, you barely make a dent in the marble!");
			outputText("\n\n[say: Magic! Always useful stuff. Well, if you're about to try to destroy me, I suppose it is only fair that I try to destroy you. Alright now!]");
			outputText("\n\nThe construct raises its one sculpted arm, and pieces of nearby statues start moving on their own, reassembling themselves!");
			outputText("\nYou're fighting Architect Jeremiah!");
			var desc:String = "Architect Jeremiah is a half-sculpted slab of marble, magically enhanced to be nearly impenetrable. He is basically harmless on his own, one arm fused to the raw marble and the other unable to reach further than two feet. Nearby, three statues are constantly rebuilding themselves. Based on your previous encounter, you're sure that, when complete, they will be more than beautiful sculptures.";
			startCombatMultiple(new ArchitectJeremiah, new IncubusStatue, new SuccubusStatue, new ImpStatue, defeatJeremiah, defeatedByJeremiah, defeatJeremiah, defeatedByJeremiah, desc);
			game.monsterArray[1].HP = 0;
			game.monsterArray[2].HP = 0;
			game.monsterArray[3].HP = 0;

		}

		public function defeatJeremiah():void{
			clearOutput();
			outputText("With a final strike, you finally manage to crack Jeremiah's magical armor, ripping off a chunk of his \"body\".");
			outputText("\n\n[say: So this is what it's like, dying. I would document this, but I don't think I'll have time.]");
			outputText("\n\nYou strike the statue again before it can talk any more, shattering it into a hundred pieces. He is silenced, finally.");
			outputText("\n\nYou hear a faint rumbling and crackling sound deep in the nearby corridor. True to his insane word, the door that leads further ahead is now open.");
			flags[kFLAGS.WIZARD_TOWER_PROGRESS] += DUNGEON_DESTROYED_JEREMIAH;
			dungeons.mapLayout[10] = 0;
			combat.cleanupAfterCombat();
			doNext(runFunc);
		}

		public function defeatedByJeremiah():void{
			clearOutput();
			if (player.lust >= player.maxLust()){
				outputText("You fall, overwhelmed by desire.");
				outputText("\n\n[say: By Marae, teased to submission by a marble statue. Can't blame you, though. I know I would try to do that, if I were ambulatory.]"
				+ "\n\nYou attempt to get up and strike the talkative statue again, but the Succubus statue holds you, and begins fondling your body sensually. You moan, and your mind loses all offensive intent."
				+ "\n\n[say: Well, despite your sinful ways, I do think you were quite competent to make it this far. I think Vilkus would approve if I added another layer of defenses against any future invaders.]"
				+ "\n\nWith his single free arm, he begins weaving some type of spell. The succubus' care prevents you from focusing on the threat for long, though; you're soon hypnotized by her movement again."
				+ "\n\n[say: Don't worry, being marble is not so bad! Well, I would say that, of course, but it is true.]"
				+ "\n\nHe casts the spell on you, and you black out.");
			}else{
				outputText("You fall, overwhelmed by your injuries.");
				outputText("\n\n[say: Golems can be quite dangerous, can't they? Unthinking, unfeeling, powerful magic making them almost invincible. Yeesh, wouldn't want to be on your spot right now!]"
				+ "\n\nYou attempt to get up and strike the talkative statue again, but the Incubus statue delivers a swift kick to your stomach, leaving you breathless."
				+ "\n\n[say: Well, despite your sinful ways, I do think you were quite competent to make it this far. I think Vilkus would approve if I added another layer of defenses against any future invaders.]"
				+ "\n\nWith his single free arm, he begins weaving some type of spell. The Incubus holds you down, and prevents you from getting up."
				+ "\n\n[say: Don't worry, being marble is not so bad! Well, I would say that, of course, but it is true.]"
				+ "\n\nHe casts the spell on you, and you black out.");
			}
			doNext(statueBadEnd);
		}

		public function statueBadEnd():void{
			clearOutput();
			outputText("Nothing much changes in Mareth, although the Champion's acquaintances always wondered where [he] met his end.");
			outputText("\n\nThe adventurous and lucky explorer venturing in the Volcanic Crag could eventually find a massive obsidian tower, lost to time and memory, an ode to the endless power of wizards before the demon plague."
			+ "\nHe would have to be skilled if he wanted a chance at exploring its secrets, however; for there was one sentinel keeping a silent watch, a marble guardian eternally protecting its gates, unbidden by the searing heat and the dust storms."
			+ " Wearing [his] [armor] and wielding [his] [weapon]. Forever.");
			game.gameOver();
			combat.cleanupAfterCombat();
		}

		public function encounterVilkus():void{
			clearOutput();
			spriteSelect(SpriteDb.s_vilkus_sleep);
			outputText("You move up the stairs, slowly and carefully. The darkness that covered your ascension is overtaken by a dim light as you reach a massive, domed chamber. The top of the dome has a hole through which ambient light pours, lighting particles of dust and a strange fog that lingers perpetually on the floor.");
			outputText("\nSixteen lethicite crystals of varying sizes adorn gothic pedestals placed in alcoves along the edge of the chamber. They pulse, brimming with unholy power.");
			outputText("\n\nAt the center of the room is a cloaked, masked figure in tattered red robes, sitting in an old wooden ornate chair and weakly holding an estoc.");
			outputText("\n\n[say: So... Jeremiah has betrayed me. Or maybe you destroyed him. Either way, that proves the weakness of his faith.] The cloaked figure gets up from his chair, trembling, using his estoc for support. The tattered robe reveals a bit of his skin. Old, scarred, thin and weathered.");
			outputText("\n\n[say: I will not let you take them, demon! Marae guides me, and she will reveal me the way soon. I know... I have Faith.]");
			outputText("\n\nYou tell the old man that you are no demon" + (player.cor >= 60 ? ", despite your corruption" : "") + ".");
			outputText("\n\nHe cackles and coughs. [say: That so? Such lies are most sinful, wretched creature. You will pay doubly for those.]");
			outputText("\n\nHe brandishes his estoc as best he can. [say: So many years waiting, and Marae gives me one final test of my resolve. Very well. In this day, the Inquisition purges anew.]");
			outputText("\n\nHe faintly pulses with energy, and points his estoc at you.You are fighting Arch Inquisitor Vilkus!");
			doNext(function(){
                startCombat(new ArchInquisitorVilkus,false,false);
				spriteSelect(SpriteDb.s_vilkus);
				playerMenu();

			})

		}

		public function defeatedByVilkus():void{
			clearOutput();
			outputText("You fall, incapable of continuing combat.");
			outputText("\n\n[say: Marae, I do not doubt your wisdom. I have proven my faith time and again. I will stay here, protecting my fallen comrades, awaiting your blessing, your revelation.]"
			+ "\n\nHe twirls his estoc and moves towards you."
			+ "\n\n[say: And whenever demons find their way into this sanctuary...]"
			+ "\n\nHe plunges his estoc into your chest, making you cough blood and groan."
			+ "\n\n[say: They shall be purged, as the Inquisition once did.]"
			+ "\n\nHe twists the blade, destroying your heart, and swiftly erasing your life."
			+ "\n\n[say: Merciful Marae, thank you for this chance to prove myself again.]");
			doNext(vilkusGameOver);
		}

		public function vilkusGameOver():void{
			clearOutput();
			outputText("After your life is snuffed out of your body, Vilkus burns your body to ashes with a mighty magical fire.");
			outputText("\n\nA gust of wind enters the chamber through the hole in its ceiling and washes down onto the floor. Your ashes are carried out of the tower, and spread through the land. A warning to any foe that dare cross the long-forgotten Inquisition.");
			outputText("\nVilkus sits on its weathered throne again, waiting for a revelation that might never come.");
			combat.cleanupAfterCombat();
			game.gameOver();
		}

		public function defeatVilkus():void{
			clearOutput();
			outputText("Vilkus falls, trembling and bleeding.");
			outputText("\n\n[say: Marae... are you abandoning me? Are we not worthy? So many of us gone, so much of this land defiled... and it isn't enough? Why... Why?!]");
			outputText("\n\nYou approach the corrupted Inquisitor, ready to deliver the final blow.");
			outputText("\n\n[say: We are all doomed, then. When the demons ambushed us, hope finally died. And now...]");
			outputText("\n\nHe lifts a hand and prepares a spell of whitefire. He still has some fight left in him!");
			outputText("\n\n[say: And now... Faith has died as well.]");
			outputText("\n\nHe brings his hand to his chest, casting his final spell on himself. He immediately bursts into flames, screaming loudly, and in a short few moments he's completely scorched and charred.");
			outputText("\n\nYou finally relax as you see his body turning to ash. Although he was a fierce opponent, you can't help but feel a tinge of melancholy over his fate.");
			outputText("\nOne object survives the Inquisitor's self-immolation: A small circular emblem of an everlasting fire. You pick it up, wondering if it has any use.");
			player.createKeyItem("Talisman of the Flame",0,0,0,0);
			outputText("\nKey Item acquired: Talisman of the Flame!\n\n");
			awardAchievement("We Are the Flame", kACHIEVEMENTS.DUNGEON_WE_ARE_THE_FLAME);
			player.upgradeBeautifulSword();
			combat.cleanupAfterCombat();
			flags[kFLAGS.VILKUS_DEFEAT_DAY] = game.time.days;
			flags[kFLAGS.WIZARD_TOWER_PROGRESS] += DUNGEON_DEFEATED_VILKUS;
			doNext(runFunc);
		}

		public function meetLaurentius():void{
			clearOutput();
			outputText("You walk into the pillar of light. Your body tingles and faintly vibrates as you're covered in the magical luminosity, and you're soon blinded by the radiance.");
			outputText("\n\nThe glowing pulses grow in strength once you're at the center. Before you can react, you're lifted by an unknown force. You struggle, but merely shift on your own axis, completely devoid of gravity. The humming and radiance of the pulses become deafening.");
			outputText("\n\nOne final pulse strikes, and you vanish, along with the pillar of light.");
			doNext(enterPillar);
		}

		public function meetLaurentius2():void{
			clearOutput();
			menu();
			outputText("You come to, amazed at your recent extra-corporeal experience, but not harmed in any way.");
			outputText("\n\nYou look around. Somehow, you ended up at the top of the Tower! It is flat, made of material similar to the rest of the structure. Runes adorn two concentric circles carved into the stone, and they somehow turn and spin through their length, as if floating on a thin sheet of water.");
			outputText("\n\nThe massive storms and gusts of volcanic ash rage harder at this altitude, but, somehow, you are not affected by them in the slightest. Must be some type of protective field.");
			outputText("\n\nAt the center of the area stands a tall, middle aged man with shoulder length, auburn hair. He is wearing black and gold robes and carrying an ornate steel staff, with a bright red gem in its top. He has his back turned to you, one fist clutched behind it.");
			addButton(0, "Approach", meetLaurentius3).hint("Approach the robed figure.");
		}

		public function meetLaurentius3():void{
			clearOutput();
			menu();
			if(!(flags[kFLAGS.WIZARD_TOWER_PROGRESS] & DUNGEON_LAURENTIUS_FOUND)){
			outputText("You approach the robed figure, with the usual caution that this place requires.");
			outputText("\n\n[say: A wonder, isn't it? This tower, I mean. I see you're cautious. Don't worry. I mean you no harm.]");
			outputText("\n\nYou voice your agreement as you drop your guard and approach him. He looks at you with kindness, and smiles as you face him.");
			outputText("\n\n[say: Wizards of old, they had great power. More than they could wield, more than they had any purpose for. They were all children, playing with fire, the first in their line to tap into the true potential of mortal creatures. The first to challenge the Old Gods themselves.]");
			outputText("\n\nYou stare at him in silence, and nod briefly. He laughs.");
			outputText("\n\n[say: Perhaps they were afraid of themselves, the power they wielded. Perhaps the only way they found to unleash their full potential was to destroy whatever brought them conscience]--the man brings a hand to his chest and holds a small necklace, a lethicite crystal encrusted within--[say: so they could see how deeply their influence could alter the fabric of reality.]");
			outputText("\n\nHe sighs, a bit melancholy.");
			outputText("\n\n[say: Or perhaps they never had any conscience at all, and they merely wanted to confirm it.]");
			outputText("\n\nYou break your silence, and ask what he's doing here, and who he is. He breathes deeply, thinking.");
			outputText("\n\n[say: You were the one that brought peace to Vilkus. I thank you for that. Mareth changed too much for a man like him. Even if he somehow managed to find a way to save his fellow Inquisitors, he would soon discover that the world he inhabited was not the same he left, not the same he suffered so much for.]");
			outputText("\n\nYou nod, but point out that he hasn't answered your question.");
			outputText("\n\n[say: I have, as a matter of fact. [name], all worlds change. They all grow, wither and die, as mortal as any living thing within it. Mareth is proof that even the Gods, to which we all look towards, can fail, fall, and disappear. The reason I'm here... Mareth is dying, [name].]");
			outputText("\n\nThat last word grabs your attention. You look at the blasted landscape of the crag, and ask him exactly what he means by that.");
			outputText("\n\n[say: Much like a loved grandfather, affected by a bout of grievous pestilence. We can attempt a cure with tremendous effort, but time moves ever forward, and its end is known to us all. If we want to make him immortal, we must preserve its legacy, not its being.]");
			outputText("\n\nYou ask him if he intends to reinvent the world. He smiles.");
			outputText("\n\n[say: Yes. The reason why I am here. Why this Tower is here. To see if this world can be forged anew, its legacy preserved, the mistakes of the past mere memories, so they are not repeated.]");
			outputText("\n\nYou ask if such a thing is even possible for mortals, no matter how powerful.");
			outputText("\n\n[say: Perhaps not. But that is a purpose worthy of the mightiest wizard. Something to focus on, so it is not led astray. We do not know our true limits, and I believe" +
					" that for such a noble purpose, we are righteous in attempting to surpass them.]");
			outputText("\n\nYou take a moment to parse his words, and ask him if his goal is to become a wizard of such power, then.");
			outputText("\n\n[say: Not mine, no. I have attempted it, and found myself lacking,] he says. If he holds any anger or disappointment over his failure, he does a perfect job of hiding" +
					" it.");
			outputText("\n\nHe pauses for a second, and looks upwards.");
			outputText("\n\n[say: My plan is to find the one that can, and challenge him for the right of Divinity.]");
			flags[kFLAGS.WIZARD_TOWER_PROGRESS] += DUNGEON_LAURENTIUS_FOUND;
			doNext(meetLaurentius3);
			}else{
				outputText("You approach the mysterious wizard. He nods and greets you.");
				addButton(0, "Divinity", laurentiusChallenge).hint("Challenge the wizard. This will be an extremely difficult fight.");
				addButton(14, "Leave", leaveLaurentius).hint("Ask him to teleport you back.");

			}

		}

		public function leaveLaurentius():void{
			clearOutput();
			outputText("You ask him if he knows of a way to bring you back down, somehow.");
			outputText("\n\n[say: Yes, [name]. I can do that. My invite remains, however. If you feel that the forge of your soul is strong enough... return here. You know the way.]");
			outputText("With a wave of his hand, you are enveloped in a glowing blue barrier. You levitate. With another wave, you disappear.");
			outputText("\nLaurentius can now be encountered in the Camp Actions menu.");
			inDungeon = false;
			dungeons.usingAlternative = false;
			menu();
			doNext(camp.returnToCampUseOneHour);
		}

		public function laurentiusChallenge():void{
			clearOutput();
				outputText("[say: You would face me? I wonder, do you do this out of courage, or foolishness? It matters not, I suppose. Still, I ask you this final time. Do you really want to face me?]");
				menu();
				addButton(0, "Yes!", laurentiusChallenge2).hint("Yes! Fight the wizard.");
				addButton(1, "No.", meetLaurentius3).hint("You better not.");

		}

		public function laurentiusChallenge2():void{
			clearOutput();
			outputText("You tell him that you do indeed want to challenge him. He opens up a smile.");
			outputText("\n\n[say: Yes, I had hoped you'd say that. Very well then, Champion, test your might against me, so that the forge of your soul can burn like the sun itself!]");
			outputText("\n\nThe wizard taps his staff against the floor, and the area around the top of the Tower is enveloped in energy. With another tap, your surroundings crack like glass," +
					" throwing the two of you into cosmic infinity!");
			outputText("\n\n[say: Show me the strength of your will, Champion! Show me that you are worthy of holding Reality upon your shoulders!]");
			outputText("\n\nThe wizard rises up, glowing, and fiercely waves his staff once, beckoning you to fight. You ready your [weapon] and prepare yourself!");
			outputText("\n\nYou are fighting an Aspect of Laurentius!");
			startCombatMultiple(new AspectOfLaurentius, null, null, null, defeatLaurentius, loseToLaurentius, defeatLaurentius, loseToLaurentius, "Before you stands one of the wizards of old, known for their near omnipotence. He levitates and glows with awesome power, space itself appearing to bend around his being. Although the power he wields is fearsome, he doesn't want to erase you from Mareth; merely test your potential.\n\nThe way light shimmers near him is evidence of the fact he's surrounded himself with a magical barrier that will weaken most physical attacks.");
		}

		public function defeatLaurentius():void{
			clearOutput();
			outputText("You hit the wizard, and, for the first time, he recoils and falls, feeling genuine pain.\n\nYou move forward, eager to finish this duel on your favor. Before you can strike, however, he disappears.");
			outputText("\n\nGradually, the abstract landscape around you reforms, and you find yourself at the top of the tower again. Laurentius stands at its center, facing you.");
			outputText("\n\n[say: Exquisite! Truly exquisite. I have battled many foes in my time, [name], but you... you gave me pause. Someone of your skill has true potential, and I can only hope that one day you fully control it.]");
			outputText("\n\nYou smile, panting with exhaustion. His face becomes serious. He turns, to face the Volcanic Crag.");
			outputText("\n\n[say: Thank you, [name]. For bringing me hope, for Mareth and all living things. There may one day come a time where this world withers and dies. In that day, I hope you" +
					" are here, to rekindle its soul as you have done mine, and reshape it, to save it from the mistakes of the past.]");
			outputText("\n\nYou tell him you really don't know how to save Mareth. Not in that way.");
			outputText("\n\n[say: I care not, and it matters not. All that is can be known. I did not challenge you to test your knowledge. I challenged you to see your willingness to learn.]");
			outputText("\n\nLaurentius taps his staff on the floor. An enormous beam of light strikes from the skies, enveloping him.");
			outputText("\n\n[say: Remember, [name]. The body can die. Your soul Endures forever.]");
			outputText("Suddenly, it vanishes, along with the old wizard.\n\n");
			combat.cleanupAfterCombat();
			flags[kFLAGS.WIZARD_TOWER_PROGRESS] += DUNGEON_LAURENTIUS_DEFEATED;
			awardAchievement("A Meeting of the Minds", kACHIEVEMENTS.DUNGEON_MEETING_OF_THE_MINDS, true);
			outputText("\nNew ability acquired: Soulburst!");
			player.createStatusEffect(StatusEffects.KnowsSoulburst, 0, 0, 0, 0);
			inDungeon = false;
			dungeons.usingAlternative = false;
			menu();
			doNext(camp.returnToCampUseOneHour);
		}

		public function loseToLaurentius():void{
			clearOutput();
			outputText("You fall, incapable of continuing your duel. Laurentius stops levitating, and slowly walks towards you.");
			outputText("\nWith a touch of his staff, you feel energized enough to stand. He taps his staff against the abstract floor, and the two of you are returned to the top of the Tower.");
			outputText("\n\n[say: You are not ready yet. That is fine. I will stay here, and wait for you to refine yourself.]");
			outputText("\n\nYou nod, panting with exhaustion.");
			outputText("\n\n[say: Return here when you desire to try again. Remember, [name], it is the fire that tempers the blade. I do not expect you to succeed without pain.]");
			outputText("\n\nHe turns to face the Volcanic Crag. With a wave of his hand, a massive beam of light surges from the sky, lifting you from the ground. Soon, you disappear.");
			inDungeon = false;
			dungeons.usingAlternative = false;
			combat.cleanupAfterCombat();
			menu();
			doNext(camp.returnToCampUseOneHour);
		}

		public function enterTower(position:Number = 58):void{
			game.dungeonLoc = 80;
			menu();
			onPillar = false;
			game.dungeons.startAlternative(this, position,"Tower of Deception");
			game.dungeons.setDungeonButtons();
			runFunc();
		}

		public var onPillar:Boolean;

		public function enterPillar():void{
			onPillar = true;
			game.dungeons.startAlternative(this, 58, "Pillar of Apotheosis");
			game.dungeons.setDungeonButtons();
			runFuncPillar();
		}

		public function mirrorPuzzle():void{
			clearOutput();
			outputText("You move away from the corpses and step forward towards the unknown.");
			outputText("\n\nThe corridor leads to a much more open area, opening up on both sides and the ceiling to reveal a massive circular room that absolutely dwarfs you."
			+ "You cannot see the ceiling when you look skywards. A massive pillar of the same smooth obsidian sits on its center, stretching towards the sky. The light pulses continue to emerge from the corridor, climbing the pillar and alighting several thousand runes along its height.");
			outputText("\n\nYou take a step in this massive room. You do not move forward, however.\n\nYou take another step, and you find yourself four steps back. You start running, and with each step, you move backwards, sidewards, up and down. You stop, breathless, and notice you haven't actually moved a single inch.");
			doNext(mirrorPuzzle2);
		}

		public function mirrorPuzzle2():void{
			clearOutput();
			outputText("An old, trembling high-pitched voice echoes through the room.");
			outputText("\n\n[say: An invader? After all these years? This is bothersome indeed.]");
			outputText("\nYou look around, attempting to find the source, with no success.");
			outputText("\n\n[say: Well, no matter. We still have time, yes. There is always more time.]");
			outputText("\n\nYou take another step forward, but the Tower's magic continues to elude your attempts.");
			outputText("\n\n[say: I forgot what I'm supposed to do now... Ah yes! The Mazing. It was nice to know you, eer- whoever you are, invader.]");
			outputText("\n\nWhatever that is, it can't be good. You begin a sprint back towards the corridor, but despite your efforts, you're still unable to actually change your position. You then notice the floor distancing from your feet, the walls disappearing into the distance.");
			outputText("\n\n[say: Marvelous traps. Laurentius knew what he was doing! The only bad part is that he added an exit. But, well, I fixed that!]");
			outputText("\n\nIn the blink of an eye, you disappear, your body folding in on itself and popping out of existence.");
			doNext(mirrorPuzzle3);
		}

		public function mirrorPuzzle3():void{
			clearOutput();
			outputText("You come to in a completely different place, screaming. You examine your surroundings and notice you're in some kind of glass maze. You look up and down and your stomach sinks as you realize the room is apparently floating in space itself. Stars dot every single direction you look at, and there doesn't seem to be any way to break free.");
			outputText("\n\nSuddenly, something morphs into existence under the glass maze, unfolding itself in a manner inverse to what happened to you. As it stretches outwards from itself, you realize it is another glass maze, it too containing a prisoner.");
			outputText("\nYou crouch to get a better look at the poor devil, and another vision bends your mind; that person is yourself... also crouched and looking downwards! You get up in surprise, and your other self does the same. You move forward, and it does too.");
			outputText("\nFrom a brief analysis, you notice that the configuration of your clone's maze is different from yours, and in one way in particular: it contains an exit! You'll have to figure out a way to lead your clone to its exit. Maybe you'll also be freed then?");
			doNext(start);

		}

		public function endPuzzle(solved:Boolean = false):void{
			clearOutput();
			dungeons.setDungeonButtons();
			flags[kFLAGS.WIZARD_TOWER_PROGRESS] += DUNGEON_SOLVED_MIRRORPUZZLE;
			if (solved){
				outputText("As your mirror-self reaches its exit, the mazes begins to disappear. One by one, pieces of the walls, ceiling and floor dash out onto infinity in absurd speeds. Soon, the only piece remaining is the one under your feet.");
				outputText("\nAfter a moment, it too is launched into space. You begin falling into the ether, but before you can scream, the uncomfortable and indescribable feeling of being folded into yourself strikes you again.");
				outputText("\n\nYou blink out of existence.");
			}else{
				outputText("You analyze your environment, the circumstances surrounding it. Your clone, the maze, the infinity of space. This is an illusion. It has to be! You close your eyes and focus, using your magic to break through whatever spell is currently afflicting you.");
				outputText("\n\nLike a person stuck in a lucid dream, you attempt to return to your real self. The spell proves resilient, but using your superior intellect, you slowly perceive reality again. The coldness of the corridor. The pulses of light. The humming runes. The old voice."
				+ "One by one, your senses help you break the illusion forced upon you. You then open your eyes, and blink out of existence.");
			}
			doNext(runFunc);
		}

		public function start():void{
		clearOutput();
		puzzleplayerLoc = 41;
	    mirrorLoc = 41;
		puzzleLayout =
	   [0,0,0,0,0,0,0,0,0,
		0,1,1,0,1,0,1,0,0,
		0,1,0,0,0,0,1,0,0,
		0,1,1,0,1,0,1,1,1,
		0,0,1,1,0,0,0,0,0,
		0,1,1,1,1,1,0,0,0,
		0,0,0,1,0,0,0,1,0,
		0,1,1,0,0,0,1,0,0,
		0,0,0,0,1,1,0,0,0]
		mirrorLayout =
	   [1,1,0,0,2,1,0,0,0,
		1,0,0,1,0,1,1,1,0,
		0,0,1,1,1,0,0,0,0,
		0,0,0,0,1,0,0,1,0,
		0,1,0,1,0,1,0,0,0,
		0,0,1,0,0,0,0,1,0,
		0,0,0,0,0,1,0,1,0,
		0,1,1,1,1,1,0,1,0,
		0,0,0,0,1,0,0,0,0]
		puzzleLayout[puzzleplayerLoc] = 3;
		mirrorLayout[mirrorLoc] = 3;
		redraw();
	}

	public function redraw():void{
		clearOutput();
		if (mirrorLoc == 4){
			menu();
			outputText("Your clone reaches its exit.");
			doNext(curry(endPuzzle,true));
		}else{
		outputText("");
		var draw:String = "";

		for (var i:int = 0; i < puzzleLayout.length; i++){
			if (puzzleLayout[i] == 0) draw += "[ ]";
			if (puzzleLayout[i] == 1) draw += "   ";
			if (puzzleLayout[i] == 3) draw += "[P]";
			if((i+1) % 9 == 0) draw += "\n";
		}
		draw += "\n\n";
		for (var j:int = 0; j < mirrorLayout.length; j++){
			if (mirrorLayout[j] == 0) draw += "[ ]";
			if (mirrorLayout[j] == 1) draw += "   ";
			if (mirrorLayout[j] == 2) draw += "[X]";
			if (mirrorLayout[j] == 3) draw += "[P]";
			if((j+1) % 9 == 0) draw += "\n";
		}
		rawOutputText(draw);
		outputText("");
		menu();
		if (puzzleLayout[puzzleplayerLoc - 9] != 1 && !(puzzleplayerLoc - 8 <= 0)){
			addButton(6, "North", move,0).hint("");
		}
		if (puzzleLayout[puzzleplayerLoc + 9] != 1 && !(puzzleplayerLoc + 9 >= 81)){
			addButton(11, "South", move,1).hint("");
		}
		if (puzzleLayout[puzzleplayerLoc - 1] != 1 && puzzleplayerLoc% 9 != 0 && puzzleplayerLoc != 0){
			addButton(10, "West", move,2).hint("");
		}
		if (puzzleLayout[puzzleplayerLoc + 1] != 1 && (puzzleplayerLoc + 1)% 9 != 0 ){
			addButton(12, "East", move,3).hint("");
		}
		addButton(0, "Reset", move, 99).hint("Reset positions and restart the puzzle.");
		//if(player.inte >= 120 && player.spellMod() >= 2) addButton(13, "Break Illusion", endPuzzle, true).hint("You know this is an illusion! You can break free by focusing hard enough and imposing your will over it!");
		//addButton(14, "Git out", camp.returnToCampUseOneHour).hint("The fuck is this anyway.");
		return;
		}
		}

		public function move(direction:int):void{
		puzzleLayout[puzzleplayerLoc] = 0;
		if (direction == 0){
			if (mirrorLayout[mirrorLoc - 9] != 1 && !(mirrorLoc - 8 < 0)){
				mirrorLayout[mirrorLoc] = 0;
				mirrorLoc -= 9;
				mirrorLayout[mirrorLoc] = 3;
			}
			puzzleplayerLoc -= 9;
		}
		if (direction == 1){
			if (mirrorLayout[mirrorLoc + 9] != 1  && !(mirrorLoc + 9 >= 81)){
				mirrorLayout[mirrorLoc] = 0;
				mirrorLoc += 9;
				mirrorLayout[mirrorLoc] = 3;
			}
			puzzleplayerLoc += 9;
		}
		if (direction == 2){
			if (mirrorLayout[mirrorLoc - 1] != 1 && mirrorLoc% 9 != 0 && mirrorLoc != 0){
				mirrorLayout[mirrorLoc] = 0;
				mirrorLoc -= 1;
				mirrorLayout[mirrorLoc] = 3;
			}
			puzzleplayerLoc -= 1;
		}
		if (direction == 3){
			if (mirrorLayout[mirrorLoc + 1] != 1 && (mirrorLoc + 1)% 9 != 0){
				mirrorLayout[mirrorLoc] = 0;
				mirrorLoc += 1;
				mirrorLayout[mirrorLoc] = 3;
			}
			puzzleplayerLoc += 1;
		}
		if (direction == 99){
			mirrorLayout[mirrorLoc] = 0;
			puzzleplayerLoc = 41;
			mirrorLoc = 41;
		}

		puzzleLayout[puzzleplayerLoc] = 3;
		mirrorLayout[mirrorLoc] = 3;
		redraw();
		}

}
}


code:
package classes.Scenes.Dungeons.WizardTower
{
	import classes.*;
    import classes.GlobalFlags.kFLAGS;
import classes.GlobalFlags.kGAMECLASS;
import classes.GlobalFlags.kGAMECLASS;
import classes.display.SpriteDb;
import classes.internals.*;

	public class ArchInquisitorVilkus extends Monster
	{
		public var nextAction:uint = 0;
		public var secondPhase:Boolean = false;
		public const SPELL_WHITEFIRE:uint = 1;
		public const SPELL_BLIND:uint = 2;
		public const SPELL_AROUSE:uint = 3;
		public const SPELL_HEAL:uint = 4;

		override protected function handleFear():Boolean
		{
			outputText("[say: I shall never tremble or fear, for I stand with Marae, and those who stand with Her are blessed for eternity!]");
			eAttack();
			removeStatusEffect(StatusEffects.Fear);
			return true;
		}

		override public function react(context:int):Boolean{
			switch(context){
				case CON_BLINDED:
					if (rand(player.inte) > rand(inte) && nextAction == 2){
						outputText("\nYour spell overpowers the Inquisitor's, and its magical energy is absorbed into yours, for an extremely effective attack!");
						nextAction = 0;
						createStatusEffect(StatusEffects.Blind, 5 * player.spellMod() + 2, 0, 0, 0);
						return false;
					}
					break;
				}
			return true;
		}

		public function inquisitorAI():void {
			if (secondPhase && !hasStatusEffect(StatusEffects.Attacks)) createStatusEffect(StatusEffects.Attacks, 2, 0, 0, 0);
			//Hurt!
			if (lust >= 100){
				sacrifice();
				return;
			}
			var actionChoices:MonsterAI = new MonsterAI();
			switch(nextAction){
				case SPELL_WHITEFIRE:
					whitefire();
					return;
				case SPELL_BLIND:
					blind();
					return;
				case SPELL_AROUSE:
					arouse();
					return;
				case SPELL_HEAL:
					heal();
					return;
			}
			nextAction = 0;
			actionChoices.add(heal, 1, HPRatio() < .6 && !secondPhase, 10, FATIGUE_MAGICAL_HEAL, RANGE_SELF);
			actionChoices.add(heal, 2, HPRatio() < .3 && !secondPhase, 10, FATIGUE_MAGICAL_HEAL, RANGE_SELF);
			actionChoices.add(chargeWeapon, 1, !hasStatusEffect(StatusEffects.ChargeWeapon), 0, FATIGUE_MAGICAL, RANGE_SELF);
			actionChoices.add(eAttack, 2, true, 0, FATIGUE_NONE, RANGE_MELEE_CHARGING);
			actionChoices.add(energyWave, 2, secondPhase, 0, FATIGUE_NONE, RANGE_RANGED);
			actionChoices.exec();
		}

		override protected function outputDefaultTeaseReaction(lustDelta:Number):void{
			if (lustDelta == 0) outputText("\n\n" + capitalA + short + " doesn't seem to be affected in any way.");
			outputText("\n\n" + capitalA + short + " does not show any emotion, but you can swear he felt tempted, despite himself.");
		}

		override protected function performCombatAction():void
		{
			inquisitorAI();
			if (HPRatio() <= .2 && !secondPhase){
				nextAction = SPELL_HEAL;
				return;
			}
			outputText("\n");
			if (player.lust/player.maxLust() >= 0.5 && rand(3) == 0) {
				outputText("\n[say: I can feel it inside you. Desire. The seed of corruption. I will tear it from your body, reveal your wickedness to the holy earth!]");
				nextAction = SPELL_AROUSE;
				return;
			}
			if (HP >= 200 && rand(2) == 0){
				outputText("\n[say: I shall scorch you. I will raze you to ashes and let the winds carry them through the earth, to warn all wicked beings of their folly and their weakness.]");
				nextAction = SPELL_WHITEFIRE;
				return;
			}
			if (!player.hasStatusEffect(StatusEffects.Blind) && rand(4) == 0){
				outputText("\n[say: I shall reveal unto you the radiance of Marae. And through her blessing, you will be purified.]");
				nextAction = SPELL_BLIND;
				return;
			}
		}

		override public function eAttack():void
		{
			if (secondPhase){
				switch(rand(2)){
					case 0:
						outputText("Vilkus jumps, launching himself in the air with unnatural force, and lunges at you!\n");
						break;
					case 1:
						outputText("Vilkus rears back, and thrusts his estoc towards you, dashing forwards with uncanny speed!\n");
						break;
					case 2:
						outputText("Vilkus rolls towards you and jumps with a slashing pirouette, displaying unmatched agility!\n");
						break;
				}

			}
			super.eAttack();
		}

		//*Attack: Whitefire
		public function whitefire():void {
			outputText("[say: Marae, who endureth forever. Cast thine might on the wicked, who art temporary. Raze it to ashes, so that proof of their weakness endureth forever.]\n\nA ball of fire materializes in the Inquisitor's hands. He throws it against you, and it grows to fearsome size!");
			var dodgeResult:Object = combatAvoidDamage({doDodge:true,doParry:false,doBlock:false});
			if (dodgeResult.dodge != null) outputText("\n\nYou manage to jump out of the way just in time, avoiding the magical attack.");
			else{
				if (player.shield == game.shields.DRGNSHL && rand(2) == 0) outputText("\n\nYou're hit by the attack, but thankfully manage to raise your shield in time. The spell is absorbed and nullified!");
				else{
					outputText("\n\nYou're hit in full by the spell, and are viciously scorched by the magical fire!");
					game.combat.monsterDamageType = game.combat.DAMAGE_FIRE;
					player.takeDamage((100 + rand(50)) * (1 + player.cor*0.01), true);
				}

			}
			outputText("\nBy using his own essence to cast spells, the Inquisitor damages himself.");
			HP -= 75;
			outputText("(" + 75 + ")");
		}

		//*Attack? Seppuku
		public function sacrifice():void{
			outputText("[say: No. I will not fall. I cannot be tempted!]\nYour opponent roars, creating a blast of force that knocks you back for a moment. He then takes his sword and swiftly stabs himself in the abdomen. After the sword has fully pierced it, he twists the blade and quickly pulls it out, in a gruesome display.");
			outputText("\n\nHe lifts the blade and stares, trembling, at the dripping blood. [say: The pain... I am still myself. I am still devout. Thank you, Marae.]\nYou're not sure how he survived that, but he seems to have overcome his growing lust!");
			lust = 0;
			var damage:Number = 300 + rand(50);
			HP -= damage;
			outputText("(" + damage + ")");
			nextAction = 0;
		}

		//*Attack: Heal
		public function heal():void {
			outputText("[say: You cannot stop me. For as long as corruption remains, I will stand tall, to purge it, raze it to ash.] Your opponent presses the hilt of his sword against his chest and chants some holy passage. Miraculously, his wounds begin to heal!");
			var healed:Number = Math.round(maxHP() * (1 + rand(2))*0.1);
			addHP(healed);
			outputText("(" + healed + ")");
			fatigue += 10;

		}

		//*Attack: Arouse
		public function arouse():void{
			outputText("[say: Your resolve is weak. Desire, bubbling through the surface. Let it spew forth, so it may be purged.] Your opponent raises an arm, and with an arcane chant, releases a wave of black magic against you!");
			var dodgeResult:Object = combatAvoidDamage({doDodge:true,doParry:false,doBlock:false});
			if (dodgeResult.dodge != null) outputText("\n\nYou manage to jump out of the way just in time, avoiding the magical attack.");
			else{
				if (player.shield == game.shields.DRGNSHL && rand(2) == 0) outputText("\n\nYou're hit by the attack, but thankfully manage to raise your shield in time. The spell is absorbed and nullified!");
				else{
					outputText("\n\nYou're hit by the spell, and immediately feel warmer.");
					if (flags[kFLAGS.TIMES_ORGASMED] > 0){
						outputText(" Memories of your past sexual encounters assault you, and you find it hard to focus on the current fight!");
						player.takeLustDamage(35 + lib / 5 + rand(cor / 5), true);
					}
					else outputText(" The effect is short lived, however, and you feel no worse for wear!\n[say: You may be untainted by lust, but I will uncover your other sins. None can be pure before my purging.]");
				}

			}
			outputText("\nBy using his own essence to cast spells, the Inquisitor damages himself.");
			HP -= 50;
			outputText("(" + 50 + ")");
		}

		//*Attack: Blind
		public function blind():void{
			outputText("[say: Darkness comprehends not the light, merciful Marae. Reveal unto them their own wickedness, ignorance torn by your holy presence, and let them be lost in your radiance.]\nThe Inquisitor holds his sword aloft, and a bright magical light shines forth from it!");
			if (rand(player.inte / 6) <= 4) {
				outputText(" You are blinded!");
				player.createStatusEffect(StatusEffects.Blind, 1 + rand(3), 0, 0, 0);
			}
			else outputText("\nYou manage to blink in time, avoiding the blinding attack.");
			outputText("\nBy using his own essence to cast spells, the Inquisitor damages itself.");
			HP -= 25;
			outputText("(" + 25 + ")");
		}

		//*Attack: Charge Weapon
		public function chargeWeapon():void{
			outputText("The Inquisitor raises his sword with both hands and stares devoutly at it. [say: As I carry thine word and bless thine radiance, please let me carry thine strength and purge thine enemies.]\nHe lifts one hand and softly slides it over the blade, and the sword begins glowing and crackling with magical energy.");
			outputText("\nLooks like he'll deal more damage with melee attacks now!");
			outputText("\nBy using his own essence to cast spells, the Inquisitor damages himself.");
			HP -= 50;
			outputText("(" + 50 + ")");
			weaponAttack += 25;
			createStatusEffect(StatusEffects.ChargeWeapon, 25, 0, 0, 0);
		}

		//*Attack: Unholy energy wave thing
		public function energyWave():void{
			outputText("Vilkus holds his sword aloft. The blade pulses with power and he slashes the air, sending a wave of energy at you!");
			var dodgeResult:Object = combatAvoidDamage({doDodge:true,doParry:false,doBlock:false});
			if (dodgeResult.dodge != null) outputText("\n\nYou manage to jump out of the way just in time, avoiding the energy wave.");
			else{
				if (player.shield == game.shields.DRGNSHL && rand(2) == 0) outputText("\n\nYou're hit by the attack, but thankfully manage to raise your shield in time. The energy wave is absorbed and nullified!");
				else{
					outputText("\n\nYou're hit by the energy wave, and it cuts straight through your [armor]. You wince in pain as the corruptive force burns you from the inside!");
					game.dynStats("cor", -5);
					player.takeDamage(Math.round(75 + rand(30) + player.cor / 3), true);
					if (player.bleed(this,4, 2)) outputText("\nThe energy wave tears your flesh, causing you to bleed profusely.");
				}

			}
			outputText("\nBy using his own essence to cast spells, the Inquisitor damages himself.");
			HP -= 100;
			outputText("(" + 100 + ")");
		}

		override public function defeated(hpVictory:Boolean):void
		{
			clearOutput();
			if (secondPhase){
				game.dungeons.wizardTower.defeatVilkus();
				return;
			}
			outputText("The Inquisitor stumbles back and falls to the ground, wounded and bleeding.\n\n[say: Marae... why hast thou challenged me so? No word of mine is spoken without thy blessing, my hand only knows thine guidance, so why... why did we fall?]");
			outputText("\nThe Inquisitor wheezes in pain. [say: Marae... my love for thee is eternal. I will serve thee even if my soul left me, my breath left my lungs.]");
			outputText("\nHe looks at his hands, stained with blood, both old and fresh, mementos of a thousand flagellations. [say: I see... I can still serve thee. If I cannot burn all corruption, then I will take it upon myself, and my spirit will scorch it to cinders.]");
			outputText("\n\nThe Inquisitor rises and kneels, holding his sword with both hands. It begins glowing brightly, illuminating the entire chamber.");
			outputText(" He rises, and the Lethicite crystals around the room glow. Trails of energy wisp out of the crystals and into the blade.");
			outputText("\n\nAfter a few moments, the crystals lose their glow, turning an opaque gray.\n[say: I will burn... Consume everything. In a world without life, there can be no corruption.]");
			outputText("\nWith a decisive motion, the Inquisitor stabs himself once again. Purple energy envelops him as he screams and trembles, his voice slowly becoming deeper and more inhumane.");
			outputText("\nHe removes the sword from his abdomen, the blood on the blade pitch black, a dark purple aura enveloping the entirety of the weapon. [say: Yes. Even now, I can serve you, Marae.]");
			outputText("\n\nHe points the sword at you. You have another fight on your hands!");
			bonusHP = 2400;
			HP = maxHP();
			removeStatusEffect(StatusEffects.ChargeWeapon);
			cor = 100;
			armorDef = 60;
			short = "Vilkus, the Last Flame";
			long = "Vilkus stands erect, proud and determined. An aura of corruption surrounds his entire being, the very air shimmering with his presence. He no longer uses his weapon for support, and its blade pulses fiercely with corrupted energy.";
			level = 35;
			lust = 0;
			lustVuln = .7;
			weaponAttack = 40;
			secondPhase = true;
			tookAction = true;
            kGAMECLASS.spriteSelect(SpriteDb.s_vilkus_tf);
			game.combat.startMonsterTurn();
			nextAction = 0;
			a = "";
			return;
		}

		override public function won(hpVictory:Boolean,pcCameWorms:Boolean = false):void
		{
			game.dungeons.wizardTower.defeatedByVilkus();
		}

		public function ArchInquisitorVilkus()
		{
			this.a = "";
			this.short = "Arch Inquisitor Vilkus";
			this.imageName = "archinqvilk";
			this.long = "Before you stands a human, covered in tattered red and gold robes, intricately woven with heraldry from a now lost kingdom. Several holes are torn through length of the robe, all stained with dried blood. He stands partially hunched, breathing deeply as he uses his estoc for support. He appears to be in pain, but a long, rusted silver mask covers his face, preventing you from accurately gauging his state.";
			// this.plural = false;
			this.balls = 0;
			this.ballSize = 0;
			this.cumMultiplier = 3;
			this.hoursSinceCum = 20;
			this.createCock(6, 1.5, CockTypesEnum.HUMAN);
			this.balls = 2;
			this.ballSize = 3;
			this.cumMultiplier = 25;
			createBreastRow(Appearance.breastCupInverse("flat"));
			this.ass.analLooseness = Ass.LOOSENESS_TIGHT;
			this.ass.analWetness = Ass.WETNESS_NORMAL;
			this.tallness = 9 * 6;
			this.skin.tone = "ashen";
			this.hair.color = "black";
			this.hair.length= 15;
			initStrTouSpeInte(100, 100, 80, 120);
			initLibSensCor(55, 40, 0);
			this.weaponName = "estoc";
			this.weaponVerb = "stab";
			this.weaponAttack = 20;
			this.armorName = "Inquisitor's Robes";
			this.armorDef = 60;
			this.bonusHP = 1000;
			this.lust = 30;
			this.bonusLust = 100;
			this.lustVuln = .5;
			this.temperment = TEMPERMENT_RANDOM_GRAPPLES;
			this.level = 27;
			this.gems = 500 + rand(250);
			this.drop = NO_DROP;
			this.additionalXP = 2500;
			this.createPerk(PerkLib.ChargingSwings, 0, 0, 0, 0);
			checkMonster();
		}

	}

}

license: unknown