begintalkscript;

variables;

begintalknode 1;
state = -1;
nextstate = 1;

question = "Megan";
text1 = "Megan is young and quite good-looking.  When she notices you, she turns to talk to you.";
text2 = "_Hello.  This is my second-hand shop.  Is there anything you want?  You can sell stuff to me too, if you want._";
text3 = "This is just the sort of thing Diana loves.  Just about everything looks like junk to you, but she ends up buying a brooch, a book about rare plants and a strange spindly thing she claims is a candle holder.";
text4 = "This is just the sort of thing Frrza loves.  Just about everything looks like junk to you, but she ends up buying a brooch, a hairbrush and something looking like a Vahnatai bikini that she says is a kind of trendy hat.";
text5 = "This is just the sort of thing Sissay loves.  Just about everything looks like junk to you, but she ends up buying a brooch, a tooth sharpener and a small metal spiky thing that, in her words, _looks interesting_.";
text6 = "You are't particuarly happy with this, but it's her money so you let her waste it with only a little grumbling.";

code = 
	clear_strings();
	add_string(1);
	add_string(2);
	if (get_flag(1,3) == 0) {
	// First time in shop
		if (get_flag(1,1) == 0) {
			add_string(3);
		} else {
			if (get_flag(1,1) == 1) {
				add_string(4);
			} else {
				add_string(5);
			}
		}
		add_string(6);
		set_flag(1,3,1);
	}
break;
		
begintalknode 2;
state = 1;
nextstate = 1;
question = "We'd like to trade with you.";
text1 = "You finish shopping";
code = 
	begin_shop_mode("Megan's Miscellany","Most of this stuff looks like junk, but you might pick up a bargain.",1,2,1);
break;
	
begintalknode 3;
state = 1;
nextstate = 1;
question = "How is business?";
text1 = "_Not great, but it keeps me alive.  People are always coming through, and many of them do buy something._";
text2 = "She smiles at Diana.";
text3 = "She smiles at Frrza.";
text4 = "She smiles at Sissay.";
text5 = "_Actually, recently things haven't been as good as they used to be.  Still, trade will probably pick up in a few weeks._";

code = 
	clear_strings();
	add_string(1);
	if (get_flag(1,1) == 0) {
		add_string(2);
	} else {
		if (get_flag(1,1) == 1) {
			add_string(3);
		} else {
			add_string(4);
		}
	}
	add_string(5);
break;

begintalknode 4;
state = -1;
nextstate = 2;

question = "Father Crilly";
text1 = "A priest is moving about the room, occassionally praying.  He doens't seem to notice you, so you cough quietly.";
text2 = "He jumps in surprise, then turns to you.";
text3 = "_Hello.  I am Father Crilly, of the Church of the Emerald Serpent.  What can I do for you?_";
code =
	set_flag(6,1,1);
break;

begintalknode 5;
state = 2;
nextstate = 2;

question = "I need healing";
text1 = "Father Crilly casts the healing spells with lighntning speed.  He's clearly very practiced, and it doesn't seem to take him any effort at all";
text2 = "You ask about paying him, but he shakes his head";
text3 = "_I get paid by the church to help people.  I can't take money from you too.  It wouldn't be right._";

code = 
	restore_pc(0);
	restore_pc(1);
	restore_pc(2);
	restore_pc(3);
	restore_pc(4);
break;

begintalknode 6;
state = 2;
nextstate = 3;

question = "What does the Church of the Emerald Serpent believe?";
text1 = "_We believe in making the world as good a place as possible, ready for the Coming of the Snake._";

begintalknode 7;
state = 3;
nextstate = 2;
question = "Coming of the Snake?";
text1 = "_In about a hundred years, the whole world will be devoured by a gigantic snake god.  There is nothing anyone can do to stop it, so we dedicate ourselves to improving the world before then.";
text2 = "That way, the coming disaster will be more tragic and meaningful._";

begintalknode 8;
state = -1;
nextstate = 4;
question = "Mayor Danby";
text1 = "The mayor is sitting at his desk doing some horrible-looking paperwork.  He looks overworked.  He looks up when you come in.";
text2 = "_I'm Mayor Danby.  And whatever you're botherng me with, it had better be important.  I'm horribly busy._";

begintalknode 9;
state = 4;
nextstate = 4;
question = "What is your job?";
text1 = "_What do you think my job is, you worthless cretins?  Do you think Mayor is my name?_";

begintalknode 10;
state = 4;
nextstate = 4;
question = "Could you tell us about Valusia?";
text1 = "_I've got better things to do than talk about local history to every bunch of ignorant yokels who come here.  Go away and leave me alone, why don't you?_";
text2 = "_I've got better things to do than talk about local history to every bunch of wretched half-breeds who come here.  Go away and leave me alone, why don't you?_";
text3 = "You manage to restrain yourselves from hitting him.  Just.";
code = 
	clear_strings();
	if (get_flag(1,1) == 0) {
		add_string(1);
	} else {
		add_string(2);
	}
	add_string(3);
break;

begintalknode 11;
state = 4;
nextstate = 5;
question = "Why are you so busy?";
text1 = "_Lord Ashford is here today.  You maybe saw him in the inn._";

begintalknode 12;
state = 5;
nextstate = 5;
question = "Why does that make you busy?";
text1 = "_You really don't understand anything about politics, do you?  I have to keep him happy, and try to get as much political gain as I can out of the visit.";
text2 = "And of course there are requisition forms, tax paperwork, liability waivers and all sorts of other things that have to be filled out in triplicate._";

begintalknode 13;
state = 5;
nextstate = 5;
question = "Isn't it unfair that some people enjoy hereditary wealth and power while so many other work far harder and die in poverty?";
text1 = "_Yes, but I don't care.  I'm moderately rich and powerful, and if I suck up to Lord Ashford enough, I could end up very rich and powerful.";
text2 = "You, on the other hand, look like you deserve to die in the poverty you complain about._";

begintalknode 14;
state = -1;
nextstate = -1;
action = END_TALK;
question = "Lord Ashford";
text1 = "This man is incredibly richly dressed, and eating a meal you could not possibly afford.  When he notices that you are looking at him, he glares at you.";
text2 = "_Leave me alone, you peasants._";

begintalknode 15;
state = -1;
nextstate = 6;
question = "Johannes";
text1 = "The muscular man behind the counter looks like he has had a lot of practice using the assortment of weaponary he sells.";
text2 = "_Hi.  I'm Johannes.  How can I help you?_";

begintalknode 16;
state = 6;
nextstate = 6;
question = "Let's trade";
code = 	begin_shop_mode("Combat Gear","You can buy the standard adventuring suppiles here.",0,3,-1);
break;
text1 = "You finish shopping.";

begintalknode 17;
state = 6;
nextstate = 6;
question = "Are you anything more than a one-dimensional character who exists only to fill some space in the town?";
text1 = "_No._";

begintalknode 18;
state = -1;
nextstate  = 7;
question = "Gregory";
text1 = "The innkeeper at the Bouncing Barrel is a large, friendly man called Gregory.";
text2 = "When you go up to the bar, he asks _What can I do for you fine people?  Beer is 2 gold, wine is 5._";

begintalknode 19;
state = 7;
nextstate = 7;
question = "Some beer, please (pay 2 gold)";
action = PAY -1 -1 -1 2;
text1 = "Gregory pours you some beer.  It isn't bad, but you've tasted better.";
text3 = "_Sorry.  No money, no alcohol._";

begintalknode 20;
state = 7;
nextstate = 7;
question = "We'd like some wine (pay 5 gold)";
action = PAY -1 -1 -1 5;
text1 = "You take your wine.  It's pretty disgusting, but you manage to pretend you liked it.";
text3 = "_Sorry.  No money, no alcohol._";

begintalknode 21; // Not been shopping
state = 7;
nextstate = 8;
condition = get_flag(1,3) == 0;
question = "We'd like to go to bed now.  Show us our room.";
text1 = "When you say this, Diana complains.";
text2 = "When you say this, Frrza complains.";
text3 = "When you say this, Sissay complains.";
text4 = "_You said we could go shopping, and we haven't done that yet.  I don't want to go to bed yet._";
code = 
	clear_strings();
	if (get_flag(1,1) == 0) {
		add_string(1);
	} else {
		if (get_flag(1,1) == 1) {
			add_string(2);
		} else {
			add_string(3);
		}
	}
	add_string(4);
break;

begintalknode 22;
state = 8;
nextstate = -1;
action = END_TALK;
question = "Okay, we'll have a look round first.";
text1 = "She immediately brightens.";
text2 = "_Okay, let's go,_ she says, heading for the door.  You mutter a goodbye to Gregory and follow her.";

begintalknode 23;
state = 8;
nextstate = 9;
question = "No.  We have to start early tomorrow, and I can't put up with you when you're tired and grumpy.";
text1 = "She mutters unhappily, but reluctantly agrees, partly because you are bigger and stronger.";
text2 = "Then she suddenly thinks of something and says _Hang on, one thing._";

begintalknode 24;
state = 7;
nextstate = 9;
condition = get_flag(1,3) != 0;
question = "We'd like to go to bed now.  Show us our room.";
text1 = "Gregory is about to tell you where you room is, when Diana says _Hang on, one thing._";
text2 = "Gregory is about to tell you where you room is, when Frrza says _Hang on, one thing._";
text3 = "Gregory is about to tell you where you room is, when Sissay says _Hang on, one thing._";
code = 
	clear_strings();
	if (get_flag(1,1) == 0) {
		add_string(1);
	} else {
		if (get_flag(1,1) == 1) {
			add_string(2);
		} else {
			add_string(3);
		}
	}
break;

begintalknode 25;
state = 9;
nextstate = 10;
question = "What's the problem?";
text1 = "_I'd like my own room.  I'm fed up sleeping with you, and I'm old enough.  And I'll pay for it myself._";

begintalknode 26;
state = 10;
nextstate = 10;
question = "No.  Don't throw your money away like that.";
text1 = "_You can't tell me what to do all the time.  I'm going in my own room, and that's that._";

begintalknode 27; // This is it!
state = 10;
nextstate = -1;
question = "Okay then";
action = INN 0 6 6;
text1 = "Gregory takes your sister's money, then shows you to your rooms.  Hers is first left, yours is second left.";
code = 
	set_flag(1,6,1);
	remove_char_from_party(1);
	remove_char_from_party(2);
	remove_char_from_party(3);
break;

begintalknode 28;
state = 7;
nextstate = 7;
question = "What do you think of Lord Ashford?";
text1 = "Gregory lowers his voice and makes sure that Ashford is not looking his way before he answers.";
text2 = "_I shouldn't be saying this sort of thing, but to be honest, he's a horrible person.  He looks down on anyone who doesn't have at least two mansions.";
text3 = "I'm only putting up with him because he's rich enough and powerful enough to make my life a misery if I don't._";

// Megan again
begintalknode 29;
state = 1;
nextstate = 1;
question = "Can you identify our items?";
action = ID 5;
text1 = "She looks at your things.  _That will be 5 gold per item, please._";