begintownscript;

variables;
short beds,pcs,cont,introd,inct,dest,lead,lead_char,walkx,time;

body;

beginstate 0;

	pcs = 3;
	cont = 1;
	while(pcs >= 1 && cont > 0){
		beds = (14 - pcs);
		if(party_size() <= pcs){
			set_terrain(beds,15,0);
		}
		else{
			cont = 0;
		}
		pcs = pcs - 1;
	}
	force_instant_terrain_redraw();

	if(get_flag(35,0) == 0){
		reset_dialog();
		add_dialog_str(0,"You wake up, only to find that your room has been substantially enlarged.  The door is gone, with two hallways placed in stead of the previous setup.",0);
		add_dialog_str(1,"The interior design of this new place is the same as Emery's house, but it would appear as if it is not the same place.",0);
		add_dialog_str(2,"The humming of machines permeates this place.  The noise is not particularly obtrusive, but is sublty eerie nevertheless.",0);
		add_dialog_str(3,"There is a crystal on a pedestal on the southernmost end of your room.  It is seemingly docile and inactive, but is emitting a strange light.  Not the kind of light that helps to see, but more of a guiding aura.",0);
		add_dialog_str(4,"You have no idea why Emery took you here, nor what manner of place this is.  Perhaps you had best explore your surroundings.",0);
		introd = run_dialog(1);
		set_flag(34,0,1);
	}

break;

beginstate 1;
break;

beginstate START_STATE;
break;

beginstate 10;

	if(get_flag(36,0) == 0){
		message_dialog("You aren't entirely sure about what happened here, but it doesn't look very pretty.  Bodies are heaped in a pile on the eastern end of the raised dais.","Surprisingly enough, they don't seem to have suffered from any obvious puncture, frost, burn or otherwise lethal wounds.  What, then, could have done them in?");
		set_flag(36,0,1);
	}

break;

beginstate 11;

	message_dialog("There are powerful barriers here, similar to the kind you saw in the top floor of Fortress Grenze.","You can't get through them, and unlike previously, Emery is not taking them down for you.");

break;

beginstate 12;

	if(get_flag(37,0) == 0){
		message_dialog("This appears to be a storeroom of sorts.  There are three corpses on the ground here, each having sustained no visible wounds of any sort.","Nevertheless, their faces show that they died in the most extreme horror, and in a way that you could not fathom.  Bizarre.");
		set_flag(37,0,1);
	}

break;

beginstate 13;

	if(is_combat() == 1){
		block_entry(1);
		end();
	}

	message_dialog("...Emery!  What is he doing here?","Time to investigate.  And perhaps be told the information which was promised to you.");




	lead = 0;
	while (char_ok(lead) == 0) {
		lead = lead + 1;
	}
	lead_char = lead;

	if(char_loc_x(lead_char) < 32){
		inct = 1;
	}
	else{
		inct = -1;
	}

	walkx = (char_loc_x(lead_char) + inct);

	while(char_loc_x(lead_char) != 32){
		march_party(walkx,41);
		block_entry(1);
		force_view_center(char_loc_x(lead_char),41);
		force_instant_terrain_redraw();
		pause(5);

		walkx = walkx + inct;
	}

//	time = get_current_tick();
//	while(time > 5000){
//		time = (time - 5000);
//		print_str("Decreasing.");
//	}
//	print_str("Day is correct.");
//	while((time < 4950) && (time > 50)){
//		set_ticks_forward(50);
//		time = (time + 50);
//		print_big_str("Time is now ",time,".");
//	}
//	print_str("Time is correct.");
//	print_big_str("Current tick is ",get_current_tick(),".");

	move_to_new_town(20,9,53);
break;