// Town 6: Frost Lizard Lair
begintownscript;

variables;

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

body;

beginstate INIT_STATE;
	set_crime_tolerance(2);
	
	set_level(25,55);
	set_level(26,55);

if (get_flag(6,0) == 0) {
	force_instant_terrain_redraw();
	set_flag(6,0,1);
	message_dialog("You enter the tunnel and immediately hear the sounds of hissing and growling. This must be the lair of the frost lizards; it is certainly cold enough.","");
	}
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
	put_field_on_space(get_ran(1,9,27),get_ran(1,36,46),4);
	put_field_on_space(get_ran(1,9,27),get_ran(1,36,46),4);
	put_field_on_space(get_ran(1,9,27),get_ran(1,36,46),4);
break;

beginstate 10;
if (get_flag(6,1) == 0) {
	set_flag(6,1,1);
	message_dialog("In this room is a messy desk, covered with papyrus sheets scrawled with various arithmetic about the day-to-day running of the mine, which is apparently what this place was. Those sheets don't look very interesting.","The shelves, on the other hand, contain a variety of wide-ranging writings. Most of them involve the most efficient ways of extracting metal from mounds of dirt, but a few may be interesting.");
	}
break;

beginstate 11;
if (get_flag(6,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 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();
		if (get_skill_total(42) >= 16) {
			set_flag(6,2,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,17) == 0)
				add_dialog_str(1,"It's a spellbook describing how to cast a powerful fire spell, _Inferno._ You take mental note of this new spell.",0);
			else
				add_dialog_str(1,"It's a spellbook describing how to cast Inferno more efficiently. You read over it carefully.",0);
			inc_flag(292,17,run_dialog(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 Inferno again, but you can learn no more from it.","");
break;

beginstate 12;
	message_dialog("You skim the shelves and find an old, tattered papyrus scroll. From the damage, you'd guess that it's at least a century or two old. You unroll it as carefully as you can.","It's entitled _The Khalthanad._ It's written in an archaic form of the ancient slith language you learned. The fragments that you can read seem to involve a slith hero on a journey to fight some sort of powerful monster. It cuts off sharply.");
break;

beginstate 13;
	message_dialog("Most of the titles on these shelves are dull, but one stands out: _The Gremlinicon._ It appears to be a raunchy, explicit novel in high prose style in the ancient slith language. As far as you can tell, the readable fragment translates:","_Khoslat Therakhasna, a slith famous for his strength and athletic prowess, having conquered the mighty beast Long Phallus and absorbed its strength for his own, turned his attention to more soft and tender matters, courting the wealthy maiden Richess._");
break;

beginstate 14;
	message_dialog("You find nothing of interest on these shelves.","");
break;

beginstate 15;
if (get_flag(6,3) == 0) {
	set_flag(6,3,1);
	message_dialog("You have found what appears to be a back exit from the mines. You smell fresh air, which means if you go much farther, you'll be outside.","");
	}
break;

beginstate 16;
	set_flag(6,3,1);
break;

beginstate 17;
if (get_flag(6,4) == 0) {
	set_flag(6,4,1);
	message_dialog("You have entered what appears to be an abandoned mine. All along the edges, you can see traces of people -- sliths, presumably -- having dug out metals decades ago.","Frost lizards have taken it over since then. You're in for a fight if you proceed. Then again, even dumb monsters like shiny things, and these monsters are likely to have gathered up some treasure in their time here.");
	}
break;

beginstate 18;
if (get_flag(6,5) == 0) {
	set_flag(6,5,1);
	message_dialog("From this part of the platform, you can look out over all of the crystal pillars in the room. There are strange devices in front of you, even more complex than anything you saw in Bahssikava, and even harder to understand.","Perhaps here you will be able to find out what these crystal pillars are and why they are here.");
	}
break;

beginstate 19;
if (get_flag(6,8) == 0) {
	reset_dialog();
	add_dialog_str(0,"This device has a whole bunch of switches and buttons. It glows dimly, as if active but dormant. Nothing is labeled.",0);
	add_dialog_str(1,"What do you do?",0);
	add_dialog_choice(0,"Leave everything alone.");
	add_dialog_choice(1,"Fiddle blindly with the controls.");
	if (run_dialog(1) == 1)
		end();
		
	flip_terrain(8,42);
	put_boom_on_space(8,41,1,0);
	run_animation_sound(73);
	
	message_dialog("A small explosion goes off! Everything shuts down and shifts back to its orginal position. Nothing else happens.","You play with the controls a little bit more, but nothing continues to happen. Apparently you cannot solve the mystery of the crystal pillars here.");
	set_flag(6,8,1);
	}
break;

beginstate 20;
if (get_flag(6,6) == 0) {
	reset_dialog();
	add_dialog_str(0,"You enter a strange room that has at once three stages of its development apparent before you. First, it was some sort of mining facility; you can still see the rocks and such nearby. Next, it became a storage for many strange crystal pillars.",0);
	add_dialog_str(1,"Sometime after that, frost lizards decided to build nests in here, and the room's temperature seems to suit them fine: walls of ice shift throughout this strange room, wafting between the rows of crystal pillars.",0);
	add_dialog_str(2,"If this weren't a completely crazy idea, you'd think that you could hear the rudiments of some sort of language coming from the frost lizards, communicating about what to do about the intruders. These frost lizards may not be as dumb as the others.",0);
	set_flag(6,6,run_dialog(1));
	}
break;

beginstate 21;
if (get_flag(6,7) == 0) {
	set_flag(6,7,1);
	message_dialog("Up ahead you can see water, the hallmark of slith habitation. Sliths must live near a significant source of water. This must come from the river somehow.","How unsanitary! You see two gigantic roaches at the edge of the water. You suppose that no one has cleaned this area in a long time.");
	}
break;