begintownscript;

variables;

int choice;

body;

beginstate INIT_STATE;
	set_crime_tolerance(3);

	set_name(6,"Mother Jeanette");
	set_name(7,"Trudy");
	set_name(8,"Bart");
	set_name(9,"Alfrond");
	set_name(13,"Mother Erika");
	set_name(18,"Mayor Boyl");
	set_name(29,"Edam");
	set_name(30,"Flanagan");
	set_name(31,"Claudia");
	set_name(32,"Clarisse");
	set_name(33,"Toby");
	set_name(38,"Boss");
	set_name(40,"Steve");
	set_name(41,"Margret");
break;

beginstate EXIT_STATE;

set_incidental_sound(0); // If turned off when flag (200,1) == 1, turn them back on

break;

beginstate START_STATE;
	if (get_crime_level () >= 3) {
		make_town_hostile();
		set_flag(1,4,1);
		}

	if (get_flag(200,1) == 1) {
			activate_hidden_group(9); // activate guards
			erase_char(32); // erases all characters who fled
			erase_char(31);
			erase_char(41);
			erase_char(40);
			erase_char(6);
			erase_char(35); // erases chickens
			erase_char(36);
			erase_char(37);
			set_terrain(15,40,223); // sets terrain of the hostel
			set_terrain(12,38,224);
			set_terrain(9,39,223);
			take_item_of_class_on_spot(32,39,4); // sets terrain and destroys items in food shop
			take_item_of_class_on_spot(32,40,4);
			take_item_of_class_on_spot(34,40,4);
			take_item_of_class_on_spot(35,40,4);
			set_terrain(34,38,223);
			set_terrain(33,37,0);
			set_terrain(35,37,0);
			take_item_of_class_on_spot(6,13,3); // sets terrain and destroys items in temple
			take_item_of_class_on_spot(10,13,3);
			set_terrain(8,20,223);
			set_terrain(9,16,223);
			set_terrain(7,14,223);
			set_terrain(32,18,0); // crops destroyed
			set_terrain(32,19,0);
			set_terrain(32,20,0);
			set_terrain(32,21,138);
			set_terrain(33,18,138);
			set_terrain(33,19,0);
			set_terrain(33,20,0);
			set_terrain(33,21,0);
			set_terrain(34,18,0);
			set_terrain(34,19,138);
			set_terrain(34,20,138);
			set_terrain(34,21,0);
			set_terrain(35,18,0);
			set_terrain(35,19,138);
			set_terrain(35,20,0);
			set_terrain(35,21,0);
			set_terrain(37,18,138);
			set_terrain(37,19,0);
			set_terrain(37,20,0);
			set_terrain(37,21,0);
			set_terrain(38,18,0);
			set_terrain(38,19,0);
			set_terrain(38,20,138);
			set_terrain(38,21,0);
			set_incidental_sound(1);
			set_flag(1,16,1); // All dialog nodes are triggered
			}

	if (get_flag(1,6) == 2)
			set_terrain(39,30,217);

	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(6,"This city is dull");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(6,"Come in and pray");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(7,"There are voices here!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(7,"I can hear them!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(8,"Just made a new sword");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(8,"Come in and buy it");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(9,"I have stupid supplies!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(9,"Come and get some!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(13,"I can teach you spells");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(28,"Don't wake me up!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(28,"Just let me sleep");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(30,"I can't find my book");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(30,"Can anybody help me?");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(31,"Buy some bread");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(31,"Vegetarians, I have apples!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(32,"I have nice rooms");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(32,"They aren't expensive");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(33,"Drink something");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(33,"Nice rooms");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(35,"Cluck");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(35,"Peck");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(36,"Cluck");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(36,"Peck");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(37,"Cluck");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(37,"Peck");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(38,"Obey the law");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(40,"I'm bored");

if (get_flag(5,12) == 1) {
		if (get_flag(1,4) == 0) {
				message_dialog("You set foot in Pleasantville. People see you, run up to you, and start hugging you like crazy. Yes, your fight with Thralni was for the good, and now that people start thanking you personally, you finally feel rewarded.","People are definitely pleased here about what you did. You hope they will remain pleased, too.");
				set_flag(1,4,1);
				}
		}

if (get_flag(16,0) == 9) {
		if (get_flag(1,17) == 0) {
				message_dialog("You enter Pleasantville, which used to be a calm, relaxed town. Now you can see that it isn't. People are definitely scared. There are more guards. It isn't safe here anymore.","");
				set_flag(1,17,1);
				}
		}

break;

beginstate 10;
	if (get_flag(1,0) == 0) {
			message_dialog("In front of you stands an old house. The wind and rain have turned the once lovely cottage into an old grim building. You think you see light inside, so it is inhabited. You think you saw an old lady inside.","Maybe you should ask the mayor about this. Maybe it has some special things about it.");
			set_flag(1,0,1);
			end();
			}
		set_state_continue(11);
break;

beginstate 11;
if (get_flag(1,1) == 1) {
		if (get_flag(1,2) == 0) {
				reset_dialog();
				add_dialog_str(0,"The house still stands here. The house just looks more creepy",0);
				add_dialog_str(1,"As you slowly start to walk to the house, you hear a voice: _We are the voices. Come to the house. Something important we have to share with you._",0);
				add_dialog_str(2,"Somewhat surprised, you look around. Apparently, nobody heard the strange voices. Still, you walk on.",0);
				add_dialog_choice(0,"Shiver");
				choice = run_dialog(1);
				set_flag(1,2,1);
				}
		}
break;

beginstate 12;
if (get_flag(6,1) == 2) {
		set_terrain(39,30,217);
		reset_dialog();
		add_dialog_str(0,"You spend some hours with Flanagan. He tells you about the Senarti and what he knows about them.",0);
		add_dialog_str(1,"_This may sound strange, but Senarti were spotted at the hills to the south. We think that they are to blame for the many problems here. Although I think there probably is a bigger power behind them, which orders them to do so._",0);
		add_dialog_str(2,"_It actually doesn't surprise me if that would be the case. The Senarti are big, vicious and highly intelligent. Much more than the Nephilim are. They probably have some kind of deal with, probably, humans._",0);
		add_dialog_str(3,"_Although I'm against the Empire as many people here are (Go speak to the Mayor of Filberton, now HE is really against them), what they are doing isn't good either. There is someone, a mage I think, who knows more about them._",0);
		add_dialog_str(4,"_Yeah, yeah, its a mage. He lives in Voughton. His name is something like _Menthol,_ I think. You'll find him._",0);
		add_dialog_choice(0,"That's very interesting");
		choice = run_dialog(1);
		set_flag(1,10,1);	
		}
break;

beginstate 13;
if (get_flag(200,1) == 1) {
		if (get_flag(1,22) == 1) {
				message_dialog("This inn is quite full. Everywhere you see soldiers sitting, waiting for their drinks. The bartender looks quite pleased with this recent development.","");
				set_flag(1,22,1);
				end();
				}
		}
		
if (get_flag(1,11) == 1)
		end();
	message_dialog("When you enter the inn, a depressed man looks at you from the counter. Its probably the bartender. You quickly see what's wrong: the inn is very, very quiet.","");
	set_flag(1,11,1);
break;

beginstate 14;
if (get_flag(1,12) == 1)
		end();
	message_dialog("You climb on top of the platform. An altar, blood and a beautiful priestess, together with a charming pile of skulls and a stone box, is all you find on it.","");
	set_flag(1,12,1);
break;

beginstate 15;
if (get_flag(1,13) == 1)
		end();
	message_dialog("It looks as this house is somewhat different then the rest you have seen until now. Not only is it quite grim, the floor is laid with black tiles and a black marble altar stands at the east wall.","When you look a bit closer, you also see the three angry priests and magi looking at you. They were busy with a ceremony, which you intruded upon during the most important part. Lucky you");
	set_flag(1,13,1);
break;

beginstate 16;
if (get_flag(1,14) == 1)
		end();
	message_dialog("When you stand a little closer to this door and hold your ear against it, you think you can hear screaming and crying. A pink sort of fog comes from out of the keyhole. Strange.","");
	set_flag(1,14,1);
break;

beginstate 17;
if (get_flag(1,15) == 1)
		end();
	message_dialog("This is the town hall. Its quite big for such a small town. Two rows of three imposing pillars stand alongside each of the walls. On a heightening you see the mayor sitting.","");
	set_flag(1,15,1);
break;

beginstate 18;
if (get_flag(1,16) == 1) {
		if (get_flag(1,21) == 1)
				end();
			message_dialog("Clarisse's lodge is very dirty, not to mention dusty. She was probably scared by the recent attacks and fled Riverrod.","");
			set_flag(1,21,1);
			}
break;

beginstate 19;
if (get_flag(1,16) == 1) {
		if (get_flag(1,18) == 1)
			end();
		message_dialog("The owner of this shop fled the province. She took away all there was and simply made a runner.","You will have to get your food from somewhere else.");
		set_flag(1,18,1);
		}
break;

beginstate 20;
if (get_flag(1,16) == 1) {
		if (get_flag(1,19) == 1)
			end();
		message_dialog("The temple of Pleasantville is left deserted. The daughter, who previously was supposed to look after this holy place, is no more. She left, like so many others in this town.","");
		set_flag(1,19,1);
		}
break;

beginstate 21;
if (get_flag(1,16) == 1) {
	if (get_flag(1,20) == 1)
			end();
		message_dialog("Previously, a women was walking around this area maintaining the crops. Now that she fled, the crops are in a disastrous condition.","If something doesn't happen soon, this city may be totally abandoned.");
		set_flag(1,20,1);
		}
break;

beginstate 22;
if (get_flag(1,24) == 1)
		end();
	message_dialog("There is a corpse lying here. You wouldn't know who it is, but it seems he is some nice trinkets on him.","");
	set_flag(1,24,1);
break;