// creator  : weidu.exe (version 23100)
// argument : _KEEPER.DLG
// game		 : .
// source	 : ./override/_KEEPER.DLG
// dialog	 : ./DIALOG.TLK
// dialogF  : (none)

BEGIN ~_KEEPER~

IF ~~ THEN BEGIN 0 // from:
  SAY #78635 /* ~I apologize, but I cannot allow you to leave.  Gorion wishes to see you as soon as possible.~ */
  IF ~~ THEN EXIT
END

IF ~True()
~ THEN BEGIN 1 // from:
  SAY #78636 /* ~Hold, travelers!  Before you will be allowed entrance, you must donate a tome of great value to our libraries.~ [_AJAN03] */
  IF ~~ THEN REPLY #78637 /* ~We don't have a book, but I used to live here.~ */ GOTO 2
  IF ~Global("Chapter","GLOBAL",6)
~ THEN REPLY #78638 /* ~We have the book you require.~ */ DO ~TakePartyItem("_BOOK68")
~ GOTO 4
  IF ~Global("X#CoranKeeper1","GLOBAL",0)
InParty("coran")
InMyArea("coran")
!StateCheck("coran",CD_STATE_NOTVALID)
~ THEN DO ~SetGlobal("X#CoranKeeper1","GLOBAL",1)~ EXTERN ~_CORANJ~ 137
END

IF ~~ THEN BEGIN 2 // from: 19.0 1.0
  SAY #78639 /* ~I am sorry friend.  I know that you are the child of Gorion and have dwelt here all your life, but I cannot exempt anyone from the sanctions of the most high Ulraunt.~ */
  IF ~~ THEN EXIT
  IF ~  !InParty("imoen")
Global("X#GorionBuried","GLOBAL",0)
Global("X#PCAloneKeeperStart","GLOBAL",0)
~ THEN GOTO 9
  IF ~Global("X#GarKee","GLOBAL",0)
InParty("garrick")
InMyArea("garrick")
!StateCheck("garrick",CD_STATE_NOTVALID)
~ THEN DO ~SetGlobal("X#GarKee","GLOBAL",1)~ EXTERN ~_GARRIJ~ 83
  IF ~  InParty("imoen")
InMyArea("imoen")
!StateCheck("imoen",CD_STATE_NOTVALID)
GlobalLT("Chapter","GLOBAL",2)
Global("X#IMPCTalkKeeperStart","GLOBAL",0)
~ THEN EXTERN ~_IMOEN2~ 124
END

IF ~~ THEN BEGIN 3 // from:
  SAY #78640 /* ~Don't lie to me child.  You do not possess the proper book.  When you do, you may return, and I will allow you entry.~ */
  IF ~~ THEN EXIT
END

IF ~~ THEN BEGIN 4 // from: 19.1 1.1
  SAY #78641 /* ~You have met the requirements to gain entry to our most holy library.  It is fine to see the child of Gorion once again within these hallowed grounds.  Please have your less civilized friends refrain from causing trouble.  We are very strict with the letter of the law, as you well know, <CHARNAME>.~ */
  IF ~~ THEN DO ~SetGlobal("X#GainedEntryCandlekeep","GLOBAL",1)
RealSetGlobalTimer("X#InsideCandlekeep","GLOBAL",FORTY_MINUTES)
ClearAllActions()
StartCutScene("_H6CUT01")
~ EXIT
  IF ~Global("X#XANCANDLEKEEP","GLOBAL",0)
InParty("xan")
InMyArea("xan")
!StateCheck("xan",CD_STATE_NOTVALID)
~ THEN DO ~SetGlobal("X#XANCANDLEKEEP","GLOBAL",1)~ EXTERN ~_XANJ~ 158
END

IF ~~ THEN BEGIN 5 // from:
  SAY #78642 /* ~I hope your time here was fruitful.~ */
  IF ~~ THEN EXIT
END

IF ~~ THEN BEGIN 6 // from:
  SAY #78643 /* ~You are accused of murdering the leaders of the Iron Throne.  Give yourselves up and stand a chance of a fair trial!~ */
  IF ~~ THEN REPLY #78644 /* ~I didn't do it, and I'll not surrender for a crime I didn't commit.~ */ EXIT
  IF ~~ THEN REPLY #78645 /* ~I surrender.~ */ GOTO 8
END

IF ~~ THEN BEGIN 7 // from:
  SAY #78646 /* ~Hold, travelers!  Before you will be allowed entrance, you must donate a tome of great value to our libraries.~ */
  IF ~~ THEN EXIT
END

IF ~~ THEN BEGIN 8 // from: 6.1
  SAY #78647 /* ~You have made a wise decision.~ */
  IF ~~ THEN EXIT
END

IF ~~ THEN BEGIN 9 // from: 2.1 _GARRIJ:83.1
  SAY #98354 /* ~What are your plans for Gorion's body?~ */
  IF ~~ THEN REPLY #98355 /* ~I think Gorion would have wished to be buried in Candlekeep. Could you arrange it?~ */ DO ~SetGlobal("X#PCAloneKeeperStart","GLOBAL",1)
~ GOTO 10
  IF ~~ THEN REPLY #98356 /* ~I will return to the Golden Way to bury my mentor myself.~ */ DO ~SetGlobal("X#PCAloneKeeperStart","GLOBAL",1)
~ GOTO 11
  IF ~~ THEN REPLY #98357 /* ~I have already buried my mentor myself.~ */ DO ~SetGlobal("X#PCAloneKeeperStart","GLOBAL",1)
~ GOTO 12
END

IF ~~ THEN BEGIN 10 // from: 9.0
  SAY #98358 /* ~We will send a search party and Gorion will be interred properly. If we find any personal effects, we will leave them there for you. I wish that I could do more for you.~ */
  IF ~~ THEN DO ~SetGlobal("X#KeepBuryGorion","GLOBAL",1)
~ EXIT
END

IF ~~ THEN BEGIN 11 // from: 9.1
  SAY #98359 /* ~You're a tough one. I wish that I could do more for you, but rules are rules. Go now, and may Tymora watch over you.~ */
  IF ~~ THEN DO ~SetGlobal("X#PCBuryGorion","GLOBAL",1)
~ EXIT
END

IF ~~ THEN BEGIN 12 // from: 9.2
  SAY #98359 /* ~You're a tough one. I wish that I could do more for you, but rules are rules. Go now, and may Tymora watch over you.~ */
  IF ~~ THEN EXIT
END

IF ~~ THEN BEGIN 13 // from:
  SAY #99767 /* ~Yet preserve it we do. Go in peace.~ */
  IF ~~ THEN DO ~SetGlobal("X#GainedEntryCandlekeep","GLOBAL",1)
RealSetGlobalTimer("X#InsideCandlekeep","GLOBAL",FORTY_MINUTES)
ClearAllActions()
StartCutScene("_H6CUT01")
~ EXIT
END

IF ~~ THEN BEGIN 14 // from: _IMOEN2:125.5
  SAY #100268 /* ~I... I am saddened to hear of Gorion's death, <CHARNAME>. Your father was a good man and my friend. I'll inform the most high Ulraunt and Tethtoril of his passing. This is grave news indeed. However, I do hope you understand that I just cannot allow you in, <CHARNAME>. My hands are tied in this matter.~ */
  IF ~~ THEN REPLY #100269 /* ~I could really use your help. I have no home, no guardian, and I need to get to the Friendly Arm Inn.~ */ DO ~SetGlobal("X#IMPCTalkKeeperStart","GLOBAL",1)
~ GOTO 16
  IF ~~ THEN REPLY #100270 /* ~I do not believe that you will not let me return. At least let Imoen in... I don't want her around.~ */ DO ~SetGlobal("X#IMPCTalkKeeperStart","GLOBAL",1)
~ GOTO 16
  IF ~~ THEN REPLY #100271 /* ~You have no right to bar my path.~ */ DO ~SetGlobal("X#IMPCTalkKeeperStart","GLOBAL",1)
~ GOTO 16
  IF ~  Global("X#GorionBuried","GLOBAL",0)
~ THEN REPLY #98355 /* ~I think Gorion would have wished to be buried in Candlekeep. Could you arrange it?~ */ DO ~SetGlobal("X#IMPCTalkKeeperStart","GLOBAL",1)
~ GOTO 15
  IF ~  Global("X#GorionBuried","GLOBAL",0)
~ THEN REPLY #100272 /* ~I will return to the Golden Way to bury my mentor myself. Imoen, though, may want to stay here. Will you let her, if she wants to?~ */ DO ~SetGlobal("X#PCBuryGorion","GLOBAL",1)
SetGlobal("X#IMPCTalkKeeperStart","GLOBAL",1)
~ GOTO 16
END

IF ~~ THEN BEGIN 15 // from: 14.3 _IMOEN2:125.3
  SAY #100273 /* ~We will send a search party and Gorion will be interred properly. I wish that I could do more for you...~ */
  IF ~~ THEN DO ~SetGlobal("X#KeepBuryGorion","GLOBAL",1)
~ GOTO 16
END

IF ~~ THEN BEGIN 16 // from: 15.0 14.4 14.2 14.1 14.0 _IMOEN2:125.4 _IMOEN2:125.2 _IMOEN2:125.1 _IMOEN2:125.0
  SAY #100274 /* ~Perhaps I can help in some small way. Here, please take this. It's not much, but I hope it will be of some assistance.~ */
  IF ~~ THEN DO ~GiveGoldForce(100)
~ GOTO 17
END

IF ~~ THEN BEGIN 17 // from: 16.0
  SAY #100275 /* ~Imoen, you, however, are free to enter if you wish. Winthrop is quite worried over your disappearance.~ */
  IF ~~ THEN EXTERN ~_IMOEN2~ 126
END

IF ~~ THEN BEGIN 18 // from: _IMOEN2:127.0
  SAY #100278 /* ~I will, Imoen. Take care, both of you. And <CHARNAME>? Be wary of strangers, and don't be too quick to give out your name. Just a bit of advice. Safe travels.~ */
  IF ~~ THEN EXIT
END

IF ~~ THEN BEGIN 19 // from:
  SAY #100672 /* ~Have you a tome?~ */
  IF ~~ THEN REPLY #78637 /* ~We don't have a book, but I used to live here.~ */ GOTO 2
  IF ~Global("Chapter","GLOBAL",6)
~ THEN REPLY #78638 /* ~We have the book you require.~ */ DO ~TakePartyItem("_BOOK68")
~ GOTO 4
END
