// Town 17: Lava Lizard Cave
begintownscript;

variables;

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

body;

beginstate INIT_STATE;
	set_crime_tolerance(2);
	
	change_outdoor_location(0,5,3,39);
	
	set_special_ability(6,2);
	set_special_ability(17,0);
	set_special_ability(18,20);
	set_special_ability(19,20);
	set_special_ability(20,20);
	set_special_ability(21,20);
	set_special_ability(22,20);
	set_special_ability(23,20);
	
	if (get_flag(17,0) == 0) {
		force_instant_terrain_redraw();
		set_flag(17,0,1);
		message_dialog("You see more signs of an ancient battle: goo, wayward fields, and blood. Across the room you see a very old corpse, which looks strange to you. You look closer.","Little is left of this body except a skeleton. Unlike everything else you've seen around here, though, the skeleton is clearly humanoid. Moreover, it is long and thin, with features that are clearly vahnatai!");
		}
break;

beginstate EXIT_STATE;
	if ((get_flag(17,1) == 0) && (get_flag(17,2) == 0)) {
		set_flag(17,1,1);
		message_dialog("You finally exit out the cave on the other side into the outdoors, hoping to find a land more hospitable than the Lava Ocean on the other side, so that the expedition can travel this way. Unfortunately, you don't.","The path that the ancient sliths must have once used is now caved in. There is no way to get out through here. You were wrong, and you must now go back to the camp and tell Kass that you have no idea how to get out of this hellish land.");
		}
break;

beginstate START_STATE;
break;

beginstate 10;
	reset_dialog();
	add_dialog_str(0,"You find a ladder. What do you wish to do?",0);
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Climb it.");
	if (run_dialog(1) == 1)
		block_entry(1);
	else {
		set_flag(17,2,1);
		move_to_new_town(16,7,2);
		}
break;

beginstate 11;
	reset_dialog();
	add_dialog_str(0,"In this desk, you find a note, written in a dialect of the ancient slith language more archaic even than the Khalthanad:",0);
	add_dialog_str(1,"_My name is Elin-Tel, and I write this note that when the investigators from Thassaka come, they may discover the truth of these things, otherwise murky and impossible-seeming.",0);
	add_dialog_str(2,"_That the laboratory in the east has transgressed is beyond doubt, having discovered and unearthed an evil so ancient and terrible that throats tremble to speak of it. They looked upon the very image of doom and expired.",0);
	add_dialog_str(3,"_From its release, destruction it sought, horror to all, reptilian murder, cutting scales with baneful fires of the eyes, strange screams full. What it was not I know, but that it be some blackest god come to dash our souls from our corporeal forms.",0);
	add_dialog_str(4,"_All outposts here lie destroyed, even before I came. I did seal the upper chambers from the lower, but the foul beasts of the violent god have found another path, and I must now speed away or gaze into the open maw of death.",0);
	add_dialog_str(5,"_I carry with me the last remaining laboratory key, with the desperate hope that I may take to Thassaka the power to enter the heart of the darkness and defeat it. I go now. They come!_",0);
	run_dialog(1);
	if (get_flag(17,3) == 0) {
		message_dialog("Several things about this note strike you as you read. This note must predate the founding of the Empire of Khalthas to be older than the Khalthanad. It was written by a vahnatai in the slith language. Thassaka. A laboratory? An ancient evil?","This land may hold many more secrets (and answers) than you at first realized.");
		set_flag(17,3,1);
		}
break;

beginstate 12;
	if (get_flag(17,4) == 0) {
		reset_dialog();
		add_dialog_str(0,"You round this corner and come into view of the ruins of an old vahnatai town. Metal is scattered around everywhere; it must have been a smithing outpost once. The Lava Ocean must have provided an ample supply of various useful minerals.",0);
		add_dialog_str(1,"Then it was attacked by powerful magic. The battle was so long ago that most of the remains are gone, with little more than some bloodstains and a few dissipating fields left. Skeletons, some recognizably vahnatai, some not, have lain here ever since.",0);
		add_dialog_str(2,"Little remains at all now except a few bars of useless metals and a handful of very large roaches. This place was obliterated thoroughly, although perhaps something useful still remains somewhere in the ruins.",0);
		set_flag(17,4,run_dialog(1));
		}
break;

beginstate 13;
	reset_dialog();
	add_dialog_str(0,"This is the body of a vahnatai. That much you can still recognize after centuries of decay. It carries a note, written in a shaking hand.",0);
	add_dialog_str(1,"_The evil that Vylas awoke has reduced the metalworks to dust. I hid here out of sight, hoping to escape when they passed on, but I brought no water, no food. Now my folly is apparent: I have barely the strength to write these words.",0);
	add_dialog_str(2,"_But I must write to warn_ -- here the writing loses vigor -- _if you enter the lab, do not trust the demon, silver-tongued but a liar. He will destroy. That you not trust, it is imperative, not listen, not trust, do not...._ Thus the writing fades.",0);
	add_dialog_str(3,"The urgency is plain in the final few words: _Oot nakh khreedhaas peklaarh nakh akessaas nekhreedhaas to naakh...._",0);
	run_dialog(1);
break;

beginstate 14; // Learning Bonechill from book, one-timed with (17,5)
if (get_flag(17,5) == 0) {
	reset_dialog();
	add_dialog_str(0,"The book on the pedestal here is badly damaged, but you can read some of it still. It appears to be a book of magic. These things are dangerous: they can do as much harm as help if you read it. 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();
		// Requires Arcane Lore of 20.
		if (get_skill_total(42) >= 20) {
			set_flag(17,5,1);
			add_dialog_str(0,"The book is written in a strange rune script, but fortunately, due to your knowledge of Arcane Lore, you can read it.",0);
			if (get_flag(292,18) == 0) // flag for spell
				add_dialog_str(1,"The book describes an interesting new spell, one that blasts your enemies with a furious cold. (You learn a level of Bonechill.)",0);
			else
				add_dialog_str(1,"It's a spellbook describing how to cast Bonechill more efficiently. You read over it carefully.",0);
			inc_flag(292,18,run_dialog(1)); // flag for spell
			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 Bonechill again, but you can learn no more from it.","");
break;

beginstate 15;
	reset_dialog();
	add_dialog_str(0,"This book is written in an extremely archaic form of the slith language, somewhat older than the Khalthanad. It appears to be a book of prayers. Translated into the modern idiom, it reads:",0);
	add_dialog_str(1,"_That you shelter and protect us, we pray, O gods of the afterlife and the beyond realms, and keep us safe from the clutches of Nghathlaghzhanth and Hathnazriakh, who contend for our souls always._",0);
	add_dialog_str(2,"It continues in this vein for some time. The language is beautiful -- _Oot ritan servakhaas nois koot thefakhaas_ -- but old and hard to understand. And evidently the prayers did no good.",0);
	run_dialog(1);
break;

beginstate 16;
	message_dialog("This corpse is vahnatai, but more is hard to tell due to the many, many years between death and the present. The question remains, though: what were vahnatai doing here, in the middle of the slith empire?","");
break;