// Town script for town 5: Pilgrims Rest (roofs)

begintownscript;

variables;
int choice,tick1;
int zombie,number;

body;

beginstate INIT_STATE;
if (get_flag(5,1) == 0) { // make sure this wasn't done before
		set_flag(250,2,6); // standard party energy is 6
		set_flag(5,1,1);
		}
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
if (get_ran(1,1,10) == 8)
		play_sound(44);

if (get_ran(1,1,10) == 8)
		play_sound(119);

if (tick1 == 0)
		tick1 = get_current_tick();

if (get_flag(5,0)==0) {
	message_dialog("As we emerge onto the roofs, we stare at the full, white moon. A cloud drifts by and obscures the moon, darkening the night. A bad omen. We should go west, to the church, and not hang around here too long.","We shall have to jump from roof to roof. A tiring but necessary exercise, so we'll probably have to rest from time to time. Let's be careful, and jump from the very edge of the roof instead of the middle, and cut the risk of falling.");
	set_flag(5,0,1);

	// Give the custom abilities
	change_custom_abil_uses(0,0,1);
	change_custom_abil_uses(1,0,1);
	change_custom_abil_uses(2,0,1);
	change_custom_abil_uses(3,0,1);
	change_custom_abil_uses(4,0,1);
	change_custom_abil_uses(5,0,1);
	
	change_custom_abil_uses(0,1,1);
	change_custom_abil_uses(1,1,1);
	change_custom_abil_uses(2,1,1);
	change_custom_abil_uses(3,1,1);
	change_custom_abil_uses(4,1,1);
	change_custom_abil_uses(5,1,1);
	}

if (get_flag(5,2) == 0 && (get_current_tick() - tick1 >= 15)) {
		activate_hidden_group(1);
		set_flag(5,2,1);
		}

// zombie controller
if (get_flag(250,1) < 28) {
		number = get_ran(1,1,3);
		if (number == 1)
				zombie = 43;
		if (number == 2)
				zombie = 237;
		if (number == 3)
				zombie = 238;
		place_monster(12,34,zombie,0);
		inc_flag(250,1,1);
		}
break;

beginstate 10;
if (is_combat() == 1) {
		message_dialog("We can only go on when we have regrouped and are not fighting, so let's do that first.","");
		block_entry(1);
		end();
		}

if (get_flag(4,0) == 1) {
		reset_dialog();
		add_dialog_str(0,"Are we sure we want to go down?",0);
		add_dialog_choice(0,"Yes, let's go down.");
		add_dialog_choice(1,"No, let's stay up here.");
		choice = run_dialog(1);
		
		if (choice == 1)
				move_to_new_town(4,34,11);
		}
break;

beginstate 11;
if (get_flag(250,2) < 2) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the east, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,40,12);
		relocate_character(1,40,13);
		relocate_character(2,40,14);
		relocate_character(3,40,15);
		print_str_color("That jump cost us 2 energy, since it was over a street.",4);
		inc_flag(250,2,-2); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 12;
if (get_flag(250,2) < 1) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the south, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,34,15);
		relocate_character(1,34,16);
		relocate_character(2,34,17);
		relocate_character(3,34,18);
		print_str_color("That jump cost us 1 energy, since it was over an alley.",4);
		inc_flag(250,2,-1); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 13;
message_dialog("We can't jump anywhere from here.","");
block_entry(1);
break;

beginstate 14;
message_dialog("If we jump that way, we'll only lose energy, since we can't go towards the fence from there. There is this enormous building to the west that will block our progress.","");
block_entry(1);
break;

beginstate 15;
if (get_flag(250,2) < 2) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the west on the roof north from that alley, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,35,11);
		relocate_character(1,34,11);
		relocate_character(2,35,10);
		relocate_character(3,34,10);
		print_str_color("That jump cost us 2 energy, since it was over a street.",4);
		inc_flag(250,2,-2); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 16;
if (get_flag(250,2) < 2) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the west, onto the roof south from that alley, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,34,15);
		relocate_character(1,34,16);
		relocate_character(2,34,17);
		relocate_character(3,34,18);
		print_str_color("That jump cost us 2 energy, since it was over a street.",4);
		inc_flag(250,2,-2); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 17;
if (get_flag(250,2) < 2) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the west, onto the roof north from that alley, shall we proceed? Caution though, that roof seems unstable.",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,35,20);
		relocate_character(1,34,20);
		relocate_character(2,33,20);
		relocate_character(3,33,19);
		inc_flag(250,2,-3); // lower party's energy
		print_str_color("That jump cost us 3 energy, since it was a dangerous one.",4);
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 18;
if (get_flag(250,2) < 2) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the west, onto the roof south from that alley, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,35,25);
		relocate_character(1,35,26);
		relocate_character(2,35,27);
		relocate_character(3,35,28);
		print_str_color("That jump cost us 2 energy, since it was over a street.",4);
		inc_flag(250,2,-2); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 19;
if (get_flag(250,2) < 1) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the north, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,35,11);
		relocate_character(1,35,10);
		relocate_character(2,34,11);
		relocate_character(3,34,10);
		print_str_color("That jump cost us 1 energy, since it was over an alley.",4);
		inc_flag(250,2,-1); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 20;
if (get_flag(250,2) < 2) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the east, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,40,15);
		relocate_character(1,40,16);
		relocate_character(2,40,17);
		relocate_character(3,40,18);
		print_str_color("That jump cost us 2 energy, since it was over a street.",4);
		inc_flag(250,2,-2); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 21;
if (get_flag(250,2) < 2) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the east, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,40,25);
		relocate_character(1,40,26);
		relocate_character(2,40,27);
		relocate_character(3,40,28);
		print_str_color("That jump cost us 2 energy, since it was over a street.",4);
		inc_flag(250,2,-2); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 22;
message_dialog("That piece of roof seem very unstable, we'd better not step there...","");
block_entry(1);
break;

beginstate 23;
if (get_flag(250,2) < 1) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the south, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,34,25);
		relocate_character(1,34,26);
		relocate_character(2,34,27);
		relocate_character(3,34,28);
		print_str_color("That jump cost us 1 energy, since it was over an alley.",4);
		inc_flag(250,2,-1); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 24;
if (get_flag(250,2) < 2) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the south, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,31,33);
		relocate_character(1,32,33);
		relocate_character(2,33,33);
		relocate_character(3,34,33);
		print_str_color("That jump cost us 2 energy, since it was over a street.",4);
		inc_flag(250,2,-2); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 25;
if (get_flag(250,2) < 2) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the east, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,40,20);
		relocate_character(1,40,21);
		relocate_character(2,40,22);
		relocate_character(3,40,23);
		print_str_color("That jump cost us 2 energy, since it was over a street.",4);
		inc_flag(250,2,-2); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 26;
if (get_flag(250,2) < 1) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the south, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,33,19);
		relocate_character(1,33,20);
		relocate_character(2,34,20);
		relocate_character(3,35,20);
		print_str_color("That jump cost us 1 energy, since it was over an alley.",4);
		inc_flag(250,2,-1); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 27;
message_dialog("That roof seems far too unstable to jump to. We could go right through it when we land on it. We'd better go a different way.","");
block_entry(1);
break;

beginstate 28;
if (get_flag(250,2) < 2) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the west, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,21,20);
		relocate_character(1,21,19);
		relocate_character(2,21,18);
		relocate_character(3,21,17);
		print_str_color("That jump cost us 2 energy, since it was over a street.",4);
		inc_flag(250,1,-2); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 29;
if (get_flag(250,2) < 2) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the east, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,26,18);
		relocate_character(1,27,18);
		relocate_character(2,28,18);
		relocate_character(3,29,18);
		print_str_color("That jump cost us 2 energy, since it was over a street.",4);
		inc_flag(250,2,-2); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 30;
if (get_flag(250,2) < 1) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the north, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,20,11);
		relocate_character(1,19,11);
		relocate_character(2,18,11);
		relocate_character(3,17,11);
		print_str_color("That jump cost us 1 energy, since it was over an alley.",4);
		inc_flag(250,2,-1); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 31;
if (get_flag(250,2) < 1) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the west, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,13,14);
		relocate_character(1,13,13);
		relocate_character(2,13,12);
		relocate_character(3,13,11);
		print_str_color("That jump cost us 1 energy, since it was over an alley.",4);
		inc_flag(250,2,-1); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 32;
if (get_flag(250,2) < 1) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,17,15);
		relocate_character(1,18,15);
		relocate_character(2,19,15);
		relocate_character(3,20,15);
		print_str_color("That jump cost us 1 energy, since it was over an alley.",4);
		inc_flag(250,2,-1); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 33;
if (get_flag(250,2) < 1) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the east, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,17,15);
		relocate_character(1,18,15);
		relocate_character(2,19,15);
		relocate_character(3,20,15);
		print_str_color("That jump cost us 1 energy, since it was over an alley.",4);
		inc_flag(250,2,-1); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;

beginstate 34;
if (is_combat() == 0) {
		message_dialog("Yes! We made it! Now, we must jump down quickly and get going.","");
		set_flag(250,2,get_flag(250,3));
		move_to_new_town(6,43,9);
		}

message_dialog("We can only go on when we have regrouped and are not fighting, so let's do that first.","");
block_entry(1);
break;

beginstate 35;
message_dialog("There is no real place to jump to that will get us any closer, if we go to that roof. We'll probably end up jumping back here...","");
block_entry(1);
break;

beginstate 36;
if (get_flag(250,2) < 2) {
		message_dialog("We don't have the energy right now to make another jump. We should take a rest before we continue...","");
		block_entry(1);
		end();
		}

reset_dialog();
add_dialog_str(0,"If we jump from here, we'll jump to the north, shall we proceed?",0);
add_dialog_choice(0,"Jump");
add_dialog_choice(1,"Stay here");
choice = run_dialog(1);

if (choice == 1) {
		block_entry(1);
		relocate_character(0,34,28);
		relocate_character(1,33,28);
		relocate_character(2,32,28);
		relocate_character(3,31,28);
		print_str_color("That jump cost us 2 energy, since it was over a street.",4);
		inc_flag(250,2,-2); // lower party's energy
		}

if (choice == 2)
		block_entry(1);
break;