// dlg.txt

begintalkscript;

variables;

short i;

begintalknode 1;
	state = -1;
	nextstate = -1;
	condition = get_sdf(31,0) == 0;
	question = "special";
	text1 = "To the west, you can see the walls of Bargha. It is a massive fortification, built up bit by bit over decades, to protect the Abyss from whatever lives in this cave.";
	text2 = "Once, it was giants. Then, the Slith Horde. Now, the servants of Melanchion. No matter who is on this side, the warriors of Bargha are ever ready to fill it full of arrows.";
	action = SET_SDF 31 0 1;

begintalknode 2;
	state = -1;
	nextstate = -1;
	condition = get_sdf(31,1) == 0;
	question = "special";
	text1 = "How amusing. Someone has built a tower here, out in the middle of these remote lands. It is new, shining construction, probably made by constructs. A wizard's tower, thoughtlessly plopped in the middle of this ravaged forest.";
	text2 = "The constructs that built it have been modified to defend the gate. They wander around aimlessly, waiting for the command that will send them into action. They have not attacked you. Yet.";
	action = SET_SDF 31 1 1;

begintalknode 3;
	state = -1;
	nextstate = -1;
	condition = get_sdf(31,2) == 0 && gf(31,6) == 0;
	question = "special";
	text1 = "You step into the tower, expecting instant retribution. Nothing attacks you, which is a nice change of pace. It's sort of warm and homey. The smell of ozone is heavy in the air, and flashes of blue light come from the top of the stairs.";
	text2 = "You hear a man's voice, shouting down from above. _Come on up, visitors. I am Shafrir. I won't hurt you as long as you display some manners._";
	action = SET_SDF 31 2 1;

begintalknode 4;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "You try to turn this wheel, but it's too large and difficult. You just don't have enough available force.";
	text3 = "You try to turn this wheel. It's very large and difficult to move, but, happily, someone oiled it recently. The gate slowly opens.";
	text5 = "You try to turn the wheel, but it refuses to budge.";
	code =
		clear_strings();
		if (gf(31,7) > 0)
			as(5);
			else if (gf(46,0) > 0) {
				sf(31,7,1);
				as(3);
				}
				else as(1);
	break;
	
begintalknode 5;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "Unsurprisingly, the construct has nothing to say to you. It just walks around, waiting to be told to kill something.";
	text2 = "There are several windows high up in the tower. You start to feel like someone is watching you.";
	
begintalknode 6;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "You flip through the book. It is a set of instructions for crafting certain enchanted items. A note near the beginning provides a helpful summary:";
	text2 = "_We will need a gazer's eyestalk first, still bearing all of its natural power and juices. We proceed from there ..._";
	text3 = "_protective ring - Focusing crystals. Many. Fine steel. Mandrake Tincture._";
	text4 = "_Halberd of Power and Mighty Impact- Wood is Easy to obtain. Crystals and steel. Demon's bile._";
	text5 = "_Magic Focusing Robe, Much to be Prized - Much of the Finest leather. Crystals. Tincture._";
	text6 = "_A Shield of lightness and altering of Time - Leather. Crystal. Steel. Much. The bile of a demon._";
	text7 = "_Sandals with the gazer's power - Leather and crystals. Some steel for reinforcement. More bile._";
	
begintalknode 7;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "This crystal pylon glows brightly. It occasionally sends a spark of energy toward the anvil to the north.";

begintalknode 8;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "The sign says:";
	text2 = "  SHAFRIR'S TOWER";
	text3 = "  Intruders unwelcome.";

begintalknode 9;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "You are surprised to find that this web is full of writing. The silk has been woven to spell magical incantation, probably for further study by the aranea.";
	text2 = "The writing is actually a chant. It describes how to summon shades from another realm to serve you. Seems quite useful. (Your skill with the spell Divine Host increases.)";
	text3 = "You stare at the web for a while, but you don't learn anything new.";
	text4 = "You stare at the web for a while, but you can't understand any of it. You don't know enough magical lore. (Improve your Arcane Lore skill to understand books like these.)";
	code =
		if (gf(31,4) == 0) {
			rs(3);
			if (get_stat_total(13) < 14)
				rs(2);
				else {
					rs(4);
					sf(31,4,1);
					alter_stat(30000,79,1);
					}
			}
			else {
				rs(1); rs(2); rs(4);
				}
	break;

//

begintalknode 10;
	state = -1;
	nextstate = 10;
	condition = 1;
	question = "Shafrir";
	text1 = "You meet the owner of this tower. Elderly, dignified and well-groomed. You suspect that he is originally from the surface, but he has been down here for a long time. When he sees you, he looks thrilled.";
	text2 = "_Ahhh ... A visitor! An Avernite! One who might even be able to help with my work. Once, I disdained your kind, but I have come to appreciate that you have your own sort of skill and courage._ He is in high spirits.";
	text3 = "_But no more babbling. I am Shafrir. Please, come forward. Let me inspect you. Come. Don't be worried. It will take but a moment._ He stares openly at your equipment, gauging its quality. He nods. _Adequate, but not impressive._";
	text5 = "As Shafrir speaks with you, he watches the activities of his magical machinery. Power flows from the large crystals toward his anvil. The anvil itself glows with a soft blue light.";
	text6 = "_Impressive, yes? This bit of equipment has helped me to imbue objects with enchantments far more quickly than I should have been able to._";
	action = INTRO;

begintalknode 11;
	state = 10;
	nextstate = 11;
	condition = 1;
	question = "What are you doing here?";
	text1 = "_Well, I had to live somewhere, didn't I?_ He laughs. _Despite my powers, I am still unable to return to the surface. So I looked for a place to plop my home, far from intruders. This place seemed convenient._";
	text2 = "";

begintalknode 12;
	state = 10;
	nextstate = 15;
	condition = 1;
	question = "What sort of work do you do here?";
	text1 = "_Crafting. Life is long, and I have been working on mastering all of the magical arts._";
	text2 = "_I have created this workshop. I have learned the techniques. Only one thing is missing._";

begintalknode 13;
	state = 10;
	nextstate = 12;
	condition = 1;
	question = "Where are you from?";
	text1 = "_Ahhh ... Once, I lived on the surface. Then I came to the underworld to sample the freedom you underworlders always go on about._";
	text2 = "_I lived in the Northern Reaches, where I had a very useful task to perform. Then I was forced to leave, so I came here._";

begintalknode 14;
	state = 10;
	nextstate = 16;
	condition = 1;
	question = "Can you craft something for me?";
	text1 = "He jumps toward you with almost childlike enthusiasm. _Yes ... It has been so long since I could practice. Let me see what you have, and I will get to work._";
	text2 = "He looks over your supplies ...";
	text3 = "Alas, without a gazer eyestalk, there is nothing he can do for you.";
	code =
		if (num_of_item(438) > 0)
			rs(3);
	break;
	
begintalknode 15;
	state = 11;
	nextstate = -1;
	condition = 1;
	question = "How did you build this tower?";
	text1 = "_Just a bit of magic. Create a few constructs and rest for a few days. And then move my things in. Magic is a great comfort, once you have mastered it._";

begintalknode 16;
	state = 11;
	nextstate = -1;
	condition = 1;
	question = "And does Melanchion bother you?";
	text1 = "_The dragon? The dragon does not mind me. I do some work for him. He lets me be. There is a certain mutual respect._";
	text2 = "_His followers are eerie and simple, but no more so than most people. I simply avoid them._";

begintalknode 17;
	state = 11;
	nextstate = -1;
	condition = 1;
	question = "What will you do with the tower when you leave?";
	text1 = "_Oh, I just leave my towers behind. Someone can make use of them. Hopefully not monsters, but who knows what will happen, really?_";

begintalknode 18;
	state = 12;
	nextstate = -1;
	condition = 1;
	question = "Why did you leave the surface?";
	text1 = "_The Empire places strong restrictions upon what mages are allowed to do. Even in these supposedly enlightened times, those harsh restrictions remain. Thus, many of us came down here to do proper work._";

begintalknode 19;
	state = 12;
	nextstate = 13;
	condition = 1;
	question = "What was your work in the Northern Reaches?";
	text1 = "_Actually, I was working in opposition to the Anama. A cult of the confused, who believe that magic is evil and must be resisted. They even had ways of placing bonds on people so that they could not even use magic._";
	text2 = "_I searched for ways to remove those bonds. Happily I succeeded. Although the Anama in the low caves are now too busy to spread their bizarre dogma._";
	
begintalknode 20;
	state = 13;
	nextstate = -1;
	condition = 1;
	question = "What happened to those Anama?";
	text1 = "_The Anama of Sanctuary?_ He laughs. _They have been besieged by the Slith Horde for months. Holding them off, I'm surprised to say, but the horde has no qualms about using magic on them._";
	text2 = "_They'll see the foolishness of their beliefs soon enough._";

begintalknode 21;
	state = 12;
	nextstate = -1;
	condition = 1;
	question = "Why did you leave the low tunnels?";
	text1 = "_Too many savage slithzerikai for my tastes. Also, all of the other humans fled, and I missed their occasional company. I like to be secluded, not totally abandoned._";

begintalknode 22;
	state = 15;
	nextstate = -1;
	condition = 1;
	question = "What?";
	text1 = "_Materials! Such as, I am sure, you have gathered in your travels._";
	text2 = "He points at the book by the west wall. _My focus of study now is how to liberate the innate power in gazer eyestalks. You should look in that book. If you can provide the correct materials, I can create equipment for you._";
	text3 = "_Or, try to. In magic, nothing is certain._ He laughs.";

begintalknode 23;
	state = 16;
	nextstate = -1;
	condition = num_of_item(294) >= 0 && num_of_item(295) >= 5 && num_of_item(296) >= 2 && num_of_item(287) >= 1 && num_of_item(288) >= 0 && num_of_item(438) >= 1;
	question = "Make a ring for me. (Give 5 focusing crystals, 2 fine steel, mandrake tincture, and an eyestalk.)";
	text1 = "Shafrir eagerly gathers the materials, takes them to his anvil, and sends you downstairs to rest and have a light meal.";
	text2 = "The sounds of lightning, hammering, and cursing echo down to you for several hours.";
	text2 = "Eventually, Shafrir calls you upstairs. He hands you a ring, still glowing from the heat of the forge. _Difficult work, but I think it is everything you hoped for._";
	action = REUSABLE;
	code =
		take_num_of_item(294,0);
		take_num_of_item(295,5);
		take_num_of_item(296,2);
		take_num_of_item(287,1);
		take_num_of_item(288,0);
		take_num_of_item(438,1);
		reward_give(174);
	break;
	
begintalknode 24;
	state = 16;
	nextstate = -1;
	condition = num_of_item(294) >= 0 && num_of_item(295) >= 3 && num_of_item(296) >= 5 && num_of_item(287) >= 0 && num_of_item(288) >= 1 && num_of_item(438) >= 1;
	question = "Make a halberd for me. (Give 3 focusing crystals, 5 fine steel, demon's bile, and an eyestalk.)";
	text1 = "Shafrir eagerly gathers the materials, takes them to his anvil, and sends you downstairs to rest and have a light meal.";
	text2 = "The sounds of lightning, hammering, and cursing echo down to you for several hours.";
	text2 = "Eventually, Shafrir calls you upstairs. He hands you a halberd, still glowing from the heat of the forge. _Difficult work, but I think it is everything you hoped for._";
	action = REUSABLE;
	code =
		take_num_of_item(294,0);
		take_num_of_item(295,3);
		take_num_of_item(296,5);
		take_num_of_item(287,0);
		take_num_of_item(288,1);
		take_num_of_item(438,1);
		reward_give(394);
	break;

begintalknode 25;
	state = 16;
	nextstate = -1;
	condition = num_of_item(294) >= 6 && num_of_item(295) >= 3 && num_of_item(296) >= 0 && num_of_item(287) >= 1 && num_of_item(288) >= 0 && num_of_item(438) >= 1;
	question = "Make a robe for me. (Give 3 focusing crystals, 6 fine leather, mandrake tincture, and an eyestalk.)";
	text1 = "Shafrir eagerly gathers the materials, takes them to his anvil, and sends you downstairs to rest and have a light meal.";
	text2 = "The sounds of lightning, hammering, and cursing echo down to you for several hours.";
	text2 = "Eventually, Shafrir calls you upstairs. He hands you a robe. It is made of wool and leather. Sturdy and warm. _Difficult work, but I think it is everything you hoped for._";
	action = REUSABLE;
	code =
		take_num_of_item(294,6);
		take_num_of_item(295,3);
		take_num_of_item(296,0);
		take_num_of_item(287,1);
		take_num_of_item(288,0);
		take_num_of_item(438,1);
		reward_give(29);
	break;

begintalknode 26;
	state = 16;
	nextstate = -1;
	condition = num_of_item(294) >= 4 && num_of_item(295) >= 4 && num_of_item(296) >= 4 && num_of_item(287) >= 0 && num_of_item(288) >= 1 && num_of_item(438) >= 1;
	question = "Make a shield for me. (Give 4 focusing crystals, fine steel, and fine leather, some demon's bile, and an eyestalk.)";
	text1 = "Shafrir eagerly gathers the materials, takes them to his anvil, and sends you downstairs to rest and have a light meal.";
	text2 = "The sounds of lightning, hammering, and cursing echo down to you for several hours.";
	text2 = "Eventually, Shafrir calls you upstairs. He hands you a shield, still glowing from the heat of the forge. _Difficult work, but I think it is everything you hoped for._";
	action = REUSABLE;
	code =
		take_num_of_item(294,4);
		take_num_of_item(295,4);
		take_num_of_item(296,4);
		take_num_of_item(287,0);
		take_num_of_item(288,1);
		take_num_of_item(438,1);
		reward_give(137);
	break;

begintalknode 27;
	state = 16;
	nextstate = -1;
	condition = num_of_item(294) >= 3 && num_of_item(295) >= 3 && num_of_item(296) >= 3 && num_of_item(287) >= 0 && num_of_item(288) >= 1 && num_of_item(438) >= 1;
	question = "Make some shoes for me. (Give 3 focusing crystals, fine steel, and fine leather, some demon's bile, and an eyestalk.)";
	text1 = "Shafrir eagerly gathers the materials, takes them to his anvil, and sends you downstairs to rest and have a light meal.";
	text2 = "The sounds of lightning, hammering, and cursing echo down to you for several hours.";
	text2 = "Eventually, Shafrir calls you upstairs. He hands you a pair of beautiful sandals, reinforced with steel. _Difficult work, but I think it is everything you hoped for._";
	action = REUSABLE;
	code =
		take_num_of_item(294,3);
		take_num_of_item(295,3);
		take_num_of_item(296,3);
		take_num_of_item(287,0);
		take_num_of_item(288,1);
		take_num_of_item(438,1);
		reward_give(153);
	break;

begintalknode 28;
	state = 16;
	nextstate = 10;
	condition = 1;
	question = "I don't need anything.";
	text1 = "Shafrir looks disappointed. _Ah, well. Maybe, if you find more materials, you can bring them to me!_";

begintalknode 29;
	state = 10;
	nextstate = -1;
	condition = 1;
	question = "Good day to you.";
	text1 = "_And safe travels to you as well. I hope you can help the dragon to bring some order to this rocky pit._";
	action = END_TALK;

//

begintalknode 30;
	state = -1;
	nextstate = 30;
	condition = 1;
	question = "Name";
	text1 = ".";
	text2 = "";
	text5 = ".";
	action = INTRO;

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

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

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

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

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

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

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

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

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

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

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

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

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

begintalknode 44;
	state = 30;
	nextstate = -1;
	condition = 1;
	question = "";
	text1 = ".";
	text2 = "";
	
//

begintalknode 50;
	state = -1;
	nextstate = 50;
	condition = 1;
	question = "Name";
	text1 = ".";
	text2 = "";
	text5 = ".";
	action = INTRO;

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

	
begintalknode 52;
	state = 50;
	nextstate = -1;
	condition = 1;
	question = "";
	text1 = ".";
	text2 = "";
	
begintalknode 53;
	state = 50;
	nextstate = -1;
	condition = 1;
	question = "";
	text1 = ".";
	text2 = "";
	
begintalknode 54;
	state = 50;
	nextstate = -1;
	condition = 1;
	question = "";
	text1 = ".";
	text2 = "";
	
begintalknode 55;
	state = 50;
	nextstate = -1;
	condition = 1;
	question = "";
	text1 = ".";
	text2 = "";
	
begintalknode 56;
	state = 50;
	nextstate = -1;
	condition = 1;
	question = "";
	text1 = ".";
	text2 = "";
	
begintalknode 57;
	state = 50;
	nextstate = -1;
	condition = 1;
	question = "";
	text1 = ".";
	text2 = "";
	
begintalknode 58;
	state = 50;
	nextstate = -1;
	condition = 1;
	question = "";
	text1 = ".";
	text2 = "";

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

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

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

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

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

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

////

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