// dlg.txt

begintalkscript;

variables;

short i;

begintalknode 1;
	state = -1;
	nextstate = -1;
	condition = get_sdf(125,7) == 0;
	question = "special";
	text1 = "As you walk down this gallery, you feel a chill. It's colder here, and the lights are dimmer. The ground is scattered with old, bleached bones. Sometimes, out of the corner of your eye, you think you can see the bones shift slightly.";
	text2 = "Some areas of Avernum are just naturally magical. Sometimes, the magic is beneficial. Other times, not. This tunnel is clearly unfriendly to living things.";
	action = SET_SDF 125 7 1;

begintalknode 2;
	state = -1;
	nextstate = -1;
	condition = get_sdf(125,8) == 0;
	question = "special";
	text1 = "There is a small camp here. There are some armed guards, a couple of sages, and a mage. You walk into the cavern, ready to extend a warm greeting, when you are interrupted.";
	text2 = "One of the guards points to the west and shouts, _Watch out! Zombies!_";
	text3 = "You look where the guard is pointing and see that there are, in fact, zombies.";
	action = SET_SDF 125 8 1;
	code =
		activate_hidden_group(43);
		set_level(13504,20);
		set_level(13505,20);
		set_level(13506,20);
		set_level(13507,20);
	break;
	
begintalknode 3;
	state = -1;
	nextstate = -1;
	condition = get_sdf(125,9) == 0;
	question = "special";
	text1 = "You have descended into the Undead Spiral. It is painfully cold down here. Patches of ice dot the floor. You try to keep the chill out, but neither cloaks nor armor keep it from sinking into your bones.";
	text2 = "There is something about this place that is disorienting. You constantly feel turned around. Sometimes, you think you are walking farther in, when, in fact, you are heading out. And vice versa.";
	text3 = "It is an amazing concentration of natural magic, focused and shaped into a malevolent form. You constantly watch the bones underfoot, aware that they could leap to life at any moment.";
	action = SET_SDF 125 9 1;

begintalknode 4;
	state = -1;
	nextstate = -1;
	condition = get_sdf(125,10) == 0;
	question = "special";
	text1 = "The sages set up a workshop here once and then quickly abandoned it. You can see it in the alcove to the west. The desk and other furniture left behind are covered with frost and marks left by zombie claws.";
	text2 = "There is a basin in the alcove. It is full of fresh, sparkling water, still liquid despite the cold.";
	text3 = "You look around for a route into the deeper tunnels, but you don't see one. The spiral seems to hit a dead end here. And, yet, oddly, when you look at the north wall, you feel dizzy and disoriented. Seems solid enough, though.";
	action = SET_SDF 125 10 1;

begintalknode 5;
	state = -1;
	nextstate = -1;
	condition = get_sdf(125,11) == 0;
	question = "special";
	text1 = "Out of the corner of your eye, you see movement around the chasm to the east. Something has just climbed out of it.";
	action = SET_SDF 125 11 1;
	code =
		activate_hidden_group(44);
		set_level(13515,20);
		set_level(13516,20);
		set_level(13517,20);
		set_level(13518,20);
	break;
	
begintalknode 6;
	state = -1;
	nextstate = -1;
	condition = get_sdf(125,14) == 0;
	question = "special";
	text1 = "The ceiling of this long gallery is very low, and a thick mist obscures your vision. There are humanoid shapes moving through the shadows. They are wisps, so insubstantial that they might as well not be there at all.";
	text2 = "When you enter, they begin to drift slowly toward you, drawn by your warmth.";
	action = SET_SDF 125 14 1;
	
begintalknode 7;
	state = -1;
	nextstate = -1;
	condition = get_sdf(125,15) == 0;
	question = "special";
	text1 = "There is a young sage in this room. He appears to have been trapped. He is frozen solid. His skin is blue and looks solid as a rock. He has also been surrounded by a circle of magical barriers.";
	text2 = "He still holds a pen and sheet of papyrus in his hands. It looks like he was transcribing the strange symbols etched into the west wall.";
	text3 = "As you inspect him, you sense that you are not alone in the room. Insubstantial shades flicker in the shadows, watching you.";
	action = SET_SDF 125 15 1;
	
begintalknode 8;
	state = -1;
	nextstate = -1;
	condition = get_sdf(125,16) == 0;
	question = "special";
	text1 = "You have reached the lowest chamber in the spiral. You are at the core of its power. The dark magic here weighs upon you, making you feel simultaneously sluggish and terrified. Desperate to escape, and unable to move.";
	text2 = "Out of the corners of your eyes, you keep seeing shapes on the floor. Glimpses of corpses, wearing outdated clothing and armor, dead and dying from gruesome wounds. But then you turn and look, and there is nothing there.";
	text3 = "To the north, you see the most powerful of the wards containing the power of this place, surrounded by abandoned magical equipment. Once it was created, its makers fled this place.";
	text4 = "It has attracted several shambling, undead forms. They lurch around it, senselessly walking in a circle. They haven't noticed you yet.";
	action = SET_SDF 125 16 1;


//

begintalknode 10;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "The obelisk says:";
	text2 = "  UNDEAD SPIRAL";
	text3 = "  Warning - Undispelled curses still active in this area!";
	text4 = "  Only proceed with proper protection or under guard!";
	
begintalknode 11;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "You talk to the guards and sages for a while. They are all understandably on edge. Groups of undead can come up from the spiral at any time.";
	text2 = "Fortunately, the wards in the tunnels below mean that the creatures are weak and fragile and tend to fall apart when they get too far from the spiral. They aren't in serious danger, as long as they stay alert.";
	text3 = "Now that the wards below have been broken, the situation here is increasingly desperate. They doubt they will be able to stay for long.";
	code =
		if (gf(125,1) == 0)
			rs(3);
			else rs(2);
	break;
	
begintalknode 12;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "The water in the basin had the marvelous effect of clearing your mind, helping you to resist the confusing aura over this place.";
	text2 = "Now that the confusion has faded, you can clearly see that there are, in fact, two narrow passages leading out of the room to the north.";
	
begintalknode 13;
	state = -1;
	nextstate = -1;
	condition = gf(138,3) == 1 && gf(125,1) == 0 && gf(125,2) == 0;
	question = "special";
	text1 = "You find the first of the four wards in the Undead Spiral. You inspect it. It seems completely intact.";
	action = SET_SDF 125 2 1;
	
begintalknode 14;
	state = -1;
	nextstate = -1;
	condition = gf(138,3) == 1 && gf(125,1) == 0 && gf(125,3) == 0;
	question = "special";
	text1 = "You find the second of the four wards in the Undead Spiral. You inspect it. It seems completely intact.";
	text2 = "A tiny bit of frost is encroaching on one end, but the magic of the ward seems to melt and evaporate the water before it does any harm.";
	action = SET_SDF 125 3 1;

begintalknode 15;
	state = -1;
	nextstate = -1;
	condition = gf(138,3) == 1 && gf(125,1) == 0 && gf(125,4) == 0;
	question = "special";
	text1 = "You find the third of the four wards in the Undead Spiral. You inspect it. It seems completely intact. The skeletons lingering around it were unable to affect it.";
	action = SET_SDF 125 4 1;

begintalknode 16;
	state = -1;
	nextstate = -1;
	condition = gf(138,3) == 1 && gf(125,1) == 0 && gf(125,5) == 0;
	question = "special";
	text1 = "You find the fourth of the four wards in the Undead Spiral. You inspect it. It seems completely intact. Even the power of the curse here at the heart of the spiral has not disrupted the ward.";
	action = SET_SDF 125 5 1;
	code =
		alert_char(30045);
	break;
	
begintalknode 17;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "When you get close to this piles of bones and skulls, they rattle together slightly. The magic of these caverns constantly threatens to animate them and send them after you.";

begintalknode 18;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "You try to talk to the frozen sage, but he can't hear you. The barriers surrounding him block all sound.";
	text2 = "As you approach the sage, you see that he is starting to thaw out slightly. He is moving very slowly. However, this angers the spirits that froze him and are keeping him here. They instantly take a more substantial (and dangerous) form.";
	text3 = "The sage stumbles out of the remnants of his prison and stumbles against the wall. He gasps, _Thank you. I suppose I've been in there for a while._";
	text4 = "You try to talk to the imprisoned sage, but the power of the spirits still holds him captive.";
	text5 = "You tell him the date. He nods. _Yes, a while. Without you, I might have been in there forever._";
	code =
		clear_strings();
		if (gf(125,17) == 0) 
			as(1);
			else if (gf(125,19) == 0) {
				as(2);
				sf(125,19,1);
				activate_hidden_group(45);
				
				set_name(13531,"Spirit");
				set_level(13531,15);
				set_name(13532,"Spirit");
				set_level(13532,15);
				set_name(13533,"Spirit");
				set_level(13533,15);
				set_name(13534,"Spirit");
				set_level(13534,15);
				}
				else if (gf(125,18) < 4)
					as(4);
					else {
						as(3);
						as(5);
						erase_char(13529);
						spawn_creature(13530);
						set_name(13530,"Sage Clarey");
						
						}
	break;
	
begintalknode 19;
	state = -1;
	nextstate = -1;
	condition = gf(125,24) == 0 && gf(125,1) > 0;
	question = "special";
	text1 = "When you reenter this cavern, you find that the piles of skulls and bones in the alcoves are rattling constantly. The newly unleashed power of the spiral has reached them.";
	text2 = "As you watch in horror, the bones begin to knit together and rise from the piles.";
	action = SET_SDF 125 24 1;

begintalknode 20;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "As you get close to escape from this accursed network of tunnels, one final creature stands there, ready to stop you. It is a small, withered form of bones and shriveled flesh. It doesn't, at first, seem like anything to worry about.";
	text2 = "And then it takes a step toward you, and your mind goes funny.";
	text3 = "You can't focus on it. Just being near it makes you feel confused. You aim a blow at it, and you suddenly find your attack directed elsewhere.";
	text4 = "The creature seems to be chaos in physical form. As long as it is fogging your mind, it will be very difficult to strike it.";
	
begintalknode 21;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "__";

begintalknode 22;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "__";

begintalknode 23;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "__";

begintalknode 24;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "__";

begintalknode 25;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "__";

begintalknode 26;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "__";

begintalknode 27;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "__";

begintalknode 28;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "__";

begintalknode 29;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "__";

//

begintalknode 30;
	state = -1;
	nextstate = 30;
	condition = 1;
	question = "Sage Martella";
	text1 = "There is one mage watching over the encampment. Like the others, she doesn't look like she's had a good sleep in weeks. She is wrapped up tightly against the chill of the tunnels.";
	text2 = "She inspects you closely, making sure that you are, in fact, alive, and not just unusually fresh zombies. Once she approves of you, she says, _Welcome to the Undead Spiral. I am Sage Martella._";
	text3 = "_If you don't have any business here, I suggest you depart. The magic in this place is powerful and dangerous, and the wards holding it in place are fragile._";
	text5 = "Sage Martella is constantly watching the west tunnel, keeping alert for invaders. _Do you need anything else? We're very busy here._";
	action = INTRO;

begintalknode 31;
	state = 30;
	nextstate = -1;
	condition = gf(125,1) > 0;
	question = "How are conditions here?";
	text1 = "She looks at you suspiciously. _The bonds below have been broken. The wild magic in this place is breaking loose. We can't imagine how it could have happened._ Though she clearly has a guess.";
	text2 = "_Conditions are, well, bad._";

begintalknode 32;
	state = 30;
	nextstate = 31;
	condition = gf(125,1) > 0;
	question = "What will you do now?";
	text1 = "_We have reported the disaster to Mertis. Now we are trying to hold the undead back until the town can put defenses in place._";

begintalknode 33;
	state = 31;
	nextstate = -1;
	condition = 1;
	question = "Can't you just recreate the wards?";
	text1 = "_Just us? It would take at least four skilled wizards, along with a considerable number of soldiers to protect them. No, with the famine and the war, we will not be able to replace the wards for years._";
	text2 = "_If ever._";

begintalknode 34;
	state = 31;
	nextstate = -1;
	condition = 1;
	question = "Anything I can do to help?";
	text1 = "She looks annoyed. _I am sure you have done quite enough. Leaving is the best thing you can do for us now._";
	action = END_TALK;

begintalknode 35;
	state = 30;
	nextstate = 32;
	condition = gf(125,1) == 0;
	question = "Tell me about the spiral.";
	text1 = "_This is the Undead Spiral. An odd name, to be sure. The first Avernites who discovered the odd properties of these tunnels were a prosaic lot._";
	text2 = "_In short, there is a powerful curse on this place. Anything dead near here comes to life. If there are no bodies or bones, then bodies and bones tend to ... appear. And then come to life. Fortunately, there are now wards in place._";

begintalknode 36;
	state = 30;
	nextstate = 34;
	condition = gf(125,1) == 0;
	question = "Can I go below?";
	text1 = "She looks nervous. _We don't have the strength to stop you, and we are under instructions to give soldiers free passage. However, I advise you to be very careful._";
	text2 = "_Also, the spiral has the tendency to fog the mind. If you become confused, we have taken steps to help you clear your mind._";

begintalknode 37;
	state = 30;
	nextstate = 37;
	condition = gf(125,1) == 0 && gf(138,3) == 1 && gf(125,5) == 0;
	question = "Sage Perth sent me to inspect the wards.";
	text1 = "_Excellent. Best news I've had in a while. It means we can rest for the week._";
	text2 = "_Simply descend into the tunnel, visit the wards, and clear away any unliving debris that has clustered around them. To protect the wards, we have placed a scattering of magical barriers. They should be easy to dispel._";

begintalknode 38;
	state = 30;
	nextstate = -1;
	condition = gf(125,1) == 0 && gf(158,15) == 3;
	question = "A wizard named Gladwell asked me to disrupt a magic circle at the bottom of the spiral.";
	text1 = "You start to speak, only to find that some force is keeping your jaws and tongue from moving. Very odd. Could Gladwell have cast some sort of binding spell on you without your knowledge?";

begintalknode 39;
	state = 32;
	nextstate = -1;
	condition = 1;
	question = "Where did the curse come from?";
	text1 = "_I don't know. I don't deal in history, only the ugliness of the present. Sage Perth, in Mertis, has studied those mysteries more than I have._";

begintalknode 40;
	state = 32;
	nextstate = -1;
	condition = 1;
	question = "What do those undead do?";
	text1 = "_Wander randomly, attacking anything alive they stumble upon. Trying to make more bodies and bones, you see._";
	text2 = "_For years, this has been a great irritation to the farmers in this area. Fortunately, we wizards have taken successful steps to restrain the evil of this place._";

begintalknode 41;
	state = 32;
	nextstate = 33;
	condition = 1;
	question = "What effect do the wards have?";
	text1 = "_They don't entirely contain the evil magic of this place, but they circumscribe it. Bones still appear and come to life, but the resulting creatures are limited._";

begintalknode 42;
	state = 33;
	nextstate = -1;
	condition = 1;
	question = "Limited how?";
	text1 = "_They are far weaker, and they crumble quickly when they get too far from the spiral. Makes farming much easier, as you can imagine._";
	text2 = "_Or, it made farming easier, before the Blight devastated Mertis. Now we mainly control the undead to keep the caravan route secure._";

begintalknode 43;
	state = 34;
	nextstate = -1;
	condition = 1;
	question = "Is it dangerous?";
	text1 = "_Yes. Out here, not so much. The closer you get to the center of the spiral, however, the worse the danger is. We have restrained the power of this place, not removed it._";

begintalknode 44;
	state = 34;
	nextstate = -1;
	condition = 1;
	question = "How can I clear my mind?";
	text1 = "_In the workshop below, there is a basin. Drink from it, and you will be temporarily protected from efforts to confuse you. The pool will slowly regenerate itself. It is very useful magic in such an accursed place._";

begintalknode 45;
	state = 30;
	nextstate = -1;
	condition = get_quest_status(182) == 2;
	question = "I have a delivery for someone named Clarey.";
	text1 = "_Ahhh. Clarey went down into the spiral not long ago, but he has not returned. Not unusual behavior for him, but I am still slightly concerned._";
	text2 = "_I have been meaning to send a search party. Perhaps you can assist him if you find him in difficulty._";

begintalknode 46;
	state = 37;
	nextstate = -1;
	condition = 1;
	question = "Can you dispel the barriers for me?";
	text1 = "_Ahhhh ... I did not make them, and I haven't the power to remove them. Hopefully, you have some piercing crystals on hand._";	
	
//

begintalknode 50;
	state = -1;
	nextstate = 50;
	condition = 1;
	question = "Name";
	text1 = "The sage you freed from his icy prison says, _I owe you a great debt, one I find myself unable to repay. I am Sage Clarey._";
	text2 = "He looks up at the odd writing on the west wall. _I was studying that odd scratching on the wall. I'll have to finish up my work quickly and get out of here._";
	text5 = "Sage Clarey looks up at the odd writing on the west wall. _Better get to work. The sooner I copy it, the sooner I can leave._";
	action = INTRO;

begintalknode 51;
	state = 50;
	nextstate = -1;
	condition = 1;
	question = "What happened to you?";
	text1 = "_A fluctuation in the dark magic of this place, which created shades that were able to seize me. They were slowly feeding off of my life. Happily, it's all better now._";

	
begintalknode 52;
	state = 50;
	nextstate = -1;
	condition = 1;
	question = "What are you studying?";
	text1 = "_That odd writing on the wall. It appeared only recently, and I hope to copy it down before it disappears again. Such odd happenings are the way in this place._";
	text2 = "_Maybe, if I can get it deciphered, it will unlock some of this place's secrets. Even help us to control its power!_";
	
begintalknode 53;
	state = 50;
	nextstate = -1;
	condition = 1;
	question = "Isn't it dangerous to be down here?";
	text1 = "_Oh, somewhat. I suppose. But, as you can see, I am still alive. So no harm done!_";
	
begintalknode 54;
	state = 50;
	nextstate = -1;
	condition = 1;
	question = "What will you do now?";
	text1 = "_I will work on copying these symbols. Hopefully, I will complete the task before I am ensnared again._";
	text2 = "_The crystal you brought me will be quite valuable. With it, I will complete the job soon._";
	text3 = "_Now, please excuse me. I need to resume my work._";
	action = END_TALK;
	code =
		if (get_quest_status(182) < 3) 
			rs(2);
	break;


begintalknode 70;
	state = -1;
	nextstate = 70;
	condition = gf(158,15) == 3 && gf(125,1) == 0;
	question = "Name";
	text1 = "You look at the magic circle on the floor. This is definitely the one Gladwell described. The long, delicate curves of the ward are etched deep in the stone. It was made to be very difficult to disrupt.";
	text2 = "And yet, you could do it. One sharp blow from a tool or weapon would crack the stone, breaking the delicate balance of power stored within the symbol.";
	text3 = "The effects of this, however, would be unpredictable at best.";


begintalknode 71;
	state = 70;
	nextstate = -1;
	condition = 1;
	question = "Leave the circle alone.";
	text1 = "You back away from the circle. Gladwell might be putting you in a good deal of danger.";
	action = END_TALK;
	
begintalknode 72;
	state = 70;
	nextstate = -1;
	condition = 1;
	question = "Break the circle.";
	text1 = "It takes several blows, but you succeed. You create a long, thin crack in the stone, severing the outer loop of the rune. There is a hum and a flash of light, as the power in the ward drains out. And then it is quiet.";
	text2 = "At first.";
	text3 = "Then the ground vibrates under your feet. The air grows even colder. A long, low keening echoes through the tunnels. And, gradually, years of pent up power breaks loose.";
	text4 = "From above you, you hear the echoing sounds of many feet, scraping their way across the icy floors. The army of the Undead Spiral lurks between you and escape.";
	action = END_TALK;
	code =
		sf(125,1,1);
		activate_hidden_group(46);

		set_name(30044,"Enraged Wisp");
		set_level(30044,20);
		set_aggression(30044,75);
		
		set_name(13556,"Spirit");
		set_name(13557,"Spirit");
		
		set_name(13574,"Fearsome Dead");
		set_level(13574,16);
		set_new_abil(13574,12);
		set_name(13575,"Fearsome Dead");
		set_level(13575,16);
		set_new_abil(13575,12);
		set_name(13576,"Fearsome Dead");
		set_level(13576,16);
		set_new_abil(13576,12);
		set_name(13577,"Fearsome Dead");
		set_level(13577,16);
		set_new_abil(13577,12);
		
		// kill perth quest
		sf(138,3,2);
		toggle_quest(95,4);
	break;
	
////

begintalknode 299;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "";
	text1 = ".";
	text2 = "";
		