// TOWN SCRIPT
//    

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

begintownscript;

variables;
short i, species;

body;

beginstate INIT_STATE;
// This state called whenever this town is entered.
set_crime_tolerance(1);

set_name(10, "Father Crilly");
set_name(11, "Megan");
set_name(16, "Mayor Danby");
set_name(12, "Johannes");
set_name(6, "Lord Ashford");


if (get_flag(1,8) == 0) {
	set_flag(1,8,1);
	set_flag(1,4,1);
	set_ticks_forward(6000);
	restore_pc(0);
	restore_pc(1);
	restore_pc(2);
	restore_pc(3);
	if (get_flag(6,1)) {
		message_dialog("You wake up back in your room.  Father Crilly is standing over you, and he has clearly just been restoring you to health.","_Let me explain what happened,_ he says.");
	} else {
		message_dialog("You wake up back in your room.  A priest is standing over you, and he has clearly just been restoring you to health.","_I am Father Crilly, Valusia's priest._ he says. _Let me explain what happened._");
	}
} else {
	relocate_character(10, 35,14);
	if (character_in_party(316) != -1) {
		set_flag(5,1,1);
		message_dialog("As soon as you get back to Valusia and safety, Lord Ashford leaves you without a backward glance and heads to the mayor's office.","");
		activate_hidden_group(1);
		remove_char_from_party(316);
	}
}
break;

beginstate EXIT_STATE;
// Always called when the town is left.
set_flag(4,9,1);
break;

beginstate START_STATE;
break;

beginstate 10; // Border control
if (get_flag(1,9) == 0) {
message_dialog("You don't want to leave until you have asked Father Crilly about the attack.","");
block_entry(1);
}
break;
