begintownscript;

variables;
short talk;

body;

beginstate 0;

	if(get_flag(26,0) == 0){
		message_dialog("This is Fortress Grenze, made to protect the border between North Canopy and Sud Canopy.  It's thin, but also tall.","It's a testament to North Canopy's military strength.  You can't help but admire the architecture.");
		set_flag(26,0,1);
	}
	if(get_flag(23,0) <= 8){
		message_dialog("The gates are closed, and understandably so.  Controlling this tower would be devastating, and people can't be allowed to waltz on in.","You'll have to get your kicks elsewhere, apparently.");
	}
	if(get_flag(23,0) >= 9 && get_flag(26,0) == 1){
		message_dialog("The gates are closed.  Understandably, considering that the fortress doesn't want you inside.","There is a guard standing at the gate.  Perhaps you should approach him to seek entrance.");
		set_flag(26,0,2);
		activate_hidden_group(3);
		set_name(12,"Gatekeeper");
	}

break;

beginstate 1;
break;

beginstate START_STATE;
break;

beginstate 10;

	if(get_flag(26,0) == 2){
		if(party_size() > 1)
			message_dialog("You call out to the soldier standing out the door.  _Right, and who are you?_","You tell him that you are the Specialists, come to see Liason Lealte.");
		if(party_size() == 1)
			message_dialog("You call out to the soldier standing out the door.  _Right, and who are you?_","You tell him that you are the Specialist, come to see Liason Lealte.");
		message_dialog("He thinks for a while.  He pauses, turns around, and puts his hand to his chin, almost mockingly.  Then, he turns around.","_And do you have a Writ of Entrance signed by Leader?_");

		if(get_flag(75,0) == 0){
			talk = 14;
		}
		else{
			talk = get_flag(75,0);
		}

		set_total_visibility(1);
		force_view_center(16,9);
		relocate_character(0,16,8);
		relocate_character(1,16,7);
		relocate_character(2,16,6);
		relocate_character(3,16,5);
		activate_hidden_group(1);
		text_bubble_on_char(11,"Let them in.");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(11,"");
		relocate_character(11,17,4);
		force_instant_terrain_redraw();
		pause(5);

		relocate_character(11,17,5);
		force_instant_terrain_redraw();
		pause(5);

		relocate_character(11,17,6);
		force_instant_terrain_redraw();
		pause(5);

		relocate_character(11,17,7);
		force_instant_terrain_redraw();
		pause(5);

		relocate_character(11,17,8);
		force_instant_terrain_redraw();
		pause(5);

		text_bubble_on_char(12,"General Moerder!");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		text_bubble_on_char(11,"Open the damn gate.");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(11,"");
		text_bubble_on_char(12,"But they don't have");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		text_bubble_on_char(12,"a writ of entrance.");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		text_bubble_on_char(11,"They don't NEED");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(11,"");
		text_bubble_on_char(11,"your goddamn writ.");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(11,"");
		text_bubble_on_char(12,"...");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		force_instant_terrain_redraw();
		pause(5);

		text_bubble_on_char(12,"...right.");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		text_bubble_on_char(12,"They can come in.");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		text_bubble_on_char(12,"But YOU, ma'am,");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		text_bubble_on_char(12,"are not allowed.");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		text_bubble_on_char(11,"Fine.  It doesn't matter.");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(11,"");
		text_bubble_on_char(11,"You're dead anyway.");
		force_instant_terrain_redraw();
		pause(talk);

		set_terrain(16,8,68);
		force_instant_terrain_redraw();
		play_sound(99);
		pause(5);

		relocate_character(11,17,6);
		relocate_character(12,16,11);
		set_character_facing(11,0);
		set_character_facing(12,4);
		march_party(16,9);
		force_instant_terrain_redraw();
		pause(5);

		relocate_character(11,17,5);
		relocate_character(12,17,12);
		march_party(16,10);
		force_view_center(16,10);
		force_instant_terrain_redraw();
		pause(5);

		relocate_character(11,17,4);
		relocate_character(12,16,13);
		march_party(16,11);
		force_view_center(16,11);
		force_instant_terrain_redraw();
		pause(5);

		relocate_character(11,17,3);
		relocate_character(12,16,14);
		march_party(17,12);
		force_view_center(17,12);
		force_instant_terrain_redraw();
		pause(5);

		set_terrain(16,8,64);
		erase_char(11);
		erase_char(12);
		activate_hidden_group(3);
		play_sound(99);
		block_entry(1);
		set_name(27,"Gatekeeper");
		force_instant_terrain_redraw();

		set_flag(26,0,3);
		message_dialog("As you enter the fortress, the gates are closed behind you.  They aren't attacking you yet, but it can only be a matter of time.","You had best keep your wits about you here.");
		set_total_visibility(0);
	}

break;

beginstate 11;

	if(get_flag(26,0) == 3 && get_flag(68,2) == 0){
		message_dialog("The gatekeeper scowls, squints his eye, and draws his sword.","_C'mon, boys, let's get 'em._");
		set_flag(68,2,1);
	}
break;

beginstate 12;

	if(get_flag(26,0) <= 9){
		message_dialog("You should talk with Liason Lealta while you're here, in order to confirm the obvious.","Even though fighting these brigands is probably absolutely necessary, you can still check to be sure...");
		block_entry(1);
	}
	else{
		move_to_new_town(10,14,19);
	}

break;

beginstate 13;

	message_dialog("This lever is held in place by a lock which you do not have the key for.","You are forced to let it be.");
	block_entry(1);

break;