/* Activate healing Beador */
IF %BGT_VAR%
AreaCheck("%CloakwoodWyverns%")
Global("X#JaheiraQuest","GLOBAL",3)
Global("X#JaheiraHealsB","GLOBAL",0)
Dead("jadruid8a")
Dead("jadruid8b")
Dead("jadruid6a")
Dead("jadruid6b")
Dead("jadruid6")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
!Dead("beador")
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#JaheiraHealsB","GLOBAL",1)
END

/* Initiate block */
IF %BGT_VAR%
Global("X#JaheiraHealsB","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
StartDialogueNoSet(Player1)
END

/* Intro of Cutscene with Healing Beador */
IF %BGT_VAR%
Global("X#JaheiraHealsB","GLOBAL",2)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
ClearAllActions()
SetGlobal("X#JaheiraHealsB","GLOBAL",3)
StartCutSceneMode()
StartCutScene("X#JABE1")
END

/* If Beador Died in Combat */
IF %BGT_VAR%
Global("X#JaheiraQuest","GLOBAL",3)
Global("X#JQBeadorDead","GLOBAL",0)
AreaCheck("%CloakwoodWyverns%")
Dead("beador")
Dead("jadruid8a")
Dead("jadruid8b")
Dead("jadruid6a")
Dead("jadruid6b")
Dead("jadruid6")
!See([ENEMY])
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#JQBeadorDead","GLOBAL",1)
END

/* Initiate block */
IF %BGT_VAR%
Global("X#JQBeadorDead","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
StartDialogueNoSet(Player1)
END

/* one of the two following happen immediately: */
/* Activate Beador's Talk Start, Jaheira no Faldorn  */
IF %BGT_VAR%
See("beador")
Global("X#BeadorStarts","GLOBAL",0)
Global("X#JaheiraQuestFaldorn","GLOBAL",0)
Global("X#JaheiraQuest","GLOBAL",2)
!InParty("faldorn")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#BeadorStarts","GLOBAL",1)
END

/* Initiate Beador's Talk Start, Jaheira no Faldorn  */
IF %BGT_VAR%
Global("X#BeadorStarts","GLOBAL",1)
InParty(Myself)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
ActionOverride("beador",StartDialogNoSet(Player1))
END

/* Activate Beador's Talk Start, Jaheira AND Faldorn  */
IF %BGT_VAR%
See("beador")
Global("X#BeadorStarts","GLOBAL",0)
Global("X#JaheiraQuestFaldorn","GLOBAL",0)
Global("X#JaheiraQuest","GLOBAL",2)
InParty("faldorn")
InParty("jaheira")
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
See("jaheira")
!StateCheck("jaheira",CD_STATE_NOTVALID)
See("faldorn")
!StateCheck("faldorn",CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#JaheiraQuestFaldorn","GLOBAL",1)
END

/* Initiate Beador's Talk Start, Jaheira AND Faldorn  */
IF %BGT_VAR%
Global("X#JaheiraQuestFaldorn","GLOBAL",1)
InParty(Myself)
InParty("faldorn")
InMyArea("faldorn")
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck("faldorn",CD_STATE_NOTVALID)
THEN
RESPONSE #100
ActionOverride("beador",StartDialogNoSet(Player1))
END

/* Quest Resolved prompt activate */
IF %BGT_VAR%
Global("X#JaheiraQuest","GLOBAL",6)
OR(2)
AreaCheck("%CloakwoodDruids%")
AreaCheck("%CloakwoodDruids_Treehouse_L1%")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#JaheiraQuest","GLOBAL",7)
END

/* Quest Resolved prompt initiate */
IF %BGT_VAR%
Global("X#JaheiraQuest","GLOBAL",7)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
StartDialogueNoSet(Player1)
END

/* Andarthe Surrenders but killed */
IF %BGT_VAR%
Global("X#AndSurrender","GLOBAL",3)
Dead("andarthe")
AreaCheck("%CloakwoodDruids%")
InParty(Myself)
THEN
RESPONSE #100
SetGlobal("X#AndSurrender","GLOBAL",6)
StartDialogueNoSet(Player1)
END

/* creates Andarthe */
IF %BGT_VAR%
AreaCheck("%CloakwoodDruids%")
Global("X#JaheiraQuest","GLOBAL",3)
Global("X#AndartheExists","%CloakwoodDruids%",0)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#AndartheExists","%CloakwoodDruids%",1)
CreateCreature("X#ANDART",[995.2306],3)
CreateCreature("X#SHDR8A",[1066.2261],3)
END

/* Creates Maretha if Andarthe Surrenders or is Killed */
IF %BGT_VAR%
OR(2)
Dead("andarthe")
GlobalGT("X#AndSurrender","GLOBAL",6)
InParty(Myself)
AreaCheck("%CloakwoodDruids_Treehouse_L1%")
Global("X#JaheiraQuest","GLOBAL",4)
Global("X#MarethaExist","%CloakwoodDruids_Treehouse_L1%",0)
THEN
RESPONSE #100
SetGlobal("X#MarethaExist","%CloakwoodDruids_Treehouse_L1%",1)
CreateCreature("X#MARETH",[369.273],3)
END