begintownscript;

variables;
short clocx,clocy,sdfx,pcs,leadchar;

body;

beginstate 0;

	set_crime_tolerance(5);

	if(get_flag(14,0) == 2){
		force_instant_terrain_redraw();
		message_dialog("The place itself is actually rather empty and small, now that you near its center.  The entire complex is only four small barrack buildings and a modest amphitheater.","A good-looking amphitheater to say the least, but modest nevertheless.");
		message_dialog("Machtschrein seems to be sparsely populated.  Weren't you supposed to report here after successfully completing your mission, though?","Somebody here HAS to be able to give you better direction.");
		set_flag(14,0,3);
	}
	if(get_flag(14,0) <= 3 && get_flag(17,0) <= 1){
		activate_hidden_group(1);
	}
	if(get_flag(17,0) >= 3){
		set_terrain(10,18,32);
	}

	if(get_flag(17,0) == 13){
		activate_hidden_group(2);
		force_instant_terrain_redraw();
		message_dialog("You climb out of the catacombs and find yourself where you came in!  But wasn't the way you came up different than the way you went down?","Regardless, you're still in one piece, and back in the real world.  Leader is sitting on a throne ahead of you, hopefully he has some answers.");
		set_flag(17,0,14);
	}
	if(get_flag(17,0) >= 13){
		activate_hidden_group(2);
		set_char_dialogue_pic(27,401,0);
	}

	if(get_flag(35,0) >= 100){
		erase_char(27);
		set_terrain(24,23,137);
		set_terrain(26,23,138);
		set_terrain(24,25,138);
		set_terrain(22,23,138);
		set_terrain(24,21,138);
		force_instant_terrain_redraw();
	}

	if(get_flag(35,0) == 100){
		pcs = 0;
		while(pcs < 4){
			if(char_ok(pcs) == TRUE){
				sdfx = (73 + pcs);
				clocx = get_flag(sdfx,2);
				clocy = get_flag(sdfx,3);
				relocate_character(pcs,clocx,clocy);
			}
			pcs = (pcs + 1);
		}
		block_entry(1);
		message_dialog("The crowds disperse.  Spiegel is led off of the dais by two wizards, and Leader leaves his alcove.","Machtschrein, filled with life and energy only a small while earlier, is now left barren and empty again.");
		erase_char(27);
		set_flag(35,0,101);
	}

break;

beginstate 1;
break;

beginstate START_STATE;

	if(get_crime_level() > 0){
		message_dialog("The guards sound their horns and the entire nation begins pouring into Machtschrein.  You last for approximately ten seconds before you are swamped completely.","You are restrained, imprisoned, and killed slowly and painfully.");
		kill_char(1000,3,0);
	}

break;

beginstate 10;
	message_dialog("You have no reason to climb to the second tier of the amphitheater.","Plus, the guards seem to disapprove.  You back off.");
	block_entry(1);
break;

beginstate 11;
	if(get_flag(17,0) == 2){
		message_dialog("General Adlerauge hands you a key.  _Use this to open the western gate of the amphitheater._","You insert the key into the gate and gently lift it up.");
		change_spec_item(24,1);
		set_terrain(10,18,32);
		set_flag(17,0,3);
	}
break;

beginstate 12;
	if(get_flag(17,0) == 3){
		message_dialog("You take your first steps into the room where Leader prepares himself before addressing his most powerful supporters.","It's a sacred place.  The ground almost glistens, the fires burn constantly.  It's somewhat humble, but impressively so.");
		set_flag(17,0,4);
	}
break;

beginstate 13;
	if(get_flag(17,0) == 4){
		message_dialog("There is a long, lighted hallway here that appears to ascend as it reaches the middle.","It's not that long of a walk, although it is a cramped one.");
		set_flag(17,0,5);
	}
break;

beginstate 14;
	if(get_flag(17,0) == 5){
		message_dialog("You finally reach the top of the amphitheater.  Here, you have an unrivaled view.  From here, it looks like all of Machtschrein is embracing YOU.","You feel like a mountain, a centripetal force drawing everything around it closer to your power.");
		message_dialog("General Adlerauge points to a set of descending stairs.  _That is where we have to be._","_Come, let's not waste any more time._");
		set_flag(17,0,6);
	}
break;

beginstate 15;
	if(get_flag(17,0) == 6){
		block_entry(1);
		move_to_new_town(8,26,8);
	}
	else{
		message_dialog("The catacombs lie below you, but you have no reason whatsoever to return.","The first time was trippy enough.  Doing it twice would be overkill.");
		block_entry(1);
	}
break;

beginstate 16;
	block_entry(1);
break;

beginstate 17;

	leadchar = 0;
	while(char_ok(leadchar) == FALSE){
		leadchar = (leadchar + 1);
	}
	if((char_loc_x(leadchar) >= 22) && (char_loc_x(leadchar) <= 26)){
		if((char_loc_y(leadchar) >= 18) && (char_loc_y(leadchar) <= 19)){
			block_entry(1);
		}
	}

break;
