// TOWN DIALOGUE SCRIPT
//    Town 56: Fort Emerald

begintalkscript;

variables;

short i,j,k,r1,choice;


begintalknode;
	tag = 1;
	state = -1;
	nextstate = -1;
	condition = 1;
	text1 = "Several cave cows are allowed to wander freely around the south end of the fort. They are probably a reliable source of milk. Watery, bitter milk.";


begintalknode;
	tag = 2;
	state = -1;
	nextstate = -1;
	condition = 1;
	text1 = "Discipline is high at Fort Emerald. The guards want to speak with you, but they're under orders to not share any information with outsiders.";
	text2 = "They say that, if you want information or work, the general is by the north wall.";
	
// Silverio

begintalknode;
	tag = 10;
	state = -1;
	nextstate = 1;
	question = "Silverio";
	text1 = "This woman is staring through an arrow slit, watching carefully for attackers. She wears mage's robes, and she stands ready to fling a spell at any moment.";
	text2 = "She idly waves at you as you approach, not looking away from the blasted ground outside. _I am Silverio._";
	text5 = "_Anything else you want to know?_ As Silverio speaks, she doesn't look away from the window.";
	action = INTRO;

begintalknode;
	state = 1;
	nextstate = 2;
	question = "_What are you looking for?_";
	text1 = "She makes a soft shushing noise. _Quiet. I'm watching for an attack._";

begintalknode;
	state = 2;
	nextstate = 3;
	question = "_Is an attack imminent?_";
	text1 = "She speaks quickly and quietly, never averting her eyes. _That's just it. We don't know. We never know. We all take shifts watching for Empire raids._";
	text2 = "_They can conceal themselves magically. They can appear in seconds, throw a few balls of fire, and get away. We then have very little time to strike back._";

begintalknode;
	state = 3;
	nextstate = 4;
	question = "_How do you repair the walls?_";
	text1 = "_We have to plug any holes in the walls with magic barriers, before any attackers can climb through them. The barriers are our most powerful defense._";

begintalknode;
	state = 4;
	nextstate = -1;
	question = "_How do you use the barriers?_";
	text1 = "_Even when the enemy smashes a hole in our defenses, we can plug it up right away! Without that ability, this fort would have fallen long ago._";

begintalknode;
	state = 4;
	nextstate = -1;
	condition = 1;
	question = "_How do you make the barriers go away when you're done with them?_";
	text1 = "_Heustess takes care of that. He's somewhere else along the wall._";
	text2 = "_Now, please excuse me. You are distracting me and it is annoying._";
	action = END_TALK;

// General Landren

begintalknode;
	tag = 30;
	state = -1;
	nextstate = 28;
	question = "General Landren";
	text1 = "A strong, weathered man stares intently out the window, watching for movement. He wears the insignia of a general. This is one of the handful of warriors who directs Avernum's defense against the Empire. He really, really outranks you.";
	text2 = "He turns and gives you a quick inspection. _Hello, soldier. I know about your work. You may have some of my time._";
	text3 = "As he speaks, he doesn't look away from the window. _I am General Landren. Welcome to my fort._";
	text5 = "General Landren grunts quietly. You aren't sure whether he's trying to indicate that you should ask him something else or that you should go away.";
	text6 = "As you speak, your conversation is constantly interrupted by approaching couriers. They are always needing him to approve this order or sign that letter.";
	action = INTRO;

begintalknode;
	state = 28;
	nextstate = 29;
	question = "_You are in command of this region?_";
	text1 = "He nods, not looking away from the uncontrolled territory to the north. _Yes. I lead all the troops from just east of the Great Cave Front to just west of Almaria._";

begintalknode;
	state = 29;
	nextstate = -1;
	question = "_Command is divided?_";
	text1 = "_Yes, by geography. Communication can be slow in Avernum, so each general controls an autonomous area._";


begintalknode;
	state = 29;
	nextstate = 30;
	condition = 1;
	question = "_How large is the area under your control?_";
	text1 = "_All Avernite forces within roughly fifty miles get their orders from this fort. My fort._ He smiles briefly in pride, but he doesn't stop watching out the window. _And my responsibility. In this area, we face a tenacious foe._";

begintalknode;
	state = 30;
	nextstate = 31;
	question = "_Who is your enemy?_";
	text1 = "_My opposing general is Limoncelli, of Fort Dolthar. He is the Empire commander, a deadly, vicious warrior, and my sworn enemy. If any raiders were willing to undertake a mission to deal with this menace, I would reward them._";
	text3 = "_There is no end to our foes. Although Limoncelli is dead, many Empier soldiers remain in our lands._";
	action = DEP_ON_SDF 49 11 0;

begintalknode;
	state = 31;
	nextstate = -1;
	condition = gf(56,12) < 2;
	question = "_What do you know about this Limoncelli?_";
	text1 = "_Limoncelli is my opposite number, the commander of all enemy forces in this area. He lives in Fort Dolthar. It is a huge fort on an island to the northeast, where the slith lord Sss-Thsss used to live. And he's really, really smart._";
	text2 = "_It's been all we could do to keep him from destroying us. Yet, I will outsmart him._";

begintalknode;
	state = 31;
	nextstate = -1;
	condition = gf(56,12) <= 1;
	question = "_I might be able to help with this. Can you give any more details?_";
	text1 = "_I want you to go kill Limoncelli. Find a way to Fort Dolthar, get in, and slay him. Do it, and not only will I try to get you a promotion, but I'll tell one of my mages to teach you to destroy magical barriers. That is not easy intelligence to obtain._";
	text2 = "_You'll need a boat to get there. Perhaps you can find one in Silvar._";
	action = SET_SDF 56 12 1;
	code =
		toggle_quest(59,1);
	break;

begintalknode;
	state = 28;
	nextstate = -1;
	condition = gf(56,12) == 1 && gf(49,11) >= 1;
	question = "_I did it. Limoncelli is dead. It wasn't easy._";
	code =
	run_hardcode(136);
	break;

begintalknode;
	state = 28;
	nextstate = 32;
	question = "_What are you looking for?_";
	text1 = "He points north. _Out there? That's the Scree Caves. Empire territory. We're on the border, right now. Empire troops have control of the caves to the north. Not strong control, but we can't send patrols out there. You want to go out there? Watch out! Oh, and a warning._";

begintalknode;
	state = 32;
	nextstate = -1;
	question = "_What warning?_";
	text1 = "_If you leave this fort to the north, you likely won't be able to return this way. The Empire enemy can disguise themselves, magically. We won't open the gates for you, 'cause it might not be you._";

// Captain Schnitzius

begintalknode;
	tag = 50;
	state = -1;
	nextstate = 55;
	question = "Captain Schnitzius";
	text1 = "You meet a Captain of the Avernum army. When he sees you, he walks over to greet you. Although he technically outranks you, your accomplishments have made you a celebrity. He's eager to meet you.";
	text2 = "_Welcome to our fort, envoy to the vahnatai. I am Captain Schnitzius. It is an honor to have you here. We can always use the help of raiders with your skill._";
	text5 = "Captain Schnitzius waits patiently. He is eager to learn if there's anything else you need. _We're eager to serve. Always like to help a hero of Avernum._";
	action = INTRO;

begintalknode;
	state = 55;
	nextstate = 56;
	question = "_Are you busy?_";
	text1 = "_I'm preparing to send another raid. That's what I do, mainly._";

begintalknode;
	state = 56;
	nextstate = 57;
	question = "_Tell me about the raids._";
	text1 = "_We're all fighting Limoncelli's forces here. He's a nasty and cunning Empire commander. Soon, I'll be off on another raid to try to penetrate his defenses and control the Scree Caves to the north. I'm not optimistic._";
	text3 = "_We're all fighting the army of Limoncelli here. Or, what was the army of Limoncelli, before you killed him. Thanks for that, by the way. Made our jobs here much easier. We want to retake the Scree Caves, to the north._";
	action = DEP_ON_SDF 56 12 1;

begintalknode;
	state = 57;
	nextstate = -1;
	condition = 1;
	question = "_The Empire controls the north?_";
	text1 = "_Yes, but only until we dislodge them. Our raids are picking away at the small bands they have been able to spare to control the Scree Caves._";

begintalknode;
	state = 57;
	nextstate = 58;
	question = "_Where is Limoncelli's army?_";
	text1 = "_He lives in Fort Dolthar, on an island to the northeast. He directs all his raids from there. We're just trying to find a way to get at him._ He looks grim. _Of course, even if we did reach him, he's a ... well ... an unusual warrior._";
	text3 = "_Limoncelli is dead, thank the Gods, but his army still remains, and it's a good one. But we'll beat them, have no fear!_";
	action = DEP_ON_SDF 56 12 1;

begintalknode;
	state = 58;
	nextstate = -1;
	condition = gf(56,12) < 2;
	question = "_In what way?_";
	text1 = "_I don't know how much of this is rumors and how much is fact. But he's ... he's magical. He's fast! He moves twice as fast as even the most skilled warrior, and he's that way all the time!_";
	text2 = "_I don't know how he got that way, but let me tell you, it don't make me too happy about the idea of facing him._";

begintalknode;
	state = 55;
	nextstate = 59;
	question = "_Seen lots of action here?_";
	text1 = "He laughs. _You don't know the half of it. Hardly a day goes by when some Empire soldiers don't sneak up and throw a few fireballs. They hope to get a lucky kill on us. Sometimes, they succeed._";

begintalknode;
	state = 59;
	nextstate = -1;
	question = "_But it's the Empire. Why don't they just overwhelm you with their huge armies?_";
	text1 = "_Because those armies are on the surface, not down here, and they're likely to stay that way. It's hard to teleport lots of people down here. This whole war is only small troop actions, on our home ground. That's been the only thing that's saved our lives._";

begintalknode;
	state = 55;
	nextstate = 56;
	condition = gf(56,12) <= 1;
	question = "_Do you need any jobs done?_";
	text1 = "_Yes. A thousand times yes. If you could kill Limoncelli, I could give you a real reward. We keep sending out raids, but we never get him. If you're interested, go speak with General Landren. He's on the north wall._";
	action = SET_SDF 56 14 1;

begintalknode;
	state = 56;
	nextstate = -1;
	condition = gf(56,14) == 1;
	question = "_What sort of reward would you give me for killing Limoncelli?_";
	text1 = "_Well, one of the hardest spells to learn, as I understand it, is the one that destroys magical barriers. If you could help us with this little task, I'm sure General Landren could see it clear to help you get this valuable and in-demand spell._";

// Buck

begintalknode;
	tag = 70;
	state = -1;
	nextstate = 82;
	question = "Buck";
	text1 = "You meet a priest in long robes. He sits cross-legged, staring into a large, green crystal. His eyes are closed in quiet meditation.";
	text2 = "When you get close, even though you are trying to be quiet, his eyes open. He looks at you and smiles. _A new arrival, yes? I'm Buck. Welcome to the fort._";
	text5 = "Buck leans back from the crystal, highly relaxed, and looks up to you. _We can talk. I don't need to meditate to use the crystal. If there's anything else you want to know, fire away._ The crystal before him hums quietly.";
	action = INTRO;

begintalknode;
	state = 82;
	nextstate = 83;
	question = "_What are you doing?_";
	text1 = "_I'm doing my meditations. Then I will return to my healing._";

begintalknode;
	state = 83;
	nextstate = -1;
	question = "_You are the fort's healer?_";
	text1 = "_One of them. When an attack comes, a lot of people can be hurt very quickly. I need to move fast and work hard. That's why I keep as much energy stored up as I possibly can at all times._";

begintalknode;
	state = 83;
	nextstate = 84;
	condition = gf(56,2) == 0;
	question = "_How do you meditate?_";
	text1 = "He points at the green crystal which dominates the room. _We don't know where that stone came from or who made it, but it regenerates our magical power very quickly. You should try it. It's a wonderful sensation._";
	text2 = "_It's an amazing crystal. We wish we knew who made it. It's very strange, sometimes, though._";

begintalknode;
	state = 84;
	nextstate = -1;
	question = "_How is it strange?_";
	text1 = "He looks nervous. _I don't like to talk about it, and people laugh at me for saying it, but sometimes, sometimes, when I feel the energy from the crystal, I almost think it's trying to talk to me._";
	text2 = "He smiles nervously. _Just the stress of the war, I'm sure._";

begintalknode;
	state = 84;
	nextstate = -1;
	question = "_Might the crystal have been made by the vahnatai?_";
	text1 = "He thinks. _Hmmm. An interesting theory, and frightening. We'll keep using it, I think, but maybe we should be a lot more careful about it._";

begintalknode;
	state = 82;
	nextstate = 85;
	question = "_You heal the soldiers when they are wounded?_";
	text1 = "_Not quite. I heal the soldiers I can. When I run out of energy, all I can do is sit back and watch them die. And who heals me when I'm grievously wounded?_";
	text2 = "He sighs. _We need more priests. But we're not getting them._";

begintalknode;
	state = 85;
	nextstate = -1;
	condition = 1;
	question = "_Can you teach any spells?_";
	text1 = "_I am not like the other priests of the land. I do not share my secrets for barter goods. No offense._";

// Tessa

begintalknode;
	tag = 90;
	state = -1;
	nextstate = 109;
	question = "Tessa";
	text1 = "A tiny woman in loose clothes sits cross-legged on her stool, absorbing the energy of the glowing, green crystal. Her gaze flickers up to you for a moment. _I am Tessa. What brings you here, stranger?_";
	text5 = "Tessa continues to absorb the energy of the crystal. It seems to have a powerful hypnotic effect.";
	action = INTRO;

begintalknode;
	state = 109;
	nextstate = 110;
	question = "_What are you doing?_";
	text1 = "_Preparing for my next raid. Move fast, strike hard, that sort of thing. We're heading north._";

begintalknode;
	state = 110;
	nextstate = 111;
	question = "_What are you going to raid?_";
	text1 = "_There's an Empire fort being built to the north, then a ways to the northwest. On the other side of the Scree Caves. We're trying to disrupt things, and maybe come up with a pass._";

begintalknode;
	state = 111;
	nextstate = -1;
	question = "_Do you think you can stop them?_";
	text1 = "_No. We don't yet have the forces to remove them from the far end of the Scree Caves. We can certainly slow things down, though. Harass them. You know?_";

begintalknode;
	state = 111;
	nextstate = -1;
	question = "_What pass?_";
	text1 = "_We've been trying to get our hands on a blue pass. You know? The passes the Empire folks use to get places. They've been having lots of supplies shipped into the new fort, so we think they must have some passes there._";
	text2 = "She focuses into the crystal. _Please excuse me. It's a very dangerous run, and I need all the power I can get._";
	action = END_TALK;

// Heustess

begintalknode;
	tag = 110;
	state = -1;
	nextstate = 136;
	question = "Heustess";
	text1 = "You meet another of Avernum's mages, though he is less presentable than most. His robes are in tatters, after being recently grazed by a stray fireball. His hands and face are flushed and burned, and patches of his hair are missing.";
	text2 = "He is looking at a magical barrier plugging holes in the north wall of the fort, looking for those that need repair. He turns and nods to you. _I am Heustess. Greetings._";
	text5 = "Heustess continues to ponder the barriers. Occasionally he pokes at one with his finger. _Excuse my ignoring you. Testing these things is my job._ His robes are still charred and ruined, but he doesn't seem to care.";
	action = INTRO;

begintalknode;
	state = 136;
	nextstate = 137;
	question = "_What are you working on?_";
	text1 = "_I am currently dispelling some barriers. It needs doing, sometimes, when we want to build a wall somewhere and the fields we put up to repair things are in the way._ He sighs. _It's tedious, but it's my responsibility._";

begintalknode;
	state = 136;
	nextstate = -1;
	condition = gf(56,12) >= 2;
	question = "_The commander said that you can teach how to dispel a magical barrier?_";
	text1 = "__";
	code =
	run_hardcode(137);
	break;

begintalknode;
	state = 137;
	nextstate = 138;
	question = "_What did you do before the war?_";
	text1 = "_Before I joined up to fight, I was doing research at the Tower of Magi. That seems a long time ago._";

begintalknode;
	state = 138;
	nextstate = -1;
	question = "_What research were you involved with?_";
	text1 = "_I was trying to create a spell to scry large areas of the caves. Alas, a spell to see a large area is a terribly difficult thing to create, and it is even harder to summon up the energy to cast._";
	text2 = "_I believe that someone has figured out how to do this. I have heard rumors. But I don't know if it is actually possible._";

begintalknode;
	state = 137;
	nextstate = 139;
	condition = gf(56,12) <= 1;
	question = "_Can you teach me how to dispel barriers?_";
	text1 = "_Sadly, no. I am under strict orders to not teach adventurers anything useful without permission from General Landren. You should talk to him._";

begintalknode;
	state = 139;
	nextstate = -1;
	question = "_That's stupid. We're on the same side._";
	text1 = "_Perhaps. But we've had a terrible time getting supplies and help. We've had to trade for most of what we need. I think the general wants to trade my knowledge for your help._";
	text2 = "_Look at it from our point of view. We have a job, and Avernum needs us to do it. If this is what it takes, well, there you go._";
	
begintalknode;
	state = 136;
	nextstate = -1;
	condition = gf(56,22) > 0;
	question = "_I want to learn to destroy barriers._";
	text1 = "You conclude your business.";	
	code = 
		begin_shop_mode("Heustess",
		  "Heustess is willing to teach you how to dispel magical barriers.",
		  78,1,0);	
	break;

// Theresa

begintalknode;
	tag = 130;
	state = -1;
	nextstate = 163;
	question = "Theresa";
	text1 = "You meet a young merchant. She has rough clothes and an equally rough expression. She coldly nods to you. _Soldier. Call me Theresa. What do you want?_";
	text5 = "Theresa stares at you impatiently. She wants to go back to work. Something is definitely bothering her. _Still here? What do you want?_";
	action = INTRO;
	
begintalknode;
	state = 163;
	nextstate = -1;
	question = "_I'm looking for information, mostly._";
	text1 = "_I don't have any._";

begintalknode;
	state = 163;
	nextstate = 164;
	question = "_I'm looking for equipment._";
	text1 = "_Well I'm a merchant, see, and I'm waiting for my current shipment to be approved so I can head out. I don't have anything to spare for you._";

begintalknode;
	state = 164;
	nextstate = -1;
	question = "_You're a merchant?_";
	text1 = "_Yeah, what of it? Tough work, traveling in these times._";

begintalknode;
	state = 164;
	nextstate = 165;
	question = "_What's in your shipment?_";
	text1 = "_Four hundred pounds of dried rations for Fort Emerald. Then on to Dharmon._ She says the word Dharmon with great lack of enthusiasm.";

begintalknode;
	state = 165;
	nextstate = 166;
	question = "_Not looking forward to Dharmon then?_";
	text1 = "_Yeah, Dharmon, westernmost city of Avernum, and city nearest to where all the real bloodshed is going on. I got to take a load there, and then I'm getting back east, where it's safe!_";

begintalknode;
	state = 166;
	nextstate = -1;
	question = "_Nowhere is safe from the Empire._";
	text1 = "_Hmm. Well, safer, anyway._";

begintalknode;
	state = 163;
	nextstate = -1;
	question = "_Can you sell me anything?_";
	text1 = "_No. No, I can't. My goods are supposed to go to regular soldiers, in regular forts. Sorry._ It's the least sincere apology you've ever heard.";

begintalknode;
	state = 163;
	nextstate = -1;
	condition = gf(56,13) <= 1;
	question = "_Why are you upset?_";
	text1 = "Surprisingly, she seems eager for someone to talk to.";
	text2 = "_A common mistake. I fell for someone I shouldn't. A soldier. Here. Named Brian. And now he's hurt, and the priests here can't do anything for him. I can't help him. Nobody can. It's driving me mad._ She closes her mouth, embarrassed that she's said so much.";
	text3 = "_I already told you. Brian is wounded, and nobody can do anything for him. Don't make me dwell on it. It's all I can do to stay sane as it is._";
	code =
		if (gf(56,13) == 0) {
			sf(56,13,1);
			rs(3);
			}
			else rs(1);
		toggle_quest(60,1);
	break;
	
begintalknode;
	state = 163;
	nextstate = -1;
	condition = gf(56,13) == 2;
	question = "_I healed Brian for you. He should be better now._";
	code =
	run_hardcode(43);
	break;

begintalknode;
	state = 163;
	nextstate = -1;
	condition = gf(56,13) >= 3;
	question = "_How is Brian doing now?_";
	text1 = "_Getting better faster and ready to go out and get killed. Why am I bothering with a soldier? I'm a fool!_ She sighs. _I really appreciate what you did, but it's difficult._ She turns away.";
	action = END_TALK;

// Brian

begintalknode;
	tag = 150;
	state = -1;
	nextstate = 190;
	question = "Brian";
	text1 = "This soldier is sitting by his bed. He is grievously wounded. His ribs are wrapped in a broad, gauze bandage, and the blood is slowly seeping through. He looks up at you and groans. _I'm Brian. What do you want?_";
	text5 = "Brian looks up at you, but he doesn't try to say anything. Understandable. Even with magical healing available, someone with this grievous a wound needs to conserve his strength.";
	action = INTRO;

begintalknode;
	state = 190;
	nextstate = 191;
	question = "_How did you wind up like this?_";
	text1 = "He starts to stand up, winces in pain, and settles back down. _I was scouting the Scree Caves. That's how I ended up this way._";

begintalknode;
	state = 191;
	nextstate = 192;
	question = "_Scouting?_";
	text1 = "_Reconnaissance. Spying. Watching the enemy to the north. Real risky._ He winces in pain again. _See, my patrol was on a boat trip, up northeast, and when we landed, we got ambushed._";

begintalknode;
	state = 192;
	nextstate = 193;
	question = "_Ambushed by who?_";
	text1 = "_Empire soldiers. They're all dead now. But one of 'em got me across the ribs with his sword. I'll be OK. I hope. Better off than him, anyway._ He touches the bandage gingerly, then winces.";
	text2 = "_And you know what burns me up? I say what I saw on my scouting, and nobody believes me! Nobody!_";

begintalknode;
	state = 193;
	nextstate = 194;
	question = "_What did you see?_";
	text1 = "_Yeah. See, we brushed near Limoncelli's fort to take a look, and I saw a bunch of those tall, skinny, weird guys landing in a boat. Those weird guys with the barriers. What were they called?_";

begintalknode;
	state = 194;
	nextstate = -1;
	question = "_Vahnatai?_";
	text1 = "_Yeah! Those freaks. I saw a bunch of 'em talking with Limoncelli's troops, right outside his fort! I don't know why they'd be there, but I don't trust 'em!_";

begintalknode;
	state = 190;
	nextstate = -1;
	condition = gf(56,13) <= 1;
	question = "_How are you doing?_";
	text1 = "He coughs savagely and shakes his head. _I'm not getting better. The priests here just aren't strong enough to help. I'll try to pull through, but, well..._ he closes his eyes.";
	text3 = "_A lot better, thanks to you. I think I'll be up and taking it to the Empire again pretty soon._";
	action = DEP_ON_SDF 56 13 1;

begintalknode;
	state = 190;
	nextstate = -1;
	condition = gf(56,13) == 1 && party_has_item(495) == 0;
	question = "Try to heal Brian.";
	text1 = "You summon up your powers and attempt to heal Brian. However, your magic isn't quite enough to do it. It's as if he's been afflicted with some sort of magical disease, making things worse.";

begintalknode;
	state = 190;
	nextstate = -1;
	condition = gf(56,13) == 1 && party_has_item(495) > 0;
	question = "Use graymold salve to heal Brian.";
	code =
	run_hardcode(42);
	break;

