// TOWN SCRIPT
//    Town 5: Pergamos - Part 5 (dump)

// 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:
//  5, 2 = conversation flag
//

begintownscript;

variables;

short i, j, k, choice;

body;

beginstate INIT_STATE;
	set_flag(5, 1, 20);
	turn_off_training(1);
	set_crime_tolerance(3);

	set_name(6, "Angus");
	set_char_dialogue_pic(6, 1955, 0);
break;

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

beginstate START_STATE;
	if (get_flag(5, 0) == 0) {
		set_flag(5, 0, 1);
		reset_dialog();
		add_dialog_str(0, "From the smell, you figure out where Pergamos dumps their trash.", 0);
		add_dialog_str(1, "You gag and cough from the obnoxious odors emanating from the place.", 0);
		add_dialog_str(2, "You wonder why anyone would want to live close to this area.", 0);
		add_dialog_choice(0, "Ok");
		choice = run_dialog(1);
		j = 15;
	}
	else {
		j = 5;
	}
	inc_flag(5, 1, 1);
	if (get_flag(5, 1) > 20) {
		set_flag(5, 1, 0);
		i = 0;
		k = 0;
		while (i < 4) {
			if (char_ok(i) == TRUE) {
				if (item_type_in_slot(i, 4) != 450) {
					play_sound(66);
					set_char_status(i, 7, j, 1, 0);
					if ((j == 15) && (k == 0)) {
						k = 1;
						message_dialog("After gagging, you vow next time that you'll bring something to cover your nose with.", "");
					}
				}
			}
			i = i + 1;
		}		
	}
break;

beginstate 10;
	block_entry(1);
	move_to_new_town(4, 45, 39);
break;
