// TOWN SCRIPT
//    Town 3: Marralis

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

body;

beginstate INIT_STATE;
	if (get_flag(0,16) == 250) {
		activate_hidden_group(1);
		set_terrain(23,39,209);
		if (get_flag(2,2) == 0) {
			set_flag(2,2,250);
			message_dialog("These are the deep forests of Megiddo. They are known for being home to a pack of vicious, bloodthirsty wolves. You had best be on your guard.","Luckily, Deadeye is already here. He's built a decent fire. He nods to you. _Let's get this over with, and get out as soon as we can._");
			add_char_to_party(6);
			end();
			}
		}
	if (get_flag(0,15) >= 25) {
		erase_char(6);
		}
	set_flag(2,2,250);
	if (get_flag(2,2) ==250) {
		end();
		}
	message_dialog("These are the deep forests of Megiddo. They are known for being home to a pack of vicious, bloodthirsty wolves. You had best be on your guard.","");
// This state called whenever this town is entered.
//Names	
	//set_name(7,"Yossi");
	//set_name(8,"Yvan");
	//set_name(9,"Vandor");
	//set_name(10,"Somreth");
	//set_name(11,"Mayor Broder");
	//set_name(12,"Covington");
	//set_name(13,"Kevin");
	//set_name(14,"Unger");
	//set_name(15,"Yvan");

	enable_add_chars(1);

	set_crime_tolerance(3);
break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;
// Starting state of the town, called every turn until you change the state.
	if (get_ran(1,0,99) < 10) {
		if (get_flag(0,15) == 2) {
			if (get_flag(2,3) == 0) {
				print_str("From the dense woods, you hear rustling.");
				}
			}
		}
	if (get_ran(1,0,99) < 10) {
		if (get_flag(0,15) == 2) {
			if (get_flag(2,3) == 0) {
				print_str("There is growling from the bushes.");
				}
			}
		}
	if (get_ran(1,0,99) < 10) {
		if (get_flag(0,15) == 2) {
			if (get_flag(2,3) == 0) {
				print_str("Some ways away, a wolf howls.");
				}
			}
		}
		//text_bubble_on_char(23,"Baaa.");

break;

beginstate 10;
	if (get_flag(0,15) == 2) {
		set_flag(0,15,25);
		message_dialog("The howl of a wolf pierces the relative quiet of the forest. The call is taken up all around you; you're surrounded, and you're dinner.","");
		activate_hidden_group(2);
		}
break;

beginstate 11;
	if (get_flag(2,5) == 250) {
		if (get_flag(2,6) == 0) {
				set_flag(2,6,250);
				message_dialog("The wolves, in their rush to kill you, tore through a part of the forest so thoroughly that it has essentially cleared a new path to the deeper parts of the forest.","Maybe now you can actually investigate this woods spirit. The path is to the north of the water pool.");
				set_terrain(20,15,0);
				force_instant_terrain_redraw();
				}
		}
break;

beginstate 12;
	if (get_flag(2,7) == 250)
		end();
	set_flag(2,7,250);
	message_dialog("You are amazed to see it, but a pack of filthy Hunan people has managed to penetrate the borders of Megiddo. They have bypassed the walls designed to contain them, by crawling through the brush.","They probably heard you fighting with the wolves, and have been cowering here. You see that they have set up campfires; these are probably the lights the soldiers saw, that you were sent to investigate.");
break;

beginstate 13;
	if (get_flag(2,9) == 250)
		end();
	set_flag(2,9,250);
	message_dialog("You see something with revulsion and amazement. One of the savage Hunan nomads has managed to wander through this part of the forest. It is dressed as one of the people's shamans, a wielder of nature magic.","It shrieks and grunts in its primitive language. Then it reaches for its weapon.");
break;

beginstate 14;
	if (get_flag(2,8) == 250) {
		block_entry(0);
		end();
		}
	message_dialog("You can't leave the woods yet, your mission isn't done!","");
	block_entry(1);
break;

beginstate 80;
	begin_talk_mode(1);
break;