// Town 18: Vahnatai Lab
begintownscript;

variables;

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

body;

beginstate INIT_STATE;
	set_crime_tolerance(2);
	
	change_outdoor_location(1,6,3,27);
	
	change_blocked(44,28,1);
	change_blocked(44,29,1);
	change_blocked(44,30,1);
	change_blocked(44,31,1);
	change_blocked(44,32,1);
	change_blocked(44,33,1);
	change_blocked(44,34,1);
	change_blocked(44,35,1);
	change_blocked(44,36,1);
	
	change_blocked(29,5,1);
	change_blocked(30,5,1);
	change_blocked(31,5,1);
	change_blocked(29,4,1);
	change_blocked(30,4,1);
	change_blocked(31,4,1);
	
	set_special_ability(19,17);
	set_special_ability(20,17);
	set_special_ability(21,17);
	set_strategy(21,1);
	
	if (get_flag(18,4) == 1) {
		if (get_flag(15,8) == 0) {
			set_terrain(52,28,453);
			set_terrain(52,29,453);
			set_terrain(52,30,453);
			set_terrain(52,31,453);
			set_terrain(52,32,453);
			set_terrain(52,33,453);
			set_terrain(52,34,453);
			set_terrain(52,35,453);
			set_terrain(52,36,453);
			}
		else {
			force_instant_terrain_redraw();
			message_dialog("You return to the vahnatai building, the deed done. You have proven yourself. You should be allowed into Nathaganth's cult now.","You still shake with an overwhelming sense of dread at what you have done, but you know that it will soon pass. Soon you will be beyond all regret.");
			
			put_boom_on_char(0,2,0);
			put_boom_on_char(1,2,0);
			put_boom_on_char(2,2,0);
			put_boom_on_char(3,2,0);
			run_animation_sound(51);
			
			march_party(55,5);
			march_party(56,5);
			march_party(57,5);
			march_party(58,5);
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 2);
			
			set_terrain(9,19,453);
			set_terrain(10,19,453);
			set_terrain(11,19,453);
			set_terrain(12,19,453);
			set_terrain(13,19,453);
			set_terrain(14,19,453);
			set_terrain(15,19,453);
			set_terrain(16,19,453);
			set_terrain(17,19,453);
			
			activate_hidden_group(1);
			relocate_character(6,13,10);
			set_character_facing(6,4);
			
			force_view_center(13,13);
			march_party(13,16);
			march_party(13,15);
			march_party(13,14);
			march_party(13,13);
			
			put_boom_on_char(0,2,0);
			put_boom_on_char(1,2,0);
			put_boom_on_char(2,2,0);
			put_boom_on_char(3,2,0);
			run_animation_sound(51);
			
			i = 0;
			while (char_ok(i) == 0)
				{i = i + 1; }
				
			text_bubble_on_char(6,"You have done what I asked?");
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 5);
				
			text_bubble_on_char(6,"");
			text_bubble_on_char(i,"Yes.");
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 5);
				
			text_bubble_on_char(i,"");
			text_bubble_on_char(6,"Before you may become one of us,");
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 5);
				
			text_bubble_on_char(6,"");
			text_bubble_on_char(6,"you must learn");
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 5);
				
			text_bubble_on_char(6,"");
			text_bubble_on_char(6,"the proper forms of address.");
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 5);
				
			text_bubble_on_char(6,"");
			text_bubble_on_char(6,"AGAIN.");
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 5);
				
			text_bubble_on_char(6,"");
			text_bubble_on_char(6,"YOU HAVE DONE WHAT I ASKED?");
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 5);
				
			text_bubble_on_char(6,"");
			text_bubble_on_char(i,"Yes, master.");
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 5);
				
			text_bubble_on_char(i,"");
			text_bubble_on_char(6,"GOOD.");
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 5);
				
			text_bubble_on_char(6,"");
			text_bubble_on_char(6,"YOU HAVE EARNED THE RIGHT");
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 5);
				
			text_bubble_on_char(6,"");
			text_bubble_on_char(6,"TO APPROACH THE ALTAR.");
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 5);
				
			text_bubble_on_char(6,"");
			text_bubble_on_char(6,"COME.");
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 5);
			
			}
		}
	
	if (get_flag(15,3) < 3) {
		set_terrain(53,28,5);
		set_terrain(53,29,5);
		set_terrain(53,30,5);
		set_terrain(53,31,5);
		set_terrain(53,32,5);
		set_terrain(53,33,5);
		set_terrain(53,34,5);
		set_terrain(53,35,5);
		set_terrain(53,36,5);
		message_dialog("How strange. You could swear that you saw some indent in the wall from a distance, but you can see nothing now.","");
		end();
		}
	
	if (get_flag(18,0) == 0) {
		set_flag(18,0,1);
		force_instant_terrain_redraw();
		message_dialog("Before you is a strange sight: a building built into the very structure of the wall, a building with clear vahnatai architecture, not just slith architecture influenced by the vahnatai.","This vahnatai building looks very old, at least as old as anything you've seen so far on this trip.");
		}
		
if (get_flag(19,1) != 1)
	end();
	
	set_flag(19,1,2);
	force_view_center(13,13);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 2);
	
	activate_hidden_group(1);
	relocate_character(6,13,10);
	set_character_facing(6,4);
	march_party(13,17);
	march_party(13,16);
	march_party(13,15);
	march_party(13,14);
	force_instant_terrain_redraw();
	
	message_dialog("He leads you to a temple, the beating heart of the darkness that you sensed when you first entered this ancient building, with horrific altars at the head of the room, dripping with fresh crimson blood.","The vahnatai architecture underpinning the appearance of this room does little to alleviate the impression it gives, because the terror stems from the general outline, the geometry that seems all wrong somehow.");
	
	text_bubble_on_char(6,"Here unknowing Vylas-Ihrno discovered");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"our Lord in the prison into which");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"he had been cast, aeons ago.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	force_instant_terrain_redraw();
	
	reset_dialog();
	add_dialog_str(0,"_Here we sacrifice to God in hopes that one day, when he rises again, he will remember our diligence and reward us with high places next to him, that we may feel the rising orgy of blood and pleasure at its apogee._",0);
	add_dialog_str(1,"He adds, _Until then, we keep the memory alive._",0);
	add_dialog_str(2,"What do you say?",0);
	add_dialog_choice(0,"(Nothing.)");
	add_dialog_choice(1,"It sounds truly glorious.");
	if (run_dialog(1) == 2) {
		reset_dialog();
		add_dialog_str(0,"The demon lord looks at you carefully. _You think so, do you? Would you like to be a part of this glorious future? Would you like to join us?_",0);
		add_dialog_str(1,"What do you say?",0);
		add_dialog_choice(0,"No thanks. I'll pass on devil-worship.");
		add_dialog_choice(1,"Yes. This is truly my calling.");
		if (run_dialog(1) == 1) {
			text_bubble_on_char(6,"Pity. Oh well.");
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 5);
			
			text_bubble_on_char(6,"");
			}
		else {
			text_bubble_on_char(6,"Very well.");
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 5);
			
			text_bubble_on_char(6,"");
			
			put_boom_on_char(0,2,0);
			put_boom_on_char(1,2,0);
			put_boom_on_char(2,2,0);
			put_boom_on_char(3,2,0);
			run_animation_sound(51);
			
			march_party(55,5);
			march_party(56,5);
			march_party(57,5);
			march_party(58,5);
			force_instant_terrain_redraw();
			pause(get_flag(290,0) * 2);
			
			set_terrain(52,28,453);
			set_terrain(52,29,453);
			set_terrain(52,30,453);
			set_terrain(52,31,453);
			set_terrain(52,32,453);
			set_terrain(52,33,453);
			set_terrain(52,34,453);
			set_terrain(52,35,453);
			set_terrain(52,36,453);
			
			march_party(56,31);
			march_party(55,31);
			march_party(54,31);
			march_party(53,31);
			force_view_center(53,31);
			
			put_boom_on_char(0,2,0);
			put_boom_on_char(1,2,0);
			put_boom_on_char(2,2,0);
			put_boom_on_char(3,2,0);
			run_animation_sound(51);
			
			message_dialog("_In order to join the cult of Nathaganth,_ the demon lord's voice speaks in your mind, _you must sever your ties with your old allies. You must kill Legare. Once you have done so, you may return, and you will become as one of us._","");
			set_flag(18,4,1);
			end();
			
			}
		}
		
	text_bubble_on_char(6,"With the proper rites,");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
		
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"our Lord's memory will remain intact,");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
		
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"and you will make a perfect sacrifice.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
		
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"Do not struggle.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
		
	text_bubble_on_char(6,"");
	force_instant_terrain_redraw();
	
	reset_dialog();
	add_dialog_str(0,"What do you say?",0);
	add_dialog_choice(0,"(Nothing.)");
	if (party_size() == 1)
		add_dialog_choice(1,"A sacrifice? If you were going to kill me, why tell me all of this?");
	else
		add_dialog_choice(1,"A sacrifice? If you were going to kill us, why tell us all of this?");
	if (run_dialog(1) == 2) {
		text_bubble_on_char(6,"I last spoke with another being");
		force_instant_terrain_redraw();
		pause(get_flag(290,0) * 5);
		
		text_bubble_on_char(6,"");
		text_bubble_on_char(6,"more than a thousand years ago.");
		force_instant_terrain_redraw();
		pause(get_flag(290,0) * 5);
		
		text_bubble_on_char(6,"");
		text_bubble_on_char(6,"Sometimes I miss the conversation.");
		force_instant_terrain_redraw();
		pause(get_flag(290,0) * 5);
		
		text_bubble_on_char(6,"");
		force_instant_terrain_redraw();
		pause(get_flag(290,0) * 3);
		
		text_bubble_on_char(6,"");
		text_bubble_on_char(6,"But not enough to let you live.");
		force_instant_terrain_redraw();
		pause(get_flag(290,0) * 5);
		
		text_bubble_on_char(6,"");
		force_instant_terrain_redraw();
		}
	
	activate_hidden_group(2);
	put_boom_on_char(8,2,0);
	put_boom_on_char(9,2,0);
	put_boom_on_char(10,2,0);
	put_boom_on_char(11,2,0);
	put_boom_on_char(15,2,0);
	run_animation_sound(10);
	
	text_bubble_on_char(6,"Finish this.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"I must commune with our God.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	force_instant_terrain_redraw();
	
	put_boom_on_char(6,2,0);
	run_animation_sound(51);
	
	erase_char(6);
	force_instant_terrain_redraw();

break;

beginstate EXIT_STATE;
if (get_flag(18,3) == 0)
	end();
if (get_flag(18,11) != 0)
	end();
	
	i = 0;
	while (char_ok(i) == 0)
		{i = i + 1; }
		
	if (char_loc_x(i) < 32)
		end();
	
	set_flag(18,11,1);
	message_dialog("You leave Dalaghant's home completely empty-handed. You have not found a way out, and you have no clues about where to find one. You can't do anything but return to the camp and hope that they have found something, because you certainly haven't.","");
break;

beginstate START_STATE;
break;

beginstate 10;
	if (get_flag(18,1) == 0) {
		set_flag(18,1,1);
		message_dialog("This must be the lab at which the vahnatai unleashed an _ancient evil._ You can feel the magic, still alive after all these years, and you can sense the evil. Sinister, musty air sits still around you as you walk.","If whatever came out of here was enough to destroy the vahnatai in this area, it may be enough to destroy you, too. You'd better tread lightly if you want to enter this place.");
		}
break;

beginstate 11;
if (get_flag(18,2) != 0)
	end();
	
	set_flag(18,2,1);
	
	activate_hidden_group(1);
	put_boom_on_char(6,2,0);
	run_animation_sound(51);
	
	i = 0;
	while (char_ok(i) == 0)
		{i = i + 1; }
	
	message_dialog("Abject horror seizes you. Before you is a very copy of a demon lord you fought before, the unholy Nolagh-Khar who enslaved Bahssikava and for decades ruled over that subjected city.","This being is so nearly identical that you at first think it is Nolagh-Khar brought back from the dead, but it cannot be. Slight differences suggest this must be a relative, a brother perhaps.");
	
	clear_buffer();
	append_char_name(i);
	append_string("!");
	get_buffer_text(dlgstr);
	text_bubble_on_char(6,dlgstr);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"Thus are God's words fulfilled.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"He foretold your arrival.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	force_instant_terrain_redraw();
	
	message_dialog("_Welcome to our home,_ the demon lord says. _My name is Dalaghant. Perhaps you have heard of me?_ You shake your head. _Ah, then,_ he continues, _you should learn who we are and where you have come. Follow me, and I will show you all._","You feel powerful magic swirl around you!");
	
	put_boom_on_char(6,2,0);
	put_boom_on_char(0,2,0);
	put_boom_on_char(1,2,0);
	put_boom_on_char(2,2,0);
	put_boom_on_char(3,2,0);
	run_animation_sound(51);
	
	relocate_character(6,47,14);
	set_character_facing(6,4);
	march_party(47,20);
	march_party(47,19);
	march_party(47,18);
	march_party(47,17);
	force_view_center(10,17);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 2);
	
	force_view_center(47,17);
	put_boom_on_char(6,2,0);
	put_boom_on_char(0,2,0);
	put_boom_on_char(1,2,0);
	put_boom_on_char(2,2,0);
	put_boom_on_char(3,2,0);
	run_animation_sound(51);
	
	reset_dialog();
	add_dialog_str(0,"You stare around in terror. You are surrounded by demon gods!",0);
	add_dialog_str(1,"No... no. They are merely statues. They are lifelike and hideous, but they are merely statues. All around you are representations of dark gods, each with a sign giving the name and describing the god's function.",0);
	add_dialog_str(2,"You start to read one sign, but the demon lord interrupts you.",0);
	
	text_bubble_on_char(6,"This is the Hall of Gods,");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"the Pantheon.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"Here you can see those we worship");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"and the mortals who have performed");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"great service.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	relocate_character(6,47,13);
	set_character_facing(6,0);
	march_party(47,16);
	force_view_center(47,16);
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"At the head, of course,");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(6,47,12);
	march_party(47,15);
	force_view_center(47,15);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(6,47,11);
	march_party(47,14);
	force_view_center(47,14);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(6,47,10);
	march_party(47,13);
	force_view_center(47,13);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	relocate_character(6,47,9);
	march_party(47,12);
	force_view_center(47,12);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 1);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"is our Lord himself,");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"Nathaganth.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	force_instant_terrain_redraw();
	
	message_dialog("Nathaganth stares at you with his penetrating eyes, his tail alert as if ready to sting you, his arms like tentacles outstretched as if to swarm you.","There is a resemblance between this demon lord and Nathaganth, although you're not sure how much that means.");
	
	text_bubble_on_char(6,"He sleeps now, but not forever.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"Someday he will rise again,");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"and we will be as we once were,");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"free and wild, beyond good and evil,");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"to shout and kill and revel in joy");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"until the end of days.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	text_bubble_on_char(6,"Glorious, isn't it?");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	force_instant_terrain_redraw();
	
	reset_dialog();
	add_dialog_str(0,"What do you say?",0);
	add_dialog_choice(0,"(Nothing.)");
	add_dialog_choice(1,"Yes, it is truly glorious.");
	add_dialog_choice(2,"It sounds like a nightmare.");
	choice = run_dialog(1);
	if (choice == 2) {
		message_dialog("The demon lord gives you a long look.","");
		
		text_bubble_on_char(6,"We anticipate the day with excitement.");
		force_instant_terrain_redraw();
		pause(get_flag(290,0) * 5);
		
		text_bubble_on_char(6,"");
		}
	if (choice == 3) {
		message_dialog("The demon lord gives you a long look.","");
		
		text_bubble_on_char(6,"One man's dream");
		force_instant_terrain_redraw();
		pause(get_flag(290,0) * 5);
		
		text_bubble_on_char(6,"");
		text_bubble_on_char(6,"is another's nightmare.");
		force_instant_terrain_redraw();
		pause(get_flag(290,0) * 5);
		
		text_bubble_on_char(6,"");
		text_bubble_on_char(6,"We are each entitled to our views.");
		force_instant_terrain_redraw();
		pause(get_flag(290,0) * 5);
		
		text_bubble_on_char(6,"");
		}
	
	text_bubble_on_char(6,"Come, there is more to see.");
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 5);
	
	text_bubble_on_char(6,"");
	force_instant_terrain_redraw();
	
	put_boom_on_char(6,2,0);
	put_boom_on_char(0,2,0);
	put_boom_on_char(1,2,0);
	put_boom_on_char(2,2,0);
	put_boom_on_char(3,2,0);
	run_animation_sound(51);
	
	relocate_character(6,54,5);
	march_party(55,5);
	march_party(56,5);
	march_party(57,5);
	march_party(58,5);
	force_instant_terrain_redraw();
	pause(get_flag(290,0) * 2);
	
	move_to_new_town(19,18,18);
	
break;

beginstate 12;
if (get_flag(15,8) == 1) {
	set_terrain(13,8,268);
	force_instant_terrain_redraw();
	play_sound(53);
	
	reset_dialog();
	add_dialog_str(0,"As you approach, a portal rips open in the air, destroying one of the altars. It swirls, maddeningly, beckoning you forward.",0);
	add_dialog_str(1,"What do you do?",0);
	add_dialog_choice(0,"Walk away.");
	add_dialog_choice(1,"Enter the portal.");
	if (run_dialog(1) == 2)
		move_to_new_town(20,16,16);
	}
break;

beginstate 13;
if (get_flag(18,5) == 0) {
	set_flag(18,5,1);
	message_dialog("You enter a library so old and dusty that you imagine it must have lain untouched for centuries before you opened these doors. For some reason, the current inhabitants have never found a reason to come in here.","Rows and rows of bookshelves continue towards the back of the room. This is incredible! The sheer amount of knowledge here must be even greater than that in Thassaka!");
	}
break;

beginstate 14;
if (get_flag(18,6) == 0) {
	set_flag(18,6,1);
	message_dialog("You get your first glimpse of the bookshelves, and you are shocked by what you see. All of the works were written on papyrus, but, in the intervening centuries, that papyrus has rotted through. Almost nothing remains.","You have no doubt that this library once contained invaluable information, but it is doubtful that it still does.");
	}
break;

beginstate 15;
	message_dialog("A tiny fragment of a papyrus scroll remains. It reads: _Biological experiments proceeding well. New life forms created at an astounding rate. Only a few survive, but those that do are strong. Soon we will be forging species at will._","");
break;

beginstate 16;
if (get_flag(18,8) == 1)
	message_dialog("You find the cursed book again, but you don't read it this time.","");
else {
	reset_dialog();
	add_dialog_str(0,"You find a book that looks partly intact. More significantly, it looks magical! These things can be dangerous; reading a cursed book can bring terrible things upon you. However, it could also contain priceless knowledge.",0);
	add_dialog_str(1,"What do you do?",0);
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Read it.");
	if (run_dialog(1) == 2) {
		set_flag(18,8,1);
		message_dialog("You begin reading. The book describes in exquisite, painstaking detail the nightmare visions of one unfortunate vahnatai spontaneously stricken with madness. He describes tentacles, shapeless blobs, and a single lidless, staring eye, pulsating.","His descriptions are so vivid that you can almost feel the eye turning to bring its unhallowed gaze upon you, or not you, precisely, but your mind itself. You feel grievously unwell. (You have received a Dread Curse.)");
		alter_stat(1000,31,2);
		}
	}
break;

beginstate 17;
	reset_dialog();
	add_dialog_str(0,"You find a scrap of papyrus that is still legible, although it is clearly old beyond reckoning. The part that you can read is this: _Iita nesakhaam kaanam theifam Hathnazriakham riit thaanotheneekh voonony vaanatony belleekh._",0);
	add_dialog_str(1,"Loosely translated, that means, _Thus I sing of the dark goddess Hathnazriakh and her mortal battles against good vahnatai._ It has strange archaic features, though, including an archaic instrumental case and an epic lengthening of the word _ita._",0);
	add_dialog_str(2,"This is by far the oldest form of the ancient slith language you have ever seen. This Hathnazriakh must have been a mortal enemy of the vahnatai and sliths since time immemorial.",0);
	run_dialog(1);
break;

beginstate 18;
if (get_flag(18,7) == 0) {
	reset_dialog();
	add_dialog_str(0,"You find a book that looks partly intact. More significantly, it looks magical! These things can be dangerous; reading a cursed book can bring terrible things upon you. However, it could also contain priceless knowledge.",0);
	add_dialog_str(1,"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();
		// Requires Arcane Lore of 20.
		if (get_skill_total(42) >= 20) {
			set_flag(18,7,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,2) == 0) // flag for spell
				add_dialog_str(1,"The book describes an interesting new spell, one that inflicts a powerful sickness upon your enemies. (You learn a level of Poison.)",0);
			else
				add_dialog_str(1,"It's a spellbook describing how to cast Poison more efficiently. You read over it carefully.",0);
			inc_flag(292,2,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 Poison again, but you don't learn anything new from it.","");
break;

beginstate 19; // Demons dying state.
	// Weirdness necessitated by the fact that during a character's DEAD_STATE,
	// the character is still alive.
	i = 0;
	if (char_ok(8))
		i = i + 1;
	if (char_ok(9))
		i = i + 1;
	if (char_ok(10))
		i = i + 1;
	if (char_ok(11))
		i = i + 1;
	if (char_ok(15))
		i = i + 1;
	if (i > 1)
		end();
	
	message_dialog("As the last of the demons falls, you brace for another attack from Dalaghant, your host, but nothing comes. He has apparently not decided to check on you yet. You'd better get out of this room before he does.","You still need to see if this former laboratory has any path by which the expedition can escape the Lava Ocean.");
	
break;

beginstate 20;
	block_entry(1);
	reset_dialog();
	add_dialog_str(0,"You have reached the stairs going down to the Sacrifice Fields. What do you do?",0);
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Descend the stairs.");
	if (run_dialog(1) == 2)
		move_to_new_town(19,28,38);
break;

beginstate 21;
if (get_flag(18,9) == 0) {
	reset_dialog();
	add_dialog_str(0,"This shelf has been preserved better than the ones in the other room. One small spellbook is almost completely intact, and you feel fairly certain that you can read it.",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();
		// Requires Arcane Lore of 20.
		if (get_skill_total(42) >= 20) {
			set_flag(18,9,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,1) == 0) // flag for spell
				add_dialog_str(1,"The book describes an interesting new spell, one that wraps an enemy in a stack of webs! (You learn a level of Bind Foe.)",0);
			else
				add_dialog_str(1,"The page describes describing how to cast Bind Foe more efficiently. You read over it carefully.",0);
			inc_flag(292,1,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 Bind Foe again, but you don't learn anything new from it.","");
break;

beginstate 22;
	reset_dialog();
	add_dialog_str(0,"This shelf contains a number of books that clearly are not magical in subject matter. They look like records, very old records of transactions.",0);
	add_dialog_str(1,"What do you do?",0);
	add_dialog_choice(0,"Leave it alone.");
	add_dialog_choice(1,"Read it.");
	if (run_dialog(1) == 2) {
		reset_dialog();
		add_dialog_str(0,"This book, written in a dialect older than the Khalthanad, older probably than the Empire of Khalthas itself, describes buying and selling in a city. This city was not far from Thassaka, because of speaks of imports and exports from Thassaka.",0);
		add_dialog_str(1,"As far as you can tell, the merchants themselves are vahnatai, and they buy and sell food, crystals, and... sliths.",0);
		add_dialog_str(2,"Sliths! These vahnatai owned sliths as slaves, and they bought and sold them, forced them to work in the fields, and dispensed with them as they pleased. These sliths were commodities.",0);
		add_dialog_str(3,"But how? Why? You can't find any explanation of any of this. The book is just a record of what was bought and sold when, which taxes were collected and who was punished for tax evasion, and other such details. You can find no answers here.",0);
		run_dialog(1);
		}
break;

beginstate 23;
if (get_flag(18,10) == 0) {
	reset_dialog();
	add_dialog_str(0,"This shelf has been preserved better than the ones in the other room. One small spellbook is almost completely intact, and you feel fairly certain that you can read it.",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(18,10,1);
		add_dialog_str(0,"The book describes an interesting new spell, one that creates a small field of ice around an enemy! (You learn a level of Ice Field.)",0);
		set_flag(292,13,run_dialog(1)); // flag for spell
		set_flag(292,0,1);
		}
	}
else
	message_dialog("You find the book on Ice Field again, but you don't learn anything new from it.","");
break;

beginstate 24;
	message_dialog("You sit at a mind crystal, a vahnatai invention intended to teach some specialized knowledge to the viewer. This mind crystal appears inactive, though: it must not have been charged with new information recently.","");
break;