// creator  : weidu.exe (version 23100)
// argument : SCJERLIA.DLG
// game		 : .
// source	 : ./DATA/DIALOG.BIF
// dialog	 : ./DIALOG.TLK
// dialogF  : (none)

BEGIN ~SCJERLIA~
//////////////////////////////////////////////////
// WARNING: this file contains non-trivial WEIGHTs
//////////////////////////////////////////////////

IF WEIGHT #0 ~Global("TalkedToSarles","GLOBAL",0)
NumTimesTalkedTo(0)
!GlobalTimerExpired("JerliaLeave","GLOBAL")
~ THEN BEGIN 0 // from:
  SAY #28737 /* ~Get on with ya, I don't deal with individuals. Bulk ore is what I sells. You need a few pebbles, you go scrounge it yourself.~ */
  IF ~~ THEN DO ~SetNumTimesTalkedTo(0)
~ EXIT
END

IF WEIGHT #1 ~Global("TalkedToSarles","GLOBAL",1)
NumTimesTalkedTo(0)
!GlobalTimerExpired("JerliaLeave","GLOBAL")
~ THEN BEGIN 1 // from:
  SAY #28740 /* ~You interested in a bulk purchase of ore? I've got fine prices for masonry as well, and crafters that can build you everything from arches to overhangs.~ */
  IF ~~ THEN REPLY #28742 /* ~I have need of illithium for Sir Sarles. How much would 200 pounds be worth?~ */ GOTO 4
  IF ~~ THEN REPLY #28743 /* ~Nothing, sorry I bothered you.~ */ GOTO 2
  IF ~~ THEN REPLY #28745 /* ~I'm looking for a rare metal suitable for sculpture.~ */ GOTO 3
END

IF ~~ THEN BEGIN 2 // from: 1.1
  SAY #28746 /* ~S'alright friend. Come back when you need.~ */
  IF ~~ THEN DO ~SetNumTimesTalkedTo(0)
~ EXIT
END

IF ~~ THEN BEGIN 3 // from: 1.2
  SAY #28748 /* ~Ain't but one sculptor that even bears mentioning in this town right now. You fishing to hire Sir Sarles? Overrated, he is. I suppose he wants illithium again, too. How much this time?~ */
  IF ~~ THEN REPLY #28751 /* ~200 pounds. Is that going to be expensive?~ */ GOTO 4
  IF ~~ THEN REPLY #28752 /* ~I'm sure you have it in stock. He needs 200 pounds.~ */ GOTO 4
END

IF ~~ THEN BEGIN 4 // from: 3.1 3.0 1.0
  SAY #28754 /* ~200 pounds! He's mad! Raving! Out of his mind!~ */
  IF ~~ THEN REPLY #28757 /* ~So does this mean you don't have it in stock?~ */ GOTO 5
  IF ~~ THEN REPLY #28758 /* ~I'm sure your theatrics make it all worthwhile. What will the price be then?~ */ GOTO 5
END

IF ~~ THEN BEGIN 5 // from: 4.1 4.0
  SAY #28762 /* ~You don't know what is involved in getting illithium. I've an agreement with a rather special source, but there's only so much I'm allowed to take. 50 pounds a season at most.~ */
  IF ~~ THEN REPLY #28764 /* ~50 pounds a season? I don't have that kind of time.~ */ GOTO 6
  IF ~~ THEN REPLY #28765 /* ~So this is a fruitless enterprise then? He has sent me on a merry little chase.~ */ GOTO 6
END

IF ~~ THEN BEGIN 6 // from: 5.1 5.0
  SAY #28770 /* ~Hold on. It's difficult, but not impossible. There are two options to you. You can go to my source and try and ply the extra out of him, or you can use a... substitute.~ */
  IF ~~ THEN REPLY #28777 /* ~Where is your source? I'm sure he will see reason.~ */ GOTO 14
  IF ~~ THEN REPLY #28772 /* ~You mean a cheaper metal as a replacement? Won't Sarles know?~ */ GOTO 12
END

IF ~~ THEN BEGIN 7 // from: 36.2 35.0 18.0 14.1 13.1
  SAY #28780 /* ~His name is Unger Hilldark. He stays in the Copper Coronet when he's in town. Don't get him mad, will you? He's at enough of a risk just coming here. He's... he's Duergar.~ */
  IF ~~ THEN REPLY #28784 /* ~Duergar? Where does a dwarf of such evil nature find sanctuary in Amn?~ */ GOTO 8
  IF ~Global("AskOreSub","LOCALS",0)
~ THEN REPLY #28785 /* ~I don't deal with the likes of Duergar. What was that about a substitute?  Wouldn't Sir Sarles know the difference?~ */ DO ~SetGlobal("AskOreSub","LOCALS",1)
SetGlobal("ToldAboutDuergar","GLOBAL",1)
~ GOTO 12
END

IF ~~ THEN BEGIN 8 // from: 7.0
  SAY #28793 /* ~At the Copper Coronet, of course. It hides worse than him within. Besides, they have to eat too, you know. Nothing wrong with a mutually beneficial trading agreement.~ */
  IF ~~ THEN GOTO 9
END

IF ~~ THEN BEGIN 9 // from: 8.0
  SAY #28796 /* ~He's in disguise. His kind doesn't look all that different, and as long as he's left alone, he's fine. Not a bad guy, once you get to know him.~ */
  IF ~~ THEN DO ~SetGlobal("ToldAboutDuergar","GLOBAL",1)
~ UNSOLVED_JOURNAL #2081 /* ~Gain the services of Sir Sarles for the temple.

I was able to get Jerlia to tell me who her illithium supplier is.  It is a duergar named Unger Hilldark, and he is staying at the Copper Coronet, a bar in the Slums District.  Jerlia advises that I approach him there and ask about the ore, although she thinks it will be quite expensive.~ */ GOTO 10
END

IF ~~ THEN BEGIN 10 // from: 9.0
  SAY #28798 /* ~You go talk to him. Tell him I sent you. Maybe he'll let you pull a little more illithium out of him than I can get. It won't be cheap though.~ */
  IF ~~ THEN REPLY #28801 /* ~Thanks. I'll do that.~ */ GOTO 11
  IF ~Global("OreSub","LOCALS",0)
~ THEN REPLY #28802 /* ~Perhaps I should try to get that substitute you mentioned as well.~ */ GOTO 12
  IF ~Global("OreSub","LOCALS",1)
~ THEN REPLY #29012 /* ~I'll pay for that alloy substitute as well.~ */ GOTO 25
END

IF ~~ THEN BEGIN 11 // from: 39.0 10.0
  SAY #28806 /* ~Good luck. You'll need it. Of course, you knew I would say that.~ */
  IF ~~ THEN EXIT
END

IF ~~ THEN BEGIN 12 // from: 38.1 18.1 10.1 7.1 6.1
  SAY #28809 /* ~For all his pomp and balderdash, Sir Sarles wouldn't know quality materials if you beat him over the head with them. Now that's a fine image, eh?~ */
  IF ~!IsValidForPartyDialog("Keldorn")
!IsValidForPartyDialog("Anomen")
!IsValidForPartyDialog("Mazzy")
!Global("JerliaBack","GLOBAL",1)~ THEN GOTO 13
  IF ~IsValidForPartyDialog("Keldorn")
!Global("JerliaBack","GLOBAL",1)~ THEN EXTERN ~KELDORJ~ 167
  IF ~!IsValidForPartyDialog("Keldorn")
IsValidForPartyDialog("Anomen")
!Global("JerliaBack","GLOBAL",1)~ THEN EXTERN ~ANOMENJ~ 241
  IF ~!IsValidForPartyDialog("Keldorn")
!IsValidForPartyDialog("Anomen")
IsValidForPartyDialog("Mazzy")
!Global("JerliaBack","GLOBAL",1)~ THEN EXTERN ~MAZZYJ~ 155
  IF ~Global("JerliaBack","GLOBAL",1)~ THEN GOTO 39
END

IF ~~ THEN BEGIN 13 // from: 12.0
  SAY #28812 /* ~Enough of that. Anyway, I would wager that a derivative of illithium would serve just as well. Pure illithium is quite rare, but an alloy could be fashioned at a reasonable rate.~ */
  IF ~Global("Paid","LOCALS",0)
~ THEN REPLY #28871 /* ~Perhaps I should just talk to your source about the real thing. He may help.~ */ GOTO 14
  IF ~Global("Paid","LOCALS",1)
~ THEN REPLY #28872 /* ~Perhaps I should just talk to your source about the real thing.~ */ GOTO 7
  IF ~Global("JerliaBack","GLOBAL",0)~ THEN REPLY #28873 /* ~Sounds like a good idea. Can you fashion this alloy?~ */ DO ~

~ GOTO 19
END

IF ~~ THEN BEGIN 14 // from: 13.0 6.0
  SAY #28851 /* ~He may at that, but I will require compensation for revealing him to you. If word got out who and where my source was, I would be out of business. Make it worth my while.~ */
  IF ~PartyGoldGT(499)
~ THEN REPLY #28856 /* ~It's your career, so how does, 500 gold sound?~ */ GOTO 17
  IF ~PartyGoldGT(999)
~ THEN REPLY #28857 /* ~If this could ruin you, I should offer no less than 1,000 gold.~ */ DO ~TakePartyGold(1000)
SetGlobal("Paid","LOCALS",1)
~ GOTO 7
  IF ~Global("SculptorPlot","GLOBAL",1)
~ THEN REPLY #28858 /* ~Come now. don't you wish to earn the favor of the Morninglord?~ */ GOTO 15
  IF ~Global("SculptorPlot","GLOBAL",2)
~ THEN REPLY #28862 /* ~The everseeing eye of Helm would look on you favorably if you help.~ */ GOTO 15
  IF ~Global("SculptorPlot","GLOBAL",3)
~ THEN REPLY #28863 /* ~The storms of Talos would surely spare you amongst your neighbors if you help.~ */ GOTO 15
  IF ~~ THEN REPLY #28867 /* ~I cannot afford to pay you for this information.~ */ GOTO 16
END

IF ~~ THEN BEGIN 15 // from: 14.4 14.3 14.2
  SAY #28880 /* ~Sorry, but I follow Waukeen and the ways of the Merchants' Friend. She has been quiet as of late, but I still feel her wisdom telling me that this would be a bad deal.~ */
  IF ~~ THEN GOTO 18
END

IF ~~ THEN BEGIN 16 // from: 14.5
  SAY #28887 /* ~I am sorry, but I cannot give this information out without compensation.~ */
  IF ~~ THEN GOTO 18
END

IF ~~ THEN BEGIN 17 // from: 14.0
  SAY #28889 /* ~It sounds like the end of me for a mere pittance. No, that is not enough.~ */
  IF ~~ THEN GOTO 18
END

IF ~~ THEN BEGIN 18 // from: 17.0 16.0 15.0
  SAY #28892 /* ~So, shall we discuss proper payment or would you like to hear the substitute offer again?~ */
  IF ~PartyGoldGT(999)
~ THEN REPLY #28894 /* ~Very well, I will offer 1,000 gold to compensate you.~ */ DO ~TakePartyGold(1000)
SetGlobal("Paid","LOCALS",1)
~ GOTO 7
  IF ~~ THEN REPLY #28895 /* ~Tell me of the substitute.~ */ GOTO 12
END

IF ~~ THEN BEGIN 19 // from: 13.2
  SAY #28902 /* ~I will require some measure of coin for the service. Tell you what I'll do. I'll get 200 pounds of the alloy together and you can pick it up tomorrow.~ */
  IF ~~ THEN GOTO 20
END

IF ~~ THEN BEGIN 20 // from: 19.0
  SAY #28933 /* ~You just be sure to have 200 gold ready. You'll agree that the price is very reasonable. Alloy requires very little illithium, so it is quite inexpensive.~ */
  IF ~~ THEN REPLY #28936 /* ~200 gold? I thought this was the cheap solution.~ */ GOTO 21
  IF ~~ THEN REPLY #28937 /* ~Very well. I will return tomorrow.~ */ GOTO 22
END

IF ~~ THEN BEGIN 21 // from: 20.0
  SAY #28938 /* ~It is, at least compared to the price of me telling you my source and then you doing whatever he required. Take it or leave it, I'll be here tomorrow with the goods.~ */
  IF ~~ THEN DO ~SetGlobalTimer("JerliaLeave","GLOBAL",ONE_DAY)
EscapeArea()
~ UNSOLVED_JOURNAL #2082 /* ~Gain the services of Sir Sarles for the temple.

Jerlia has agreed to fashion an alloy of illithium for me, since 200 pounds of the pure ore is just not feasible.  I should return to her after a day with 200 gp to pick up the facsimile.~ */ EXIT
END

IF ~~ THEN BEGIN 22 // from: 20.1
  SAY #28939 /* ~I will be here in a day.~ */
  IF ~~ THEN DO ~SetGlobalTimer("JerliaLeave","GLOBAL",ONE_DAY)
EscapeArea()
~ UNSOLVED_JOURNAL #2082 /* ~Gain the services of Sir Sarles for the temple.

Jerlia has agreed to fashion an alloy of illithium for me, since 200 pounds of the pure ore is just not feasible.  I should return to her after a day with 200 gp to pick up the facsimile.~ */ EXIT
END

IF WEIGHT #2 ~GlobalTimerExpired("JerliaLeave","GLOBAL")
NumTimesTalkedTo(0)
~ THEN BEGIN 23 // from:
  SAY #28941 /* ~Well now, you've returned. I've got the alloy that you wanted. Looks just like illithium and it has most of the same properties as well. There's just a slight problem.~ */
  IF ~~ THEN REPLY #28944 /* ~And what might that be?~ */ DO ~SetGlobal("JerliaBack","GLOBAL",1)~ GOTO 24
  IF ~~ THEN REPLY #28945 /* ~Problem? We had a deal.~ */ DO ~SetGlobal("JerliaBack","GLOBAL",1)~ GOTO 25
END

IF ~~ THEN BEGIN 24 // from: 23.0
  SAY #28960 /* ~It 'might' be that I have been approached by no less than two other churches for illithium of their own. It seems they are courting Sarles as well.~ */
  IF ~~ THEN GOTO 29
END

IF ~~ THEN BEGIN 25 // from: 23.1 10.2
  SAY #28964 /* ~I know we had a deal, but the market has changed drastically in the last few hours. I have been approached by two other churches for illithium of their own. It seems they are courting Sarles as well.~ */
  IF ~Global("SculptorPlot","GLOBAL",1)
~ THEN GOTO 26
  IF ~Global("SculptorPlot","GLOBAL",2)
~ THEN GOTO 27
  IF ~Global("SculptorPlot","GLOBAL",3)
~ THEN GOTO 28
END

IF ~~ THEN BEGIN 26 // from: 25.0
  SAY #28968 /* ~I'm afraid you are in competition with both the Temple of Helm and the Temple of Talos. They both seem very determined.~ */
  IF ~~ THEN GOTO 29
END

IF ~~ THEN BEGIN 27 // from: 25.1
  SAY #28969 /* ~I'm afraid you are in competition with both the Temple of Lathander and the Temple of Talos. They both seem very determined.~ */
  IF ~~ THEN GOTO 29
END

IF ~~ THEN BEGIN 28 // from: 25.2
  SAY #28970 /* ~I'm afraid you are in competition with both the Temple of Lathander and the Temple of Helm. They both seem very determined.~ */
  IF ~~ THEN GOTO 29
END

IF ~~ THEN BEGIN 29 // from: 28.0 27.0 26.0 24.0
  SAY #28980 /* ~Don't worry, I have honored my deal and you get the first shot at the alloy I have made. I didn't even tell them about it. I cannot make any more until I get more illithium, so they are out of luck.~ */
  IF ~~ THEN GOTO 30
END

IF ~~ THEN BEGIN 30 // from: 29.0
  SAY #28983 /* ~My price has to be higher though. You understand the pressures of the market, don't you? Well, I must ask for 500 gold instead of 200. It is still quite reasonable.~ */
  IF ~PartyGoldGT(499)
~ THEN REPLY #28984 /* ~I have no choice. I will pay.~ */ DO ~TakePartyGold(500)
~ GOTO 33
  IF ~~ THEN REPLY #28985 /* ~This is highly unreasonable of you. I will report you as a cheat!~ */ GOTO 31
  IF ~PartyGoldLT(500)
~ THEN REPLY #28986 /* ~I cannot afford this right now.~ */ GOTO 32
  IF ~Global("ToldAboutDuergar","GLOBAL",0)
~ THEN REPLY #29003 /* ~For this price I might as well have asked about your source and got it myself.~ */ GOTO 35
END

IF ~~ THEN BEGIN 31 // from: 30.1
  SAY #28991 /* ~Prices are subject to change without notice. I have done you a favor in even suggesting this at all. Take it or leave it. I have others lined up.~ */
  IF ~PartyGoldGT(499)
~ THEN REPLY #28994 /* ~I have no choice. I will take it.~ */ DO ~TakePartyGold(500)
~ GOTO 33
  IF ~~ THEN REPLY #28995 /* ~I cannot afford this yet. Will you wait?~ */ GOTO 32
  IF ~Global("ToldAboutDuergar","GLOBAL",0)
~ THEN REPLY #29007 /* ~For this price I might as well have asked about your source and got it myself.~ */ GOTO 35
END

IF ~~ THEN BEGIN 32 // from: 39.1 36.1 35.1 31.1 30.2
  SAY #28998 /* ~Then return when you can. I will wait if you are sure to return.~ */
  IF ~~ THEN DO ~SetGlobal("JerliaOreNoBuy","GLOBAL",1)~ EXIT
END

IF ~~ THEN BEGIN 33 // from: 36.0 35.2 31.0 30.0
  SAY #29000 /* ~Oh, it's not so bad now, is it? You've got a close approximation of what you need, and I have fair compensation for the demand on the item.~ */
  IF ~~ THEN DO ~SetGlobal("OreSub","LOCALS",1)
~ GOTO 34
END

IF ~~ THEN BEGIN 34 // from: 39.2 33.0
  SAY #29002 /* ~Go on, I'm sure Sarles will be waiting.~ */
  IF ~~ THEN DO ~GiveItemCreate("MISC6S",LastTalkedToBy,0,0,0)~ UNSOLVED_JOURNAL #2083 /* ~Gain the services of Sir Sarles for the temple.

Jerlia has fashioned the illithium alloy for me... now all I need to do is give the metal to Sarles and hope that he does not distinguish between it and the real thing.~ */ EXIT
END

IF ~~ THEN BEGIN 35 // from: 39.3 31.2 30.3
  SAY #29004 /* ~The price for that knowledge is 1,000 gold. Do you wish to pay that instead?~ */
  IF ~PartyGoldGT(999)
~ THEN REPLY #29009 /* ~Yes, I will.~ */ DO ~TakePartyGold(1000)
SetGlobal("Paid","LOCALS",1)~ GOTO 7
  IF ~~ THEN REPLY #29010 /* ~No, I can't afford either.~ */ GOTO 32
  IF ~PartyGoldGT(499)
~ THEN REPLY #29011 /* ~I'll just take the ore for 500.~ */ DO ~TakePartyGold(500)
~ GOTO 33
END

IF WEIGHT #3 ~Global("OreSub","LOCALS",0)
Global("JerliaOreNoBuy","GLOBAL",1)
~ THEN BEGIN 36 // from:
  SAY #29016 /* ~Do you have the 500 gold yet? That alloy is burning a hole in my pocket.~ */
  IF ~PartyGoldGT(499)
~ THEN REPLY #29017 /* ~Yes, I have no choice.~ */ GOTO 33
  IF ~~ THEN REPLY #29018 /* ~No, I cannot afford it.~ */ GOTO 32
  IF ~Global("ToldAboutDuergar","GLOBAL",0)
PartyGoldGT(999)
Global("UngerInfo","GLOBAL",0)~ THEN REPLY #29019 /* ~Perhaps I should just ask about your source. That was 1,000 gold, wasn't it?~ */ DO ~TakePartyGold(1000)
SetGlobal("Paid","LOCALS",1)~ GOTO 7
END

IF WEIGHT #5 /* Triggers after states #: 38 even though they appear after this state */
~True()
~ THEN BEGIN 37 // from: 38.0
  SAY #29028 /* ~A pleasure doing business with you.~ */
  IF ~~ THEN EXIT
END

IF WEIGHT #4 ~Global("OreSub","LOCALS",0)
Global("ToldAboutDuergar","GLOBAL",1)
~ THEN BEGIN 38 // from:
  SAY #29148 /* ~I trust you got on with Unger? Don't go telling me that you buggered up my only source for illithium.~ */
  IF ~~ THEN REPLY #29149 /* ~Everything is fine. Sorry to bother you.~ */ GOTO 37
  IF ~~ THEN REPLY #29150 /* ~I wanted to ask about that substitute for illithium.~ */ GOTO 12
END

IF ~~ THEN BEGIN 39 // from: 12.4
  SAY #61206 /* ~I have made this alloy for you, as we discussed before. Will you take it now? The price is 500.~ */
  IF ~Global("ToldAboutDuergar","GLOBAL",1)~ THEN REPLY #61207 /* ~No, I will try this Unger Hilldark you spoke of.~ */ GOTO 11
  IF ~~ THEN REPLY #61208 /* ~I am not prepared to pay that price.~ */ GOTO 32
  IF ~~ THEN REPLY #61209 /* ~I'll take the alloy. Sarles will not know the difference.~ */ GOTO 34
  IF ~Global("ToldAboutDuergar","GLOBAL",0)~ THEN REPLY #61210 /* ~Tell me of your source.~ */ GOTO 35
END
