IF
  Die()
  !AreaCheck("AR2402")
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    SetGlobal("DrowCityHostile","GLOBAL",1)
    EraseJournalEntry(15797)
    AddJournalEntry(62079,QUEST_DONE)
    ActionOverride(Player1,ApplySpell(Myself,UNDER_NORM))
    ActionOverride(Player2,ApplySpell(Myself,UNDER_NORM))
    ActionOverride(Player3,ApplySpell(Myself,UNDER_NORM))
    ActionOverride(Player4,ApplySpell(Myself,UNDER_NORM))
    ActionOverride(Player5,ApplySpell(Myself,UNDER_NORM))
    ActionOverride(Player6,ApplySpell(Myself,UNDER_NORM))
    DisplayStringHead(Myself,62029)
    SetGlobal("PlayerLooksLikeDrow","GLOBAL",0)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("AdalonStone","LOCALS")
THEN
  RESPONSE #100
    ChangeClass(Myself,CLERIC)
    ReallyForceSpell(Myself,DRAGON_STONE_SKIN)
    ReallyForceSpell(Myself,CLERIC_DEATH_WARD)
    SetGlobalTimer("AdalonStone","LOCALS",TWO_HOURS)
    Continue()
END

IF
  Allegiance(Myself,ENEMY)
  Global("DrowCityHostile","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobal("DrowCityHostile","GLOBAL",1)
    Continue()
END

IF
  Allegiance(Myself,ENEMY)
  Global("PlayerLooksLikeDrow","GLOBAL",1)
THEN
  RESPONSE #100
    ActionOverride(Player1,ApplySpell(Myself,UNDER_NORM))
    ActionOverride(Player2,ApplySpell(Myself,UNDER_NORM))
    ActionOverride(Player3,ApplySpell(Myself,UNDER_NORM))
    ActionOverride(Player4,ApplySpell(Myself,UNDER_NORM))
    ActionOverride(Player5,ApplySpell(Myself,UNDER_NORM))
    ActionOverride(Player6,ApplySpell(Myself,UNDER_NORM))
    DisplayStringHead(Myself,62029)
    SetGlobal("PlayerLooksLikeDrow","GLOBAL",0)
    Continue()
END

IF
  AreaCheck("AR2402")
  !Detect([NEUTRAL])
  !Detect([ENEMY])
  Detect([PC])
  !Allegiance(Myself,ENEMY)
THEN
  RESPONSE #100
    SetGlobal("udDrowPlot","GLOBAL",99)
    DialogueInterrupt(TRUE)
    StartDialogNoSet(LastSeenBy(Myself))
END

IF
  Allegiance(Myself,ENEMY)
  AreaCheck("AR2402")
THEN
  RESPONSE #100
    ForceSpell(Myself,WIZARD_STONE_SKIN)
    ForceSpell(Myself,DRYAD_TELEPORT)
END

IF
  !Allegiance(Myself,ENEMY)
  Detect("uddoor05")  // ~Drow Wizard~
  !Dead("uddoor05")  // ~Drow Wizard~
THEN
  RESPONSE #100
    ForceSpell(LastSeenBy(Myself),WIZARD_LOWER_RESISTANCE)
    ForceSpell(LastSeenBy(Myself),WIZARD_MAGIC_MISSILE)
    Kill("uddoor05")
END

IF
  Detect("uddoor06")  // ~Drow Priestess~
  !Allegiance(Myself,ENEMY)
  !Dead("uddoor06")  // ~Drow Priestess~
THEN
  RESPONSE #100
    ForceSpell(LastSeenBy(Myself),WIZARD_LOWER_RESISTANCE)
    ForceSpell(LastSeenBy(Myself),WIZARD_HOLD_PERSON)
    ForceSpell(LastSeenBy(Myself),WIZARD_MAGIC_MISSILE)
    Kill("uddoor06")
END

IF
  OR(2)
    See([NEUTRAL])
    See([ENEMY])
  !Allegiance(Myself,ENEMY)
  HPGT(LastSeenBy(Myself),0)
THEN
  RESPONSE #60
    ForceSpell(LastSeenBy(Myself),WIZARD_LOWER_RESISTANCE)
    ForceSpell(LastSeenBy(Myself),WIZARD_FLAME_ARROW)
    ForceSpell(LastSeenBy(Myself),WIZARD_FLAME_ARROW)
    ForceSpell(LastSeenBy(Myself),WIZARD_FLAME_ARROW)
  RESPONSE #60
    ForceSpell(LastSeenBy(Myself),WIZARD_FINGER_OF_DEATH)
  RESPONSE #60
    AttackReevaluate(LastSeenBy(Myself),15)
END

IF
  Global("Returned","LOCALS",1)
THEN
  RESPONSE #100
    SetGlobal("Returned","LOCALS",0)
    ReallyForceSpell(Myself,DRAGON_STONE_SKIN)
    DisplayString(Myself,11132)
    CreateVisualEffectObject("SPDIMNDR",Myself)
    Continue()
END

IF
  Allegiance(Myself,ENEMY)
  Global("AdalonTurning","LOCALS",0)
THEN
  RESPONSE #100
    ChangeClass(Myself,MAGE)
    ReallyForceSpell(Myself,BEHOLDER_SPELL_TURNING)
    ReallyForceSpell(Myself,WIZARD_HASTE)
    SetGlobal("AdalonTurning","LOCALS",1)
    Continue()
END

IF
  Allegiance(Myself,ENEMY)
  GlobalTimerExpired("SILVERDRAGONBREATH","LOCALS")
  See([PC])
THEN
  RESPONSE #100
    SetGlobalTimer("SILVERDRAGONBREATH","LOCALS",THREE_ROUNDS)
    ReallyForceSpell(LastSeenBy(Myself),SILVER_DRAGON_BREATH_PARALIZATION)
    ReallyForceSpell(LastSeenBy(Myself),SILVER_DRAGON_BREATH_COLD)
    Continue()
END

IF
  Allegiance(Myself,ENEMY)
  HPPercentLT(Myself,40)
  GlobalLT("AdalonFlee","LOCALS",2)
THEN
  RESPONSE #100
    DisplayString(Myself,4159)  // ~ Live smart!  Live long!  Run away!~ [QUAYL02]
    CreateVisualEffectObject("SPDIMNDR",Myself)
    GiveItemCreate("udsilver",Myself,1,0,0)  // ~Potion of Extra Healing~
    SetGlobal("Returned","LOCALS",1)
    IncrementGlobal("AdalonFlee","LOCALS",1)
    UseItem("udsilver",Myself)  // ~Potion of Extra Healing~
END

IF
  Allegiance(Myself,ENEMY)
  !CombatCounter(0)
  !Detect(Player1)
  InMyArea(Player1)
  Delay(6)
THEN
  RESPONSE #100
    ReallyForceSpell(Player1,WIZARD_DIMENSION_DOOR)
END

IF
  Allegiance(Myself,ENEMY)
  Range(NearestEnemyOf(Myself),25)
THEN
  RESPONSE #100
    ForceSpell(NearestEnemyOf(Myself),DRAGON_WING_BUFFET)
    Continue()
END

IF
  Detect(Player1)
  Global("AdalonRemove","LOCALS",0)
  Allegiance(Myself,ENEMY)
  !GlobalTimerNotExpired("Cast","LOCALS")
THEN
  RESPONSE #100
    ChangeClass(Myself,MAGE)
    SetGlobalTimer("Cast","LOCALS",ONE_ROUND)
    SpellNoDec(Player1,WIZARD_REMOVE_MAGIC)
    SetGlobal("AdalonRemove","LOCALS",1)
END

IF
  Allegiance(Myself,ENEMY)
  Detect(StrongestOf)
  Global("AdalonGreater","LOCALS",0)
  !GlobalTimerNotExpired("Cast","LOCALS")
THEN
  RESPONSE #100
    ChangeClass(Myself,MAGE)
    SetGlobalTimer("Cast","LOCALS",ONE_ROUND)
    SpellNoDec(StrongestOf,WIZARD_GREATER_MALISON)
    ReallyForceSpell(StrongestOf,DRAGON_FEAR)
    SetGlobal("AdalonGreater","LOCALS",1)
END

IF
  Allegiance(Myself,ENEMY)
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(Player1)
  CheckStatGT(Player1,0,RESISTMAGIC)
THEN
  RESPONSE #100
    ChangeClass(Myself,MAGE)
    SetGlobalTimer("Cast","LOCALS",ONE_ROUND)
    ReallyForceSpell(Player1,WIZARD_LOWER_RESISTANCE)
    ReallyForceSpell(Player1,WIZARD_LOWER_RESISTANCE)
    ReallyForceSpell(Player1,WIZARD_LOWER_RESISTANCE)
END

IF
  Allegiance(Myself,ENEMY)
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOfType([PC]))
  CheckStatGT(LastSeenBy(Myself),0,RESISTMAGIC)
  !CheckStatGT(Player1,0,RESISTMAGIC)
THEN
  RESPONSE #100
    ChangeClass(Myself,MAGE)
    SetGlobalTimer("Cast","LOCALS",ONE_ROUND)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_LOWER_RESISTANCE)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_LOWER_RESISTANCE)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_LOWER_RESISTANCE)
END

IF
  Allegiance(Myself,ENEMY)
  See(NearestEnemyOfType([PC]))
  !GlobalTimerNotExpired("Cast","LOCALS")
  HaveSpell(WIZARD_FINGER_OF_DEATH)
  CheckStatGT(LastSeenBy(Myself),1,SAVEVSSPELL)
  CheckStat(LastSeenBy(Myself),0,SCRIPTINGSTATE2)
  CheckStatLT(LastSeenBy(Myself),10,RESISTMAGIC)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #100
    ChangeClass(Myself,MAGE)
    SetGlobalTimer("Cast","LOCALS",ONE_ROUND)
    SpellNoDec(LastSeenBy(Myself),WIZARD_FINGER_OF_DEATH)
END

IF
  Allegiance(Myself,ENEMY)
  See(SecondNearestEnemyOfType([PC]))
  !GlobalTimerNotExpired("Cast","LOCALS")
  HaveSpell(WIZARD_FINGER_OF_DEATH)
  CheckStatGT(LastSeenBy(Myself),1,SAVEVSSPELL)
  CheckStat(LastSeenBy(Myself),0,SCRIPTINGSTATE2)
  CheckStatLT(LastSeenBy(Myself),10,RESISTMAGIC)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #100
    ChangeClass(Myself,MAGE)
    SetGlobalTimer("Cast","LOCALS",ONE_ROUND)
    SpellNoDec(LastSeenBy(Myself),WIZARD_FINGER_OF_DEATH)
END

IF
  Allegiance(Myself,ENEMY)
  Global("AdalonIce","LOCALS",0)
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOfType([PC]))
  !HasItem("clck26",NearestEnemyOfType([PC]))  // ~Cloak of Mirroring~
  CheckStatLT(NearestEnemyOfType([PC]),75,RESISTCOLD)
THEN
  RESPONSE #100
    ChangeClass(Myself,MAGE)
    SetGlobalTimer("Cast","LOCALS",ONE_ROUND)
    SpellNoDec(LastSeenBy(Myself),WIZARD_ICE_STORM)
    SetGlobal("AdalonIce","LOCALS",1)
END

IF
  See(NearestEnemyOfType([PC]))
  CheckStatGT(LastSeenBy(Myself),1,SAVEVSSPELL)
  !Kit(LastSeenBy(Myself),16)
  !HasItemEquiped("FREERING",LastSeenBy(Myself))
  !HasItemEquiped("ROSSRING",LastSeenBy(Myself))
  !HasItemEquiped("RING09",LastSeenBy(Myself))
  !HasItemEquiped("NPSW01",LastSeenBy(Myself))
  Global("AdalonHold","LOCALS",0)
  Allegiance(Myself,ENEMY)
  !GlobalTimerNotExpired("Cast","LOCALS")
THEN
  RESPONSE #100
    ChangeClass(Myself,CLERIC)
    SetGlobalTimer("Cast","LOCALS",ONE_ROUND)
    SpellNoDec(Player1,CLERIC_HOLD_PERSON)
    SetGlobal("AdalonHold","LOCALS",1)
END

IF
  Allegiance(Myself,ENEMY)
  Global("AdalonSilence","LOCALS",0)
  !GlobalTimerNotExpired("Cast","LOCALS")
  OR(2)
    See([GOODCUTOFF.0.0.LONG_BOW])
    See([GOODCUTOFF.0.0.CLERIC_ALL])
THEN
  RESPONSE #100
    ChangeClass(Myself,CLERIC)
    SetGlobalTimer("Cast","LOCALS",ONE_ROUND)
    SpellNoDec(LastSeenBy(Myself),CLERIC_SILENCE_15_FOOT)
    SetGlobal("AdalonSilence","LOCALS",1)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  Allegiance(Myself,ENEMY)
  Detect([PC])
  !HasItem("clck26",NearestEnemyOfType([PC]))  // ~Cloak of Mirroring~
  CheckStatLT(NearestEnemyOfType([PC]),75,RESISTFIRE)
THEN
  RESPONSE #100
    ChangeClass(Myself,MAGE)
    SetGlobalTimer("Cast","LOCALS",ONE_ROUND)
    SpellNoDec(NearestEnemyOfType([PC]),WIZARD_FLAME_ARROW)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  Allegiance(Myself,ENEMY)
  Detect(SecondNearest([PC]))
  !HasItem("clck26",SecondNearest([PC]))  // ~Cloak of Mirroring~
  CheckStatLT(SecondNearest([PC]),75,RESISTFIRE)
THEN
  RESPONSE #100
    ChangeClass(Myself,MAGE)
    SetGlobalTimer("Cast","LOCALS",ONE_ROUND)
    SpellNoDec(SecondNearest([PC]),WIZARD_FLAME_ARROW)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  Allegiance(Myself,ENEMY)
  Detect(ThirdNearest([PC]))
  !HasItem("clck26",ThirdNearest([PC]))  // ~Cloak of Mirroring~
  CheckStatLT(ThirdNearest([PC]),75,RESISTFIRE)
THEN
  RESPONSE #100
    ChangeClass(Myself,MAGE)
    SetGlobalTimer("Cast","LOCALS",ONE_ROUND)
    SpellNoDec(ThirdNearest([PC]),WIZARD_FLAME_ARROW)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  Allegiance(Myself,ENEMY)
  Detect(ThirdNearest([PC]))
  CheckStatGT(ThirdNearest([PC]),6,SAVEVSSPELL)
THEN
  RESPONSE #100
    ChangeClass(Myself,MAGE)
    SetGlobalTimer("Cast","LOCALS",ONE_ROUND)
    SpellNoDec(ThirdNearest([PC]),WIZARD_CHROMATIC_ORB)
END

IF
  !GlobalTimerExpired("Cast","LOCALS")
  Allegiance(Myself,ENEMY)
  See([PC])
THEN
  RESPONSE #100
    AttackOneRound(LastSeenBy(Myself))
END

IF
  Allegiance(Myself,ENEMY)
  !Detect(NearestEnemyOf(Myself))
  CombatCounter(0)
THEN
  RESPONSE #100
    DisplayString(Myself,26703)  // ~Damn, where are they?~
    ForceSpell(Myself,CLERIC_HEAL)
    SetGlobal("AdalonGreater","LOCALS",0)
    SetGlobal("AdalonHaste","LOCALS",0)
    SetGlobal("AdalonSilence","LOCALS",0)
    SetGlobal("AdalonRemove","LOCALS",0)
    SetGlobal("AdalonHold","LOCALS",0)
    SetGlobal("AdalonIce","LOCALS",0)
    SetGlobal("AdalonTurning","LOCALS",0)
    ReallyForceSpell(Player1,WIZARD_DIMENSION_DOOR)
END

IF
  !Allegiance(Myself,ENEMY)
  OR(8)
    AttackedBy([GOODCUTOFF],DEFAULT)
    SpellCastOnMe([GOODCUTOFF],0)
    SpellCastInnateRES("SPCL910",[GOODCUTOFF])
    SpellCastInnateRES("SPCL911",[GOODCUTOFF])
    SpellCastInnateRES("SPCL912",[GOODCUTOFF])
    SpellCastInnateRES("SPCL412",[GOODCUTOFF])
    SpellCastInnateRES("SPCL414",[GOODCUTOFF])
    Detect([GOODCUTOFF.0.0.0.0.SUMMONED])
THEN
  RESPONSE #100
    DisplayString(Myself,21726)
    EraseJournalEntry(15797) 
    AddJournalEntry(62079,QUEST_DONE)
    Enemy()
END

IF
  Global("AdalonInit","LOCALS",0)
THEN
  RESPONSE #100
    ChangeClass(Myself,CLERIC)
    ReallyForceSpell(Myself,DRAGON_STONE_SKIN)
    ReallyForceSpell(Myself,CLERIC_DEATH_WARD)
    EquipMostDamagingMelee()
    SetGlobal("AdalonInit","LOCALS",1)
    ChangeAIScript("",DEFAULT)
END

