// townscript for town 27: Machinery level after explosion

begintownscript;

variables;

int i,j,choice;

body;

beginstate INIT_STATE;
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;

	if (get_flag(5,18) > 0) {
			set_terrain(21,25,137);
			erase_char(24);
			}

break;

beginstate 10;
	if (get_flag(5,18) > 0) {
			end();
			}
		message_dialog("There's a mage standing at the control panel of the power creator machines. He doesn't look pleased.","");
		
		// starting cutscene
		
		march_party(34,32);
		force_view_center(34,32);
		force_instant_terrain_redraw();
		pause(6);
		
		march_party(34,31);
		force_view_center(34,31);
		force_instant_terrain_redraw();
		pause(6);
		
		march_party(34,30);
		force_view_center(34,30);
		force_instant_terrain_redraw();
		pause(6);
		
		march_party(35,29);
		force_view_center(35,29);
		force_instant_terrain_redraw();
		pause(6);
		
		march_party(35,28);
		force_view_center(35,28);
		force_instant_terrain_redraw();
		pause(6);
		
		march_party(35,27);
		force_view_center(35,27);
		force_instant_terrain_redraw();
		pause(6);
		
		march_party(35,26);
		force_view_center(35,26);
		force_instant_terrain_redraw();
		pause(6);
		
		march_party(35,25);
		force_view_center(35,25);
		force_instant_terrain_redraw();
		pause(10);
		
		// Talking to mage
		
		text_bubble_on_char(0,"Sir?");
		text_bubble_on_char(24,"mumble");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(24,"");
		force_instant_terrain_redraw();
		pause(5);
		
		text_bubble_on_char(0,"");
		text_bubble_on_char(24,"mumble");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(1,"He doesn't seem to hear us");
		text_bubble_on_char(24,"");
		force_instant_terrain_redraw();
		pause(5);
		
		text_bubble_on_char(24,"mumble");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(1,"");
		text_bubble_on_char(3,"");
		text_bubble_on_char(24,"");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(3,"Lets go");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(3,"");
		march_party(34,25);
		force_view_center(34,25);
		force_instant_terrain_redraw();
		pause(7);
		
		set_character_facing(24,4);
		march_party(34,26);
		force_view_center(34,26);
		force_instant_terrain_redraw();
		pause(7);
		
		text_bubble_on_char(24,"WAIT!");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(24,"");
		text_bubble_on_char(24,"Who are you?");
		force_instant_terrain_redraw();
		pause(10);
		
		march_party(34,25);
		relocate_character(2,35,26);
		force_view_center(34,25);
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(24,"");
		text_bubble_on_char(24,"WHO ARE YOU!!");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(0,"We are adventurers");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(24,"");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(0,"");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(24,"Right");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(24,"");
		text_bubble_on_char(24,"Adventurers");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(24,"");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(24,"What are you doing here?");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(24,"");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(24,"This place is such a mess!");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(24,"");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(24,"Tell me...");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(24,"");
		text_bubble_on_char(24,"what are you doing here?");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(24,"");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(0,"");
		text_bubble_on_char(0,"We know who made the mess");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(24,"WHO!");
		force_instant_terrain_redraw();
		pause(5);
		
		text_bubble_on_char(0,"");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(24,"");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(1,"We did");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(1,"");
		force_instant_terrain_redraw();
		pause(20);
		
		message_dialog("He stares blankly at you. _You... you did this?_ he mutters. You say you did. Then he gets angry. But really, really, REALLY angry.","");
		
		text_bubble_on_char(24,"WHAT!");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(24,"");
		force_instant_terrain_redraw();
		pause(10);
		
		message_dialog("He throws his hands in the air and starts shouting a spell. In his hands, two glowing balls start appearing. Its quite frightening to look at...","");
		
		set_character_pose(24,1);
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(24,"Cum spirito et sancte");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(24,"");
		text_bubble_on_char(24,"Ade me");
		force_instant_terrain_redraw();
		pause(20);
	
		text_bubble_on_char(24,"");
		text_bubble_on_char(24,"ET ME ADEBIS TU!!");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(24,"");
		force_instant_terrain_redraw();
		pause(5);
		
		message_dialog("The glowing balls start to rise from his hands, forming long tentacles of light, hitting you...","");
		
		// teleport
		
		pause(10);
		
		put_straight_zap(33,21,34,25,2);
		put_straight_zap(33,21,34,26,2);
		put_straight_zap(33,21,35,25,2);
		put_straight_zap(33,21,35,26,2);
		put_boom_on_char(0,4,0);
		put_boom_on_char(1,4,0);
		put_boom_on_char(2,4,0);
		put_boom_on_char(3,4,0);
		run_animation_sound(54);
		run_animation();
		pause(10);
		
		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(10);
		run_animation();
		
		set_character_pose(24,0);
		force_instant_terrain_redraw();
		pause(5);
		
		message_dialog("Your vision becomes black. For a few moments, you can only see small white flickering lights. When you open your eyes, you see that you are in a completely different place...","");
		
		set_flag(27,1,2); // enables you to enter the powerlvl again
		set_flag(22,11,2);
		
		change_outdoor_location(4,2,17,19);
		move_to_new_town(3,26,22);
break;

beginstate 11;
if (get_flag(27,1) == 0) {
		set_flag(27,1,1);
		message_dialog("You return to the power level of Thralni's castle. You think you hear somebody shuffling around somewhere, but you can't really say where that somebody really is. The sound is too soft for that.","");
		end();
		}
break;

beginstate 12;
if (get_flag(27,2) == 1) 
		end();
	message_dialog("This corridor is blocked by boulders. You'll have to find another way.","");
	set_flag(27,2,1);
break;

beginstate 13;
if (get_flag(5,18) == 1 && get_flag(27,4) == 0) {
		message_dialog("You have the impression that its a bit lighter in the small library in front of you, as if a new chamber with lighting has been opened.","");
		set_flag(27,4,1);
		}
break;

beginstate 14;
	message_dialog("This book is too damaged to be read properly. Even if it weren't too damaged, it wouldn't have been of interest to you. You look at the cover: _Elizabeth's machinery guide to the galaxy_","");
break;

beginstate 15;
if (get_flag(22,17) == 1) 
		end();
	message_dialog("This small chamber was opened by recent walls collapsing as a result of you blowing up the energy reactor. You could give a look and see what's in the chamber.","");
	set_flag(22,17,1);
break;

beginstate 16;
	reset_dialog();
	add_dialog_str(0,"You read this old book. The book was damaged by the humid conditions. However, some parts seem to be readable:",0);
	add_dialog_str(1,"_The Empire is slowly coming to this section of the Thraldom. The Emperor ordered us to pack everything up. We are leaving._ The book is too heavily damaged to read this note any farther. It looks as if it was removed from Thralni's castle.",0);
	add_dialog_str(2,"However, when you flip through the book for a while, you come across this small bit  of text:",0);
	add_dialog_str(3,"_If people look for the Emperor, they can find their answers there were crystals shine, although it's dark, until their day comes, and they can experience the world of light._ You don't really understand what it means. Maybe somebody can help you?",0);
	add_dialog_choice(0,"Hmmm...");
	choice = run_dialog(1);
	set_flag(8,9,1);
break;

beginstate 17;
	move_to_new_town(20,7,53);
break;

beginstate 18;
if (get_flag(27,1) == 1) {
		message_dialog("You surely don't want to leave the power level before finding the person you heard, don't you? Maybe he has information that can be useful for you!","The fact that this person, or at least you hope it's a person and not some creature, found this place, is already extraordinary, given the time it took you to get here. If you go away, he might not be here when you return.");
		block_entry(1);
		}
break;