// Town 7: Nakhtha
begintownscript;

variables;

short choice,i,j,k;
string dlgstr;

body;

beginstate INIT_STATE;
	set_crime_tolerance(2);
	
	set_name(6,"Kafthss");
	set_name(14,"Askss");
	
	set_level(20,80);
	set_level(21,80);
	
	change_blocked(35,49,1);
	change_blocked(35,50,1);
	
	change_blocked(11,40,1);
	change_blocked(11,41,1);
	change_blocked(11,42,1);
	
	set_level(6,75);
	
if (get_flag(7,0) == 0) {
	force_instant_terrain_redraw();
	set_flag(7,0,1);
	reset_dialog();
	add_dialog_str(0,"You approach the ruins of a city straddling the river. Battle marks cover the outer walls, which have been repaired but not cleaned since the sack.",0);
	add_dialog_str(1,"In order to continue by boat, the expedition will have to pass through this city. The gates in the north for boat-travel are closed right now, but there must be machinery somewhere to open them, if you can find it and work it.",0);
	add_dialog_str(2,"Surely this is what you must clear before you return to Legare. And there is something to clear: you see movement inside the walls.",0);
	run_dialog(1);
	run_scenario_script(11);
	}
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
if (get_flag(7,1) == 0) {
	set_flag(7,1,1);
	message_dialog("You enter the ruins of the library. The rest of the town contains traces of battle, but at least there the traces have been cleaned up a bit; here there is no evidence of cleaning at all. The library has been untouched since the barbarians arrived.","This library was once large and, by the look of it, quite extensive. So little remains of so much knowledge once here that you can only stare at the damage. A few of the remaining pieces look interesting, though.");
	}
break;

beginstate 11;
	message_dialog("You skim this shelf. Most of the documents are destroyed. It carried several papyrus scrolls and a few books, but now only one is readable. It is a fragment of a poem, a long one by the size of the blasted parts. The title is, _The Khalthanad._ You read:","_Thus his mighty hand hurled the two-tined spear at the dragon's watery eye, hoping with one stroke both to end the battle and to win glory; the points pierced the vile jelly, and the magnificent beast with one screech fell: Mahanyakshetra was dead._");
break;

beginstate 12;
	reset_dialog();
	add_dialog_str(0,"On these shelves, you find a book that appears to be a history. It is badly damaged, but you can read a small part. It is damned difficult language, with tortured word-order and obscure usage, but you can piece it together.",0);
	add_dialog_str(1,"_Pethenokrheedithi polykorhoom polykoose rheesikhi rheesohesse ingenithi bitakhathiithi, peritham tiini kaalohesse ritan desviidaden kotan copoonaden aletheekh naakh akessohessekh. Ghoorh menoom probainaem: bellekh._",0);
	add_dialog_str(2,"It translates, _The credulity of the many on matters of popular history is great, but I have attempted in this work to set apart the facts from legend and gather together what is true, not merely hearsay. Let me then proceed to my subject: the war._",0);
	run_dialog(1);
break;

beginstate 13;
if (get_flag(7,2) == 0) {
	reset_dialog();
	add_dialog_str(0,"You skim over the shelves, finding one title that looks interesting. It appears to be a book of magic. These things are dangerous: they can do as much harm as help if you read them. What do you wish to do?",0);
	add_dialog_choice(0,"Leave it alone.");
	add_dialog_choice(1,"Attempt to read it.");
	if (run_dialog(1) == 2) {
		reset_dialog();
		if (get_skill_total(42) >= 16) {
			set_flag(7,2,1);
			message_dialog("The book is written in a strange rune script, but fortunately, due to your knowledge of Arcane Lore, you can read it.","It's a spellbook describing how to cast a spell to slow your enemies, _Bind Foe._ You take mental note of this new spell.");
			inc_flag(292,1,1);
			set_flag(292,0,1);
			}
		else
			message_dialog("The book is written in a strange rune script, and unfortunately, you can't read it. Perhaps if you knew more about Arcane Lore, you would be able to.","");
		}
	}
else
	message_dialog("You find the book on Bind Foe again, but you can learn no more from it.","");

break;

beginstate 14;
if (get_flag(7,3) == 0) {
	set_flag(7,3,1);
	message_dialog("You enter a room with several wheels and windows that look out at the closed gates that make it impossible for you to pass through this town in your boat. Perhaps here you can open those gates and continue on your journey.","");
	}
break;

beginstate 15;
if (get_flag(7,4) == 0) {
	set_flag(7,4,1);
	message_dialog("You enter a room with several wheels and windows that look out at the closed gates that make it impossible for you to pass through this town in your boat. Perhaps here you can open those gates and continue on your journey.","");
	}
break;

beginstate 16;
	reset_dialog_preset_options(8);
	if (run_dialog(1) == 2) {
		set_flag(7,5,1);
		message_dialog("You attempt to turn the wheel, but it moves only with great strain. You notice the gates lift slightly in the water, but not enough to let you through, and after a short distance, the wheel ceases to move at all.","As soon as you let go, it unwinds exactly as far as you turned it. It appears that you won't be able to get these gates open now. The leaders of the expedition will probably want to know about this dead end.");
		}
break;

beginstate 17;
if (get_flag(7,7) == 0) {
	set_flag(7,7,1);
	message_dialog("You enter Nakhtha from the west. Right in front of you, just past this gate, you hear the deep hissing of a very large slith. The greatest warrior within these walls must be just in front of you.","Suddenly you realize that you can barely understand this slith. His language is a barbarized form of the ancient tongue, one so full of breathy hisses and sharp stops that it lacks all of the elegance of the former speech. He is nearly incoherent.");
	}
break;

beginstate 18;
if (get_flag(7,7) == 0) {
	set_flag(7,7,1);
	message_dialog("You approach the west bank of the river, but you hear something and stop short. You hear deep hissing drifting to your ear, that of a very large slith. The greatest warrior within these walls must be just in front of you.","Suddenly you realize that you can barely understand this slith. His language is a barbarized form of the ancient tongue, one so full of breathy wind and sharp stops that it lacks all of the elegance of the former speech. He is nearly incoherent.");
	}
break;

beginstate 19; // barbarian slith leader dies
	set_flag(7,6,1);
	message_dialog("The massive, frilled brute falls, succumbing to the terrible pain of his wounds. As he dies, bleeding, he utters a single sentence in his barbaric tongue: _Rashank slay you!_","Rashank? He spoke as if the word were the name of some god, but you've never heard of it.");
break;

beginstate 20;
if (get_flag(7,8) == 0) {
	reset_dialog();
	add_dialog_str(0,"The open book here appears to be a book of magic. These things are dangerous: they can do as much harm as help if you read them. What do you wish to do?",0);
	add_dialog_choice(0,"Leave it alone.");
	add_dialog_choice(1,"Attempt to read it.");
	if (run_dialog(1) == 2) {
		set_flag(7,8,1);
		message_dialog("This book describes several investigations into the summoning of demons, starting small and building to very mighty ones. Once you begin reading, it is hard to stop, and as you turn the last few pages, you realize that you are muttering aloud.","You are no longer alone in the room.");
		activate_hidden_group(2);
		}
	}
break;

beginstate 21;
if (get_flag(7,9) == 0) {
	reset_dialog();
	add_dialog_str(0,"You step inside the great temple, the greatest building untouched by the barbarians. It is of the sort which you are familiar with from Bahssikava. There are large statues, banners, kneeling mats for worshippers, and all sorts of machinery for displays.",0);
	add_dialog_str(1,"One conspicuous absence is the lack of pools of differently-colored water. Those pools, you learned in Vasskolis, were pools of atonement. The unclean washed their hands in each, coming from the darkness to the light, whenever purification was necessary.",0);
	add_dialog_str(2,"Evidently the Bahssikavans always felt the need to purify, but the homeland sliths feel no such insecurity.",0);
	set_flag(7,9,run_dialog(1));
	}
break;

beginstate 22;
if (get_flag(7,10) == 0) {
	reset_dialog();
	add_dialog_str(0,"In this box is a small, blue, runed-covered book. It must be a spellbook of the sliths! Most of the pages have been torn out, but a few remain legible.",0);
	add_dialog_str(1,"Reading strange spellbooks can be dangerous: they can carry curses or other terrible effects. However, they can also have great spells recorded within.",0);
	add_dialog_str(2,"What do you do?",0);
	add_dialog_choice(0,"Leave it alone.");
	add_dialog_choice(1,"Attempt to read it.");
	if (run_dialog(1) == 2) {
		reset_dialog();
		set_flag(7,10,1);
		add_dialog_str(0,"The book describes an interesting new spell, one that hastes all of the members of your party simultaneously. (You learn a level of Major Haste.)",0);
		set_flag(293,3,run_dialog(1)); // flag for spell
		set_flag(293,0,1);
		}
	}
else
	message_dialog("You find the book on Major Haste again, but you don't learn anything new from it.","");
break;