/* Activate Dynaheir Firewine */
IF %BGT_VAR%
AreaCheck("%FirewineBridge%")
Global("X#DYINT1","GLOBAL",0)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#DYINT1","GLOBAL",1)
END

/* Initiate Dynaheir Firewine */
IF %BGT_VAR%
Global("X#DYINT1","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
PlaySong(0)
PlaySound("dynah99")
StartDialogueNoSet(Player1)
END

/* Activate Dynaheir, Shandalar's Girls Dead */
IF %BGT_VAR%
AreaCheck("%CentralBaldursGate_OberonsEstate_L3%")
Global("X#DSGD","GLOBAL",0)
OR(3)
Dead("delorna")
Dead("ithmeera")
Dead("helshara")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
PlaySong(0)
PlaySound("dynah99")
SetGlobal("X#DSGD","GLOBAL",1)
Dialogue(Myself)
END

/* Initiate Dynaheir, Shandalar's Girls Dead */
IF %BGT_VAR%
Global("X#DSGD","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
PlaySong(0)
PlaySound("dynah99")
Dialogue(Myself)
END

/* Setup: Dynaheir, Back At Candlekeep */
IF %BGT_VAR%
Global("Chapter","GLOBAL",%tutu_chapter_6%)
AreaCheck("%Candlekeep%")
Global("X#DBAC","GLOBAL",0)
PartyHasItem("%tutu_var%BOOK68")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#DBAC","GLOBAL",1)
END

/* Activate got rid of book */
IF %BGT_VAR%
Global("X#DBAC","GLOBAL",1)
!PartyHasItem("%tutu_var%BOOK68")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#DBAC","GLOBAL",2)
END

/* Initiate got rid of book */
IF %BGT_VAR%
Global("X#DBAC","GLOBAL",2)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
PlaySong(0)
PlaySound("dynah99")
StartDialogueNoSet(Player1)
END

/* Dynaheir, Gazib Fled, Oopah Left */
IF %BGT_VAR%
AreaCheck("%NashkelCarnival%")
Global("X#DGFOL","GLOBAL",0)
Dead("Oopah2")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#DGFOL","GLOBAL",1)
END

/* Initiate Dynaheir, Gazib Fled, Oopah Left */
IF %BGT_VAR%
Global("X#DGFOL","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
Dialogue(Myself)
END

/* EdwinKilledBosses */
IF %BGT_VAR%
Global("X#EdwinBetrayRW","GLOBAL",1)
AreaCheck("%SpiderWood%")
InParty("edwin")
InMyArea("edwin")
!StateCheck("edwin",CD_STATE_NOTVALID)
Dead("brendan")
Dead("lasala")
Dead("diana")
Dead("denak")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#EdwinBetrayRW","GLOBAL",3)
END

/* EdwinKilledBosses */
IF %BGT_VAR%
Global("X#EdwinBetrayRW","GLOBAL",3)
InParty("edwin")
InMyArea("edwin")
!StateCheck("edwin",CD_STATE_NOTVALID)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
ActionOverride("edwin",StartDialogueNoSet(Player1))
END

/* For Ajantis */
IF %BGT_VAR%
AreaCheck("%GnollStronghold%")
!InParty(Myself)
Global("X#PartyAttackedDynaheir","GLOBAL",0)
OR(2)
!GlobalTimerExpired("edwin","GLOBAL") //Edwin help promise = yes
Global("FindDynaheir","GLOBAL",1) // " " " " 
AttackedBy([GOODCUTOFF],DEFAULT)
THEN
RESPONSE #100
SetGlobal("X#PartyAttackedDynaheir","GLOBAL",1)
END

/* Activate Stealing in Beregost */
IF %BGT_VAR%
AreaCheck("%Beregost_House09%")
Global("X#DYRobb1","GLOBAL",0)
PartyHasItem("%tutu_var%MISC16")
PartyHasItem("%tutu_var%MISC17")
PartyHasItem("%tutu_var%MISC18")
PartyHasItem("%tutu_var%MISC19")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#DYRobb1","GLOBAL",1)
StartDialogueNoSet(Player1)
END

/* Initiate Stealing in Beregost */
IF %BGT_VAR%
Global("X#DYRobb1","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
StartDialogueNoSet(Player1)
END

/* Helped Gallor */
IF %BGT_VAR%
  Global("X#DynaMinscHelpGallor","GLOBAL",1) //auto-set from interjection
  InParty(Myself) //No "CombatCounter(0)" here!
  !StateCheck(Myself,CD_STATE_NOTVALID)
  InMyArea(Player1)
  !StateCheck(Player1,CD_STATE_NOTVALID)
THEN
  RESPONSE #100
    SetGlobal("X#DynaMinscHelpGallor","GLOBAL",2)
    SetLeavePartyDialogFile() 
    ChangeAIScript("",DEFAULT) 
    LeaveParty() 
    Enemy()
END

IF %BGT_VAR%
  Global("X#DynaNoMinscHelpGallor","GLOBAL",1) //auto-set from interjection
  InParty(Myself) //No "CombatCounter(0)" here!
  !StateCheck(Myself,CD_STATE_NOTVALID)
  InMyArea(Player1)
  !StateCheck(Player1,CD_STATE_NOTVALID)
THEN
  RESPONSE #100
    SetGlobal("X#DynaMinscHelpGallor","GLOBAL",2)
    SetLeavePartyDialogFile() 
    ChangeAIScript("",DEFAULT) 
    LeaveParty() 
    Enemy()
END
