beginoutdoorscript;

variables;
short choice;

body;

beginstate INIT_STATE;
break;

beginstate START_STATE;
	if (get_flag(0,2) == 0) {
		set_flag(0,2,1);
		set_state_continue(10);
	}
break;

beginstate 10;
	message_dialog("After many days of grueling travel, you are finally nearing the Vale of Faces. It is only a few miles to the south. You should reach it before the day is out. Maybe on the way you'll get to see some of the legendary Faces.","");
break;

beginstate 11;
	message_dialog("You approach a tall watch tower looking down at the valley from atop a small hill. You can see a group of Smiley Faces inside. They don't seem to have noticed you. You move on.","");
break;

beginstate 12;
	message_dialog("You have not heard of these... they look to be the opposite of the Smiley Faces. They are each a furious red color and wear depressing frowns. There are four of them holding swords, and one wielding a magic staff.","You at first hope that they are friendly, but not so...");
break;

beginstate 13;
	message_dialog("You finish off the last of the strange Frowney Faces. They didn't seem to be carrying any treasure.","");
break;

beginstate 14;
if(get_flag(0,3)==0){
	message_dialog("A ring of water surrounds a small island to the east. There doesn't seem to be any way to reach it from here for now.","");
	set_flag(0,3,1);
}
break;

beginstate 15;
	if (get_flag(0,4)==0) {
		message_dialog("So at last you get to meet some Smiley Faces! A whole patrol of them is moving towards you. It is a formidable force, all armed. Fortunately they look friendly.","You chat with them for a while about the Vale. They tell you about how a few years ago there was a war between them and the 'Frowney Faces'. Now they live in peace, but some of the Frowneys are still hostile. They live by a hill close by.");
		set_flag(0,4,1);
	}
	else {
		message_dialog("You meet a Smiley patrol. They smile at you and move on.","");
	}
	outdoor_enc_result(1);
break;

beginstate 16;
	reset_dialog();
	add_dialog_str(0,"The Vale of Faces isn't only inhabited by the Smiley Faces. They also have wolves. You sneak up on a pack of them that has surrounded a herd of helpless sheep. You could probably take them on and save the sheep, if you wanted to.",0);
	add_dialog_choice(0,"I'll save you, sheep!");
	add_dialog_choice(1,"Aaaaah! Wolves!");
	choice = run_dialog(1);
	if (choice == 1)
		set_state_continue(17);
	if (choice == 2)
		set_state_continue(18);
break;

beginstate 17;
	message_dialog("You charge the wolves from behind. They howl in anger at being interrupted during their meal and attack.","");
	outdoor_enc_result(0);
break;

beginstate 18;
	message_dialog("You wait like a coward, standing by as the wolves devour their cute, cuddly prey.","Once they finish you notice your mistake. Unfortunately, they're still hungry, and you forgot to run!");
	outdoor_enc_result(3);
	create_out_spec_enc(0);
break;

beginstate 19;
	message_dialog("You triumph over the wolves, saving their would-be prey. The sheep don't seem to have any way to repay you, so they all march away without so much as as a _baaa._","");
	award_party_xp(100,10);
break;

beginstate 20;
	message_dialog("You only barely manage to defeat your foe. The experience leaves you vowing that the next time you'll just save the sheep.","");
break;

beginstate 21;
	if (get_flag(0,6) == 0) {
		reset_dialog();
		add_dialog_str(0,"You reach a very long, very tall wall blocking your path to the Vale of Faces. Fortunately there is a gate, guarded by an assortment of armed Smiley and Frowney Faces.",0);
		if (get_flag(0,1) == 1)
			set_state_continue(22);
		add_dialog_str(1,"Frowney faces? You've never even heard of them, let alone seen them. Well, it stands to reason that if there are Smileys there's bound to be frowneys.",0);
		add_dialog_str(2,"When you reach the gate the Faces ask you for your names. You tell them, and they write them down. They wave you through.",0);
		set_state_continue(23);
	}
break;

beginstate 22;
	add_dialog_str(1,"Frowney Faces? Like the ones that attacked you? Could these ones possibly be hostile, too? They don't look like it, although it's still possible. But it's a risk you'll have to take.",0);
	add_dialog_str(2,"When you reach the gate the Faces ask you for your names. You tell them, and they write them down. They wave you through.",0);
	add_dialog_str(3,"Phew!",0);
	set_state_continue(23);
break;

beginstate 23;
	run_dialog(1);
	set_flag(0,6,1);
break;

beginstate 24;
	if (get_flag(2,3) == 1) {
		reset_dialog();
		add_dialog_str(0,"It is time to return to the Empire and tell them what you have seen. After a few days' journey you reach your superior. He asks you to recount your journey.",0);
		add_dialog_str(1,"What will you tell him?",32);
		add_dialog_choice(0,"(Accurately describe the Faces.)");
		add_dialog_choice(1,"(Tell him they are weak.)");
		choice = run_dialog(1);
		if (choice == 1) {
			set_flag(4,1,1);
		}
		else {
			toggle_quest(1,0);
		}
		set_flag(2,3,2);
		toggle_quest(0,0);
		set_state_continue(25);
	}
	if (get_flag(1,29) == 1) {
		reset_dialog();
		add_dialog_str(0,"You begin the march out of the Vale of Faces to meet the Army King Smiley told you of. You don't have to march far.",0);
		add_dialog_str(1,"The Army is massive. Row after row of Empire soldiers, all lined up. You spot a group of Smileys hiding in the cover of some bushes. These are the only aid the Smileys sent, that you can see.",0);
		add_dialog_str(2,"Are you ready to fight the Army?",32);
		add_dialog_choice(0,"(Attack)");
		add_dialog_choice(1,"(Run Away)");
		choice = run_dialog(1);
		if (choice == 1)
			create_out_spec_enc(1);
	}
break;

beginstate 25;
	reset_dialog();
	add_dialog_str(0,"You finish your description to your superior. He nods.",0);
	add_dialog_str(1,"_A force of soldiers is being sent to the Vale. Your next orders are to join them._",0);
	add_dialog_str(2,"(Hint: Talk to King Smiley first.)",0);
	run_dialog(1);
break;

beginstate 26;
	if (get_flag(2,20) == 1) {
		message_dialog("A smiley is waiting here with a boat, just like King Smiley said. It takes you across the river, without saying a word.","");
		out_move_party(43,21);
	}
break;

beginstate 27;
	message_dialog("The smiley is here, waiting for you. It takes you back across.","");
	out_move_party(43,25);
break;

beginstate 28;
	reset_dialog();
	add_dialog_str(0,"You didn't think you could do it, but you beat the Army. The shock of the realization hits you like a cannonball to the chest.",0);
	add_dialog_str(1,"You beat the Army.",0);
	add_dialog_str(2,"You snap yourself out of a daze. It's time to return to King Smiley and tell him of your triumph.",0);
	add_dialog_str(3,"You recount the tale in front of King Smiley. He is amazed. _You did it!_ he yells. _Thank you!_",0);
	add_dialog_str(4,"He orders a squire to come with a reward, and you are presented with 1000 gold pieces for your troubles.",0);
	add_dialog_str(5,"THE END",0);
	add_dialog_choice(0,"Hooray!");
	run_dialog(1);
	change_coins(1000);
	end_scenario(1);
break;