// TOWN SCRIPT
//    Town 24: Fort Dranlon


// 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;

int i,j,k,r1,choice;
int u;

body;

beginstate INIT_STATE;
	set_name(7,"Mairwen");
	set_name(8,"Sylow");
	set_name(9,"Toddric");
	set_name(32,"Captain Rosie");
	set_name(38,"Sianonn");

break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 11;
	if (is_object_on_space(25,37,4) == 0)
	end();
	if (get_flag(24,0) == 250){
	message_dialog("As you approach, a gap appears in the magical barrier, allowing you entry.","");
	put_object_on_space(25,37,-1);
	}
	else {
	u = 11;
	set_state_continue(13);
	}
break;

beginstate 12;
	if (is_object_on_space(38,12,4) == 0)
	end();
	if (get_flag(24,0) == 250){
	message_dialog("As you approach, a gap appears in the magical barrier, allowing you entry.","");
	put_object_on_space(38,12,-1);	
	}
	else {
	u = 12;
	set_state_continue(13);
	}

break;

beginstate 13;
	reset_dialog();
	add_dialog_str(0,"As you look around, a soldier peeks out through a window._Greetings, visitor. Please say your name and business here._",0);
	add_dialog_choice(0,"Give your names.");
	add_dialog_choice(1,"Refuse.");
	choice = run_dialog(0);
	if (choice == 1) {
		message_dialog("He nods and writes the information down. Then, a few moments later, a gap opens in the barrier. He says _Come on in. Can't be too careful, way things are nowadays._","");
		set_flag(24,0,250);
		set_state_continue(u);		
		}
	if (choice == 2) {
		message_dialog("The soldier looks at you, chuckles grimly, and walks away. You call for him to return but get no answer.","");
	end();
	}
break;

