// TOWN DIALOGUE SCRIPT
//    Town 13: Erika's Tower

begintalkscript;

variables;

short i,j,k,r1,choice;

begintalknode;
	tag = 1;
	state = -1;
	nextstate = -1;
	condition = 1;
	text1 = "The enemy wizard has vanished entirely. Her shades disappear too. Very soon, the Empire invaders will know a lot more about you.";
	text2 = "On the bright side, you have earned Erika a nice, long respite from the attacks on her. You have to hope she is grateful.";
	action = END_TALK;
	code =
		erase_char(1303);
	break;
	
// Erika

begintalknode;
	tag = 10;
	state = -1;
	nextstate = 1;
	question = "Erika";
	text1 = "At last, you meet Erika, the infamous, reclusive archmage of Avernum. She is a tall, imposing woman with long, raven-black hair. She watches you with cold, analytical eyes, evaluating how useful the fresh material before her can potentially be.";
	text2 = "At last, she nods and pours you some tea. _Social niceties must be observed, I suppose. Welcome. At last, we can talk._";
	text5 = "Erika takes advantage of the lull in conversation to sip her tea. _What else do we need to talk about?_ She is not great at small talk.";
	action = INTRO;
	code =
		toggle_quest(132,3);
		run_hardcode(1010);
	break;
	
begintalknode;
	state = 1;
	nextstate = -1;
	condition = gf(13,14) == 0;
	question = "_Greetings. It was difficult to reach you._";
	text1 = "_Good. The approach was difficult but not impossible? Yes. I live here in my tower, watching my defenses and keeping the Empire from taking my head. I also prepare assaults against the Empire. Important assaults._";
	text2 = "_I will help you now. I will help you find one of the Crystal Souls, and I will help you learn of Garzahd. Both things are crucial._";
	action = SET_SDF 13 14 1;

begintalknode;
	state = 1;
	nextstate = 4;
	condition = gf(13,14) >= 1;
	question = "_Why does the Empire want you dead?_";
	text1 = "_The Empire will stop at nothing to slay me. It was I who engineered the assassination of Hawthorne._ She pauses. _Of course, for that, some fools resent me!_";

begintalknode;
	state = 4;
	nextstate = -1;
	question = "_You've encountered resentment?_";
	text1 = "Her face twists in fury. _Avernum is full of tiny minds! Pathetic worms who blame me for this invasion! As if the Empire would not have eventually decided to slay us anyway! At least I struck a decisive blow before it happened._";
	text2 = "She shakes her head. _Tiny-minded fools. That's what they all are. But I'll show them!_";
	
begintalknode;
	state = 4;
	nextstate = 5;
	question = "_Tell me about Hawthorne._";
	text1 = "_The pathetic emperor of the Empire. It was I who found the assassins. It was I who told them how to reach Hawthorne. It was I who sent them there. I am responsible._";
	text2 = "_They will do all that they can to exact vengeance upon me._ She chuckles grimly. _They will fail. And thus I avenge myself for my banishment._";

begintalknode;
	state = 5;
	nextstate = 12;
	question = "_Revenge can be an effective motivator._";
	text1 = "_Yes! They dared send me down here! And they cursed me as well! The insult, the arrogance, to think once I was down here I could no longer harm them!_ She laughs. _I showed them! And I will show them still!_";
	
begintalknode;
	state = 12;
	nextstate = -1;
	question = "_How did they curse you?_";
	text1 = "_If I am ever touched by the light of the sun, I will instantly die. They thought this would make them safe from me. Fools._";



begintalknode;
	state = 1;
	nextstate = 3;
	condition = gf(13,14) >= 1;
	question = "_I'm impressed by your tower._";
	text1 = "_You should be. This is my home, and I will not leave it, although my enemies work day and night to slay me. The Empire wishes me dead like no other._ She thinks. _By the way, you have passed my tests, and shall be rewarded._";

begintalknode;
	state = 3;
	nextstate = -1;
	question = "_What reward?_";
	text1 = "_You have reached the center of my tower once. The next time will be easier._ She points to the southeast. _I have created a pylon there. You can use it to easily travel from the Tower of Magi to here._";

	
begintalknode;
	state = 1;
	nextstate = -1;
	condition = gf(13,14) >= 1 && gf(13,29) == 0;
	question = "_What assaults are you planning against the Empire?_";
	text1 = "_Two missions occupy my mind. They are desperately important, but nothing can be done without adventurers who can leave here and strike the actual blows. Though I can't help directly, I can provide invaluable information._";
	text2 = "_I speak of recovering the Crystal Souls, and of the destruction of Garzahd._";
	code =
		sf(13,29,1);
	break;
	
begintalknode;
	state = 1;
	nextstate = 7;
	condition = gf(13,29) > 0;
	question = "_Tell me of Garzahd._";
	text1 = "Her smile is chilling. _Oh, sweet Garzahd, the withered man, the vermin who sent me down here. Now he is in Avernum. He thinks he can hunt me, and I want him dead! And I have several leads on how it may be done._";
	text3 = "She bows her head. It is a rare sign of respect. _You have slain the worm. I thank you. It was well done indeed._";
	action = DEP_ON_SDF 16 11 0;

begintalknode;
	state = 7;
	nextstate = 8;
	condition = gf(16,11) == 0;
	question = "_How can I affect such a powerful mage?_";
	text1 = "_To slay Garzahd, you will need to be able to reach him and then kill him before he kills you. Someone named Thompson might help with the former, and Solberg might help with the latter._";
	text2 = "_And, of course, for what it's worth, you will want to see King Micah._";
	action = SET_SDF 10 11 1;
	code =
		toggle_quest(133,3);
	break;
	
begintalknode;
	state = 8;
	nextstate = -1;
	question = "_What's your opinion of King Micah?_";
	text1 = "She shakes her head. _A good man, but he's up against the greatest foes the Empire has to offer. Fortunately, his resources may have uncovered something necessary to slay Garzahd. You should speak with him._";

begintalknode;
	state = 8;
	nextstate = -1;
	question = "_Tell me more about Solberg._";
	text1 = "_He is a worthy mage. Alas, he is trapped in his tower as much as I am. He lives southwest of Formello. After you see King Micah, ask Solberg about Garzahd. They knew each other. He might know something of how to slay him._";

begintalknode;
	state = 8;
	nextstate = -1;
	question = "_Can you tell me where Thompson might be found?_";
	text1 = "She sniffs. _He is a lesser mage, but he knows a lot about teleportation. That seems the best route to reach Garzahd. Ask people about him in Blosk. That was where he lived before he disappeared._";
	text2 = "_You may have to poke around a bit. He was a quiet one._ (You take note of this.)";
	action = SET_SDF 10 11 1;
	code =
		toggle_quest(106,1);
	break;


begintalknode;
	state = 1;
	nextstate = -1;
	condition = gf(30,15) >= 1;
	question = "_I found the Crystal of Vyvnas-Bok and returned it._";
	text1 = "_Good. I would help you find the others, but I don't know where they are. But bear this in mind. The vahnatai must have helped the Empire steal them. Look for any signs of vahnatai in Empire forts, or vahnatai who have rebelled against their fellows._";
	text2 = "_Those are places where valuable evidence might be found._";
	code =
		sf(13,16,1);
	break;
	
begintalknode;
	state = 1;
	nextstate = 9;
	condition = gf(30,15) == 0 && gf(13,29) > 0;
	question = "_I would like to help the vahnatai recover their Crystal Souls. Where should I go?_";
	text1 = "__";
	code =
		toggle_quest(114,3);
	run_hardcode(142);
	break;

begintalknode;
	state = 9;
	nextstate = -1;
	question = "_What do you think of the vahnatai?_";
	text1 = "She looks uncomfortable. _Those bizarre aliens will cause us trouble yet. They will not be happy sharing their home with us for long. When they tire of us, they will exercise their considerable power against us. When it happens ..._";
	text2 = "She sighs. _Let's just say these days of war may be a happy and nostalgic past. Vahnatai power runs strong and deep._";

begintalknode;
	state = 9;
	nextstate = 10;
	condition = gf(13,15) >= 2 && gf(30,15) == 0;
	question = "_What can you tell me of Angierach?_";
	text1 = "_Angierach is an Empire fort, and a bizarre one. A variety of powerful magical creatures live and work there, preparing strange magics. I know, for example, that they were researching magical barriers there._";
	text2 = "_I also know that the fort has strong wards._";

begintalknode;
	state = 10;
	nextstate = 11;
	question = "_Wards? What does that mean?_";
	text1 = "_The fort is very hard to get into. There are powerful magical statues in front of it which block entry. However, there is a mage named Ostoth who knows how to reach it._";

begintalknode;
	state = 11;
	nextstate = -1;
	question = "_Where is Ostoth?_";
	text1 = "_I cannot remember. I spoke with him some time ago. He said he knew a 'Teleportation code' to reach the fort. If you meet him, you should ask him about Angierach. He knows how to get to that fortress._ (You take note of this.)";
	text2 = "She thinks. _I do not know where he is now. And yet ... Now that I think of it, he did express an interest in studying dragons. For what it is worth._";
	action = SET_SDF 23 25 1;
	code =
		toggle_quest(103,1);
	break;
	
begintalknode;
	state = 10;
	nextstate = 13;
	question = "_I don't suppose you know more about these magical barriers they are researching?_";
	text1 = "_I know that some rakshasi there are working on a new sort of magical barrier that is immune to normal dispelling. It was originally created by Garzahd. There is a woman named Enla who knows more about it than me._ (You take note of this.)";
	text2 = "_If you meet her, ask her about Garzahd. She may help you. Then again, maybe not._";
	action = SET_SDF 23 26 1;
	code =
		toggle_quest(141,1);
	break;

begintalknode;
	state = 13;
	nextstate = -1;
	question = "_Where can I find Enla?_";
	text1 = "_I know a lot, but I can hardly be expected to track the presence of every person in Avernum! I think somewhere in the east. Somewhere around Formello, last I heard._";


begintalknode;
	state = 1;
	nextstate = -1;
	condition = gf(13,14) >= 1 && get_prestige() < 55;
	question = "_Can you give me magical training?_";
	text1 = "She thinks. _No. Not yet.  Only the most intrepid of adventurers, who have done many, many acts to aid Avernum, earn my assistance and training._";

begintalknode;
	state = 1;
	nextstate = -1;
	condition = gf(13,14) >= 1 && get_prestige() >= 55;
	question = "_We have traveled far, and done much. Can you give me magical training?_";
	text1 = "You conclude your business.";
	code =
		begin_shop_mode("Erika's Training","Erika is the finest mage in Avernum, and being trained by her is a vanishingly rare privilege.",92,5,3);
	break;

