begintownscript;

variables;

int i,j,k,choice,pc;

body;

beginstate INIT_STATE;

if (get_flag(4, 0) == 0)
{
	pc = random_party_member();

	force_instant_terrain_redraw();

	reset_dialog();
	add_dialog_str(0, "Except for the walkway, the temple has completely vanished.", 0);
	add_dialog_str(1, "Surrounding you is space, with asteroids drifting above you.", 0);
	add_dialog_str(2, "Somehow, you get the impression that as long as you stay on the walkway, you won't suffocate, explode, or suffer similar nasty fates.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);

	pause(8);

	set_terrain(28, 15, 0);
	set_terrain(29, 16, 449);
	set_height(28, 15, 4);
	set_height(29, 16, 6);
	force_instant_terrain_redraw();
	pause(8);

	set_terrain(29, 16, 0);
	set_terrain(29, 17, 449);
	set_height(29, 16, 4);
	set_height(29, 17, 6);
	set_terrain(21, 16, 0);
	set_terrain(21, 17, 450);
	set_height(21, 16, 4);
	set_height(21, 17, 9);
	force_instant_terrain_redraw();
	pause(8);

	set_terrain(29, 17, 0);
	set_terrain(29, 18, 449);
	set_height(29, 17, 4);
	set_height(29, 18, 6);
	set_terrain(21, 17, 0);
	set_terrain(20, 18, 450);
	set_height(21, 17, 4);
	set_height(20, 18, 9);
	force_instant_terrain_redraw();
	pause(8);

	reset_dialog();
	add_dialog_str(0, "The mage - or can it be a mage, able to speak Republican so well? - looks around in wonder.", 0);
	add_dialog_str(1, "Then he sees you.", 0);
	add_dialog_str(2, "He looks, if possible, even more surprised than you are at your being here.", 0);
	add_dialog_str(3, "Unfortunately, it looks like he wants some alone time. He raises his hand to cast a spell that will presumably lead to your death in some unpleasant fashion.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);

	reset_dialog();
	add_dialog_str(0, "The skull - fortunately, still in your hand - blurs the air around you, and you see the mage slowing down.", 0);
	add_dialog_str(1, "As the bolt of energy is flung towards you, you step quickly out of its way.", 0);
	add_dialog_choice(0, "Great!");
	run_dialog(1);

	pause(5);
	set_character_pose(pc, 13);
	put_jagged_zap(24, 23, char_loc_x(pc), char_loc_y(pc), 2);
	force_instant_terrain_redraw();
	pause(5);
	run_animation_sound(54);
	pause(5);
	set_character_pose(pc, 0);
	force_instant_terrain_redraw();
	pause(5);

	reset_dialog();
	add_dialog_str(0, "Nice.", 0);
	add_dialog_str(1, "The mage begins to panic. He starts chanting again, presumably planning to get back to the temple where he can set twenty or so Eagle Warriors on you.", 0);
	add_dialog_str(2, "You rush him.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);

	set_flag(4, 0, 1);
	set_attitude(6, 10);
}

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.
if ((get_flag(4, 0) == 1) && (get_flag(4, 1) == 0))
{
	if (get_ran(1, 0, 20) < 2)
	{
		print_str("The mage continues chanting.");
		print_str("Best hurry.");
	}
}
break;

beginstate 10;
	reset_dialog();
	add_dialog_str(0, "Jumping off into space is perhaps not the brightest of ideas.", 0);
	add_dialog_choice(0, "Thanks for the tip..");
	run_dialog(1);
	block_entry(1);
break;

beginstate 11;
	if (get_flag(4, 1) > 0)
	{
		reset_dialog();
		add_dialog_str(0, "As the shorn one falls, his chanting seems to have worked.", 0);
		add_dialog_str(1, "The temple comes back into view, minus the five hundred or so occupants that were watching the ritual.", 0);	
		add_dialog_str(2, "Seeing as it saves you having to fight off however many elite warriors that can decapitate a horse, you don't mind too much.", 0);
		add_dialog_str(3, "It's clear, though, that bringing him down had a serious effect on the spell.", 0);
		add_dialog_choice(0, "OK");
		run_dialog(1);
	
		reset_dialog();
		add_dialog_str(0, "Whether they're floating in space now or not, the entire native population of this temple has been removed.", 0);
		add_dialog_str(1, "Not bad for a day's work.", 0);
		add_dialog_choice(0, "OK");
		run_dialog(1);

		move_to_new_town(5, 25, 23);
	}
break;

beginstate 12;//NEVER ACTUALLY USED: FROM AN OLD VERSION

	pc = random_party_member();

	march_party(25, 21);
	force_view_center(25, 21);
	force_instant_terrain_redraw();
	pause(3);

	march_party(25, 22);
	force_view_center(25, 22);
	force_instant_terrain_redraw();
	pause(3);

	march_party(25, 23);
	force_view_center(25, 23);
	force_instant_terrain_redraw();
	pause(3);

	set_character_facing(pc, 2);
	force_instant_terrain_redraw();
	pause(3);

	set_character_pose(pc, 1);
	force_instant_terrain_redraw();
	run_animation_sound(71);
	put_effect_on_char(6, 12, 1, 2);
	pause(5);

	damage_near_loc(24, 23, 100, 0, 0);
	pause(5);

	set_character_pose(pc, 0);
	force_instant_terrain_redraw();

	reset_dialog();
	add_dialog_str(0, "As the shorn one falls, his chanting seems to have worked.", 0);
	add_dialog_str(1, "The temple comes back into view, minus the five hundred or so occupants that were watching the ritual.", 0);
	add_dialog_str(2, "Seeing as it saves you having to fight off however many elite warriors that can decapitate a horse, you don't mind too much.", 0);
	add_dialog_str(3, "It's clear, though, that bringing him down had a serious effect on the spell.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);
	
	reset_dialog();
	add_dialog_str(0, "Whether they're floating in space now or not, the entire native population of this temple has been removed.", 0);
	add_dialog_str(1, "Not bad for a day's work.", 0);
	add_dialog_choice(0, "OK");
	run_dialog(1);

	move_to_new_town(5, 25, 23);
break;

	