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

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

IF WEIGHT #3 /* Triggers after states #: 6 11 12 even though they appear after this state */
~Global("KickedOut","LOCALS",1)
~ THEN BEGIN 0 // from:
  SAY #86950 /* ~Hello, my unfortunate friends.  No doubt a comrade or two has met their deaths, and now you require me to step into their still-warm boots.~ */
  IF ~~ THEN REPLY #86951 /* ~Nothing quite so gruesome, though I do have need of your skills once again.~ */ GOTO 1
  IF ~~ THEN REPLY #86952 /* ~For now I would rather have the constant specter of their empty place, rather than tolerate your incessant gloom.~ */ GOTO 2
END

IF ~~ THEN BEGIN 1 // from: 0.0
  SAY #86953 /* ~Then I shall do my best for you, though I am sure we both know that the worst is inevitable.~ */
  IF ~~ THEN DO ~SetGlobal("KickedOut","LOCALS",0)
JoinParty()
~ EXIT
END

IF ~~ THEN BEGIN 2 // from: 0.1
  SAY #86954 /* ~Your decision is understandable, and not altogether undesirable.  I shall do my best to not try at all in your absence.  We're all doomed you know.~ */
  IF ~~ THEN EXIT
END

IF WEIGHT #4 /* Triggers after states #: 6 11 12 even though they appear after this state */
~  !Global("X#XARomanceActive","GLOBAL",2)
HappinessLT(Myself,0)
~ THEN BEGIN 3 // from:
  SAY #86955 /* ~This whole mission has been a dismal failure from the very start. Consider my debt repaid, friends, as I certainly do.~ */
  IF ~~ THEN DO ~SetGlobal("IHATEYOUALL","LOCALS",0)
ChangeAIScript("",DEFAULT)
LeaveParty()
EscapeArea()
~ EXIT
END

IF WEIGHT #5 /* Triggers after states #: 6 11 12 even though they appear after this state */
~  OR(3)
Global("X#XARomanceInactive","GLOBAL",1)
Global("X#XARomanceActive","GLOBAL",1)
Global("X#XARomanceActive","GLOBAL",0)
Global("KickedOut","LOCALS",0)
~ THEN BEGIN 4 // from:
  SAY #86956 /* ~While my stay with you was admittedly fruitless, it has, at least, been fun. I might even enjoy sharing another ill-fated adventure with you, should you ever require the use of my considerable talents.~ */
  IF ~  False()
~ THEN DO ~SetGlobal("KickedOut","LOCALS",1)
~ EXIT
  IF ~  !AreaCheck("FW5100")
!AreaCheck("FW5101")
!AreaCheck("FW5102")
!AreaCheck("FW5103")
!AreaCheck("FW5401")
!AreaCheck("FW5402")
!AreaCheck("FW5403")
!AreaCheck("FW5404")
!AreaCheck("FW5405")
!AreaCheck("FW1900")
!AreaCheck("FW1901")
!AreaCheck("FW1903")
!AreaCheck("FW3900")
!AreaCheck("FW3901")
!AreaCheck("FW4500")
!AreaCheck("FW5201")
!AreaCheck("FW3500")
!AreaCheck("FW1603")
!AreaCheck("FW4501")
!AreaCheck("FW3601")
!AreaCheck("FW1401")
!AreaCheck("FW2101")
!AreaCheck("FW1801")
!AreaCheck("FW1802")
!AreaCheck("FW1803")
!AreaCheck("FW1804")
!AreaCheck("FW2615")
!AreaCheck("FW2619")
!AreaCheck("FW5506")
!AreaCheck("FW0500")
!AreaCheck("FW0501")
!AreaCheck("FW0502")
!AreaCheck("FW0503")
!AreaCheck("FW0504")
!AreaCheck("FW0505")
!AreaCheck("FW0506")
!AreaCheck("FW0507")
!AreaCheck("FW0508")
!AreaCheck("FW0509")
!AreaCheck("FW0510")
!AreaCheck("FW0511")
!AreaCheck("FW0512")
!AreaCheck("FW0513")
!AreaCheck("FW0514")
!AreaCheck("FW0515")
!AreaCheck("FW0516")
!AreaCheck("FW1002")
!AreaCheck("FW1003")
!AreaCheck("FW1008")
!AreaCheck("FW1009")
!AreaCheck("FW1500")
!AreaCheck("FW2000")
!AreaCheck("FW2012")
!AreaCheck("FW1501")
!AreaCheck("FW1502")
!AreaCheck("FW1503")
!AreaCheck("FW1504")
!AreaCheck("FW1505")
!AreaCheck("FW0400")
!AreaCheck("FW0606")
!AreaCheck("FW0607")
!AreaCheck("FW0608")
!AreaCheck("FW1113")
!AreaCheck("FW1114")
!AreaCheck("FW1201")
!AreaCheck("FW1202")
!AreaCheck("FW1207")
!AreaCheck("FW0721")
!AreaCheck("FW0611")
!AreaCheck("FW0621")
!AreaCheck("FW0123")
!AreaCheck("FW0125")
!AreaCheck("FW0126")
!AreaCheck("FW0137")
!AreaCheck("FW0138")
!AreaCheck("FW0139")
!AreaCheck("FW0140")
!AreaCheck("FW0141")
!AreaCheck("FW0142")
!AreaCheck("FW0146")
!AreaCheck("FW0161")
!AreaCheck("FW0224")
!AreaCheck("FW0225")
!AreaCheck("FW0226")
~ THEN REPLY #113736 /* ~Xan, I do not want to part ways with you forever. Just wait for me here. I will return for you when I need your help again.~ */ GOTO 17
  IF ~  OR(84)
AreaCheck("FW5100")
AreaCheck("FW5101")
AreaCheck("FW5102")
AreaCheck("FW5103")
AreaCheck("FW5401")
AreaCheck("FW5402")
AreaCheck("FW5403")
AreaCheck("FW5404")
AreaCheck("FW5405")
AreaCheck("FW1900")
AreaCheck("FW1901")
AreaCheck("FW1903")
AreaCheck("FW3900")
AreaCheck("FW3901")
AreaCheck("FW4500")
AreaCheck("FW5201")
AreaCheck("FW3500")
AreaCheck("FW1603")
AreaCheck("FW4501")
AreaCheck("FW3601")
AreaCheck("FW1401")
AreaCheck("FW2101")
AreaCheck("FW1801")
AreaCheck("FW1802")
AreaCheck("FW1803")
AreaCheck("FW1804")
AreaCheck("FW2615")
AreaCheck("FW2619")
AreaCheck("FW5506")
AreaCheck("FW0500")
AreaCheck("FW0501")
AreaCheck("FW0502")
AreaCheck("FW0503")
AreaCheck("FW0504")
AreaCheck("FW0505")
AreaCheck("FW0506")
AreaCheck("FW0507")
AreaCheck("FW0508")
AreaCheck("FW0509")
AreaCheck("FW0510")
AreaCheck("FW0511")
AreaCheck("FW0512")
AreaCheck("FW0513")
AreaCheck("FW0514")
AreaCheck("FW0515")
AreaCheck("FW0516")
AreaCheck("FW1002")
AreaCheck("FW1003")
AreaCheck("FW1008")
AreaCheck("FW1009")
AreaCheck("FW1500")
AreaCheck("FW2000")
AreaCheck("FW2012")
AreaCheck("FW1501")
AreaCheck("FW1502")
AreaCheck("FW1503")
AreaCheck("FW1504")
AreaCheck("FW1505")
AreaCheck("FW0400")
AreaCheck("FW0606")
AreaCheck("FW0607")
AreaCheck("FW0608")
AreaCheck("FW1113")
AreaCheck("FW1114")
AreaCheck("FW1201")
AreaCheck("FW1202")
AreaCheck("FW1207")
AreaCheck("FW0721")
AreaCheck("FW0611")
AreaCheck("FW0621")
AreaCheck("FW0123")
AreaCheck("FW0125")
AreaCheck("FW0126")
AreaCheck("FW0137")
AreaCheck("FW0138")
AreaCheck("FW0139")
AreaCheck("FW0140")
AreaCheck("FW0141")
AreaCheck("FW0142")
AreaCheck("FW0146")
AreaCheck("FW0161")
AreaCheck("FW0224")
AreaCheck("FW0225")
AreaCheck("FW0226")
~ THEN REPLY #113736 /* ~Xan, I do not want to part ways with you forever. Just wait for me here. I will return for you when I need your help again.~ */ GOTO 19
  IF ~  Global("Drawbridge","GLOBAL",1)
~ THEN REPLY #113562 /* ~Our paths have to separate right now, but they will cross again one of these days. I might seek your help again soon. Let us set up a meeting place somewhere in the city of Baldur's Gate.~ */ GOTO 21
  IF ~~ THEN REPLY #113563 /* ~Our paths have to separate right now, but they will cross again one of these days. I might seek your help again soon. Let us set up a meeting place somewhere along the Sword Coast.~ */ GOTO 20
  IF ~~ THEN REPLY #113737 /* ~On second thought, Xan, I want you to stay with the group.~ */ GOTO 16
END

IF WEIGHT #6 /* Triggers after states #: 6 11 12 even though they appear after this state */
~StateCheck(Myself,STATE_CHARMED)
~ THEN BEGIN 5 // from:
  SAY #86957 /* ~If you are interested friend, I am a Greycloak from Evereksa.  It is my duty to watch over the political events of the human nations along our borders.  From what I have learned so far, there is some sort of mercantile organization known as the Iron Throne that has been trying to cause turmoil along the Sword Coast.  To what end I could not tell you, as I was captured before learning any more.~ */
  IF ~~ THEN EXIT
END

IF WEIGHT #0 ~  Global("X#XQXanFightsPC","GLOBAL",2)
~ THEN BEGIN 6 // from:
  SAY #101621 /* ~I... I thought that your foes had better luck, <CHARNAME>. But my doom is inevitable, no matter what side I choose.~ */
  IF ~  CheckStatGT(Player1,17,CHR)
OR(2)
Gender(Player1,MALE)
!Race(Player1,ELF)
~ THEN REPLY #101622 /* ~It does not have to be this way, Xan! You had sworn fealty to me, and you rebelled. Do you want to die a traitor and an oath-breaker, or do you want to live to redeem yourself?~ */ DO ~SetGlobal("X#XQXanFightsPC","GLOBAL",3)
~ GOTO 7
  IF ~  Gender(Player1,FEMALE)
Race(Player1,ELF)
~ THEN REPLY #101622 /* ~It does not have to be this way, Xan! You had sworn fealty to me, and you rebelled. Do you want to die a traitor and an oath-breaker, or do you want to live to redeem yourself?~ */ DO ~SetGlobal("X#XQXanFightsPC","GLOBAL",3)
~ GOTO 7
  IF ~  !CheckStatGT(Player1,17,CHR)
OR(2)
Gender(Player1,MALE)
!Race(Player1,ELF)
~ THEN REPLY #101622 /* ~It does not have to be this way, Xan! You had sworn fealty to me, and you rebelled. Do you want to die a traitor and an oath-breaker, or do you want to live to redeem yourself?~ */ DO ~SetGlobal("X#XQXanFightsPC","GLOBAL",3)
~ GOTO 8
  IF ~  CheckStatGT(Player1,17,CHR)
OR(2)
Gender(Player1,MALE)
!Race(Player1,ELF)
~ THEN REPLY #101623 /* ~Do you yield, elf?~ */ DO ~SetGlobal("X#XQXanFightsPC","GLOBAL",3)
~ GOTO 7
  IF ~  Gender(Player1,FEMALE)
Race(Player1,ELF)
~ THEN REPLY #101623 /* ~Do you yield, elf?~ */ DO ~SetGlobal("X#XQXanFightsPC","GLOBAL",3)
~ GOTO 7
  IF ~  !CheckStatGT(Player1,17,CHR)
OR(2)
Gender(Player1,MALE)
!Race(Player1,ELF)
~ THEN REPLY #101623 /* ~Do you yield, elf?~ */ DO ~SetGlobal("X#XQXanFightsPC","GLOBAL",3)
~ GOTO 9
  IF ~~ THEN REPLY #101624 /* ~Ha, this whining reminds me why I thought it would be so great to kill you in the first place!~ */ DO ~SetGlobal("X#XQXanFightsPC","GLOBAL",3)
~ GOTO 10
END

IF ~~ THEN BEGIN 7 // from: 6.4 6.3 6.1 6.0
  SAY #101625 /* ~Mercy, my <LADYLORD>. I shall not betray you again.~ */
  IF ~~ THEN DO ~RealSetGlobalTimer("X#XanBadOutcomeTimer","GLOBAL",EIGHTEEN_MINUTES)
ActionOverride("xan",JoinParty())
~ EXIT
END

IF ~~ THEN BEGIN 8 // from: 6.2
  SAY #101626 /* ~You disgraced yourself, my liege <LADYLORD>. The Seldarine will judge me.~ */
  IF ~~ THEN DO ~ActionOverride("xan",Kill(Myself))
~ EXIT
END

IF ~~ THEN BEGIN 9 // from: 6.5
  SAY #101627 /* ~*bitterly* No, I am not yielding. I am dying undefeated... Another man to throw away his life in a hopeless defense of the righteousness. How droll.~ */
  IF ~~ THEN DO ~ActionOverride("xan",Kill(Myself))
~ EXIT
END

IF ~~ THEN BEGIN 10 // from: 6.6
  SAY #101628 /* ~It matters not. I am dying undefeated... Another man to throw away his life in hopeless defense of the righteousness. How droll.~ */
  IF ~~ THEN DO ~ActionOverride("xan",Kill(Myself))
~ EXIT
END

IF WEIGHT #1 ~  Global("X#XQSlavesExchanged","GLOBAL",1)
~ THEN BEGIN 11 // from:
  SAY #101690 /* ~And now we... charge! Oh, Corellon, what am I saying? Are you with us, <CHARNAME>?~ */
  IF ~~ THEN REPLY #101691 /* ~Yes! I stand with you! Attack!~ */ EXTERN ~X#SKODD~ 14
  IF ~~ THEN REPLY #101692 /* ~You are on your own, noble fools!~ */ EXTERN ~X#SKODD~ 15
  IF ~~ THEN REPLY #101693 /* ~What a show! I will sit aside and enjoy the slaughter of fools. Always a welcome sight.~ */ EXTERN ~X#SKODD~ 15
  IF ~~ THEN REPLY #101694 /* ~What are you... oh, to hell with it. Charge!~ */ EXTERN ~X#SKODD~ 14
END

IF WEIGHT #2 ~  Global("X#XQFriendlyArmsAlone","GLOBAL",1)
~ THEN BEGIN 12 // from:
  SAY #101696 /* ~Ah, you are still alive! You will be pleased to know that Siene, Diala and Minuwiel accepted protection from a tribe of wild elves.~ */
  IF ~~ THEN GOTO 13
END

IF ~~ THEN BEGIN 13 // from: 12.0
  SAY #101697 /* ~*sigh* And here I was starting to hope that you decided to solve the iron shortage puzzle on your own, <CHARNAME>. But, alas, it seems that I have to continue walking the narrow chasm in your company, trying not to fall to my death.~ */
  IF ~~ THEN GOTO 14
END

IF ~~ THEN BEGIN 14 // from: 13.0
  SAY #101698 /* ~Although sometimes it seems almost... passable.~ */
  IF ~~ THEN DO ~SetGlobal("X#XQFriendlyArmsAlone","GLOBAL",2)
SetGlobal("X#XQXanMissionAccomplished","GLOBAL",2)
ActionOverride("xan",JoinParty())
ReputationInc(1)
RealSetGlobalTimer("X#XanGoodOutcomeTimer","GLOBAL",EIGHTEEN_MINUTES)
~ EXIT
END

IF WEIGHT #7 ~  Global("KickedOut","LOCALS",0)
!Global("X#XARomanceInactive","GLOBAL",1)
Global("X#XARomanceActive","GLOBAL",2)
~ THEN BEGIN 15 // from:
  SAY #111825 /* ~Just like that? Very... very well. You will not hear from me again.~ */
  IF ~~ THEN DO ~SetGlobal("KickedOut","LOCALS",1)
SetGlobal("X#XARomanceInactive","GLOBAL",1)
LeaveParty()
EscapeArea()
~ EXIT
END

IF ~~ THEN BEGIN 16 // from: 19.1 4.5
  SAY #86953 /* ~Then I shall do my best for you, though I am sure we both know that the worst is inevitable.~ */
  IF ~~ THEN DO ~SetGlobal("KickedOut","LOCALS",0)
JoinParty()
~ EXIT
END

IF ~~ THEN BEGIN 17 // from: 4.1
  SAY #113738 /* ~No doubt some untenable disaster will befall me the moment you walk away. Hopefully my bleached bones will remain here to tell the tale.~ */
  IF ~~ THEN DO ~SetGlobal("KickedOut","LOCALS",1)
~ EXIT
END

IF ~~ THEN BEGIN 18 // from: 19.0
  SAY #86955 /* ~This whole mission has been a dismal failure from the very start. Consider my debt repaid, friends, as I certainly do.~ */
  IF ~~ THEN DO ~LeaveParty()
EscapeArea()
~ EXIT
END

IF ~~ THEN BEGIN 19 // from: 4.2
  SAY #113739 /* ~The dismal failure of this whole operation is inevitable, whether I stay here or not. Yet wooing one's doom seems excessive, to say the least.~ */
  IF ~~ THEN REPLY #113571 /* ~Farewell then.~ */ GOTO 18
  IF ~~ THEN REPLY #113572 /* ~On second thought, I want you to stay with the group.~ */ GOTO 16
  IF ~  OR(59)
AreaCheck("FW5100")
AreaCheck("FW5101")
AreaCheck("FW5102")
AreaCheck("FW5103")
AreaCheck("FW5401")
AreaCheck("FW5402")
AreaCheck("FW5403")
AreaCheck("FW5404")
AreaCheck("FW5405")
AreaCheck("FW1900")
AreaCheck("FW1901")
AreaCheck("FW1903")
AreaCheck("FW3900")
AreaCheck("FW3901")
AreaCheck("FW4500")
AreaCheck("FW5201")
AreaCheck("FW3500")
AreaCheck("FW1603")
AreaCheck("FW4501")
AreaCheck("FW3601")
AreaCheck("FW1401")
AreaCheck("FW2101")
AreaCheck("FW1801")
AreaCheck("FW1802")
AreaCheck("FW1803")
AreaCheck("FW1804")
AreaCheck("FW2615")
AreaCheck("FW2619")
AreaCheck("FW5506")
AreaCheck("FW0500")
AreaCheck("FW0501")
AreaCheck("FW0502")
AreaCheck("FW0503")
AreaCheck("FW0504")
AreaCheck("FW0505")
AreaCheck("FW0506")
AreaCheck("FW0507")
AreaCheck("FW0508")
AreaCheck("FW0509")
AreaCheck("FW0510")
AreaCheck("FW0511")
AreaCheck("FW0512")
AreaCheck("FW0513")
AreaCheck("FW0514")
AreaCheck("FW0515")
AreaCheck("FW0516")
AreaCheck("FW1002")
AreaCheck("FW1003")
AreaCheck("FW1008")
AreaCheck("FW1009")
AreaCheck("FW1500")
AreaCheck("FW2000")
AreaCheck("FW2012")
AreaCheck("FW1501")
AreaCheck("FW1502")
AreaCheck("FW1503")
AreaCheck("FW1504")
AreaCheck("FW1505")
AreaCheck("FW0400")
~ THEN REPLY #113573 /* ~Oh, I trust in your outstanding skills of survival. When you are out of here, go to the safe haven of your choice and wait for me there.~ */ GOTO 20
  IF ~  OR(25)
AreaCheck("FW0606")
AreaCheck("FW0607")
AreaCheck("FW0608")
AreaCheck("FW1113")
AreaCheck("FW1114")
AreaCheck("FW1201")
AreaCheck("FW1202")
AreaCheck("FW1207")
AreaCheck("FW0721")
AreaCheck("FW0611")
AreaCheck("FW0621")
AreaCheck("FW0123")
AreaCheck("FW0125")
AreaCheck("FW0126")
AreaCheck("FW0137")
AreaCheck("FW0138")
AreaCheck("FW0139")
AreaCheck("FW0140")
AreaCheck("FW0141")
AreaCheck("FW0142")
AreaCheck("FW0146")
AreaCheck("FW0161")
AreaCheck("FW0224")
AreaCheck("FW0225")
AreaCheck("FW0226")
~ THEN REPLY #113573 /* ~Oh, I trust in your outstanding skills of survival. When you are out of here, go to the safe haven of your choice and wait for me there.~ */ GOTO 21
END

IF ~~ THEN BEGIN 20 // from: 19.2 4.4
  SAY #113740 /* ~I shall wait for you at the Friendly Arm Inn then. No doubt the place will burn to the ground the moment I set my foot inside.~ */
  IF ~~ THEN DO ~SetGlobal("KickedOut","LOCALS",1)
EscapeAreaMove("FW2302",790,660,13)
~ EXIT
END

IF ~~ THEN BEGIN 21 // from: 19.3 4.3
  SAY #113741 /* ~I will go to the Elfsong tavern then. By all odds it will be washed away by a flood, or destroyed by an earthquake.~ */
  IF ~~ THEN DO ~SetGlobal("KickedOut","LOCALS",1)
EscapeAreaMove("FW0705",403,864,12)
~ EXIT
END
