IF
  OnCreation()
  !GlobalTimerNotExpired("StartingDefense","LOCALS")
  !DifficultyLT(EASY)
THEN
  RESPONSE #100
    SetGlobalTimer("StartingDefense","LOCALS",1000)
    ApplySpell(Myself,WIZARD_STONE_SKIN)
END

IF
  HPPercentLT(Myself,15)
  HPGT(Myself,1)
  Range(NearestEnemyOf(Myself),10)
  HPPercentGT(NearestEnemyOf(Myself),25)
  Global("GateAway","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("GateAway","LOCALS",1)
    CreateVisualEffectObject("SPGFLSH1",Myself)
    DisplayString(Myself,14260)  // ~Gate~
    DestroySelf()
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
  Allegiance(Myself,GOODCUTOFF)
  !See([ENEMY])
  CombatCounter(0)
  !Range(Player1,20)
THEN
  RESPONSE #100
    MoveToObject(Player1)
END

IF
  Allegiance(Myself,GOODCUTOFF)
  !See([ENEMY])
  CombatCounter(0)
  Range(Player1,20)
THEN
  RESPONSE #100
    NoAction()
END

IF
  Allegiance(Myself,ENEMY)
  Delay(6)
  !GlobalTimerNotExpired("Spell","LOCALS")
  OR(2)
    NumCreatureLT([ENEMY.0.DEMONIC],3)
    NumCreatureVsPartyLT([ENEMY.0.DEMONIC],0)
  HaveSpellRES("GATE4")
  !Range(NearestEnemyOf(Myself),10)
  OR(2)
    NumInPartyAliveGT(2)
    DifficultyGT(EASY)
THEN
  RESPONSE #100
    SetGlobalTimer("Spell","LOCALS",6)
    SpellRES("GATE4",Myself)  // ~Gate~
  RESPONSE #100
    Continue()
END

IF
  See(NearestEnemyOf(Myself))
  Range(NearestEnemyOf(Myself),10)
  !GlobalTimerNotExpired("Spell","LOCALS")
  !StateCheck(Myself,STATE_MIRRORIMAGE)
THEN
  RESPONSE #50
    SetGlobalTimer("Spell","LOCALS",6)
    ForceSpell(Myself,WIZARD_MIRROR_IMAGE)
  RESPONSE #50
    SetGlobalTimer("Spell","LOCALS",6)
    SpellNoDec(Myself,WIZARD_MIRROR_IMAGE)
  RESPONSE #100
    Continue()
END

IF
  Global("FoundStunTarget","LOCALS",1)
THEN
  RESPONSE #100
    SetGlobal("FoundStunTarget","LOCALS",0)
    Continue()
END

IF
  !GlobalTimerNotExpired("Spell","LOCALS")
  HPLT(NearestEnemyOf(Myself),90)
  !Gender(NearestEnemyOf(Myself),SUMMONED)
  !Gender(NearestEnemyOf(Myself),ILLUSIONARY)
  !StateCheck(NearestEnemyOf(Myself),STATE_STUNNED)
  !StateCheck(NearestEnemyOf(Myself),STATE_SLEEPING)
  !StateCheck(NearestEnemyOf(Myself),STATE_PANIC)
  !StateCheck(NearestEnemyOf(Myself),STATE_HELPLESS)
  !CheckStatGT(NearestEnemyOf(Myself),50,RESISTMAGIC)
  See(NearestEnemyOf(Myself))
THEN
  RESPONSE #100
    SetGlobal("FoundStunTarget","LOCALS",1)
    Continue()
END

IF
  !GlobalTimerNotExpired("Spell","LOCALS")
  HPLT(ThirdNearestEnemyOf(Myself),90)
  !Gender(ThirdNearestEnemyOf(Myself),SUMMONED)
  !Gender(ThirdNearestEnemyOf(Myself),ILLUSIONARY)
  !StateCheck(ThirdNearestEnemyOf(Myself),STATE_STUNNED)
  !StateCheck(ThirdNearestEnemyOf(Myself),STATE_SLEEPING)
  !StateCheck(ThirdNearestEnemyOf(Myself),STATE_PANIC)
  !StateCheck(ThirdNearestEnemyOf(Myself),STATE_HELPLESS)
  !CheckStatGT(ThirdNearestEnemyOf(Myself),50,RESISTMAGIC)
  See(ThirdNearestEnemyOf(Myself))
THEN
  RESPONSE #100
    SetGlobal("FoundStunTarget","LOCALS",1)
    Continue()
  RESPONSE #30
    Continue()
END

IF
  !GlobalTimerNotExpired("Spell","LOCALS")
  HPLT(SixthNearestEnemyOf(Myself),90)
  !Gender(SixthNearestEnemyOf(Myself),SUMMONED)
  !Gender(SixthNearestEnemyOf(Myself),ILLUSIONARY)
  !StateCheck(SixthNearestEnemyOf(Myself),STATE_STUNNED)
  !StateCheck(SixthNearestEnemyOf(Myself),STATE_SLEEPING)
  !StateCheck(SixthNearestEnemyOf(Myself),STATE_PANIC)
  !StateCheck(SixthNearestEnemyOf(Myself),STATE_HELPLESS)
  !CheckStatGT(SixthNearestEnemyOf(Myself),50,RESISTMAGIC)
  See(SixthNearestEnemyOf(Myself))
THEN
  RESPONSE #100
    SetGlobal("FoundStunTarget","LOCALS",1)
    Continue()
  RESPONSE #60
    Continue()
END

IF
  !GlobalTimerNotExpired("Spell","LOCALS")
  HPLT(NearestEnemyOf(Myself),60)
  !Gender(NearestEnemyOf(Myself),SUMMONED)
  !Gender(NearestEnemyOf(Myself),ILLUSIONARY)
  !StateCheck(NearestEnemyOf(Myself),STATE_STUNNED)
  !StateCheck(NearestEnemyOf(Myself),STATE_SLEEPING)
  !StateCheck(NearestEnemyOf(Myself),STATE_PANIC)
  !StateCheck(NearestEnemyOf(Myself),STATE_HELPLESS)
  !CheckStatGT(NearestEnemyOf(Myself),50,RESISTMAGIC)
  See(NearestEnemyOf(Myself))
THEN
  RESPONSE #100
    SetGlobal("FoundStunTarget","LOCALS",1)
    Continue()
  RESPONSE #20
    Continue()
END

IF
  !GlobalTimerNotExpired("Spell","LOCALS")
  HPLT(ThirdNearestEnemyOf(Myself),60)
  !Gender(ThirdNearestEnemyOf(Myself),SUMMONED)
  !Gender(ThirdNearestEnemyOf(Myself),ILLUSIONARY)
  !StateCheck(ThirdNearestEnemyOf(Myself),STATE_STUNNED)
  !StateCheck(ThirdNearestEnemyOf(Myself),STATE_SLEEPING)
  !StateCheck(ThirdNearestEnemyOf(Myself),STATE_PANIC)
  !StateCheck(ThirdNearestEnemyOf(Myself),STATE_HELPLESS)
  !CheckStatGT(ThirdNearestEnemyOf(Myself),50,RESISTMAGIC)
  See(ThirdNearestEnemyOf(Myself))
THEN
  RESPONSE #100
    SetGlobal("FoundStunTarget","LOCALS",1)
    Continue()
  RESPONSE #60
    Continue()
END

IF
  !GlobalTimerNotExpired("Spell","LOCALS")
  HPLT(SixthNearestEnemyOf(Myself),60)
  !Gender(SixthNearestEnemyOf(Myself),SUMMONED)
  !Gender(SixthNearestEnemyOf(Myself),ILLUSIONARY)
  !StateCheck(SixthNearestEnemyOf(Myself),STATE_STUNNED)
  !StateCheck(SixthNearestEnemyOf(Myself),STATE_SLEEPING)
  !StateCheck(SixthNearestEnemyOf(Myself),STATE_PANIC)
  !StateCheck(SixthNearestEnemyOf(Myself),STATE_HELPLESS)
  !CheckStatGT(SixthNearestEnemyOf(Myself),50,RESISTMAGIC)
  See(SixthNearestEnemyOf(Myself))
THEN
  RESPONSE #100
    SetGlobal("FoundStunTarget","LOCALS",1)
    Continue()
  RESPONSE #120
    Continue()
END

IF
  !GlobalTimerNotExpired("Spell","LOCALS")
  HPLT(NearestEnemyOf(Myself),30)
  !Gender(NearestEnemyOf(Myself),SUMMONED)
  !Gender(NearestEnemyOf(Myself),ILLUSIONARY)
  !StateCheck(NearestEnemyOf(Myself),STATE_STUNNED)
  !StateCheck(NearestEnemyOf(Myself),STATE_SLEEPING)
  !StateCheck(NearestEnemyOf(Myself),STATE_PANIC)
  !StateCheck(NearestEnemyOf(Myself),STATE_HELPLESS)
  !CheckStatGT(NearestEnemyOf(Myself),50,RESISTMAGIC)
  See(NearestEnemyOf(Myself))
THEN
  RESPONSE #100
    SetGlobal("FoundStunTarget","LOCALS",1)
    Continue()
  RESPONSE #30
    Continue()
END

IF
  !GlobalTimerNotExpired("Spell","LOCALS")
  HPLT(ThirdNearestEnemyOf(Myself),30)
  !StateCheck(ThirdNearestEnemyOf(Myself),STATE_STUNNED)
  !StateCheck(ThirdNearestEnemyOf(Myself),STATE_SLEEPING)
  !StateCheck(ThirdNearestEnemyOf(Myself),STATE_PANIC)
  !StateCheck(ThirdNearestEnemyOf(Myself),STATE_HELPLESS)
  !CheckStatGT(ThirdNearestEnemyOf(Myself),50,RESISTMAGIC)
  See(ThirdNearestEnemyOf(Myself))
THEN
  RESPONSE #100
    SetGlobal("FoundStunTarget","LOCALS",1)
    Continue()
  RESPONSE #90
    Continue()
END

IF
  !GlobalTimerNotExpired("Spell","LOCALS")
  HPLT(SixthNearestEnemyOf(Myself),30)
  !StateCheck(SixthNearestEnemyOf(Myself),STATE_STUNNED)
  !StateCheck(SixthNearestEnemyOf(Myself),STATE_SLEEPING)
  !StateCheck(SixthNearestEnemyOf(Myself),STATE_PANIC)
  !StateCheck(SixthNearestEnemyOf(Myself),STATE_HELPLESS)
  !CheckStatGT(SixthNearestEnemyOf(Myself),50,RESISTMAGIC)
  See(SixthNearestEnemyOf(Myself))
THEN
  RESPONSE #100
    SetGlobal("FoundStunTarget","LOCALS",1)
    Continue()
  RESPONSE #180
    Continue()
END

IF
  Global("FoundStunTarget","LOCALS",1)
  HaveSpell(WIZARD_POWER_WORD_STUN)
  !GlobalTimerNotExpired("Spell","LOCALS")
  !GlobalTimerNotExpired("PowerWordStun","LOCALS")
THEN
  RESPONSE #50
    SetGlobal("FoundStunTarget","LOCALS",0)
    SetGlobalTimer("Spell","LOCALS",6)
    SetGlobalTimer("PowerWordStun","LOCALS",18)
    RemoveSpell(WIZARD_POWER_WORD_STUN)
    ForceSpell(LastSeenBy(Myself),WIZARD_POWER_WORD_STUN)
  RESPONSE #50
    SetGlobal("FoundStunTarget","LOCALS",0)
    SetGlobalTimer("Spell","LOCALS",6)
    SetGlobalTimer("PowerWordStun","LOCALS",18)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_STUN)
  RESPONSE #50
    Continue()
END

IF
  Allegiance(Myself,GOODCUTOFF)
  OR(4)
    See(SixthNearestEnemyOf(Myself))
    See([EVILCUTOFF.0.0.FIGHTER_ALL])
    See([EVILCUTOFF.0.0.RANGER_ALL])
    See([EVILCUTOFF.0.0.PALADIN_ALL])
  RandomNumGT(5,3)
  See([EVILCUTOFF.0.0.PALADIN_ALL])
  False()
THEN
  RESPONSE #100
END

IF
  Allegiance(Myself,EVILCUTOFF)
  OR(6)
    See(SixthNearestEnemyOf(Myself))
    See(StrongestOf)
    See([GOODCUTOFF.0.0.FIGHTER_ALL])
    See([GOODCUTOFF.0.0.RANGER_ALL])
    See([GOODCUTOFF.0.0.PALADIN_ALL])
    See(BestAC)
  RandomNumGT(5,3)
  See([GOODCUTOFF.0.0.PALADIN_ALL])
  False()
THEN
  RESPONSE #100
END

IF
  !GlobalTimerNotExpired("Spell","LOCALS")
  !Allegiance(Myself,GOODCUTOFF)
  Allegiance(LastSeenBy(Myself),GOODCUTOFF)
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  OR(2)
    StateCheck(Myself,STATE_MIRRORIMAGE)
    !Range(NearestEnemyOf(Myself),10)
THEN
  RESPONSE #70
    SetGlobalTimer("spell","LOCALS",6)
    ForceSpell(LastSeenBy(Myself),CLERIC_CONFUSION)
  RESPONSE #30
    SetGlobalTimer("spell","LOCALS",6)
    SpellNoDec(LastSeenBy(Myself),CLERIC_CONFUSION)
  RESPONSE #200
    Continue()
END

IF
  Allegiance(Myself,GOODCUTOFF)
  CombatCounter(0)
THEN
  RESPONSE #100
    NoAction()
END

IF
  OR(6)
    See(SixthNearestEnemyOf(Myself))
    See(FifthNearestEnemyOf(Myself))
    See(FourthNearestEnemyOf(Myself))
    See(ThirdNearestEnemyOf(Myself))
    See(SecondNearestEnemyOf(Myself))
    See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
END

IF
  Allegiance(Myself,EVILCUTOFF)
  !StateCheck(SecondNearest([GOODCUTOFF.0.0.CLERIC_ALL]),STATE_SILENCED)
  !StateCheck(SecondNearest([GOODCUTOFF.0.0.CLERIC_ALL]),STATE_STUNNED)
  !StateCheck(SecondNearest([GOODCUTOFF.0.0.CLERIC_ALL]),STATE_PANIC)
  !StateCheck(SecondNearest([GOODCUTOFF.0.0.CLERIC_ALL]),STATE_SLEEPING)
  CheckStatLT(SecondNearest([GOODCUTOFF.0.0.CLERIC_ALL]),100,SPELLFAILUREPRIEST)
  See(SecondNearest([GOODCUTOFF.0.0.CLERIC_ALL]))
  False()
THEN
  RESPONSE #100
END

IF
  Allegiance(Myself,GOODCUTOFF)
  !StateCheck([EVILCUTOFF.0.0.CLERIC_ALL],STATE_SILENCED)
  !StateCheck([EVILCUTOFF.0.0.CLERIC_ALL],STATE_STUNNED)
  !StateCheck([EVILCUTOFF.0.0.CLERIC_ALL],STATE_PANIC)
  !StateCheck([EVILCUTOFF.0.0.CLERIC_ALL],STATE_SLEEPING)
  CheckStatLT([EVILCUTOFF.0.0.CLERIC_ALL],100,SPELLFAILUREPRIEST)
  See([EVILCUTOFF.0.0.CLERIC_ALL])
  False()
THEN
  RESPONSE #100
END

IF
  Allegiance(Myself,EVILCUTOFF)
  !StateCheck([GOODCUTOFF.0.0.CLERIC_ALL],STATE_SILENCED)
  !StateCheck([GOODCUTOFF.0.0.CLERIC_ALL],STATE_STUNNED)
  !StateCheck([GOODCUTOFF.0.0.CLERIC_ALL],STATE_PANIC)
  !StateCheck([GOODCUTOFF.0.0.CLERIC_ALL],STATE_SLEEPING)
  CheckStatLT([GOODCUTOFF.0.0.CLERIC_ALL],100,SPELLFAILUREPRIEST)
  See([GOODCUTOFF.0.0.CLERIC_ALL])
  False()
THEN
  RESPONSE #100
END

IF
  Allegiance(Myself,EVILCUTOFF)
  !StateCheck(SecondNearest([GOODCUTOFF.0.0.LONG_BOW]),STATE_SILENCED)
  !StateCheck(SecondNearest([GOODCUTOFF.0.0.LONG_BOW]),STATE_STUNNED)
  !StateCheck(SecondNearest([GOODCUTOFF.0.0.LONG_BOW]),STATE_PANIC)
  !StateCheck(SecondNearest([GOODCUTOFF.0.0.LONG_BOW]),STATE_SLEEPING)
  CheckStatLT(SecondNearest([GOODCUTOFF.0.0.LONG_BOW]),100,SPELLFAILUREMAGE)
  See(SecondNearest([GOODCUTOFF.0.0.LONG_BOW]))
  False()
THEN
  RESPONSE #100
END

IF
  Allegiance(Myself,GOODCUTOFF)
  !StateCheck([EVILCUTOFF.0.0.MAGE_ALL],STATE_SILENCED)
  !StateCheck([EVILCUTOFF.0.0.MAGE_ALL],STATE_STUNNED)
  !StateCheck([EVILCUTOFF.0.0.MAGE_ALL],STATE_PANIC)
  !StateCheck([EVILCUTOFF.0.0.MAGE_ALL],STATE_SLEEPING)
  CheckStatLT([EVILCUTOFF.0.0.MAGE_ALL],100,SPELLFAILUREMAGE)
  See([EVILCUTOFF.0.0.MAGE_ALL])
  False()
THEN
  RESPONSE #100
END

IF
  Allegiance(Myself,EVILCUTOFF)
  !StateCheck([GOODCUTOFF.0.0.MAGE_ALL],STATE_SILENCED)
  !StateCheck([GOODCUTOFF.0.0.MAGE_ALL],STATE_STUNNED)
  !StateCheck([GOODCUTOFF.0.0.MAGE_ALL],STATE_PANIC)
  !StateCheck([GOODCUTOFF.0.0.MAGE_ALL],STATE_SLEEPING)
  CheckStatLT([GOODCUTOFF.0.0.MAGE_ALL],100,SPELLFAILUREMAGE)
  See([GOODCUTOFF.0.0.MAGE_ALL])
  False()
THEN
  RESPONSE #100
END

IF
  !CheckStatGT(SixthNearestEnemyOf(Myself),0,128)
  !Gender(SixthNearestEnemyOf(Myself),ILLUSIONARY)
  OR(2)
    !Gender(SixthNearestEnemyOf(Myself),SUMMONED)
    LevelGT(SixthNearestEnemyOf(Myself),10)
  !CheckStatLT(SixthNearestEnemyOf(Myself),-9,ARMORCLASS)
  !StateCheck(SixthNearestEnemyOf(Myself),STATE_HELPLESS)
  Range(SixthNearestEnemyOf(Myself),15)
  See(SixthNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
END

IF
  !CheckStatGT(ThirdNearestEnemyOf(Myself),0,128)
  !Gender(ThirdNearestEnemyOf(Myself),ILLUSIONARY)
  OR(2)
    !Gender(ThirdNearestEnemyOf(Myself),SUMMONED)
    LevelGT(ThirdNearestEnemyOf(Myself),10)
  !CheckStatLT(ThirdNearestEnemyOf(Myself),-9,ARMORCLASS)
  !StateCheck(ThirdNearestEnemyOf(Myself),STATE_HELPLESS)
  Range(ThirdNearestEnemyOf(Myself),15)
  See(ThirdNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
END

IF
  !CheckStatGT(NearestEnemyOf(Myself),0,128)
  !Gender(NearestEnemyOf(Myself),ILLUSIONARY)
  OR(2)
    !Gender(NearestEnemyOf(Myself),SUMMONED)
    LevelGT(NearestEnemyOf(Myself),10)
  !CheckStatLT(NearestEnemyOf(Myself),-9,ARMORCLASS)
  !StateCheck(NearestEnemyOf(Myself),STATE_HELPLESS)
  Range(NearestEnemyOf(Myself),15)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
END

IF
  !CheckStatGT(SixthNearestEnemyOf(Myself),0,128)
  !Gender(SixthNearestEnemyOf(Myself),ILLUSIONARY)
  OR(2)
    !Gender(SixthNearestEnemyOf(Myself),SUMMONED)
    LevelGT(SixthNearestEnemyOf(Myself),10)
  OR(2)
    CheckStatGT(SixthNearestEnemyOf(Myself),0,ARMORCLASS)
    HPPercentLT(SixthNearestEnemyOf(Myself),30)
  !CheckStatLT(SixthNearestEnemyOf(Myself),-9,ARMORCLASS)
  !StateCheck(SixthNearestEnemyOf(Myself),STATE_HELPLESS)
  Range(SixthNearestEnemyOf(Myself),15)
  See(SixthNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
END

IF
  !CheckStatGT(ThirdNearestEnemyOf(Myself),0,128)
  !Gender(ThirdNearestEnemyOf(Myself),ILLUSIONARY)
  OR(2)
    !Gender(ThirdNearestEnemyOf(Myself),SUMMONED)
    LevelGT(ThirdNearestEnemyOf(Myself),10)
  OR(2)
    CheckStatGT(ThirdNearestEnemyOf(Myself),0,ARMORCLASS)
    HPPercentLT(ThirdNearestEnemyOf(Myself),30)
  !CheckStatLT(ThirdNearestEnemyOf(Myself),-9,ARMORCLASS)
  !StateCheck(ThirdNearestEnemyOf(Myself),STATE_HELPLESS)
  Range(ThirdNearestEnemyOf(Myself),15)
  See(ThirdNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
END

IF
  !CheckStatGT(NearestEnemyOf(Myself),0,128)
  !Gender(NearestEnemyOf(Myself),ILLUSIONARY)
  OR(2)
    !Gender(NearestEnemyOf(Myself),SUMMONED)
    LevelGT(NearestEnemyOf(Myself),10)
  OR(2)
    CheckStatGT(NearestEnemyOf(Myself),0,ARMORCLASS)
    HPPercentLT(NearestEnemyOf(Myself),30)
  !CheckStatLT(NearestEnemyOf(Myself),-9,ARMORCLASS)
  !StateCheck(NearestEnemyOf(Myself),STATE_HELPLESS)
  Range(NearestEnemyOf(Myself),15)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
END

IF
  Allegiance(Myself,EVILCUTOFF)
  HPPercentGT(Myself,50)
  !CheckStatGT([GOODCUTOFF.0.0.CLERIC_ALL],0,128)
  !Gender([GOODCUTOFF.0.0.CLERIC_ALL],ILLUSIONARY)
  OR(2)
    CheckStatGT([GOODCUTOFF.0.0.CLERIC_ALL],0,ARMORCLASS)
    HPPercentLT([GOODCUTOFF.0.0.CLERIC_ALL],30)
  !CheckStatLT([GOODCUTOFF.0.0.CLERIC_ALL],-9,ARMORCLASS)
  !StateCheck([GOODCUTOFF.0.0.CLERIC_ALL],STATE_HELPLESS)
  Range([GOODCUTOFF.0.0.CLERIC_ALL],15)
  See([GOODCUTOFF.0.0.CLERIC_ALL])
  False()
THEN
  RESPONSE #100
END

IF
  Allegiance(Myself,EVILCUTOFF)
  HPPercentGT(Myself,50)
  !CheckStatGT([GOODCUTOFF.0.0.MAGE_ALL],0,128)
  !Gender([GOODCUTOFF.0.0.MAGE_ALL],ILLUSIONARY)
  OR(2)
    CheckStatGT([GOODCUTOFF.0.0.MAGE_ALL],0,ARMORCLASS)
    HPPercentLT([GOODCUTOFF.0.0.MAGE_ALL],30)
  !CheckStatLT([GOODCUTOFF.0.0.MAGE_ALL],-9,ARMORCLASS)
  !StateCheck([GOODCUTOFF.0.0.MAGE_ALL],STATE_HELPLESS)
  Range([GOODCUTOFF.0.0.MAGE_ALL],15)
  See([GOODCUTOFF.0.0.MAGE_ALL])
  False()
THEN
  RESPONSE #100
END

IF
  Allegiance(Myself,ENEMY)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  See([GOODCUTOFF])
THEN
  RESPONSE #100
    MoveToObject([GOODCUTOFF])
END

IF
  Allegiance(Myself,ENEMY)
  OR(2)
    !Allegiance(LastSeenBy(Myself),GOODCUTOFF)
    !See([GOODCUTOFF])
THEN
  RESPONSE #100
    MoveToObject(Player1)
END

IF
  Allegiance(Myself,GOODCUTOFF)
  !Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  See([EVILCUTOFF])
THEN
  RESPONSE #100
    MoveToObject([EVILCUTOFF])
END

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

IF
  StateCheck(LastSeenBy(Myself),STATE_DEAD)
THEN
  RESPONSE #100
    AttackOneRound(NearestEnemyOf(Myself))
END

IF
  !GlobalTimerNotExpired("Spell","LOCALS")
  !Class(LastSeenBy(Myself),MONK)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),DEMONIC)
  !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))
  CheckStatGT(LastSeenBy(Myself),3,SAVEVSSPELL)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
THEN
  RESPONSE #50
    SetGlobalTimer("Spell","LOCALS",6)
    ForceSpell(LastSeenBy(Myself),WIZARD_CHARM_PERSON)
  RESPONSE #50
    SetGlobalTimer("Spell","LOCALS",6)
    SpellNoDec(LastSeenBy(Myself),WIZARD_CHARM_PERSON)
  RESPONSE #200
    Continue()
END

IF
  !GlobalTimerNotExpired("Spell","LOCALS")
  !CheckStatGT(LastSeenBy(Myself),50,RESISTFIRE)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  Range(LastSeenBy(Myself),5)
THEN
  RESPONSE #50
    SetGlobalTimer("Spell","LOCALS",6)
    ForceSpell(LastSeenBy(Myself),WIZARD_BURNING_HANDS)
  RESPONSE #50
    SetGlobalTimer("Spell","LOCALS",6)
    SpellNoDec(LastSeenBy(Myself),WIZARD_BURNING_HANDS)
  RESPONSE #200
    Continue()
END

IF
  Global("xyxManeuvered","LOCALS",0)
  GlobalTimerExpired("xyxAttack","LOCALS")
THEN
  RESPONSE #100
    SetGlobal("xyxManeuvered","LOCALS",1)
    RandomWalkContinuous()
END

IF
  OR(2)
    CheckStatLT(LastSeenBy(Myself),100,RESISTSLASHING)
    CheckStatLT(LastSeenBy(Myself),100,RESISTCRUSHING)
THEN
  RESPONSE #100
    SetGlobalTimer("xyxAttack","LOCALS",5)
    SetGlobal("xyxManeuvered","LOCALS",0)
    AttackOneRound(LastSeenBy(Myself))
END

IF
  True()
THEN
  RESPONSE #100
    RandomWalkContinuous()
END

