begintownscript;

variables;

short pc;
short talk;
short lead_char;

body;

beginstate 0;

	if(get_flag(17,0) == 6){
		message_dialog("You descend into the catacombs.  What you see around you is a pristine-looking hallway, whose walls meld perfectly with those of the amphitheater above.","The floors are shiny, almost reflective.  It's a beautiful place, even if its purposes are obscured to you.");
		message_dialog("General Adlerauge steps aside.  _There are two rooms on this floor._","_Go to the western one.  You will receive further orders when you arrive.  I will keep watch here._");
		erase_char(character_in_party(14));
		activate_hidden_group(1);
	}

	set_char_dialogue_pic(13,405,0);
	set_char_dialogue_pic(14,406,0);

	set_crime_tolerance(0);

break;

beginstate 1;
break;

beginstate START_STATE;

if(get_flag(17,0) == 8){
	if(is_object_on_space(12,20,6) == 1 || get_flag(21,0) >= 1){

		set_flag(21,0,1);

		if(get_flag(20,0) == 5){

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

			put_effect_on_space(9,25,9,1,2);
			run_animation_sound(112);
			set_total_visibility(1);
			force_view_center(9,25);
			force_instant_terrain_redraw();
			pause(4);

			text_bubble_on_char(12,"Ungh...  Damnation!");
			force_instant_terrain_redraw();
			pause(talk);

			text_bubble_on_char(12,"");
			text_bubble_on_char(12,"I couldn't prevent...");
			force_instant_terrain_redraw();
			pause(talk);

			text_bubble_on_char(12,"");
			text_bubble_on_char(12,"...the beam...");
			force_instant_terrain_redraw();
			pause(talk);

			text_bubble_on_char(12,"");
			text_bubble_on_char(12,"You won your warriors.");
			force_instant_terrain_redraw();
			pause(talk);

			text_bubble_on_char(12,"");
			text_bubble_on_char(12,"Damn you to hell, Emery...");
			force_instant_terrain_redraw();
			pause(talk);

			text_bubble_on_char(12,"");
			text_bubble_on_char(12,"Damn you to hell!");
			force_instant_terrain_redraw();
			pause(talk);

			put_boom_on_space(9,25,0,0);
			run_animation_sound(152);
			kill_char(12,3,0);
			pause(5);

			set_terrain(9,26,0);
			put_effect_on_space(9,26,8,4,0);
			set_terrain(9,21,0);
			put_effect_on_space(9,21,8,4,0);
			force_instant_terrain_redraw();
			run_animation_sound(90);
			pause(5);

			message_dialog("Over.  Zauberer is dead.  But why didn't Adlerauge come to help you?  Is he dead?","Or maybe, he lured you down here so that Zauberer could finish you off.");
			message_dialog("Anyway, it's time that you escaped this hellish cesspit.","");
			award_party_xp(500,40);
			award_party_xp(500,40);
			award_party_xp(500,40);
			set_flag(17,0,10);

	lead_char = 0;
	while(char_ok(lead_char) == FALSE){
		lead_char = (lead_char + 1);
	}
	force_view_center(char_loc_x(lead_char),char_loc_y(lead_char));
			set_total_visibility(0);
			force_instant_terrain_redraw();

		}

		if(get_flag(20,0) <= 4){ //3
			put_effect_on_space(9,25,9,1,2);
			run_animation_sound(112);
			inc_flag(20,0,1);

			print_str_color("The beam overrides Zauberer's magic!",1);
			print_str("Zauberer takes 1000 damage!");
		}
	}
}

break;

beginstate 10;
	if(party_size() > 1)
		message_dialog("General Adlerauge turns to you.  _What are you thinking?  You have your orders, Specialists!_","He's right.  You turn back.  Your orders were to go to the western room in this complex, you had best do such.");
	if(party_size() == 1)
		message_dialog("General Adlerauge turns to you.  _What are you thinking?  You have your orders, Specialist!_","He's right.  You turn back.  Your orders were to go to the western room in this complex, you had best do such.");
	block_entry(1);
break;

beginstate 11;
	put_straight_zap(24,25,21,20,4);
	put_straight_zap(20,25,21,20,4);
	put_straight_zap(20,20,21,20,4);
	put_straight_zap(24,20,21,20,4);
	put_straight_zap(22,23,21,20,4);
	run_animation_sound(90);
	block_entry(1);
	message_dialog("As you approach the interior of this room, beams shoot at the ground before you.","Since this room is not where you were ordered to be and appears to be harmful to your health, you back away.");
	block_entry(1);
break;

beginstate 12;
	put_straight_zap(24,25,22,20,4);
	put_straight_zap(20,25,22,20,4);
	put_straight_zap(20,20,22,20,4);
	put_straight_zap(24,20,22,20,4);
	put_straight_zap(22,23,22,20,4);
	run_animation_sound(90);
	block_entry(1);
	message_dialog("As you approach the interior of this room, beams shoot at the ground before you.","Since this room is not where you were ordered to be and appears to be harmful to your health, you back away.");
	block_entry(1);
break;

beginstate 13;
	put_straight_zap(24,25,23,20,4);
	put_straight_zap(20,25,23,20,4);
	put_straight_zap(20,20,23,20,4);
	put_straight_zap(24,20,23,20,4);
	put_straight_zap(22,23,23,20,4);
	run_animation_sound(90);
	block_entry(1);
	message_dialog("As you approach the interior of this room, beams shoot at the ground before you.","Since this room is not where you were ordered to be and appears to be harmful to your health, you back away.");
	block_entry(1);
break;

beginstate 14;
	if(get_flag(17,0) == 6){
		message_dialog("There is a grandiose-looking hall here, with two thrones on a raised platform overlooking both perpendicular ends of the Catacombs.","Why there are two seats here is beyond you, but that would hardly make it the first slightly confusing thing here.  It does look nice, though.");
		set_flag(17,0,7);
	}
break;

beginstate 15;
	if(get_flag(17,0) <= 7){
		relocate_character(0,9,18);
		relocate_character(1,8,18);
		relocate_character(2,10,18);
		relocate_character(3,9,17);
		set_character_facing(1000,4);
		set_total_visibility(1);
		force_view_center(9,23);
		put_object_on_space(6,17,6);
		set_terrain(6,17,0);
		erase_char(11);
		set_terrain(24,14,4);
		set_terrain(25,14,4);
		set_terrain(26,14,4);
		force_instant_terrain_redraw();
		pause(5);

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

		activate_hidden_group(2);
		put_boom_on_space(9,25,2,0);
		force_instant_terrain_redraw();
		run_animation_sound(10);
		pause(5);

		pc = random_party_member();

		text_bubble_on_char(pc,"Who are you?");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(pc,"");
		text_bubble_on_char(12,"I am called Zauberer.");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		text_bubble_on_char(12,"I am a powerful wizard,");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		text_bubble_on_char(12,"also an ex-general");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		text_bubble_on_char(12,"of Sud Canopy.");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		pc = random_party_member();
		text_bubble_on_char(pc,"What are you doing here?");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(pc,"");
		text_bubble_on_char(12,"I have come here");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		text_bubble_on_char(12,"to obliterate you.");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		pc = random_party_member();
		text_bubble_on_char(pc,"General Adlerauge!  Come quick!");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(pc,"");
		text_bubble_on_char(12,"He won't come.");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		text_bubble_on_char(12,"The only help you will get");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		text_bubble_on_char(12,"will be the Grim Reaper");
		force_instant_terrain_redraw();
		pause(talk);

		text_bubble_on_char(12,"");
		text_bubble_on_char(12,"helping you into your grave!");
		force_instant_terrain_redraw();
		pause(talk);

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

		set_terrain(9,26,475);
		set_character_pose(12,1);
		put_effect_on_space(9,26,8,4,0);
		force_instant_terrain_redraw();
		run_animation_sound(90);
		pause(5);

		set_character_facing(12,0);
		set_character_pose(12,2);
		force_instant_terrain_redraw();
		pause(5);

		set_terrain(9,21,475);
		set_character_pose(12,1);
		put_effect_on_space(9,21,8,4,0);
		force_instant_terrain_redraw();
		run_animation_sound(90);
		pause(5);

		set_character_pose(12,0);
		force_instant_terrain_redraw();
		pause(5);

		block_entry(1);
		set_total_visibility(0);
		force_view_center(9,18);
		force_instant_terrain_redraw();

		set_flag(17,0,8);

	}
break;

beginstate 16;

	if(get_flag(17,0) == 10){
		message_dialog("What happened...?  There used to be a wall here, but now there isn't.  Are you trapped?","There has to be some way out of here.  There has to be.");
		set_flag(17,0,10);
		activate_hidden_group(3);
	}
break;

beginstate 17;

	if(get_flag(17,0) == 12){
		message_dialog("Hunh!  That's strange, there weren't walls here previously.","The good news is that there are stairs ahead which lead up.  Regardless of where they lead, it's bound to make more sense than this place.");
		set_flag(17,0,13);
	}

break;

beginstate 18;
		move_to_new_town(0,24,13);
break;

beginstate 19;
		block_entry(1);
break;