IF
  HPPercentLT(Myself,15)
  HPGT(Myself,0)
  Range(NearestEnemyOf(Myself),10)
  HPPercentGT(NearestEnemyOf(Myself),20)
  Global("GateAway","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("GateAway","LOCALS",1)
    SpellNoDec(Myself,DRYAD_TELEPORT)
END

IF
  Allegiance(Myself,ALLY)
  !Detect([ENEMY])
  CombatCounter(0)
  Global("GateAway","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("GateAway","LOCALS",1)
    SpellNoDec(Myself,DRYAD_TELEPORT)
END

IF
  Allegiance(Myself,GOODCUTOFF)
  AttackedBy([ANYONE],DEFAULT)
  Allegiance(LastAttackerOf(Myself),GOODCUTOFF)
  Global("LetItGoOnce","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("LetItGoOnce","LOCALS",1)
    SetGlobalTimer("GetMadNow","LOCALS",6)
END

IF
  Allegiance(Myself,GOODCUTOFF)
  AttackedBy([ANYONE],DEFAULT)
  Allegiance(LastAttackerOf(Myself),GOODCUTOFF)
  Global("LetItGoOnce","LOCALS",1)
  GlobalTimerExpired("GetMadNow","LOCALS")
THEN
  RESPONSE #100
    SetGlobal("LetItGoOnce","LOCALS",0)
    Enemy()
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("Spell","LOCALS")
  StateCheck(Myself,STATE_SILENCED)
  HaveSpell(WIZARD_VOCALIZE)
THEN
  RESPONSE #100
    SetGlobalTimer("Spell","LOCALS",6)
    Spell(Myself,WIZARD_VOCALIZE)
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("Spell","LOCALS")
  HaveSpell(WIZARD_MIRROR_IMAGE)
  Range(NearestEnemyOf(Myself),15)
  !StateCheck(Myself,STATE_MIRRORIMAGE)
  RandomNum(2,1)
THEN
  RESPONSE #100
    SetGlobalTimer("Spell","LOCALS",6)
    Spell(Myself,WIZARD_MIRROR_IMAGE)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_HASTE)
  Allegiance(Myself,ENEMY)
  !GlobalTimerNotExpired("Spell","LOCALS")
  !StateCheck([EVILCUTOFF],STATE_HASTED)
  See([EVILCUTOFF])
  RandomNumLT(4,3)
THEN
  RESPONSE #100
    SetGlobalTimer("Spell","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_HASTE)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_HASTE)
  Allegiance(Myself,GOODCUTOFF)
  !GlobalTimerNotExpired("Spell","LOCALS")
  !StateCheck([GOODCUTOFF],STATE_HASTED)
  See([GOODCUTOFF])
  RandomNumLT(4,3)
THEN
  RESPONSE #100
    SetGlobalTimer("Spell","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_HASTE)
END

IF
  OR(2)
    !Allegiance(Myself,EVILCUTOFF)
    !Detect([GOODCUTOFF])
THEN
  RESPONSE #100
END

IF
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumLT(31,21)
  OR(6)
    See(NearestEnemyOf(Myself))
    See(WeakestOf)
    See(WorstAC)
    See(MostDamagedOf)
    See(LastAttackerOf(Myself))
    See(LastHitter(Myself))
  RandomNumLT(28,22)
  OR(4)
    See([GOODCUTOFF.0.0.0.0.SUMMONED_DEMON])
    See([GOODCUTOFF.0.0.0.0.SUMMONED])
    See([GOODCUTOFF.0.0.0.207])
    See([GOODCUTOFF.0.0.0.0.ILLUSIONARY])
  RandomNumLT(29,23)
  OR(7)
    See([PC.0.0.RANGER_ALL])
    See([PC.0.0.PALADIN_ALL])
    See([PC.0.0.BARD_ALL])
    See([PC.0.0.DRUID_ALL])
    See([PC.0.0.CLERIC_ALL])
    See([PC.0.0.LONG_BOW])
    See([PC.0.0.SORCERER])
  RandomNumLT(30,21)
  See(Protagonist)
  RandomNumLT(26,10)
  OR(4)
    See([GOODCUTOFF.0.0.RANGER_ALL])
    See([GOODCUTOFF.0.0.DRUID_ALL])
    See([GOODCUTOFF.0.0.PALADIN_ALL])
    See([GOODCUTOFF.0.0.CLERIC_ALL])
  RandomNumLT(27,10)
  OR(3)
    See([GOODCUTOFF.0.0.MONK])
    See([GOODCUTOFF.0.0.BARD_ALL])
    See([GOODCUTOFF.0.0.THIEF_ALL])
  RandomNumLT(24,9)
  OR(3)
    See(StrongestOf)
    See(BestAC)
    See(LeastDamagedOf)
  RandomNumLT(25,9)
  See(WeakestOf)
  RandomNumLT(23,8)
  See(WorstAC)
  RandomNumLT(21,8)
  See(MostDamagedOf)
  RandomNumLT(32,11)
  OR(2)
    See(TenthNearest([GOODCUTOFF.0.0.LONG_BOW]))
    See(TenthNearest([GOODCUTOFF.0.0.SORCERER]))
  RandomNumLT(20,8)
  See(TenthNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(4)
    Allegiance(LastSeenBy(Myself),ENEMY)
    Allegiance(LastSeenBy(Myself),EVILCUTOFF)
    Allegiance(LastSeenBy(Myself),GOODBUTRED)
    StateCheck(LastSeenBy(Myself),STATE_DEAD)
THEN
  RESPONSE #100
END

IF
  StateCheck(LastSeenBy(Myself),STATE_CHARMED)
THEN
  RESPONSE #80
    Continue()
  RESPONSE #20
END

IF
  ActionListEmpty()
  General(LastSeenBy(Myself),HUMANOID)
  CheckStatGT(LastSeenBy(Myself),0,SAVEVSSPELL)
  !CheckStatGT(LastSeenBy(Myself),35,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_BERSERK)
  !Class(LastSeenBy(Myself),MONK)
  !Kit(LastSeenBy(Myself),INQUISITOR)
  OR(11)
    !HasItemEquiped("HELM06",LastSeenBy(Myself))
    !HasItemEquiped("MISCBC",LastSeenBy(Myself))
    !HasItemEquiped("NPCHAN",LastSeenBy(Myself))
    !HasItemEquiped("REAVER",LastSeenBy(Myself))
    !HasItemEquiped("SHLD25",LastSeenBy(Myself))
    !HasItemEquipedReal("SPER07",LastSeenBy(Myself))
    !HasItemEquipedReal("STAF11",LastSeenBy(Myself))
    !HasItemEquipedReal("SW1H35",LastSeenBy(Myself))
    !HasItemEquipedReal("SW1H54",LastSeenBy(Myself))
    !HasItemEquipedReal("SW2H14",LastSeenBy(Myself))
    !HasItemEquiped("WA2SHIEL",LastSeenBy(Myself))
  RandomNumLT(40,21)
THEN
  RESPONSE #50
    SetGlobalTimer("Spell","LOCALS",6)
    ForceSpell(LastSeenBy(Myself),ERINYES_CHARM)
  RESPONSE #50
    SetGlobalTimer("Spell","LOCALS",6)
    SpellNoDec(LastSeenBy(Myself),ERINYES_CHARM)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_SECRET_WORD)
  !GlobalTimerNotExpired("Spell","LOCALS")
  Global("CloseCombat","LOCALS",0)
  CheckStat(LastSeenBy(Myself),0,164)
  CheckStat(LastSeenBy(Myself),0,177)
  OR(13)
    CheckStatGT(LastSeenBy(Myself),0,178)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGICFIRE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGICCOLD)
    CheckStatGT(LastSeenBy(Myself),50,RESISTACID)
    CheckStatGT(LastSeenBy(Myself),50,RESISTELECTRICITY)
    CheckStatGT(LastSeenBy(Myself),0,126)
    CheckStatGT(LastSeenBy(Myself),0,130)
    CheckStatGT(LastSeenBy(Myself),0,163)
    CheckStatGT(LastSeenBy(Myself),0,179)
    CheckStatGT(LastSeenBy(Myself),0,181)
    CheckStatGT(LastSeenBy(Myself),0,128)
    CheckStatGT(LastSeenBy(Myself),3,STONESKINS)
    CheckStatGT(LastSeenBy(Myself),0,SCRIPTINGSTATE5)
    RandomNumLT(42,29)
THEN
  RESPONSE #100
    SetGlobalTimer("Spell","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_SECRET_WORD)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_MAGIC_MISSILE)
  !GlobalTimerNotExpired("Spell","LOCALS")
  CheckStatLT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStat(LastSeenBy(Myself),2,SCRIPTINGSTATE5)
  CheckStat(LastSeenBy(Myself),0,129)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
  RandomNumLT(45,16)
THEN
  RESPONSE #100
    SetGlobalTimer("Spell","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_MAGIC_MISSILE)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_MELF_ACID_ARROW)
  !GlobalTimerNotExpired("Spell","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  CheckStatLT(LastSeenBy(Myself),50,RESISTMAGIC)
  CheckStatLT(LastSeenBy(Myself),50,RESISTACID)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
  RandomNumLT(48,17)
THEN
  RESPONSE #100
    SetGlobalTimer("Spell","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_MELF_ACID_ARROW)
END

IF
  ActionListEmpty()
  OR(3)
    !Range(NearestEnemyOf(Myself),5)
    CheckStatGT(LastSeenBy(Myself),0,121)
    CheckStatGT(LastSeenBy(Myself),0,125)
THEN
  RESPONSE #100
    EquipRanged()
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  OR(2)
    CheckStatGT(NearestEnemyOf(Myself),0,121)
    CheckStatGT(LastSeenBy(Myself),0,125)
THEN
  RESPONSE #25
    Continue()
  RESPONSE #75
END

IF
  ActionListEmpty()
  !Range(LastSeenBy(Myself),8)
THEN
  RESPONSE #90
    EquipMostDamagingMelee()
    AttackOneRound(NearestEnemyOf(Myself))
  RESPONSE #90
    EquipMostDamagingMelee()
    MoveToObjectNoInterrupt(LastSeenBy(Myself))
    AttackReevaluate(LastSeenBy(Myself),135)
END

IF
  ActionListEmpty()
THEN
  RESPONSE #100
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
END

