begintownscript;

variables;

int i,j,k,choice;

body;

beginstate INIT_STATE;

if (get_flag(3, 0) == 0)
{
	force_instant_terrain_redraw();

	set_flag(3, 0, 1);
	reset_dialog();
	add_dialog_str(0, "You step into the legendary Temple of the Ages, undetected.", 0);
	add_dialog_str(1, "In front of you is a long walkway, protected by magical runes.", 0);
	add_dialog_str(2, "To the sides of the walkway stand two entire regiments of Eagle Warriors.", 0);
	add_dialog_str(3, "When things start happening, you want to be a long way away from them. A very long way.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);

	reset_dialog();
	add_dialog_str(0, "At the end of the walkway stands another shorn one, a prisoner by his side.", 0);
	add_dialog_str(1, "Two more of the mages watch over the proceedings.", 0);
	add_dialog_str(2, "It looks like you've stumbled into one of their obscene rituals.", 0);
	add_dialog_str(3, "Whatever lives in the pit below the prisoner won't be hungry for much longer.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);

	reset_dialog();
	add_dialog_str(0, "Even if you wanted to, you doubt you could rescue the prisoner.", 0);
	add_dialog_str(1, "Obscene though they might be, the rituals command immense power, and you doubt that stepping on the runes would be wise.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);
}

break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;
// This state is called every turn the party is in this town.

break;

beginstate 10;
if (get_flag(3, 1) == 0)
{
	reset_dialog();
	add_dialog_str(0, "As you walk forwards, the Cuachicqueh on the platform begins chanting.", 0);
	add_dialog_str(1, "The prisoner, realising he doesn't have long left to live when the mage pulls out a long sacrificial knife, struggles a bit.", 0);
	add_dialog_str(2, "He cries out some unintelligible phrase as he thrashes about.", 0);
	add_dialog_str(3, "And then you see his face. He is the more influential of the two Grand Senators, Orosh.", 0);
	add_dialog_choice(0, "Oh no!");
	run_dialog(1);
	
	reset_dialog();
	add_dialog_str(0, "As the mage raises the blade up, waiting for the right moment, the sunlight streams through a small gap in the temple.", 0);
	add_dialog_str(1, "The light reflects off the blade, showing up on the far temple wall.", 0);
	add_dialog_str(2, "The wall-paintings around you give the impression that Orosh will die once the reflection is directly opposite the ritual.", 0);
	add_dialog_str(3, "It's probably time to do something....", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);

	set_flag(3, 1, 1);
}
break;

beginstate 11;
	reset_dialog();
	add_dialog_str(0, "This is a time for quick action, not a calculated approach.", 0);
	add_dialog_str(1, "The direct route is the only route that could save the Grand Senator.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);
	block_entry(1);
break;

beginstate 12;
	reset_dialog();
	add_dialog_str(0, "You run forwards, stepping across the runes.", 0);
	add_dialog_str(1, "Before, no-one had noticed your entrance, but now some of the crowd direct their attention to you.", 0);
	add_dialog_str(2, "The Eagle Warriors not still observing the ritual look on in shock as you cross the runes.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);

	reset_dialog();
	add_dialog_str(0, "Not wanting to stop the ritual, and knowing what stepping on the runes would do to them, the Eagle Warriors stand paralysed.", 0);
	add_dialog_str(1, "This is your only chance to stop the mage - and time is running out.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);

	march_party(24,11);
	force_view_center(24, 11);
	force_instant_terrain_redraw();
	pause(5);

	march_party(24,12);
	force_view_center(24, 12);
	force_instant_terrain_redraw();
	pause(5);

	reset_dialog();
	add_dialog_str(0, "The Eagle Warriors raise their blades in anticipation of the kill...", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);

	i = 9;
	while (i < 25)
	{
		set_character_pose(i, 1);
		i = i+1;
	}
	force_instant_terrain_redraw();
	pause(5);

	march_party(24,13);
	force_view_center(24, 13);
	force_instant_terrain_redraw();
	pause(5);

	march_party(24,14);
	force_view_center(24, 14);
	force_instant_terrain_redraw();
	pause(5);

	march_party(24,15);
	force_view_center(24, 15);
	force_instant_terrain_redraw();
	pause(5);

	reset_dialog();
	add_dialog_str(0, "And then the blade comes down.", 0);
	add_dialog_choice(0, "...");
	run_dialog(1);

	run_animation_sound(71);
	force_instant_terrain_redraw();
	pause(5);

	reset_dialog();
	add_dialog_str(0, "The mage throws the body into the pit below.", 0);
	add_dialog_str(1, "He raises a bloodied hand, holding the heart of Grand Senator Orosh.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);

	set_terrain(25, 23, 0);
	put_stain_on_space(25, 23, 2);
	force_instant_terrain_redraw();

	pause(10);

	reset_dialog();
	add_dialog_str(0, "Stunned by what's happening, you need to act quickly before you lose the opportunity.", 0);
	add_dialog_str(1, "Even if you can't destroy the whole temple alone, you can defeat the mage whilst the runes are still active.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);

	reset_dialog();
	add_dialog_str(0, "Before you can move, the mage shouts out - not in the native tongue, but in that of the Republic.", 0);
	add_dialog_str(1, "_And I believed in the enlightenment of the Republic?_", 0);
	add_dialog_str(2, "The mage whispers an incantation, still holding the heart of the Senator, and he begins to fade out of sight.", 0);
	add_dialog_str(3, "You need to act quickly. You reach into your pack for an arrow, and feel something else there.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);
	
	reset_dialog();
	add_dialog_str(0, "You pull out the obsidite skull. As you hold it in your hand, the mage comes back into focus, and the rest of the temple is just a blur.", 0);
	add_dialog_str(1, "Then it disappears.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);

	move_to_new_town(4, 24, 15);
break;


	