IF
    Global("OHH_HexxatSummoned","GLOBAL",1)
THEN
    RESPONSE #100
        StartDialogueNoSet(Player1)
END

IF
    PartyHasItem("ohhcloak")  // Cloak of Dragomir
    AreaCheck("AR4000")  // Spirit Heads
    Global("OHH_coat_check","LOCALS",0)
THEN
    RESPONSE #100
        SetGlobal("OHH_coat_check","LOCALS",1)
END

IF
    !PartyHasItem("ohhcloak")  // Cloak of Dragomir
    AreaCheck("AR4000")  // Spirit Heads
    Global("OHH_coat_check","LOCALS",0)
THEN
    RESPONSE #100
        SetGlobal("OHH_coat_check","LOCALS",1)
        GiveItemCreate("ohhcloak",Myself,0,0,0)  // Cloak of Dragomir
END

IF
    HasItemEquiped("ohhexam4",Myself)  // Hexxat's Amulet
    Global("OHH_RESTORE_HEXXAT","GLOBAL",1)
    InParty(Myself)
THEN
    RESPONSE #100
        ActionOverride(Player1,TransformItem("ohhcask2","ohhcask"))  // Hexxat's Coffin
        ActionOverride(Player2,TransformItem("ohhcask2","ohhcask"))  // Hexxat's Coffin
        ActionOverride(Player3,TransformItem("ohhcask2","ohhcask"))  // Hexxat's Coffin
        ActionOverride(Player4,TransformItem("ohhcask2","ohhcask"))  // Hexxat's Coffin
        ActionOverride(Player5,TransformItem("ohhcask2","ohhcask"))  // Hexxat's Coffin
        ActionOverride(Player6,TransformItem("ohhcask2","ohhcask"))  // Hexxat's Coffin
        TransformItem("ohhexam4","ohhexam1")  // Hexxat's Amulet
        CreateVisualEffectObject("SPDISPMA",Myself)
        PlaySound("mstchng")
        SetGlobal("OHH_RESTORE_HEXXAT","GLOBAL",0)
        JoinParty()
END

IF
    HasItemEquiped("ohhexam4",Myself)  // Hexxat's Amulet
    !Global("OHH_RESTORE_HEXXAT","GLOBAL",1)
    Range([PC],3)
    InParty(Myself)
THEN
    RESPONSE #100
        ActionOverride(Player1,TransformItem("ohhcask","ohhcask2"))  // Empty Casket
        ActionOverride(Player2,TransformItem("ohhcask","ohhcask2"))  // Empty Casket
        ActionOverride(Player3,TransformItem("ohhcask","ohhcask2"))  // Empty Casket
        ActionOverride(Player4,TransformItem("ohhcask","ohhcask2"))  // Empty Casket
        ActionOverride(Player5,TransformItem("ohhcask","ohhcask2"))  // Empty Casket
        ActionOverride(Player6,TransformItem("ohhcask","ohhcask2"))  // Empty Casket
        SetGlobalTimer("OHH_RESTORE","GLOBAL",ONE_HOUR)
        Kill(Myself)
END

IF
    OR(2)
        HP(Myself,1)
        StateCheck(Myself,STATE_REALLY_DEAD)
    HasItemEquiped("ohhexam1",Myself)  // Hexxat's Amulet
THEN
    RESPONSE #100
        TransformItem("ohhexam1","ohhexam4")  // Hexxat's Amulet
        DropInventory()
END

IF
    OR(2)
        HP(Myself,1)
        StateCheck(Myself,STATE_REALLY_DEAD)
    HasItemEquiped("ohhexam2",Myself)  // Hexxat's Amulet
THEN
    RESPONSE #100
        TransformItem("ohhexam2","ohhexam4")  // Hexxat's Amulet
        DropInventory()
END

IF
    Delay(3)
    OR(3)
        HP(Myself,1)
        StateCheck(Myself,STATE_REALLY_DEAD)
        !GlobalTimerExpired("OHH_IT_BURNS","LOCALS")
    HasItemEquiped("ohhexam3",Myself)  // Hexxat's Amulet
THEN
    RESPONSE #100
        CreateVisualEffectObject("sppfirri",Myself)
        PlaySound("EFF_M108")
        Continue()
END

IF
    OR(3)
        HP(Myself,1)
        StateCheck(Myself,STATE_REALLY_DEAD)
        GlobalTimerExpired("OHH_IT_BURNS","LOCALS")
    HasItemEquiped("ohhexam3",Myself)  // Hexxat's Amulet
THEN
    RESPONSE #100
        TransformItem("ohhexam3","ohhexam4")  // Hexxat's Amulet
END

IF
    HasItemEquiped("ohhexam1",Myself)  // Hexxat's Amulet
    HasItemEquiped("ohhcloak",Myself)  // Cloak of Dragomir
THEN
    RESPONSE #100
        TransformItem("ohhexam1","ohhexam2")  // Hexxat's Amulet
END

IF
    HasItemEquiped("ohhexam3",Myself)  // Hexxat's Amulet
    HasItemEquiped("ohhcloak",Myself)  // Cloak of Dragomir
    !AreaCheck("oh5500")  // Dorn - Lunia
THEN
    RESPONSE #100
        TransformItem("ohhexam3","ohhexam2")  // Hexxat's Amulet
END

IF
    HasItemEquiped("ohhexam2",Myself)  // Hexxat's Amulet
    !HasItemEquiped("ohhcloak",Myself)  // Cloak of Dragomir
THEN
    RESPONSE #100
        TransformItem("ohhexam2","ohhexam1")  // Hexxat's Amulet
END

IF
    HasItemEquiped("ohhexam1",Myself)  // Hexxat's Amulet
    !HasItemEquiped("ohhcloak",Myself)  // Cloak of Dragomir
    !HasItemEquiped("ohhkork",Myself)  // Korkorran's Cowl
    AreaType(OUTDOOR)
    !AreaCheck("ar1400")  // Shadow Temple Land (restored, Ranger)
    TimeGT(DAWN_START)
    TimeLT(DUSK_END)
THEN
    RESPONSE #100
        SetGlobalTimer("OHH_IT_BURNS","LOCALS",THREE_ROUNDS)
        TransformItem("ohhexam1","ohhexam3")  // Hexxat's Amulet
        CreateVisualEffectObject("SPSMKJET",Myself)
END

IF
    HasItemEquiped("ohhexam4",Myself)  // Hexxat's Amulet
    !Global("OHH_RESTORE_HEXXAT","GLOBAL",1)
    GlobalTimerNotExpired("OHH_RESTORE","GLOBAL")
THEN
    RESPONSE #100
        DisplayStringHead(Player1,98353)  // The spell fizzles and Hexxat reverts to her mist form. It appears you will have to wait for her to regenerate in her casket.
        Continue()
END

IF
    HasItemEquiped("ohhexam4",Myself)  // Hexxat's Amulet
    !Global("OHH_RESTORE_HEXXAT","GLOBAL",1)
    !Range(Player1,3)
    InParty(Myself)
THEN
    RESPONSE #100
        MoveToObjectNoInterrupt(Player1)
END

IF
    HasItemEquiped("ohhexam4",Myself)  // Hexxat's Amulet
    !InPartyAllowDead(Myself)
THEN
    RESPONSE #100
        SetGlobal("OHH_hexxatfightdead","GLOBAL",1)
        ActionOverride(Player1,DestroyItem("ohhbag"))  // Dragomir's Respite
        ActionOverride(Player2,DestroyItem("ohhbag"))  // Dragomir's Respite
        ActionOverride(Player3,DestroyItem("ohhbag"))  // Dragomir's Respite
        ActionOverride(Player4,DestroyItem("ohhbag"))  // Dragomir's Respite
        ActionOverride(Player5,DestroyItem("ohhbag"))  // Dragomir's Respite
        ActionOverride(Player6,DestroyItem("ohhbag"))  // Dragomir's Respite
        EscapeAreaDestroy(3)
END

IF
    Global("ohh_dom","LOCALS",0)
    LevelGT(Myself,13)
THEN
    RESPONSE #100
        AddSpecialAbility("spin883")  // Domination
        SetGlobal("ohh_dom","LOCALS",1)
END

IF
    Global("ohh_dom","LOCALS",1)
    LevelGT(Myself,23)
THEN
    RESPONSE #100
        AddSpecialAbility("spin883")  // Domination
        SetGlobal("ohh_dom","LOCALS",2)
END

IF
    HasItemEquiped("ohhexam1",Myself)  // Hexxat's Amulet
    AreaCheck("oh5500")  // Dorn - Lunia
THEN
    RESPONSE #100
        SetGlobalTimer("OHH_IT_BURNS","LOCALS",THREE_ROUNDS)
        TransformItem("ohhexam1","ohhexam3")  // Hexxat's Amulet
        CreateVisualEffectObject("SPSMKJET",Myself)
END

IF
    HasItemEquiped("ohhexam2",Myself)  // Hexxat's Amulet
    AreaCheck("oh5500")  // Dorn - Lunia
THEN
    RESPONSE #100
        TransformItem("ohhexam2","ohhexam5")  // Hexxat's Amulet
END

IF
    HasItemEquiped("ohhexam3",Myself)  // Hexxat's Amulet
    HasItemEquiped("ohhcloak",Myself)  // Cloak of Dragomir
    AreaCheck("oh5500")  // Dorn - Lunia
THEN
    RESPONSE #100
        TransformItem("ohhexam3","ohhexam5")  // Hexxat's Amulet
END

IF
    HasItemEquiped("ohhexam5",Myself)  // Hexxat's Amulet
    !HasItemEquiped("ohhcloak",Myself)  // Cloak of Dragomir
    AreaCheck("oh5500")  // Dorn - Lunia
THEN
    RESPONSE #100
        SetGlobalTimer("OHH_IT_BURNS","LOCALS",THREE_ROUNDS)
        TransformItem("ohhexam5","ohhexam3")  // Hexxat's Amulet
        CreateVisualEffectObject("SPSMKJET",Myself)
END

IF
    HasItemEquiped("ohhexam5",Myself)  // Hexxat's Amulet
    !AreaCheck("oh5500")  // Dorn - Lunia
THEN
    RESPONSE #100
        TransformItem("ohhexam5","ohhexam1")  // Hexxat's Amulet
END

IF
    HasItem("ohhprisn",Myself)  // Casque of Entrapment
    InParty(Myself)
    Global("OHH_cabrina25","GLOBAL",0)
    !See("ohhcab25")  // Cabrina
THEN
    RESPONSE #100
        SetGlobal("OHH_cabrina25","GLOBAL",1)
        Dialogue([PC])
END

IF
    IfValidForPartyDialog(Myself)
    InParty(Myself)
    Dead("ohhcab25")  // Cabrina
    Global("OHH_cabrinadead","GLOBAL",0)
THEN
    RESPONSE #100
        SetGlobal("OHH_cabrinadead","GLOBAL",1)
END

IF
    IfValidForPartyDialog(Myself)
    InParty(Myself)
    Global("OHH_cabrinadead","GLOBAL",1)
THEN
    RESPONSE #100
        Dialogue(Player1)
END

IF
    InParty(Myself)
    Global("OHH_phreya","OH7300",2)  // Hexxat - Completed Maze (Korkorran)
    !See("ohhphrey")  // Phreya
THEN
    RESPONSE #100
        Wait(1)
        Dialogue(Player1)
END

IF
    InParty(Myself)
    !See("ohhphrey")  // Phreya
    Global("OHH_phreya","OH7300",6)  // Hexxat - Completed Maze (Korkorran)
    Global("OHH_phreyatookcloak","OH7300",1)  // Hexxat - Completed Maze (Korkorran)
THEN
    RESPONSE #100
        Wait(1)
        Dialogue(Player1)
END

IF
    InParty(Myself)
    !See("ohhphrey")  // Phreya
    Global("OHH_break","OH7300",0)  // Hexxat - Completed Maze (Korkorran)
    Global("OHH_phreya","OH7300",12)  // Hexxat - Completed Maze (Korkorran)
THEN
    RESPONSE #100
        Wait(1)
        Dialogue(Player1)
END

IF
    InParty(Myself)
    Dead("ohhphrey")  // Phreya
    Dead("ohhdecoy")  // Lich
    GlobalGT("OHH_phreyatookcloak","OH7300",1)  // Hexxat - Completed Maze (Korkorran)
    Global("OHH_cloakretrieval","LOCALS",0)
THEN
    RESPONSE #100
        PickUpItem("ohhcloak")  // Cloak of Dragomir
        Continue()
END

IF
    InParty(Myself)
    Dead("ohhphrey")  // Phreya
    Dead("ohhdecoy")  // Lich
    GlobalGT("OHH_phreyatookcloak","OH7300",1)  // Hexxat - Completed Maze (Korkorran)
    PartyHasItem("ohhcloak")  // Cloak of Dragomir
    Global("OHH_cloakretrieval","LOCALS",0)
THEN
    RESPONSE #100
        SetGlobal("OHH_cloakretrieval","LOCALS",1)
        DisplayStringHead(Myself,100208)  // Hexxat retrieves her cloak.
END

IF
    Global("HexxatRomanceActive","GLOBAL",2)
    Global("HexxatToBLovetalks","GLOBAL",0)
    Gender(Player1,FEMALE)
THEN
    RESPONSE #100
        SetGlobal("HexxatToBLovetalks","GLOBAL",1)
        RealSetGlobalTimer("HexxatToBLovetalksTimer","GLOBAL",EIGHTEEN_HOURS)
END

IF
    Global("HexxatRomanceActive","GLOBAL",2)
    IfValidForPartyDialog(Player1)
    Global("TalkedSarMel01","GLOBAL",1)
    IfValidForPartyDialog(Myself)
    CombatCounter(0)
    !See([ENEMY])
    !AreaType(DUNGEON)
    OR(5)
        Global("HexxatToBLovetalks","GLOBAL",2)
        Global("HexxatToBLovetalks","GLOBAL",4)
        Global("HexxatToBLovetalks","GLOBAL",6)
        Global("HexxatToBLovetalks","GLOBAL",8)
        Global("OHH_saradushtalk","GLOBAL",1)
THEN
    RESPONSE #100
        PlaySong(90)
        Dialogue(Player1)
END

IF
    Global("HexxatRomanceActive","GLOBAL",2)
    IfValidForPartyDialog(Player1)
    IfValidForPartyDialog(Myself)
    CombatCounter(0)
    !See([ENEMY])
    !AreaType(DUNGEON)
    RealGlobalTimerExpired("HexxatToBLovetalksTimer","GLOBAL")
    OR(4)
        Global("HexxatToBLovetalks","GLOBAL",1)
        Global("HexxatToBLovetalks","GLOBAL",3)
        Global("HexxatToBLovetalks","GLOBAL",5)
        Global("HexxatToBLovetalks","GLOBAL",7)
THEN
    RESPONSE #100
        IncrementGlobal("HexxatToBLovetalks","GLOBAL",1)
END

IF
    Global("HexxatRomanceActive","GLOBAL",2)
    Global("SaradushSacked","GLOBAL",1)
    Global("OHH_saradushtalk","GLOBAL",0)
    IfValidForPartyDialog(Myself)
    IfValidForPartyDialog(Player1)
    CombatCounter(0)
    !See([ENEMY])
    !AreaType(DUNGEON)
    PartyRested()
THEN
    RESPONSE #100
        SetGlobal("OHH_saradushtalk","GLOBAL",1)
END

IF
    InParty(Myself)
    Global("OHH_aeriefight","GLOBAL",1)
THEN
    RESPONSE #100
        SetInterrupt(FALSE)
        LeaveParty()
        ChangeAIScript("",DEFAULT)
        ChangeAIScript("useitem",GENERAL)
        ChangeAIScript("ohhaeri2",SPECIFICS)
        SetLeavePartyDialogFile()
        ActionOverride("aerie",LeaveParty())
        ActionOverride("aerie",ChangeAIScript("",DEFAULT))
        ActionOverride("aerie",ChangeAIScript("useitem",GENERAL))
        ActionOverride("aerie",ChangeAIScript("ohhaeri",SPECIFICS))
        ActionOverride("aerie",SetLeavePartyDialogFile())
        SetInterrupt(TRUE)
END

IF
    IfValidForPartyDialog(Myself)
    Range("Door16",20)
    OpenState("Door16",FALSE)
    CombatCounter(0)
    Global("OHH_doorpuzzle","OH7300",0)  // Hexxat - Completed Maze (Korkorran)
THEN
    RESPONSE #100
        SetGlobal("OHH_doorpuzzle","OH7300",1)  // Hexxat - Completed Maze (Korkorran)
END

IF
    IfValidForPartyDialog(Myself)
    Global("OHH_doorpuzzle","OH7300",1)  // Hexxat - Completed Maze (Korkorran)
THEN
    RESPONSE #100
        AddJournalEntry(86487,INFO)  // Whoever designed this maze took great pains to ensure no one could travel easily through it. Opening one door closes another... I am sure there is a system at work, but it will take some effort to determine what that is.
        StartDialogueNoSet(Player1)
END

IF
    IfValidForPartyDialog(Myself)
    Range("Door16",10)
    OpenState("Door16",TRUE)
    OR(2)
        !IfValidForPartyDialog("dorn")  // Dorn
        !Range("dorn",30)  // Dorn
    CombatCounter(0)
    Global("OHH_necroticcomment","OH7300",0)  // Hexxat - Completed Maze (Korkorran)
THEN
    RESPONSE #100
        SetGlobal("OHH_necroticcomment","OH7300",1)  // Hexxat - Completed Maze (Korkorran)
END

IF
    IfValidForPartyDialog(Myself)
    Global("OHH_necroticcomment","OH7300",1)  // Hexxat - Completed Maze (Korkorran)
THEN
    RESPONSE #100
        StartDialogueNoSet(Player1)
END

IF
    IfValidForPartyDialog(Myself)
    Global("OHH_cabkorkleave","GLOBAL",1)
    Global("OHH_finaljournal","GLOBAL",0)
THEN
    RESPONSE #100
        SetGlobal("OHH_finaljournal","GLOBAL",1)
        AddJournalEntry(100270,INFO)  // The mystery of L has been solved. The mighty lich Larloch was willing to fulfill his promise to Hexxat and restore her mortality—but doing so would have killed her instantly. I was able to convince her a vampire's life was worth living—though if she changes her mind, I will have a difficult decision before me.
END

IF
    !InParty(Myself)
    CheckSpellState(Myself,STORY_MODE)
THEN
    RESPONSE #100
        ReallyForceSpellDeadRES("OHSMODE3",Myself)  // No such index
        Continue()
END

