// TOWN SCRIPT
//    Town 4: Pergamos - Part 4

// 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 documentation. States you write
// yourself should be numbered from 10-100.

// flags:

begintownscript;

variables;

short choice;

body;

beginstate INIT_STATE;
	turn_off_training(1);
	set_crime_tolerance(3);

	set_name(8, "Tom");
	set_char_dialogue_pic(8, 1948, 0);
	set_name(9, "Dick");
	set_char_dialogue_pic(9, 531, 0);
	set_name(10, "Greg");
	set_char_dialogue_pic(10, 1907, 0);
break;

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

beginstate START_STATE;
	if (get_ran(1, 0, 100) < 5) {
		if (get_ran(1, 0, 100) < 50) {
			text_bubble_on_char(6, "Move along.");
		}
		else {
			text_bubble_on_char(6, "Nothing to see here.");
		}
	}
	if (get_ran(1, 0, 100) < 5) {
		if (get_ran(1, 0, 100) < 50) {
			text_bubble_on_char(7, "Move along.");
		}
		else {
			text_bubble_on_char(7, "No loitering.");
		}
	}
	if (get_ran(1, 0, 100) < 5) {
		text_bubble_on_char(16, "Baaaa");
	}
	if (get_ran(1, 0, 100) < 5) {
		text_bubble_on_char(17, "Moooo");
	}
	if (get_ran(1, 0, 100) < 5) {
		text_bubble_on_char(18, "Moo Moo");
	}

	if (get_flag(4, 0) == 0) {
		set_flag(4, 0, 1);
		reset_dialog();
		add_dialog_str(0, "You seem to be in an older section of town.", 0);
		add_dialog_str(1, "The stone around you is stained from years of abuse and neglect.", 0);
		add_dialog_choice(0, "Ok");
		choice = run_dialog(1);
	}
break;

beginstate 10;
	block_entry(1);
	move_to_new_town(3, 26, 45);
break;

beginstate 11;
	teleport_party(6, 45, 1);
break;

beginstate 12;
	block_entry(1);
	move_to_new_town(1, 61, 61);
break;

beginstate 13;
	block_entry(1);
	move_to_new_town(5, 2, 5);
break;

beginstate 14;
	if (get_flag(4, 1) == 0) {
		set_flag(4, 1, 1);
		reset_dialog();
		add_dialog_str(0, "The city gates here are locked up tight (or potentially rusted shut, you can't tell).", 0);
		add_dialog_str(1, "This isn't the way out either.", 0);
		add_dialog_str(2, "Interestingly, this seems to be the only place with guards in this section of town.", 0);
		add_dialog_choice(0, "Ok");
		choice = run_dialog(1);
	}
break;

beginstate 15;
	if (get_flag(4, 2) == 0) {
		set_flag(4, 2, 1);
		if (has_item(450) == FALSE) {
			block_entry(1);
			reset_dialog();
			add_dialog_str(0, "Just when you are about to step into the walkway, you hear a voice suddenly call out.", 0);
			add_dialog_str(1, "'You may want to get a mask before you go in there pardners.' it says.", 0);
			add_dialog_str(2, "The voice seemed to come from the shop next to you.", 0);
			add_dialog_choice(0, "Ok");
			choice = run_dialog(1);
		}
		else {
			block_entry(0);
		}
	}
	else {
		block_entry(0);
	}
break;
