beginoutdoorscript;

variables;
short choice = 0;

body;

beginstate 0; //INIT_STATE

break;

beginstate 1; //EXIT_STATE

break;

beginstate 2; //START_STATE

break;


beginstate 10; //Leaving to the West

	block_entry(1);
	reset_dialog();
	add_dialog_str(0,"This is the road you took to get here from Barton, and following it would take you back there.",0);
	add_dialog_str(1,"Do you want to leave the scenario?",0);
	add_dialog_choice(0,"No, I'm not done here yet.");
	add_dialog_choice(1,"Yes, I'm ready to leave.");
	choice = run_dialog(1);
	if(choice == 2) {
		reset_dialog();
		if(get_flag(50,0) == 0) {
			add_dialog_str(0,"Well, you didn't really find out what was going on at the cathedral, but at least you're still alive. Perhaps you'll be able to find a more interesting quest elsewhere.",0);
			add_dialog_choice(0,"THE END");
			run_dialog(1);
			end_scenario(0);
			}
		else if(get_flag(50,1) == 0) {
			add_dialog_str(0,"Well, you went to the cathedral to solve a pest problem, and released a horde of angry ghosts instead. This mission will go down as a catastrophic failure",0);
			add_dialog_str(1,"You never really find out what happened to everyone, but it can't have been good. But generally, you're just glad to have gotten away.",0);
			add_dialog_choice(0,"THE END");
			run_dialog(1);
			end_scenario(0);
			}
		else if(get_flag(50,1) == 2) {
			add_dialog_str(0,"So, you're still a little confused about how all of this ties together, but you feel as though you've actually accomplished something here.",0);
			add_dialog_str(1,"Far too often, it seems that adventurers do quests for the Empire without even thinking about the consequences. So, it feels good to strike a tiny blow against the Empire.",0);
			add_dialog_str(2,"About three months later, you hear from a passing patrol of soldiers that some of the higher-ranking generals have been having ghost problems, and you just smile.",0);
			add_dialog_choice(0,"THE END");
			run_dialog(1);
			end_scenario(1);
			}
		}
break;



beginstate 20; //spires over the treetops

	if(get_flag(30,1) > 0)
		end();

	reset_dialog();
	add_dialog_str(0,"Hm... from here, you think you can see some sort of building poking above the trees. You must be getting close to the cathedral.",0);
	run_dialog(1);

	set_flag(30,1,1);

break;

beginstate 21; //the cathedral

	if(get_flag(30,1) > 1)
		end();

	reset_dialog();
	add_dialog_str(0,"As you come around this bend in the road, you get your first clear view of the Cathedral of Winds. Quite simply, it's beautiful.",0);
	add_dialog_str(1,"From here, you can make out three elegant stone spires rising up from a main building. And the building itself is surrounded by lush gardens.",0);
	add_dialog_str(2,"You start to wonder exactly what you'll be doing here.",0);
	run_dialog(1);

	set_flag(30,1,2);

break;


beginstate 25; //approaching graveyard

	if(get_flag(30,2) != 0)
		end();

	reset_dialog();
	add_dialog_str(0,"The road isn't very well-maintained past this point. Then again, the graveyard to the north doesn't look like it's in excellent shape, either.",0);
	run_dialog(1);

	set_flag(30,2,1);

break;

beginstate 26; //the graveyard

	if(get_flag(30,2) > 1)
		end();

	reset_dialog();
	add_dialog_str(0,"The graveyard isn't as poorly-maintained as you first thought. Instead, it's just a bit empty, so it looks more overgrown. Perhaps the cathedral doesn't bury many people out here.",0);
	run_dialog(1);

	set_flag(30,2,2);

break;


beginstate 30; //Empire guards

	reset_dialog();
	if(get_flag(30,4) == 0) {
		add_dialog_str(0,"A group of Empire soldiers blocks this path. As you approach, they watch you closely, and you begin to suspect that they won't just let you by. They look very unhappy to be here.",0);
		add_dialog_str(1,"Their leader, an actual Empire dervish, approaches you. _What is your business here?_ he calls out.",0);
		}
	else
		add_dialog_str(0,"The soldiers are still blocking the road. Their leader steps forward again and asks, _Why are you here?_",0);
	if(party_size() == 1)
		add_dialog_choice(0,"Explain yourself.");
	else
		add_dialog_choice(0,"Explain yourselves.");
	add_dialog_choice(1,"Run away!");
	choice = run_dialog(1);
	if(choice == 2) {
		outdoor_enc_result(1);
		message_dialog("The soldiers actually start laughing as you quietly back away.","That was a little embarassing.");
		set_flag(30,4,1);
		}
	else {
		reset_dialog();
		add_dialog_str(0,"You calmly explain to the soldiers that you were summoned here by Father Richardson at the cathedral. A few nod their heads in recognition.",0);
		add_dialog_str(1,"The dervish stares thoughtfully at the ground for a while, then he looks you straight in the eye and says, _Right. You may pass. Father Richardson told us to expect you._",0);
		add_dialog_str(2,"_You are to report to him in the cathedral's sanctuary immediately._",0);
		if(party_size() == 1)
			add_dialog_str(3,"_Watch yourself in there. We're here to guard the building, and we have the authority to deal with you as we please._",0);
		else
			add_dialog_str(3,"_Watch yourselves in there. We're here to guard the building, and we have the authority to deal with you as we please._",0);
		add_dialog_str(4,"With that, they march off towards the cathedral.",0);
		run_dialog(1);
		outdoor_enc_result(3);
		}
break;


beginstate 35; //merchants outside Barton

	outdoor_enc_result(1);
	if(get_flag(30,5) == 0) {
		reset_dialog();
		add_dialog_str(0,"A lone merchant sits on the side of the road, with a tired-looking horse grazing nearby. He notices your approach, but he doesn't stand up.",0);
		if(party_size() == 1)
			add_dialog_str(1,"_Hello, friend,_ he says glumly. _This is the road to Barton._",0);
		else
			add_dialog_str(1,"_Hello, friends,_ he says glumly. _This is the road to Barton._",0);
		add_dialog_str(2,"You ask what's wrong, and he sighs. _There's just no room in the city for another soap merchant. I wish I'd known it before riding out here, but apparently the city has four of them already._",0);
		add_dialog_str(3,"_There's nothing you can do to help, unless you're willing to buy a hundred pounds of soap._ Needless to say, you aren't... so you wish him the best of luck.",0);
		run_dialog(1);
		set_flag(30,5,1);
		}
	else 
		print_str_color("The soap merchant is still sulking here.",2);

break;