// OUTDOOR SECTION SCRIPT
//    Section: X = 1, Y = 0

// This is the special encounter script for this town.
// The states INIT_STATE and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

beginoutdoorscript;

variables;

short i,j,k,r1,choice;

body;

beginstate INIT_STATE;
	set_state_continue(42);
break;

beginstate START_STATE;
	set_state_continue(42);
break;

beginstate 10;
	if (get_flag(210,0) < 1)
		set_state_continue(11);
break;

beginstate 11;
	if (get_flag(2,0) >= 1)
		set_state_continue(12);
break;

beginstate 12;
	if (get_flag(210,0) == 0)
	message_dialog("The caravan is in sight less than a league to the north, resting just east of the road within a circle of rocks.","");
	set_flag(210,0,1);
break;

beginstate 13;
	if (get_flag(100,0) < 2)
	set_state_continue(15);
break;

beginstate 14;
	if (get_flag(210,0) == 10)
	block_entry(1);
break;

beginstate 15;
	if (get_flag(2,0) >= 1)
		set_state_continue(16);
break;

beginstate 16;
	reset_dialog();
	add_dialog_str(0,"Several wagons are drawn up a low hill. A few guards stand on watch as you approach.",0);
	add_dialog_str(1,"Now would be the perfect time to attack - the caravan can't possibly escape in time. Do you?",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Attack.");
	choice = run_dialog(1);
	if (choice == 2){
	block_entry(1);
	set_flag(210,0,10);
	create_out_spec_enc(0);
	}
break;

beginstate 20;
	block_entry(1);
	print_str("Blocked.");
break;

beginstate 21;
	message_dialog("Your assault thrown back, the guards renew their watch with renewed vigilance.","");
		set_flag(210,0,0);
break;

beginstate 23;
	if (get_flag(210,1) == 250)
		end();
	message_dialog("The escorts dispatched, you conduct a quick search of the merchants. You quickly find a letter from Finn of Hatherond to Scyld, master of the Falcon.",
	  "The surviving merchants scatter. A Falcon patrol is approaching from the north. It would be wise to depart.");
	change_spec_item(0,1);
	set_flag(210,1,250);	
break;

beginstate 24;
	set_flag(100,0,2);
	set_flag(210,0,2);
break;

beginstate 26;
	reset_dialog();
	add_dialog_str(0,"You come upon a well-off large scale estate. Tenant farmers tend to the fields. There is very little of interest here.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
break;

beginstate 27;
	message_dialog("A lone obelisk is erected here, as though in commemoration of some past event. It is utterly bare of any signs, however. Perhaps this was once the site of a great battle.","");
break;

beginstate 28;
	if (get_flag(128,4) >= 1)
		set_state_continue(29);
	set_state_continue(27);
break;

beginstate 29;
	if (get_flag(128,5) >= 1)
		set_state_continue(33);
	set_state_continue(30);
break;

beginstate 30;
	set_flag(128,5,1);
	set_state_continue(31);
break;

beginstate 31;
	reset_dialog();
	add_dialog_str(0,"You come upon a large obelisk in a field of stones. Remembering Dasmaf's words, you begin digging around it. It's not long before you hit something. What you hit, though, isn't quite the treasure you were looking for.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_state_continue(38);
break;

beginstate 32;
	reset_dialog();
	add_dialog_str(0,"You search some more in the excavation. A few feet down, you come upon another surprise.",0);
	add_dialog_str(1,"It is an alien humanoid, long dead. Its features, however, are perfectly preserved, despite all these years under the earth. Remarkably thin and tall, it still clasps a gleaming short sword in its bony hands.",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Take.");
	choice = run_dialog(1);
	if (choice == 2)
		set_state_continue(34);
break;

beginstate 33;
	if (get_flag(128,6) >= 1)
		set_state_continue(27);
	set_state_continue(32);
break;

beginstate 34;
	set_flag(128,6,1);
	set_state_continue(35);
break;

beginstate 35;
	message_dialog("As soon as you touch the sword, the figure comes to life - or unlife. Your hand is suddenly seized with a freezing pain. As you draw back, it raises itself until it stands at its full height, over six feet tall.",
	  "Wordlessly, it directs the point of its sword at you, and advances.");
	create_out_spec_enc(2);
break;

beginstate 36;
	if (reward_give(351) > 0) {
	message_dialog("The limp form of the alien warrior shivers into ash. A thin smoke rises, then nothing remains, except for the coveted blade.",
	  "You bend down to take it.");
		}
		else set_state_continue(37);
break;

beginstate 37;
	message_dialog("As you reach for the sword, it too disappears. Perhaps it recognizes that you are not its rightful owner. Perhaps you were simply not meant to have it.","");
break;

beginstate 38;
	create_out_spec_enc(1);
break;

beginstate 39;
	outdoor_enc_result(1);
	message_dialog("You are hailed by a small patrol of Falcon soldiers. After a brief conversation and news-sharing, they depart.","");
break;

beginstate 41;
	if (get_flag(275,4) == 1)
		end();
	message_dialog("You have intruded upon a nest of ice drakes.","");
break;

beginstate 42;
	if (get_flag(210,1) == 250)
		set_terrain(30,29,0);
	if (get_flag(12,0) == 250){
		set_terrain(45,34,137);
		}
break;


beginstate 46;
	if (get_flag(210,0) >= 2)
		set_state_continue(23);
break;




