// Town 21: Mount Galthrax (L3)
begintownscript;

variables;

short choice,dummy,i,j,which_flag,golem_type,hold_loc_x,hold_loc_y;
string dlgstr;

body;

beginstate INIT_STATE;
	turn_off_training(1);
	
	set_name(77,"Experimental Golem");
	set_name(79,"Experimental Golem");
	set_name(80,"Experimental Golem");
	set_name(82,"Experimental Golem");
	set_name(83,"Experimental Golem");
	set_level(77,55);
	set_level(79,55);
	set_level(80,65);
	set_level(82,65);
	set_level(83,70);
	
	change_blocked(29,5,1);
	change_blocked(30,5,1);
	change_blocked(31,5,1);
	change_blocked(32,5,1);
	change_blocked(33,5,1);
	change_blocked(33,6,1);
	change_blocked(33,7,1);
	change_blocked(33,8,1);
	change_blocked(33,9,1);
	
	change_blocked(29,4,1);
	change_blocked(30,4,1);
	change_blocked(31,4,1);
	change_blocked(32,4,1);
	change_blocked(33,4,1);
	change_blocked(34,4,1);
	change_blocked(34,5,1);
	change_blocked(34,6,1);
	change_blocked(34,7,1);
	change_blocked(34,8,1);
	change_blocked(34,9,1);
	
	change_blocked(29,3,1);
	change_blocked(30,3,1);
	change_blocked(31,3,1);
	change_blocked(32,3,1);
	change_blocked(33,3,1);
	change_blocked(34,3,1);
	change_blocked(35,3,1);
	change_blocked(35,4,1);
	change_blocked(35,5,1);
	change_blocked(35,6,1);
	change_blocked(35,7,1);
	change_blocked(35,8,1);
	change_blocked(35,9,1);
	
	change_blocked(53,58,1);
	change_blocked(53,59,1);
	change_blocked(53,60,1);
	change_blocked(54,58,1);
	change_blocked(54,59,1);
	change_blocked(54,60,1);
	change_blocked(55,58,1);
	change_blocked(55,59,1);
	change_blocked(55,60,1);
	
if (get_flag(21,8) == 0)
	{change_blocked(17,15,1);
	change_blocked(18,15,1);
	change_blocked(19,15,1);
	change_blocked(20,15,1);
	change_blocked(21,15,1);
	change_blocked(22,15,1);
	change_blocked(23,15,1);
	change_blocked(24,15,1);
	change_blocked(25,15,1);
	change_blocked(26,15,1);
	change_blocked(17,16,1);
	change_blocked(18,16,1);
	change_blocked(19,16,1);
	change_blocked(20,16,1);
	change_blocked(21,16,1);
	change_blocked(22,16,1);
	change_blocked(23,16,1);
	change_blocked(24,16,1);
	change_blocked(25,16,1);
	change_blocked(26,16,1);
	}
	
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
if (get_flag(21,1) != 0)
	end();
if (get_flag(21,3) != 0)
	end();
	
	set_flag(21,1,1);
	message_dialog("You step to a small window. From here, you can observe the goings-on in the next room, but you won't be seen.","The room appears to be a dark temple, and a ceremony is in progress. You stand by the window and watch.");

	if (get_flag(250,9)) {
		reset_dialog();
		add_dialog_str(0,"You have reached another cut scene, one in which Galthrax's followers worship it. Would you like to skip it or see it?",0);
		add_dialog_choice(0,"Skip it.");
		add_dialog_choice(1,"See it.");
		if (run_dialog(1) == 1)
			set_state_continue(38);
		}

	set_total_visibility(1);
	force_view_center(6,19);
	force_instant_terrain_redraw();
	pause(1 * get_flag(250,8));
	
	text_bubble_on_char(50,"O Powerful Galthrax,");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"Mountain King, Lord of Undead Hordes,");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"your guidance we humbly seek,");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"and in tribute we have brought");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	activate_hidden_group(1);
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"A SACRIFICE!");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	force_instant_terrain_redraw();
	
	message_dialog("The slith looks completely vacant, as if it has no mind of its own. The undead lord beckons to it, and it approaches.","");

	relocate_character(62,6,28);
	force_instant_terrain_redraw();
	pause(2 * get_flag(250,8));

	set_character_facing(62,1);
	relocate_character(62,5,27);
	force_instant_terrain_redraw();
	pause(2 * get_flag(250,8));

	relocate_character(62,4,26);
	force_instant_terrain_redraw();
	pause(2 * get_flag(250,8));

	relocate_character(62,3,25);
	force_instant_terrain_redraw();
	pause(2 * get_flag(250,8));
	
	set_character_facing(62,0);
	relocate_character(62,3,24);
	force_instant_terrain_redraw();
	pause(2 * get_flag(250,8));

	relocate_character(62,3,23);
	force_instant_terrain_redraw();
	pause(2 * get_flag(250,8));

	set_character_facing(62,7);
	relocate_character(62,4,22);
	force_instant_terrain_redraw();
	pause(2 * get_flag(250,8));

	relocate_character(62,5,21);
	force_instant_terrain_redraw();
	pause(2 * get_flag(250,8));
	
	set_character_facing(62,6);
	relocate_character(62,6,21);
	force_instant_terrain_redraw();
	pause(5 * get_flag(250,8));
	
	set_character_facing(50,2);
	set_character_pose(50,1);
	put_effect_on_char(62,12,1,2);
	run_animation_sound(71);
	kill_char(62,2,0);
	
	message_dialog("He moved swiftly. The hypnotized slith never had a chance. The undead lord slowly places the slith's head on the altar, wiping the blood in a deliberate but indistinct pattern. He begins to chant.","");

	set_character_facing(50,0);
	set_character_pose(50,0);
	text_bubble_on_char(50,"O Galthrax,");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"from the lofty heights,");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"from the hellfire in the skies,");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"from thy sulf'rous clime,");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"descend to our temple");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"and with thy wing'd strength");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"and thy redden'd claws");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"rend our mortal bodies asunder");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"if our sacrifice pleaseth not");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"thy fierce soul,");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"else grant unto us, O great beast,");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"thy sage counsel.");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"GALTHRAX, MIGHTY IN TOOTH AND CLAW,");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(50,"I SUMMON THEE!");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	force_instant_terrain_redraw();
	
	message_dialog("You feel the ground itself shaking. Powerful wings beat air into the room so forcefully that you can feel it even behind the narrow window. A gargantuan leathery body slowly descends into view.","");

	relocate_character(49,7,10);
	set_character_facing(49,4);
	force_instant_terrain_redraw();
	pause(2 * get_flag(250,8));
	
	relocate_character(49,7,11);
	force_instant_terrain_redraw();
	pause(2 * get_flag(250,8));
	
	relocate_character(49,7,12);
	force_instant_terrain_redraw();
	pause(2 * get_flag(250,8));
	
	relocate_character(49,7,13);
	force_instant_terrain_redraw();
	pause(2 * get_flag(250,8));
	
	relocate_character(49,7,14);
	force_instant_terrain_redraw();
	pause(2 * get_flag(250,8));
	
	relocate_character(49,7,15);
	force_instant_terrain_redraw();
	pause(3 * get_flag(250,8));
	
	message_dialog("It stands, regal, majestic, awe-inspiring, and terrible. Its imperial purple wings tuck behind its body, and its royal crimson body ripples with every movement. Its muscles, prominent and brutal, flex and shift.","");

	pause(1 * get_flag(250,8));

	text_bubble_on_char(49,"VISHANTH");
	force_instant_terrain_redraw();
	play_sound(48);
	play_sound(65);
	play_sound(44);
	
	message_dialog("The dragon king's roar hits your chest like a great hammer blow from one of the mighty smiths of Fort Draco, or like an impact from a club of one of the monstrous giants north of the ruined Tower of Elderan.","You firmly hold your ground against the onslaught of voice, leveraging against it as if it were a thousandweight boulder.");

	text_bubble_on_char(49,"");
	text_bubble_on_char(49,"YOUR SACRIFICE PLEASES ME.");
	force_instant_terrain_redraw();
	play_sound(-48);
	pause(6 * get_flag(250,8));

	text_bubble_on_char(49,"");
	text_bubble_on_char(49,"OUR WAR AGAINST VASSKOLIS");
	force_instant_terrain_redraw();
	play_sound(-44);
	pause(6 * get_flag(250,8));

	text_bubble_on_char(49,"");
	text_bubble_on_char(49,"GOES WELL;");
	force_instant_terrain_redraw();
	play_sound(-65);
	pause(6 * get_flag(250,8));

	text_bubble_on_char(49,"");
	text_bubble_on_char(49,"OUR DREAD ARMIES WILL SOON");
	force_instant_terrain_redraw();
	play_sound(-48);
	pause(6 * get_flag(250,8));

	text_bubble_on_char(49,"");
	text_bubble_on_char(49,"RAVAGE THEIR FERTILE LANDS.");
	force_instant_terrain_redraw();
	play_sound(-65);
	pause(6 * get_flag(250,8));

	text_bubble_on_char(49,"");
	text_bubble_on_char(49,"IT IS TIME, VISHANTH.");
	force_instant_terrain_redraw();
	play_sound(-44);
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(49,"");
	text_bubble_on_char(50,"Time, my lord?");
	force_instant_terrain_redraw();
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(49,"YES.");
	force_instant_terrain_redraw();
	play_sound(-44);
	pause(5 * get_flag(250,8));
	
	text_bubble_on_char(49,"");
	text_bubble_on_char(49,"THE ARMIES ARE ALREADY IN THE FIELD.");
	force_instant_terrain_redraw();
	play_sound(-65);
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(49,"");
	text_bubble_on_char(49,"GIVE THEM THE ORDER.");
	force_instant_terrain_redraw();
	play_sound(-65);
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(49,"");
	text_bubble_on_char(49,"THIS DAY, VASSKOLIS WILL FALL.");
	force_instant_terrain_redraw();
	play_sound(-48);
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(49,"");
	force_instant_terrain_redraw();
	pause(2);
	
	text_bubble_on_char(53,"YES!");
	force_instant_terrain_redraw();
	pause(3);
	
	text_bubble_on_char(60,"YES!");
	force_instant_terrain_redraw();
	pause(1);
	
	text_bubble_on_char(58,"YES!");
	force_instant_terrain_redraw();
	pause(2);
	
	text_bubble_on_char(59,"YES!");
	force_instant_terrain_redraw();
	pause(1 * get_flag(250,8));
	
	text_bubble_on_char(50,"YES, GREAT LORD!");
	force_instant_terrain_redraw();
	pause(5 * get_flag(250,8));
	
	text_bubble_on_char(50,"");
	text_bubble_on_char(53,"");
	text_bubble_on_char(58,"");
	text_bubble_on_char(59,"");
	text_bubble_on_char(60,"");
	force_instant_terrain_redraw();
	pause(3 * get_flag(250,8));
	
	text_bubble_on_char(49,"I WILL BE IN MY CHAMBERS.");
	force_instant_terrain_redraw();
	play_sound(-44);
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(49,"");
	text_bubble_on_char(49,"WHEN THE GLORIOUS TIME COMES,");
	force_instant_terrain_redraw();
	play_sound(-48);
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(49,"");
	text_bubble_on_char(49,"ENTER AND INFORM ME,");
	force_instant_terrain_redraw();
	play_sound(-65);
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(49,"");
	text_bubble_on_char(49,"SO THAT I MAY WITNESS");
	force_instant_terrain_redraw();
	play_sound(-48);
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(49,"");
	text_bubble_on_char(49,"THE DESTRUCTION OF VASSKOLIS.");
	force_instant_terrain_redraw();
	play_sound(-44);
	pause(6 * get_flag(250,8));
	
	text_bubble_on_char(49,"");
	force_instant_terrain_redraw();
	
	put_boom_on_space(6,14,2,0);
	put_boom_on_space(7,14,2,0);
	put_boom_on_space(8,14,2,0);
	put_boom_on_space(6,15,2,0);
	put_boom_on_space(7,15,2,0);
	put_boom_on_space(8,15,2,0);
	put_boom_on_space(6,16,2,0);
	put_boom_on_space(7,16,2,0);
	put_boom_on_space(8,16,2,0);
	run_animation_sound(163);
	
	relocate_character(49,22,27);
	set_character_facing(49,0);
	force_instant_terrain_redraw();
	
	set_total_visibility(0);
	force_view_center(3,31);
	force_instant_terrain_redraw();
	
	reset_dialog();
	clear_buffer();
	if (get_flag(15,22) == 0)
		{append_string("Vasskolis? ");
		if (get_flag(19,4))
			{append_string("That must be the city that you saw in the scale model");
			if (get_flag(19,8))
				append_string(" and from the top of the cliff.");
			else
				append_string(".");
			}
		else
			{if (get_flag(19,8))
				append_string("That must be the city that you saw from the top of the cliff.");
			else
				append_string("That must be a city to the north, since you know what is south of here. And it must have sliths, too, because of the sacrifice you saw.");
			}
		append_string(" You must get to this city before it is destroyed.");
		}
	else
		{append_string("The dragon is going to destroy Vasskolis? ");
		if (get_flag(19,10))
			append_string("Ithik told you that the situation was dire, but he may not have even known that the final attack was coming so soon. ");
		else
			append_string("That was Ithik's city. ");
		append_string("The impending attack gives your mission greater urgency than it had before.");
		}
	get_buffer_text(dlgstr);
	add_dialog_str(0,dlgstr,0);
	add_dialog_str(1,"Legare would want you to save Vasskolis if at all possible. Vasskolis, a city of sliths in the slith homeland, may finally offer you some answers about the history of Bahssikava and the nature of the homeland.",0);
	add_dialog_str(2,"You must stop the dragon before he can commit the greatest crime against sliths since the Empire destroyed Bahssikava.",0);
	dummy = run_dialog(1);
	
break;

beginstate 11;
if (get_flag(21,2) != 0)
	end();
	
	set_flag(21,2,1);
	message_dialog("In front of you, you can see the goal of your quest, the way through the mountain to the presumably more hospitable lands beyond! However, between you and them are formidable gates, interlocking in a complex series.","You clearly cannot open them from here. There appear to be guardrooms to the east and west, but you are unable to see if you can open them from there, either. They might be reasonable places to start, though.");
break;

beginstate 12;
	reset_dialog();
	add_dialog_str(0,"There is a chain in front of you. It appears to open and close the gates nearby. You could probably turn it, but it would make a lot of noise.",0);
	add_dialog_str(1,"And a lot of noise in this hostile environment would probably not be conducive to a long life. Turning this chain would likely be suicidal, especially given the army of undead you can see through the windows to the north.",0);
	add_dialog_str(2,"Would you like to turn the chain?",0);
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Turn the chain.");
	if (run_dialog(1) == 2)
		{message_dialog("You turn the chain. It creaks unbelievably as it turns, alerting every single undead creature anywhere near the mountain, including the sizable army just outside the gates.","Your deaths are not quick.");
		kill_char(1000,2,0);
		}
break;

beginstate 13;
if (get_flag(21,3) == 0)
	set_flag(21,3,1);
if (get_flag(21,19) != 0)
	end();
	
	j = 0;
	i = 50;
	while (i <= 61)
		{if (char_ok(i))
			j = 1;
		i = i + 1;
		}
	if (j)
		end();
	
	set_flag(21,19,1);
	message_dialog("You look at the gates to the north. They look inviting, and you imagine that they would open before you.","You can't see anything specific that would make you think this, but you can't shake the feeling.");
break;

beginstate 14;
if (get_flag(21,3))
	end();
	
	set_attitude(51,4);
	set_attitude(54,4);
	set_attitude(57,4);
	set_attitude(60,4);
break;

beginstate 15;
	set_attitude(51,10);
	set_attitude(54,10);
	set_attitude(57,10);
	set_attitude(60,10);
break;

beginstate 16;
	message_dialog("The undead lord falls, his powerful body ravaged by your blows. You pause for a moment, expecting the tension in the room to lessen, but it doesn't.","The dragon still remains to be fought.");
break;

beginstate 17;
	set_flag(21,4,1);
break;

beginstate 18;
	set_flag(21,5,1);
break;

beginstate 19;
if (get_flag(21,7) != 0)
	end();
	
	reset_dialog();
	add_dialog_str(0,"Before you is the library of the dragon who commands all of the forces in this mountain. Beyond these shelves, somewhere, is that dragon.",0);
	add_dialog_str(1,"You quickly assess if you are ready to proceed. If you enter, you will draw very near the dragon, and if he sees you, it's unlikely that you could get out without fighting him. You should be ready for the fight of your lives before you continue.",0);
	add_dialog_str(2,"You skim the titles on the shelves to see if they contain anything important, but the overwhelming majority are written in alphabets that you have never seen before. You can't read anything here.",0);
	set_flag(21,7,run_dialog(1));
break;

beginstate 20;
if (get_flag(21,9) == 1)
	{message_dialog("You approach the exit from this place, but you don't hear the gates re-open. If the dragon really wanted you to leave, why is he forcing you to stay here?","Suddenly you feel movement in the air behind you. You spin, but it is too late. The dragon is upon you, and you are unable to draw your weapons fast enough to fend him off. He rends you limb from limb.");
	kill_char(1000,2,0);
	}

if (get_flag(21,6) != 0)
	end();
	
	set_flag(21,6,1);
	
	set_terrain(6,16,64);
	set_terrain(7,16,64);
	set_terrain(8,16,64);
	set_terrain(9,16,64);
	play_sound(99);
	
	reset_dialog();
	add_dialog_str(0,"As you enter this room, deep within the dragon's personal territory, you can hear a soft, deep hissing noise. Suddenly the hissing turns into a voice, a terrible, rumbling voice.",0);
	clear_buffer();
	append_string("_Greetings, strange being");
	if (party_size() > 1)
		append_string("s");
	append_string(",_ the dragon says. _Please forgive my guards for their inhospitable actions as you entered my home. They are not used to armed travelers, ");
		if (get_flag(250,0) >= 4)
			append_string("and sliths in particular frighten them. There is a war, you see._");
		else
			{if (party_size() > 1)
				append_string("particularly such exotic ones as yourselves. I have never seen creatures of your like._"); 
			else
				append_string("particularly such an exotic one as yourself. I have never seen a creature of your like._");
			}
	get_buffer_text(dlgstr);
	add_dialog_str(1,dlgstr,0);
	add_dialog_str(2,"The dragon rumbles. _Please, come closer, so that we may talk._ It rumbles again, a sound that almost resembles a laugh. _You have no choice, after all: I have sealed off the way through which you came._",0);
break;

beginstate 21;
if (get_flag(21,8) != 0)
	end();
	
	set_flag(21,8,1);
	
	change_blocked(15,3,1);
	change_blocked(15,4,1);
	change_blocked(15,5,1);
	change_blocked(15,6,1);
	change_blocked(15,7,1);
	change_blocked(15,8,1);
	change_blocked(15,9,1);
	change_blocked(14,3,1);
	change_blocked(14,4,1);
	change_blocked(14,5,1);
	change_blocked(14,6,1);
	change_blocked(14,7,1);
	change_blocked(14,8,1);
	change_blocked(14,9,1);
	
	change_blocked(17,15,0);
	change_blocked(18,15,0);
	change_blocked(19,15,0);
	change_blocked(20,15,0);
	change_blocked(21,15,0);
	change_blocked(22,15,0);
	change_blocked(23,15,0);
	change_blocked(24,15,0);
	change_blocked(25,15,0);
	change_blocked(26,15,0);
	change_blocked(17,16,0);
	change_blocked(18,16,0);
	change_blocked(19,16,0);
	change_blocked(20,16,0);
	change_blocked(21,16,0);
	change_blocked(22,16,0);
	change_blocked(23,16,0);
	change_blocked(24,16,0);
	change_blocked(25,16,0);
	change_blocked(26,16,0);
	
	// The skeleton warriors show up.
	i = 0;
	activate_hidden_group(2);
	if (get_flag(19,12) == 1)
		erase_char(65);
	else
		{put_boom_on_char(65,6,0);
		i = i + 1;
		alert_char(65);
		}
	if (get_flag(19,13) == 1)
		erase_char(69);
	else
		{put_boom_on_char(69,6,0);
		i = i + 1;
		alert_char(69);
		}
	if (get_flag(20,13) == 1)
		erase_char(68);
	else
		{put_boom_on_char(68,6,0);
		i = i + 1;
		alert_char(68);
		}
	if (get_flag(20,14) >= 1)
		erase_char(63);
	else
		{put_boom_on_char(63,6,0);
		i = i + 1;
		alert_char(63);
		}
	if (get_flag(20,14) == 2)
		erase_char(64);
	else
		{put_boom_on_char(64,6,0);
		i = i + 1;
		alert_char(64);
		}
	if (get_flag(21,4) == 1)
		erase_char(66);
	else
		{put_boom_on_char(66,6,0);
		i = i + 1;
		alert_char(66);
		}
	if (get_flag(20,15) == 1)
		erase_char(71);
	else
		{put_boom_on_char(71,6,0);
		i = i + 1;
		alert_char(71);
		}
	if (get_flag(21,5) == 1)
		erase_char(67);
	else
		{put_boom_on_char(67,6,0);
		i = i + 1;
		alert_char(67);
		}
	if (i > 0)
		{message_dialog("The dragon roars, _My guards! To me!_ and you hear a loud magical blast.","");
		run_animation_sound(54);
		}
	else
		message_dialog("The dragon roars, _My guards! To me!_ However, nothing happens. You recall that you slew all of his skeletal undead leaders.","");
	
	// The factory-made undead show up.
	if (get_flag(20,23) > 0)
		message_dialog("The dragon also calls for more undead, attempting to summon some minor footsoldiers. However, since you destroyed his undead-making factory, none appears.","The dragon screams in rage.");
	else
		{message_dialog("The dragon also calls for more undead, attempting to summon some minor footsoldiers, and many appear!","");
		activate_hidden_group(5);
		}
	
	// Ithik shows up.
	if (get_flag(19,11) == 1)
		{activate_hidden_group(3);
		message_dialog("And suddenly, out from a secret passage in the wall, appears Ithik! True to his word, he is here to help you fight the dragon!","_For Vasskolis, and for the slithzerikai!_ he cries.");
		}
	if (get_flag(19,14) == 1)
		{activate_hidden_group(3);
		message_dialog("And suddenly, out from a secret passage in the wall, appears the slith you met but could not speak with in the levels above! Apparently, he is here to help you fight the dragon!","He lets out a battlecray and charges into the fray.");
		}
	
	// The freed golems show up.
	if (get_flag(250,7) == 2)
		{i = 0;
		activate_hidden_group(4);
		if (get_flag(20,20) == 0)
			erase_char(79);
		else
			{put_boom_on_char(79,2,0);
			i = i + 1;
			}
		if (get_flag(20,21) == 0)
			erase_char(77);
		else
			{put_boom_on_char(77,2,0);
			i = i + 1;
			}
		if (get_flag(20,22) == 0)
			erase_char(83);
		else
			{put_boom_on_char(83,2,0);
			i = i + 1;
			}
		if (get_flag(21,18) == 0)
			erase_char(80);
		else
			{put_boom_on_char(80,2,0);
			i = i + 1;
			}
		if (get_flag(19,15) == 0)
			erase_char(82);
		else
			{put_boom_on_char(82,2,0);
			i = i + 1;
			}
		clear_buffer();
		append_string("Then, true to ");
		if (i > 1)
			append_string("their");
		else
			append_string("its");
		append_string(" word, ");
		append_number(i);
		if (i > 1)
			append_string(" golems teleport ");
		else
			append_string(" golem teleports ");
		append_string("into the room! ");
		if (i > 1)
			append_string("They attack");
		else
			append_string("It attacks");
		append_string(" the dragon with great ferocity.");
		get_buffer_text(dlgstr);
		message_dialog(dlgstr,"");
		run_animation_sound(10);
		}
	
	message_dialog("And so it is. This dragon is the last obstacle that stands between you and the object of your quest: living sliths from the homeland. You must defeat him, for the sake of Legare, for Bahssikava, and for all of slithkind.","You draw your weapons, and the battle commences.");
	
break;

beginstate 22;
if (get_flag(21,9) != 0)
	end();
	
	put_field_on_space(11,3,4);
	put_field_on_space(11,4,4);
	set_flag(21,9,1);
	begin_talk_mode(1);
break;

beginstate 23;
	i = get_ran(1,1,3);
	if (i == 1)
		play_sound(65);
	if (i == 2)
		play_sound(48);
	if (i == 3)
		play_sound(44);
break;

beginstate 24;
if (get_flag(21,8) != 0)
	{message_dialog("You can't go back this way. The only way out is forward.","");
	block_entry(1);
	end();
	}
	
if ((get_flag(21,10) != 0) || (get_flag(21,9) == 0))
	end();
	
	set_flag(21,10,1);
	message_dialog("You get the feeling, walking back this way, that it is a very bad idea to turn your back to the dragon. It's just a hunch, but you've learned through your adventures to trust your instincts.","");
break;

beginstate 25;
	play_sound(44);
	add_dialog_str(0,"You strike the final blow that slays the dragon. Galthrax, with all his might and majesty, all his monstrosity and terror, is no more. You have saved Vasskolis.",0);
	if (char_ok(70))
		{add_dialog_str(1,"Ithik stares at the beast's corpse for a long moment. _He's dead. He's really dead. This... monster... we have fought for a decade is dead. The war is over. It is over!_",0);
		add_dialog_str(2,"He turns to you, elated. _Come with me! There is a secret door in the corner of this room! Follow me, and let me show you the city that you have saved!_ He rushes through an exit in the southeast corner, vanishing.",0);
		set_flag(21,13,1);
		}
	else
		{if (get_flag(19,11))
			{add_dialog_str(1,"Ithik, severely wounded, lays on the ground bleeding. With the last energy that you have left in you, you heal him. He rises gingerly, looking at the dragon. _He's dead,_ he whispers. _He's really dead._",0);
			add_dialog_str(2,"_Come,_ he says. _Follow me, and let me show you the city that you have saved. There is a secret passage in the corner._ He leaves through an exit in the southeast corner, vanishing.",0);
			set_flag(21,14,1);
			}
		else
			{add_dialog_str(1,"Ithik would be happy to see this. The dragon that has menaced his city for years is now dead. You wonder where he is. Presumably you will find out when you journey to Vasskolis.",0);
			set_flag(21,15,1);
			}
		}
	add_dialog_str(3,"Now it is time for you to find this city that you have saved and complete your quest. The way you came is blocked with force fields. You must go out another way.",0);
	erase_char(70);
	set_flag(21,11,run_dialog(1));
	
	// Golems thank you.
	i = 0;
	if (char_ok(77))
		i = i + 1;
	if (char_ok(79))
		i = i + 1;
	if (char_ok(80))
		i = i + 1;
	if (char_ok(82))
		i = i + 1;
	if (char_ok(83))
		i = i + 1;
	if (i > 0)
		{clear_buffer();
		append_string("The ");
		append_number(i);
		append_string(" remaining golem");
		if (i > 1)
			append_string("s cheer");
		else
			append_string(" cheers");
		append_string("! You have saved all intelligent golems under Galthrax's yoke from a lifetime of slavery and abuse. ");
		if (i > 1)
			append_string("One");
		else
			append_string("The");
		append_string(" golem steps forward.");
		get_buffer_text(dlgstr);
		message_dialog(dlgstr,"_Thank you for this great service. We golems have no reward to offer you, but you have our eternal thanks, and if we can ever repay you, rest assured that we will._");
		}
	
	i = 6;
	while (i < 120)
		{erase_char(i);
		i = i + 1;
		}
break;

beginstate 26;
if (get_flag(21,11) == 0)
	{block_entry(1);
	end();
	}
	
if (get_flag(21,12) != 0)
	end();
	
	set_flag(21,12,1);
	message_dialog("You squeeze through the secret passage in the wall. It takes you several minutes to manage it, but eventually you do.","");
break;

beginstate 27;
if ((get_flag(250,5) == 1) && (has_item(451) == 0))
	{message_dialog("You can't just leave Phaedra behind. You must take her with you to the guardpost immediately or she will die.","");
	block_entry(1);
	end();
	}

	reset_dialog();
	add_dialog_str(0,"Do you wish to proceed on towards Vasskolis and finish your quest?",0);
	add_dialog_choice(0,"No. I'm not ready yet.");
	add_dialog_choice(1,"Yes. Onward!");
	if (run_dialog(1) == 2)
		move_to_new_town(22,32,55);
	else
		block_entry(1);
break;

beginstate 28;
if ((get_flag(250,5) == 1) && (has_item(451) == 0))
	{message_dialog("You can't just leave Phaedra behind. You must take her with you to the guardpost immediately or she will die.","");
	block_entry(1);
	end();
	}
	
	reset_dialog();
	add_dialog_str(0,"The ground slopes sharply up here. Do you climb up it?",0);
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Climb up it.");
	if (run_dialog(1) == 1)
		block_entry(1);
	else
		move_to_new_town(20,55,57);
break;

beginstate 29;
	if (get_terrain(6,16) == 64)
		{message_dialog("As you step near, the gates open smoothly. Whether this is a good sign or not, you cannot be sure.","");
		set_terrain(6,16,68);
		set_terrain(7,16,68);
		set_terrain(8,16,68);
		set_terrain(9,16,68);
		}
break;

beginstate 30;
if (get_flag(21,16) == 0)
	{set_flag(21,16,1);
	message_dialog("As you walk by, you notice the wall to the west looks insubstantial, as if it isn't completely there.","");
	}
break;

beginstate 31;
if (get_flag(21,17) == 0)
	{set_flag(21,17,1);
	message_dialog("On the other side of this door, you hear a large number of voices, most guttural and harsh. You stand on edge, ready for combat at any moment.","");
	}
break;

beginstate 32;
if (get_flag(21,21) != 0)
	end();
	
	set_flag(21,21,1);
	message_dialog("You hear a VERY large number of undead on the other side of this door. You may not be able to get through.","");
	place_monster(50,18,138,1);
	place_monster(49,17,138,1);
	place_monster(50,16,138,1);
	place_monster(49,14,138,1);
break;

beginstate 33;
if (get_flag(21,22) != 0)
	end();
	
	set_flag(21,22,1);
	message_dialog("You hear a VERY large number of undead on the other side of this door. You may not be able to get through.","");
	place_monster(50,18,138,1);
	place_monster(49,17,138,1);
	place_monster(50,16,138,1);
	place_monster(49,14,138,1);
break;

beginstate 34;
if (get_flag(21,20) != 0)
	end();
	
	set_flag(21,20,1);
	message_dialog("You hear a VERY large number of undead on the other side of this door. You may not be able to get through.","");
	place_monster(31,19,138,1);
	place_monster(32,17,138,1);
	place_monster(31,16,138,1);
	place_monster(33,18,138,1);
break;

beginstate 35;
	// Set the variables for the golem freeing state
	which_flag = 18;
	golem_type = 217; // Fire Golem
	hold_loc_x = 62; // location of the holding cell
	hold_loc_y = 39;

	set_state_continue(36);
break;

beginstate 36;
// Golem freeing state for this town
if (get_flag(current_town(),which_flag))
	{message_dialog("You've already done all that you can do here. You leave the control panel alone.","");
	end();
	}

	reset_dialog();
	add_dialog_str(0,"You come to a control panel for this strange device.",0);
	if (has_special_item(7) > 0)
		add_dialog_str(1,"You remember the instructions page that you found and pull it out. It seems to describe how to do something with this control panel.",0);
	add_dialog_str(2,"What do you do?",0);
	add_dialog_choice(0,"Leave.");
	if (has_special_item(7) > 0)
		add_dialog_choice(1,"Use the controls, following the instructions on the page.");
	else
		add_dialog_choice(1,"Fiddle with the controls blindly.");
	if (run_dialog(1) == 1)
		end();
		
	if (has_special_item(7) == 0)
		{message_dialog("You press some buttons here and there, but nothing happens.","");
		end();
		}
		
	message_dialog("You follow the instructions and press numerous buttons in a particular order. Nothing seems to happen at first, but then the machine activates!","");
	
	set_flag(current_town(),which_flag,1); // freed this golem
	
	set_terrain(hold_loc_x,hold_loc_y,138);
	put_boom_on_space(hold_loc_x,hold_loc_y,6,0);
	run_animation_sound(53);
		
	if (get_flag(250,7) == 1)
		message_dialog("You free this golem and give him the same lame story about not being here to help the dragon. Disappointed, he vanishes.","");
	
	if (get_flag(250,7) == 2)
		message_dialog("You free this golem and tell him the same thing that you told the first golem that you freed. You ask if he will help you fight the dragon. He assents quite willingly.","You have gained the aid of a fire golem.");
	
	if (get_flag(250,7) > 0)
		end();
	
	place_monster(hold_loc_x,hold_loc_y,golem_type,2); 
	
	while (char_ok(j) == 0)
		{j = j - 1; }
		
	run_scenario_script(15);
	
break;

beginstate 37;
	block_entry(1);
	message_dialog("You hear more undead in this direction. You hear a lot more, in fact. It would probably be a really bad idea to go this way.","");
break;

beginstate 38;
	message_dialog("You witness a dark being named Vishanth sacrifice a completely hypnotized slith and call forth the dragon Galthrax. They vow to destroy Vasskolis immediately. Then Galthrax returns to his inner chambers northward.","");
break;