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

// 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;
// This state called whenever this section is loaded into memory.
break;

beginstate START_STATE;
set_state_continue(58);
break;

beginstate 10;
	if (get_flag(211,0) >= 1)
		set_state_continue(16);
	set_state_continue(11);
break;

beginstate 11;
	if (get_flag(100,0) >= 1)
	set_flag(211,0,10);
	set_state_continue(31);
break;

beginstate 13;
	reset_dialog();
	add_dialog_str(0,"A band of armored swordsmen bar your road. There are a half dozen of them, all armed with sharp weapons. Seeing you, they talk amongst themselves for a few brief moments. Then one of them yells out:",0);
	add_dialog_str(1,"_Ravenswood is off-limits as decreed by Scyld, Master of the Falcon! There is no passage! All thoroughfare must circle round west!_",0);
	add_dialog_str(2,"They keep their weapons unsheathed in case you decide to make a sudden move. You can do as they say, or try to blast your way through. After all, who knows if they're just common bandits?",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Attack.");
	choice = run_dialog(1);
	if (choice == 2)
		set_state_continue(36);
	set_state_continue(14);
break;

beginstate 14;
	block_entry(1);
	set_state_continue(55);
break;

beginstate 15;
	message_dialog("The attack would either be wise or rash, but you can't possibly know before it's over...","");
	create_out_spec_enc(0);
break;

beginstate 16;
	if (get_flag(211,0) >= 2)
		set_state_continue(53);
	set_state_continue(17);
break;

beginstate 17;
	reset_dialog();
	add_dialog_str(0,"The swordsmen are still here, and still do not let you pass.",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Attack.");
	choice = run_dialog(1);
	if (choice == 2)
		set_state_continue(56);
	set_state_continue(14);
break;

beginstate 18;
	message_dialog("The battle finished, you search the swordsmen's equipment to attempt to confirm their identity, but there isn't anything particularly useful.",
	  "Still, the road is now open. The caravan's tracks went west of the road - perhaps it would be wise to follow.");
	set_flag(211,0,2);
break;

beginstate 19;
	message_dialog("You retreat from the battle. The swordsmen do not give chase.","");
	set_state_continue(52);
break;

beginstate 20;
	if (get_flag(211,1) == 250)
		end();
	set_flag(211,1,250);
	set_state_continue(21);
break;

beginstate 21;
	if (get_flag(55,0) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"Wolvish howlings echo all around you. Turning around, you see that you've been surrounded by a large pack. And not all of them are true wolves.",0);
	add_dialog_str(1,"There are severals fiery-eyed wargs with them; more importantly, however, there is one huge beast, red and black in hue. The ursag snarls menacingly. One second, two, three...",0);
	add_dialog_str(2,"The wolves pounce.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(55,0,250);
	set_state_continue(51);
break;

beginstate 22;
	set_flag(211,1,1);
	set_state_continue(23);
break;

beginstate 23;
	if (get_skill_total(16) >= 20)
		set_state_continue(24);
	set_state_continue(25);
break;

beginstate 24;
	message_dialog("With your Nature Lore skills, you are able to gather up some pelts, worth a small sum of gold.","");
	reward_give(180);
	reward_give(180);
	reward_give(180);
break;

beginstate 25;
	message_dialog("There is nothing of worth among the wolves, and you aren't skilled enough in hunting to be able to take any pelts.","");
break;

beginstate 26;
	if (get_flag(111,20) >= 1)
		set_state_continue(27);
	set_state_continue(28);
break;

beginstate 27;
	message_dialog("The Mandrake hasn't all grown back yet.","");
break;

beginstate 28;
	reset_dialog_preset_options(1);
	add_dialog_str(0,"You find a small patch of promising plants in the thick of the forest. Investigating more closely, you see that it's Mandrake, a useful alchemical ingredient.",0);
	add_dialog_str(1,"Do you take some?",0);
	choice = run_dialog(1);
	if (choice == 2) {
		if (reward_give(219)) 
		set_flag(111,20,1);
		}
break;

beginstate 31;
	if (get_skill_total(16) >= 20)
		set_state_continue(32);
	set_state_continue(13);
break;

beginstate 32;
	reset_dialog();
	add_dialog_str(0,"A band of armored swordsmen bar your road. There are a half dozen of them, all armed with sharp weapons. Seeing you, they talk amongst themselves for a few brief moments. Then one of them yells out:",0);
	add_dialog_str(1,"_Ravenswood is off-limits as decreed by Scyld, Master of the Falcon! There is no passage! All thoroughfare must circle round west!_",0);
	add_dialog_str(2,"With your keen woodscraft, you notice the tracks of passing wagons swerve away from the main road just past where the swordsmen now stand. If a caravan recently came this way, they must have gone off the main road.",0);
	add_dialog_str(3,"Odd. If these are guards of the caravan, they certainly wouldn't claim to be soldiers of the Falcon. But if what they say is true, why didn't the caravan go through or turn back, but instead travel into the thick of the forest?",0);
	add_dialog_str(4,"You could do as the swordsmen say, or attack and risk the consequences. What do you decide?",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Attack.");
	choice = run_dialog(1);
	if (choice == 2)
		set_state_continue(57);
	set_state_continue(14);
break;

beginstate 33;
	if (get_flag(2,0) >= 1)
		set_state_continue(35);
	set_state_continue(34);
break;

beginstate 34;
	message_dialog("Stranded here are the wagons of a merchant caravan, but all stripped of goods. There are no people here.",
	  "Foot tracks lead away to the west.");
break;

beginstate 35;
	message_dialog("A single wagon is left here - apparently, the others have been driven away. Wheel tracks run to the northeast.","");
break;

beginstate 36;
	block_entry(1);
	set_state_continue(15);
break;

beginstate 37;
	if (get_flag(111,21) > 0)
	message_dialog("The patch of Energetic Herbs hasn't all grown back yet.","");
	else set_state_continue(39);
break;

beginstate 39;
	if (get_flag(211,13) == 250)
		set_state_continue(40);
	set_state_continue(43);
break;

beginstate 40;
	reset_dialog_preset_options(1);
	add_dialog_str(0,"The patch of Energetic Herbs is ripe for picking right now.",0);
	add_dialog_str(1,"Do you take some?",0);
	choice = run_dialog(1);
	if (choice == 2) {
		if (reward_give(216)) {
			set_flag(111,21,1);
		}
}
break;

beginstate 43;
	reset_dialog();
	add_dialog_str(0,"You stumble upon a small clearing. Scanning quickly, you can see that, next to some small reptiles, some Energetic Herbs are growing. They can be used to produce moderately strong alchemical potions.",0);
	add_dialog_str(1,"The reptiles, however, small as they are, pose a real threat. Black-scaled and red-eyed, these are basilisks, deadly creatures capable of turning an enemy to stone with one hostile gaze.",0);
	add_dialog_str(2,"Do you attack?",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Attack.");
	choice = run_dialog(1);
	if (choice == 1)	
		block_entry(1);	
	if (choice == 2){
	message_dialog("You decide that you wouldn't mind having your statues standing around in a forest. It's not as bad as some other ends.","");
	block_entry(1);
	create_out_spec_enc(2);
	}
break;

beginstate 47;
	set_flag(211,13,250);
break;

beginstate 48;
	if (get_flag(188,7) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"An extensive web system has been strung over the woods here. Countless spiders, some small, some large, peep out from the shadows. Plenty of valuables hang on the webs.",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Take.");
	choice = run_dialog(1);
	if (choice == 2){
	message_dialog("The spiders, agitated by your presence, attack.","");
	create_out_spec_enc(3);
	set_flag(188,7,250);
	}			
break;

beginstate 50;
	if (reward_give(282) > 0) {
	message_dialog("You search the webs with limited thoroughness. A good deal of valuables are reaped, as well as a strange magical wand.","");
		change_coins(100);
		}
break;

beginstate 51;
	create_out_spec_enc(1);
break;

beginstate 52;
	set_flag(211,0,1);
break;

beginstate 53;
	if (get_flag(211,0) == 10)
		block_entry(1);
	set_state_continue(54);
break;

beginstate 54;
break;

beginstate 55;
	set_flag(211,0,1);
break;

beginstate 56;
	set_flag(211,0,10);
	set_state_continue(36);
break;

beginstate 57;
	block_entry(1);
	set_state_continue(15);
break;

beginstate 58;
	if (get_flag(188,7) == 250)
	set_terrain(11,13,0);
	if (get_flag(55,0) == 250)
	set_terrain(27,29,0);
break;