// 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(6, "Gregory");
set_name(16, "Mayor Danby");
set_name(17, "Lord Ashford");
set_name(12, "Johannes");

if (get_flag(1,2) == 0) {
	// Set up sister.
	i = 0;
	while (char_status(i) == 0) {
		i = i + 1;
	}
	species = get_species(i);
	if (species > 0) {
		species = species - 1;
	}
	set_flag(1,1,species);
	activate_hidden_group(species + 1);
	add_char_to_party(species + 7);
	set_flag(1,2,1);
	reset_dialog();
	add_dialog_str(0,"The town of Redby is large, busy and full of exciting things to do.  Unlike your village, where there is nothing to do except farm and sit around.",0);
	if (species == 0) {
		add_dialog_str(1,"Which is why your younger sister Diana wants to spend a few nights in Redby, to see a real city for the first time, and do the things she can't do at home.",0);
	}
	if (species == 1) {
		add_dialog_str(1,"Which is why your younger sister Frrza wants to spend a few nights in Redby, to see a real city for the first time, and do the things she can't do at home.",0);
	}
	if (species == 2) {
		add_dialog_str(1,"Which is why your younger sister Sissay wants to spend a few nights in Redby, to see a real city for the first time, and do the things she can't do at home.",0);
	}
	add_dialog_str(2, "She has never been allowed to before, but your parents have decided that she is old enough now, so long as you go with her.  You complain a little, of course, but not too much because Redby is much more interesting than home.",0);
	if (party_size() == 3) {
		add_dialog_str(3, "You also take along your best friend, who will make the company far more bearable.",0);
	}
	if (party_size() > 3) {
		add_dialog_str(3, "You also take along some of your friends, who will make the company far more bearable.",0);
	}
	run_dialog(1);
	reset_dialog();
	add_dialog_str(0, "After travelling all day, you arrive in the village of Valusia, where you will be staying the night.",0);
	add_dialog_str(1, "You book a room in the inn, and sit down to a meal.  It is not a bad meal, but someone important-looking is having a far better one a few tables away.",0);
	add_dialog_str(2, "The innkeeper tells you that he is Lord Ashford, who is going round inspecting the towns in the region he commands.",0);
	add_dialog_str(3, "You finish the meal, and decide to have a look round the village and maybe do a little shopping before you go to bed.",0);
	run_dialog(1);
	
}
	
break;

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

beginstate START_STATE;

set_ticks_forward(-1); // Always evening



break;

beginstate 10; // Border control
message_dialog("It's getting late, and you don't feel like traipsing through the countryside any more tonight.  You've been walking all day.","");
block_entry(1);
break;

beginstate 11;
if (get_flag(1,6) == 1) {
	message_dialog("You go to bed, and fall asleep quickly.","");
	play_sound(20);
	move_to_new_town(1,4,6);
}
break;