begintalkscript;

variables;

begintalknode 1;
state = -1;
nextstate = 1;
question = "Father Crilly";
text1 = "After making sure you are feeling okay, Father Crilly tells you what happened last night.";
text2 = "_You have probably worked out some of this already, but a group of bandits attacked the inn last night.";
text3 = "They killed Gregory and kidnapped Lord Ashford, and they left a ransom note.  They also kidnapped your sister, thinking that she was employed by Ashford.";
text4 = "We managed to fight them off before they did anything else.";
text5 = "We managed to fight them off before they did anything else.  You helped with that, I believe.";
text6 = "There were a few outside the inn when you left, and they got some heavy hits in.  It was a real test of my skill to get you healthy again._";
code = if (get_flag(1,7)) {
	remove_string(4);
	} else {
	remove_string(5);
	}
	set_flag(1,9,1);
break;

begintalknode 2;
state = -1;
nextstate = 1;
question = "Father Crilly";
text1 = "_I am sorry about what happened to your poor sister.  Sadly I am unable to help you, except by healing any injuries you have._";


begintalknode 3;
state = 1;
nextstate = 1;
condition = get_flag(2,1) == 0;
question = "What should I do now?";
text1 = "_You should probably speak to Mayor Danby.  He might be able to help you get your sister back._";

begintalknode 4;
state = 1;
nextstate = 1;
condition = get_flag(2,1);
action = SET_SDF 2 2 1;
question = "Mayor Danby isn't going to help";
text1 = "_In that case, you should either forget about her and assume she is dead, or go and rescue her.";
text2 = "A rescue would, of course, almost certainly only get you killed, but sometimes it is better to die honourably than to live with guilt._";

begintalknode 5;
state = 1;
nextstate = 1;
condition = get_flag(1,1) == 0;
question = "What will happen to Diana?";
text1 = "_When they find out that she has nothing to do with Lord Ashford, they will probably kill her.  After all, you aren't going to be able to pay a worthwhile ransom.";
text2 = "I don't like giving bad news, but that's the way it is._";

begintalknode 6;
state = 1;
nextstate = 1;
condition = get_flag(1,1) == 1;
question = "What will happen to Frrza?";
text1 = "_When they find out that she has nothing to do with Lord Ashford, they will probably kill her.  After all, you aren't going to be able to pay a worthwhile ransom.";
text2 = "I don't like giving bad news, but that's the way it is._";

begintalknode 7;
state = 1;
nextstate = 1;
condition = get_flag(1,1) == 2;
question = "What will happen to Sissay?";
text1 = "_When they find out that she has nothing to do with Lord Ashford, they will probably kill her.  After all, you aren't going to be able to pay a worthwhile ransom.";
text2 = "I don't like giving bad news, but that's the way it is._";

begintalknode 8;
state = 1;
nextstate = 1;
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 = "_You have enough troubles without having to worry about money._";

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

begintalknode 9;
state = -1;
nextstate = 2;
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 10;
state = 2;
nextstate = 2;
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 11;
state = 2;
nextstate = 2;
question = "Is your character development so shallow that your village being attacked has absolutely no effect on your mood?";
text1 = "_Yes._";

begintalknode 12;
state = -1;
nextstate = 3;
question = "Megan";
text1 = "Megan is visibly shaken by the events of last night, but she has still opened her shop.";
text2 = "_I'm really sorry about what happened to your sister last night.  I hope you get her back._";
text3 = "She looks at your sister with pleased surprise. _It's nice to see you.  I have to admit I had assumed you were dead._";
code = 
	if (get_flag(4,5) == 0) {
		remove_string(3);
	} else {
		remove_string(2);
	}
break;

begintalknode 13;
state = 3;
nextstate = 3;
question = "Let's trade.";
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;

// A bit more Crilly
begintalknode 14;
state = 1;
nextstate = 1;
condition = get_flag(2,2);
question = "Do you have any idea where the bandits have gone?";
text1 = "_They fled to the North.  And I heard one of them shouting to regroup at the first boulder.  That's all I know._";


// Mayor Danby
begintalknode 15;
state = -1;
nextstate = 4;
question = "Mayor Danby";
text1 = "Mayor Danby looks frantically worried.  He is looking at a lot of paperwork, and fiddling with it, but clearly not actually able to concentrate on it.";
text2 = "He sees you, and scowls.";
text3 = "_I've got enough problems without having a constant stream if idiots in my office.  Don't you know that Lord Ashford was kidnapped?  Go away!_";

begintalknode 16;
state = 4;
nextstate = 5;
action = SET_SDF 2 1 1;
condition = get_flag(1,1) == 0;
question = "What about Diana?";
text1 = "_Who the hell is Diana?  Oh, your sister.  The bandits asked for a huge ransom for Lord Ashford and for her.  His will be paid.  Hers, of course, won't._";

begintalknode 17;
state = 4;
nextstate = 5;
action = SET_SDF 2 1 1;
condition = get_flag(1,1) == 1;
question = "What about Frrza?";
text1 = "_Who the hell is Frrza?  Oh, your sister.  The bandits asked for a huge ransom for Lord Ashford and for her.  His will be paid.  Hers, of course, won't._";

begintalknode 18;
state = 4;
nextstate = 5;
action = SET_SDF 2 1 1;
condition = get_flag(1,1) == 2;
question = "What about Sissay?";
text1 = "_Who the hell is Sissay?  Oh, your sister.  The bandits asked for a huge ransom for Lord Ashford and for her.  His will be paid.  Hers, of course, won't._";

begintalknode 19;
state = 5;
nextstate = -1;
action = END_TALK;
question = "You have to do something!";
text1 = "_Have to?  I don't have to do anything.  But the longer you stay here, the more likely I am to decide to have you executed for annoying me.  Go away._";

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

// Crilly, post-rescue
begintalknode 21;
state = -1;
nextstate = 10;
question = "Father Crilly";
text1 = "Father Crilly is glad to see you again.";
text2 = "_Amazing!  You managed it!_  You tell him all the details.";
text3 = "_It's worrying that something on such a large scale can go on right under our noses.  I hope the Empire does something about it._";

begintalknode 22;
state = 10;
nextstate = 10;
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 = "_You've done so much.  It doesn't seem right to ask for payment._";

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

// Danby, post-rescue

begintalknode 23;
state = -1;
nextstate = 11;
question = "Mayor Danby";
text1 = "You expect Mayor Danby to be happy to see you back, but he is not.";
text2 = "_You really took the most horrendous risk, rescuing Lord Ashford like that.  They could have executed him as soon as you got near!_";
text3 = "_So you've got your pathetic sister back, have you?  What about Lord Ashford?";
text4 = "_You rescued your pathetic sister, but Lord Ashford is still missing.  You've done what you wanted, now go away._";
text5 = "_I can't prove it, but I know you're directly responsible for the death of Lord Ashford.  Go away!_";
code = 
	if (get_flag(6,3)) {
		remove_string(1);
	}
	set_flag(6,3,1);
	if (get_flag(5,1)) {
		remove_string(3);
		remove_string(4);
		remove_string(5);
	} else {
		remove_string(2);
		if (get_flag(4,7) == 1) {
			remove_string(5);
			remove_string(3);
		} else if (get_flag(4,7) == 2) {
			remove_string(4);
			remove_string(3);
		} else {
			remove_string(4);
			remove_string(5);
		}
	}
break;

begintalknode 24;
state = 11;
nextstate = 11;
condition = (get_flag(5,1));
question = "But we saved the Empire a huge ransom.  We deserve a reward.";
text1 = "_Reward? Your reward is that I don't have you arrested for recklessly endangering the life of a noble.  That's your reward._";

begintalknode 25;
state = 11;
nextstate = 11;
condition = (get_flag(5,1) == 0) && (get_flag(4,7) == 0);
question = "We never came across Lord Ashford.  Maybe they were holding him somewhere else.";
text1 = "Major Danby doesn't sound happy at all.";
text2 = "_Well, I hope your reckless escapade didn't result in any harm.  If it did, you are in trouble._";
code = set_flag(4,7,1);
break;

begintalknode 26;
state = 11;
nextstate = -1;
condition = (get_flag(5,1) == 0) && (get_flag(4,7) == 0);
question = "Lord Ashford was killed by the bandits.  There was nothing we could do.";
text1 = "Major Danby looks furious.";
text2 = "_You utter fools!  You've caused the death of the most important noble in the region!_";
text3 = "_You don't live here, and you didn't technically break a law, so sadly I can't execute you.  But that doesn't mean you got away with it.  You'll pay later.  Now get out.  Now._";
action = END_TALK;
code = set_flag(4,7,2);
break;

begintalknode 27;
state = 11;
nextstate = -1;
condition = (get_flag(5,1) == 0) && (get_flag(4,7) == 0);
question = "We killed Lord Ashford.";
text1 = "Major Danby goes purple and looks like he is about to explode.";
text2 = "_You KILLED him?!  Are you insane?  Well, it doesn't matter.  The penalty for that is death.  Applied immediately._";
code = kill_char(1000,2,0);
break;

begintalknode 28;
state = -1;
nextstate = 12;
question = "Lord Ashford";
text1 = "Lord Ashford looks pleased to be back, but not pleased that you are near him.";
text2 = "When he sees you looking at him, he says _Why should I talk to you fools?_";
text3 = "He looks away.";

begintalknode 29;
state = 12;
nextstate = 13;
question = "But we rescued you!";
text1 = "_You almost got me killed!  I was safe in my cell, and I would have been released eventualy, without danger._";

begintalknode 30;
state = 13;
nextstate = 12;
question = "You seemed keen to get out when you were there.";
text1 = "He looks embarrassed.";
text2 = "_Well, I wasn't thinking clearly then.  But now I am.  Go away._";