// ****************************
//                            *
//   Arath start sequence     *
//                            *
// ****************************

IF
    Global("LK#ArathCCFight","AR0406",1)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathCCFight","AR0406",2)
    Wait(10)
    Deactivate(Myself)
END

IF
    !InParty(Myself)
    Global("LK#ArathCCTalk","GLOBAL",1)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathCCTalk","GLOBAL",2)
    JumpToPoint([1346.1500])
    MoveToObject(Player1)
    Dialogue(Player1)
END

IF
    !InParty(Myself)
    Global("LK#ArathMet","AR0406",1)
    Global("HendakReleased","AR0406",4)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathMet","AR0406",2)
END


// When in party
IF
    InParty(Myself)
    !StateCheck("Arath",CD_STATE_NOTVALID)
//    Global("LK#ArathCCFight","AR0406",2)
    Global("HendakReleased","AR0406",3)
    Global("LK#ArathCCSlavers","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathCCSlavers","GLOBAL",1)
END

IF
    InParty(Myself)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    Global("LK#ArathCCSlavers","GLOBAL",1)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END

// AR0404; triggered in front of Slaver Stockade door
IF
    InParty(Myself)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    Global("LK#ArathCCTrig","AR0404",1)
    Global("LK#ArathJoinDoor","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathJoinDoor","GLOBAL",1)
END

IF
    InParty(Myself)
    AreaCheck("AR0405")
    !StateCheck("Arath",CD_STATE_NOTVALID)
    Global("LK#ArathJoinDoor","GLOBAL",1)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathJoinDoor","GLOBAL",2)
END

IF
    InParty(Myself)
    AreaCheck("AR0404")
    !See([ENEMY])
    !StateCheck("Arath",CD_STATE_NOTVALID)
    Global("LK#ArathJoinDoor","GLOBAL",1)
THEN
  RESPONSE #100
    Dialogue(Player1)
END

// AR0405; in top right room of slaver stockade
IF
    InParty(Myself)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    Global("LK#ArathCCTrig2","AR0405",1)
    Global("LK#ArathSlavers","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathSlavers","GLOBAL",1)
END

IF
    InParty(Myself)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    Global("LK#ArathSlavers","GLOBAL",1)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END

// after telling Hendak
IF
    InParty(Myself)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    Global("HendakReleased","AR0406",4)
    Global("LK#ArathJoinTalk","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathJoinTalk","GLOBAL",1)
END

IF
    InParty(Myself)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    Global("LK#ArathJoinTalk","GLOBAL",1)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// ****************************
//                            *
// Arath non-romantic content *
//                            *
// ****************************

// Scenery: Underdark
IF
    InParty(Myself)
    See(Player1)
    AreaCheck("AR2200")
    Global("LK#ArathUnderdark","GLOBAL",0)
THEN
  RESPONSE #50
    SetGlobal("LK#ArathUnderdark","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathUnderdarkTimer","GLOBAL",600)
  RESPONSE #50
    SetGlobal("LK#ArathUnderdark","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathUnderdarkTimer","GLOBAL",1200)
END

IF
    InParty(Myself)
    See(Player1)
    Global("LK#ArathUnderdark","GLOBAL",1)
    RealGlobalTimerExpired("LK#ArathUnderdarkTimer","GLOBAL")
THEN
  RESPONSE #100
    SetGlobal("LK#ArathUnderdark","GLOBAL",2)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathUnderdark","GLOBAL",2)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// Scenery: North Forest
IF
    InParty(Myself)
    See(Player1)
    OR(2)
      AreaCheck("AR1700")
      AreaCheck("AR1800")
    Global("LK#ArathNorthForest","GLOBAL",0)
THEN
  RESPONSE #50
    SetGlobal("LK#ArathNorthForest","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathNorthForestTimer","GLOBAL",30)
  RESPONSE #50
    SetGlobal("LK#ArathNorthForest","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathNorthForestTimer","GLOBAL",120)
END

IF
    InParty(Myself)
    See(Player1)
    Global("LK#ArathNorthForest","GLOBAL",1)
    RealGlobalTimerExpired("LK#ArathNorthForestTimer","GLOBAL")
THEN
  RESPONSE #100
    SetGlobal("LK#ArathNorthForest","GLOBAL",2)
END

IF
    InParty(Myself)
    See(Player1)
    OR(2)
      AreaCheck("AR1700")
      AreaCheck("AR1800")
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathNorthForest","GLOBAL",2)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END

// Plot: Killing the dragon in Suldannessellar
IF
    InParty(Myself)
    See(Player1)
    Dead("dragblac")
    Global("LK#ArathSuldanessellar","GLOBAL",0)
THEN
  RESPONSE #50
    SetGlobal("LK#ArathSuldanessellar","GLOBAL",1)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathSuldanessellar","GLOBAL",1)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END

// Plot: Killing Firkraag
IF
    InParty(Myself)
    See(Player1)
    Dead("firkra02")
    Global("LK#ArathFirkraag","GLOBAL",0)
THEN
  RESPONSE #50
    SetGlobal("LK#ArathFirkraag","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathFirkraagTimer","GLOBAL",60)
  RESPONSE #50
    SetGlobal("LK#ArathFirkraag","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathFirkraagTimer","GLOBAL",120)
END

IF
    InParty(Myself)
    See(Player1)
    Global("LK#ArathFirkraag","GLOBAL",1)
    RealGlobalTimerExpired("LK#ArathFirkraagTimer","GLOBAL")
THEN
  RESPONSE #100
    SetGlobal("LK#ArathFirkraag","GLOBAL",2)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathFirkraag","GLOBAL",2)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// Scenery: On Being Raised
IF
    InParty(Myself)
    See(Player1)
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathRaised","GLOBAL",1)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathRaised","GLOBAL",2)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathRaised","GLOBAL",2)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// Scenery: On Being Raised... Again
IF
    InParty(Myself)
    See(Player1)
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathRaised","GLOBAL",3)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathRaised","GLOBAL",4)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathRaised","GLOBAL",4)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// Scenery: Caged Animals in Athkatla
IF
    InParty(Myself)
    See(Player1)
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathAnimals","GLOBAL",1)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// Plot: Lavok and the Planar Sphere
IF
    InParty(Myself)
    See(Player1)
    Dead("lavok02")
    Global("LK#ArathSphere","GLOBAL",0)
THEN
  RESPONSE #50
    SetGlobal("LK#ArathSphere","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathSphereTimer","GLOBAL",300)
  RESPONSE #50
    SetGlobal("LK#ArathSphere","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathSphereTimer","GLOBAL",600)
END

IF
    InParty(Myself)
    See(Player1)
    Global("LK#ArathSphere","GLOBAL",1)
    RealGlobalTimerExpired("LK#ArathSphereTimer","GLOBAL")
THEN
  RESPONSE #100
    SetGlobal("LK#ArathSphere","GLOBAL",2)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathSphere","GLOBAL",2)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// Plot: Corrupted Forest
IF
    InParty(Myself)
    See(Player1)
    AreaCheck("AR1404")
    Global("LK#ArathShade","GLOBAL",0)
THEN
  RESPONSE #50
    SetGlobal("LK#ArathShade","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathShadeTimer","GLOBAL",30)
  RESPONSE #50
    SetGlobal("LK#ArathShade","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathShadeTimer","GLOBAL",120)
END

IF
    InParty(Myself)
    See(Player1)
    Global("LK#ArathShade","GLOBAL",1)
    RealGlobalTimerExpired("LK#ArathShadeTimer","GLOBAL")
THEN
  RESPONSE #100
    SetGlobal("LK#ArathShade","GLOBAL",2)
END

IF
    InParty(Myself)
    See(Player1)
    AreaCheck("AR1404")
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathShade","GLOBAL",2)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END

// Plot: Working for Bodhi
IF
    InParty(Myself)
    See(Player1)
    Global("WorkingForBodhi","GLOBAL",1)
    !See("Bodhi")
    Global("LK#ArathBodhi","GLOBAL",0)
THEN
  RESPONSE #50
    SetGlobal("LK#ArathBodhi","GLOBAL",1)
END

IF
    InParty(Myself)
    See(Player1)
    !See("Bodhi")
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathBodhi","GLOBAL",1)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// Plot: Working for the Shadow Thieves
IF
    InParty(Myself)
    See(Player1)
    Global("AranJob","GLOBAL",1)
    !See("Aran")
    Global("LK#ArathShadowThieves","GLOBAL",0)
THEN
  RESPONSE #50
    SetGlobal("LK#ArathShadowThieves","GLOBAL",1)
END

IF
    InParty(Myself)
    See(Player1)
    !See("Aran")
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathShadowThieves","GLOBAL",1)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// Plot: PC Loses his/her soul in Spellhold
IF
    InParty(Myself)
    See(Player1)
    AreaCheck("AR1512")
    Global("LK#ArathSpellhold","GLOBAL",0)
THEN
  RESPONSE #50
    SetGlobal("LK#ArathSpellhold","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathSpellholdTimer","GLOBAL",300)
  RESPONSE #50
    SetGlobal("LK#ArathSpellhold","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathSpellholdTimer","GLOBAL",600)
END

IF
    InParty(Myself)
    See(Player1)
    Global("LK#ArathSpellhold","GLOBAL",1)
    RealGlobalTimerExpired("LK#ArathSpellholdTimer","GLOBAL")
THEN
  RESPONSE #100
    SetGlobal("LK#ArathSpellhold","GLOBAL",2)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathSpellhold","GLOBAL",2)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// Plot: Sahuagin City
IF
    InParty(Myself)
    See(Player1)
    AreaCheck("AR2300")
    Global("LK#ArathSahuagin","GLOBAL",0)
THEN
  RESPONSE #50
    SetGlobal("LK#ArathSahuagin","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathSahuaginTimer","GLOBAL",600)
  RESPONSE #50
    SetGlobal("LK#ArathSahuagin","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathSahuaginTimer","GLOBAL",900)
END

IF
    InParty(Myself)
    See(Player1)
    Global("LK#ArathSahuagin","GLOBAL",1)
    RealGlobalTimerExpired("LK#ArathSahuaginTimer","GLOBAL")
THEN
  RESPONSE #100
    SetGlobal("LK#ArathSahuagin","GLOBAL",2)
END

IF
    InParty(Myself)
    See(Player1)
    AreaCheck("AR1404")
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathSahuagin","GLOBAL",2)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// Plot: Shadow Druids, pt. I
IF
    InParty(Myself)
    See(Player1)
    Dead("cedruid2")
    Global("LK#ArathShadowDruids","GLOBAL",0)
THEN
  RESPONSE #50
    SetGlobal("LK#ArathShadowDruids","GLOBAL",1)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathShadowDruids","GLOBAL",1)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// Plot: Shadow Druids, pt. II
IF
    InParty(Myself)
    See(Player1)
    Dead("cefald01")
    !AreaCheck("AR1901")
    Global("LK#ArathShadowDruids2","GLOBAL",0)
THEN
  RESPONSE #50
    SetGlobal("LK#ArathShadowDruids2","GLOBAL",1)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathShadowDruids2","GLOBAL",1)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// Plot: The de'Arnise Keep
IF
    InParty(Myself)
    See(Player1)
    OR(8)
      AreaCheck("AR1300")
      AreaCheck("AR1301")
      AreaCheck("AR1302")
      AreaCheck("AR1303")
      AreaCheck("AR1304")
      AreaCheck("AR1305")
      AreaCheck("AR1306")
      AreaCheck("AR1307")
    Global("LK#ArathKeep","GLOBAL",0)
THEN
  RESPONSE #50
    SetGlobal("LK#ArathKeep","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathKeepTimer","GLOBAL",300)
  RESPONSE #50
    SetGlobal("LK#ArathKeep","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathKeepTimer","GLOBAL",600)
END

IF
    InParty(Myself)
    See(Player1)
    Global("LK#ArathKeep","GLOBAL",1)
    RealGlobalTimerExpired("LK#ArathKeepTimer","GLOBAL")
THEN
  RESPONSE #100
    SetGlobal("LK#ArathKeep","GLOBAL",2)
END

IF
    InParty(Myself)
    See(Player1)
    OR(8)
      AreaCheck("AR1300")
      AreaCheck("AR1301")
      AreaCheck("AR1302")
      AreaCheck("AR1303")
      AreaCheck("AR1304")
      AreaCheck("AR1305")
      AreaCheck("AR1306")
      AreaCheck("AR1307")
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !See([ENEMY])
    Global("LK#ArathKeep","GLOBAL",2)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// Plot: Post-Killing Bodhi
IF
    InParty(Myself)
    See(Player1)
    Dead("c6bodhi")
    Global("LK#ArathVampires","GLOBAL",0)
THEN
  RESPONSE #50
    SetGlobal("LK#ArathVampires","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathVampiresTimer","GLOBAL",300)
  RESPONSE #50
    SetGlobal("LK#ArathVampires","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathVampiresTimer","GLOBAL",600)
END

IF
    InParty(Myself)
    See(Player1)
    Global("LK#ArathVampires","GLOBAL",1)
    RealGlobalTimerExpired("LK#ArathVampiresTimer","GLOBAL")
THEN
  RESPONSE #100
    SetGlobal("LK#ArathVampires","GLOBAL",2)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck(Myself,CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !Detect([ENEMY])
    Global("LK#ArathVampires","GLOBAL",2)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END


// the Bhaalspawn Cycle
IF
    InParty(Myself)
    Global("LK#ArathBhaalspawn","GLOBAL",0)
THEN
  RESPONSE #100
    RealSetGlobalTimer("LK#ArathBhaalspawnTimer","GLOBAL",5400)
    SetGlobal("LK#ArathBhaalspawn","GLOBAL",1)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    RealGlobalTimerExpired("LK#ArathBhaalspawnTimer","GLOBAL")
    CombatCounter(0)
    !See([ENEMY])
    OR(4)
      Global("LK#ArathBhaalspawn","GLOBAL",2)
      Global("LK#ArathBhaalspawn","GLOBAL",4)
      Global("LK#ArathBhaalspawn","GLOBAL",6)
      Global("LK#ArathBhaalspawn","GLOBAL",8)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END

IF
    InParty(Myself)
    See(Player1)
    RealGlobalTimerExpired("LK#ArathBhaalspawnTimer","GLOBAL")
    RealGlobalTimerExpired("LK#ArathBreakTimer","GLOBAL")
    OR(4)
      Global("LK#ArathBhaalspawn","GLOBAL",1)
      Global("LK#ArathBhaalspawn","GLOBAL",3)
      Global("LK#ArathBhaalspawn","GLOBAL",5)
      Global("LK#ArathBhaalspawn","GLOBAL",7)
THEN
  RESPONSE #100
    IncrementGlobal("LK#ArathBhaalspawn","GLOBAL",1)
END


// ****************************
//                            *
//      Break timer           *
//                            *
// ****************************

IF
    InParty(Myself)
    Global("LK#ArathBreakStart","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathBreakStart","LOCALS",1)
    RealSetGlobalTimer("LK#ArathBreakTimer","GLOBAL",1080)
END

IF
    InParty(Myself)
    Global("LK#ArathBreak","GLOBAL",1)
THEN
  RESPONSE #33
    SetGlobal("LK#ArathBreak","GLOBAL",0)
    RealSetGlobalTimer("LK#ArathBreakTimer","GLOBAL",720)
  RESPONSE #33
    SetGlobal("LK#ArathBreak","GLOBAL",0)
    RealSetGlobalTimer("LK#ArathBreakTimer","GLOBAL",900)
  RESPONSE #33
    SetGlobal("LK#ArathBreak","GLOBAL",0)
    RealSetGlobalTimer("LK#ArathBreakTimer","GLOBAL",1080)
END

// backup
IF
    InParty(Myself)
    Global("LK#ArathBreak","GLOBAL",1)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathBreak","GLOBAL",0)
    RealSetGlobalTimer("LK#ArathBreakTimer","GLOBAL",720)
END


// ****************************
//                            *
//      Romance content       *
//                            *
// ****************************

IF
    InParty(Myself)
    CheckStatGT(Player1,13,CHR)
    !Race(Player1,HALFORC)
    !Race(Player1,HALFLING)
    !Race(Player1,DWARF)
    !Race(Player1,GNOME)
    Global("LK#ArathBhaalspawn","GLOBAL",9)
    Global("LK#ArathLovetalks","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathLovetalks","GLOBAL",1)
    SetGlobal("LK#ArathRomanceActive","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathLovetalkTimer","GLOBAL",3600)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    OR(2)
      Global("LK#ArathRomanceActive","GLOBAL",1)
      Global("LK#ArathRomanceActive","GLOBAL",2)
    RealGlobalTimerExpired("LK#ArathLovetalkTimer","GLOBAL")
    CombatCounter(0)
    !See([ENEMY])
    OR(18)
      Global("LK#ArathLovetalks","GLOBAL",2)
      Global("LK#ArathLovetalks","GLOBAL",4)
      Global("LK#ArathLovetalks","GLOBAL",6)
      Global("LK#ArathLovetalks","GLOBAL",10)
      Global("LK#ArathLovetalks","GLOBAL",12)
      Global("LK#ArathLovetalks","GLOBAL",14)
      Global("LK#ArathLovetalks","GLOBAL",16)
      Global("LK#ArathLovetalks","GLOBAL",18)
      Global("LK#ArathLovetalks","GLOBAL",22)
      Global("LK#ArathLovetalks","GLOBAL",20)
      Global("LK#ArathLovetalks","GLOBAL",24)
      Global("LK#ArathLovetalks","GLOBAL",26)
      Global("LK#ArathLovetalks","GLOBAL",28)
      Global("LK#ArathLovetalks","GLOBAL",30)
      Global("LK#ArathLovetalks","GLOBAL",32)
      Global("LK#ArathLovetalks","GLOBAL",36)
      Global("LK#ArathLovetalks","GLOBAL",38)
      Global("LK#ArathLovetalks","GLOBAL",40)
THEN
  RESPONSE #100
    PlaySong(0)
    PlaySound("lk#arrom")
    MoveToObject(Player1)
    Dialogue(Player1)
END

IF
    InParty(Myself)
    See(Player1)
    OR(2)
      Global("LK#ArathRomanceActive","GLOBAL",1)
      Global("LK#ArathRomanceActive","GLOBAL",2)
    RealGlobalTimerExpired("LK#ArathLovetalkTimer","GLOBAL")
    RealGlobalTimerExpired("LK#ArathBreakTimer","GLOBAL")
    OR(15)
      Global("LK#ArathLovetalks","GLOBAL",1)
      Global("LK#ArathLovetalks","GLOBAL",3)
      Global("LK#ArathLovetalks","GLOBAL",5)
      Global("LK#ArathLovetalks","GLOBAL",11)
      Global("LK#ArathLovetalks","GLOBAL",13)
      Global("LK#ArathLovetalks","GLOBAL",15)
      Global("LK#ArathLovetalks","GLOBAL",17)
      Global("LK#ArathLovetalks","GLOBAL",19)
      Global("LK#ArathLovetalks","GLOBAL",21)
      Global("LK#ArathLovetalks","GLOBAL",23)
      Global("LK#ArathLovetalks","GLOBAL",27)
      Global("LK#ArathLovetalks","GLOBAL",29)
      Global("LK#ArathLovetalks","GLOBAL",31)
      Global("LK#ArathLovetalks","GLOBAL",37)
      Global("LK#ArathLovetalks","GLOBAL",39)
THEN
  RESPONSE #100
    IncrementGlobal("LK#ArathLovetalks","GLOBAL",1)
END

// LT 5 - Athkatla
IF
    InParty(Myself)
    See(Player1)
    OR(2)
      Global("LK#ArathRomanceActive","GLOBAL",1)
      Global("LK#ArathRomanceActive","GLOBAL",2)
    RealGlobalTimerExpired("LK#ArathLovetalkTimer","GLOBAL")
    RealGlobalTimerExpired("LK#ArathBreakTimer","GLOBAL")
    AreaType([CITY])
    !AreaCheck("AR2000")
    Global("LK#ArathLovetalks","GLOBAL",9)
THEN
  RESPONSE #100
    IncrementGlobal("LK#ArathLovetalks","GLOBAL",1)
END

// LTs after Spellhold
IF
    InParty(Myself)
    See(Player1)
    OR(2)
      Global("LK#ArathRomanceActive","GLOBAL",1)
      Global("LK#ArathRomanceActive","GLOBAL",2)
    RealGlobalTimerExpired("LK#ArathLovetalkTimer","GLOBAL")
    RealGlobalTimerExpired("LK#ArathBreakTimer","GLOBAL")
    GlobalGT("asylumplot","GLOBAL",40)
    Global("LK#ArathLovetalks","GLOBAL",25)
THEN
  RESPONSE #100
    IncrementGlobal("LK#ArathLovetalks","GLOBAL",1)
END

// LT 18 - morning after
IF
    PartyRested()
    InParty(Myself)
    See(Player1)
    OR(2)
      Global("LK#ArathRomanceActive","GLOBAL",1)
      Global("LK#ArathRomanceActive","GLOBAL",2)
    RealGlobalTimerExpired("LK#ArathLovetalkTimer","GLOBAL")
    RealGlobalTimerExpired("LK#ArathBreakTimer","GLOBAL")
    Global("LK#ArathLovetalks","GLOBAL",35)
THEN
  RESPONSE #100
    IncrementGlobal("LK#ArathLovetalks","GLOBAL",1)
END

IF
    InParty(Myself)
    Global("LK#ArathInnSex","GLOBAL",2)
    GlobalLT("LK#ArathSex","GLOBAL",1)
    OR(2) 
      Global("LK#ArathRomanceActive","GLOBAL",1)
      Global("LK#ArathRomanceActive","GLOBAL",2)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathRomanceActive","GLOBAL",3)
END

// Romance kills
IF
    InParty(Myself)
    Global("LK#ArathRomanceActive","GLOBAL",1)
    OR(4)
      Global("AerieRomanceActive","GLOBAL",2)
      Global("AnomenRomanceActive","GLOBAL",2)
      Global("JaheiraRomanceActive","GLOBAL",2)
      Global("ViconiaRomanceActive","GLOBAL",2)
    Global("LK#ArathRomKill","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathRomKill","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathRomKillTimer","GLOBAL",600)
END

IF
    InParty(Myself)
    Global("LK#ArathRomanceActive","GLOBAL",1)
    Global("LK#ArathRomKill","GLOBAL",1)
    RealGlobalTimerExpired("LK#ArathRomKillTimer","GLOBAL")
THEN
  RESPONSE #100
    SetGlobal("LK#ArathRomKill","GLOBAL",2)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !See([ENEMY])
    Global("LK#ArathRomKill","GLOBAL",2)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END

IF
    InParty(Myself)
    Global("LK#ArathRomanceActive","GLOBAL",2)
    Global("AerieRomanceActive","GLOBAL",1)
THEN
  RESPONSE #100
    SetGlobal("AerieRomanceActive","GLOBAL",3)
END

IF
    InParty(Myself)
    Global("LK#ArathRomanceActive","GLOBAL",2)
    Global("AnomenRomanceActive","GLOBAL",1)
THEN
  RESPONSE #100
    SetGlobal("AnomenRomanceActive","GLOBAL",3)
END

IF
    InParty(Myself)
    Global("LK#ArathRomanceActive","GLOBAL",2)
    Global("JaheiraRomanceActive","GLOBAL",1)
THEN
  RESPONSE #100
    SetGlobal("JaheiraRomanceActive","GLOBAL",3)
END

IF
    InParty(Myself)
    Global("LK#ArathRomanceActive","GLOBAL",2)
    Global("ViconiaRomanceActive","GLOBAL",1)
THEN
  RESPONSE #100
    SetGlobal("ViconiaRomanceActive","GLOBAL",3)
END

// ****************************
//                            *
//   Quest scripting stuff    *
//                            *
// ****************************
IF    
    InParty(Myself)
    GlobalGT("chapter","GLOBAL",%bg2_chapter_5%)
    Global("LK#ArathQuest","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathQuest","GLOBAL",1)
    RealSetGlobalTimer("LK#ArathQuestTimer","GLOBAL",600)
END

IF
    GlobalGT("chapter","GLOBAL",%bg2_chapter_5%)
    AreaType([CITY])
    InParty(Myself)
    Global("LK#ArathQuest","GLOBAL",1)
    RealGlobalTimerExpired("LK#ArathQuestTimer","GLOBAL")
THEN
  RESPONSE #100
    SetGlobal("LK#ArathQuest","GLOBAL",2)
    CreateCreatureObjectOffset("lk#armes",Myself,[-15.-15])
    RealSetGlobalTimer("LK#Arath_spawntimer","GLOBAL",300)
END

IF
    GlobalGT("chapter","GLOBAL",%bg2_chapter_5%)
    AreaType([CITY])
    InParty(Myself)
    Global("LK#ArathQuest","GLOBAL",2)
    RealGlobalTimerExpired("LK#Arath_spawntimer","GLOBAL")
THEN
  RESPONSE #100
    CreateCreatureObjectOffset("lk#armes",Myself,[-15.-15])
    RealSetGlobalTimer("LK#Arath_spawntimer","GLOBAL",300)
END


IF
    InParty(Myself)
    Global("LK#ArathQuest","GLOBAL",3)
    Global("LK#ArathQuestReminder","GLOBAL",0)
THEN
  RESPONSE #100
    Dialogue(Player1)
END

IF
    InParty(Myself)
    RealGlobalTimerExpired("LK#ArathQuestReminderTimer","GLOBAL")
    Global("LK#ArathQuestReminder","GLOBAL",1)
    Global("LK#ArathQuest","GLOBAL",3)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathQuestReminder","GLOBAL",2)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !See([ENEMY])
    Global("LK#ArathQuest","GLOBAL",3)
    Global("LK#ArathQuestReminder","GLOBAL",2)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END

IF
    InParty(Myself)
    RealGlobalTimerExpired("LK#ArathQuestReminderTimer","GLOBAL")
    Global("LK#ArathQuestReminder","GLOBAL",3)
    Global("LK#ArathQuest","GLOBAL",3)
THEN
  RESPONSE #100
    SetGlobal("LK#ArathQuestReminder","GLOBAL",4)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !See([ENEMY])
    Global("LK#ArathQuest","GLOBAL",3)
    Global("LK#ArathQuestReminder","GLOBAL",4)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !See([ENEMY])
    !AreaCheck("AR1901")
    Global("LK#ArathQuest","GLOBAL",4)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !See([ENEMY])
    Global("LK#ArathQuest","GLOBAL",7)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !See([ENEMY])
    AreaCheck("LK#AR1")
    Global("LK#ArathQuest","GLOBAL",9)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !See([ENEMY])
    AreaCheck("AR1900")
    Global("LK#ArathQuest","GLOBAL",12)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END

IF
    InParty(Myself)
    Global("LK#ArathQuest","GLOBAL",13)
    RealGlobalTimerExpired("LK#ArathQuestTalkTimer","GLOBAL")
THEN
  RESPONSE #100
    SetGlobal("LK#ArathQuest","GLOBAL",14)
END

IF
    InParty(Myself)
    See(Player1)
    !StateCheck("Arath",CD_STATE_NOTVALID)
    !StateCheck(Player1,CD_STATE_NOTVALID)
    CombatCounter(0)
    !See([ENEMY])
    Global("LK#ArathQuest","GLOBAL",14)
THEN
  RESPONSE #100
    MoveToObject(Player1)
    Dialogue(Player1)
END