
IF
  Global("GBYesSir","LOCALS",0)
  Name("MoonDog",Myself)
THEN
  RESPONSE #100
    SetGlobal("GBYesSir","LOCALS",1)
    ChangeAIScript("",OVERRIDE)
END

IF
  !Specifics(Myself,200)
THEN
  RESPONSE #100
    ChangeSpecifics(Myself,200)
END

IF
  HotKey(E)
THEN
  RESPONSE #100
    DisplayStringHead(Myself,14671)  // ~AI off~
    SetGlobalTimer("GBAIInterrupt","LOCALS",ONE_ROUND)
    PauseGame()
END

IF
  GlobalTimerNotExpired("GBAIInterrupt","LOCALS")
THEN
  RESPONSE #100
END

IF
  HotKey(S)
  Global("GBNoAI","LOCALS",0)
THEN
  RESPONSE #100
    DisplayStringHead(Myself,14671)  // ~AI off~
    SetGlobal("GBNoAI","LOCALS",1)
END

IF
  HotKey(S)
  !Global("GBNoAI","LOCALS",0)
THEN
  RESPONSE #100
    DisplayStringHead(Myself,14669)  // ~AI on~
    SetGlobal("GBNoAI","LOCALS",0)
END

IF
  Global("GBNoAI","LOCALS",1)
THEN
  RESPONSE #100
END
//////////////CLOUDLIKE  EFFECTS//////////////////////

IF
  CheckStat(Myself,11,180) // I'm in a stinking cloud
  CheckStatGT(Myself,5,INT)
  !StateCheck(Myself,STATE_SLEEPING) // not yet affected
  CheckStatGT(Myself,4,SAVEVSSPELL) //and I got a reasonable chance of failing a save throw (25%+)
  OR(2)
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStatGT(Myself,11,180) // I'm in a web,entangle, or grease spell
  CheckStatLT(Myself,15,180)
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,1,131) // I don't have free action
  CheckStatLT(Myself,1,WEB) //and not webbed up
  CheckStatLT(Myself,1,ENTANGLE) //nor entangled --I can move
  CheckStatGT(Myself,4,SAVEVSSPELL) //and I got a reasonable chance of failing a save throw (25%+)
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStat(Myself,15,180) // I'm in an Ice Storm
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,100,RESISTCOLD) // Not Immune
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStat(Myself,16,180) // I'm in a Cloudkill or Death Fog
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,100,RESISTPOISON) // Not Immune
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStat(Myself,17,180) // I'm in a Death Fog
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,100,RESISTACID) // Not Immune
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStat(Myself,18,180) // Incendiary Cloud, Meteor Swarm or Fire Storm -- bad stuff
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,100,RESISTFIRE) // Not Immune
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

// This is to try and keep them from going back in to whomp somebody
IF
  CheckStatLT(Myself,11,180) // No longer in the cloud effects
  CheckStatGT(Myself,5,INT)
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  !Range(LastSeenBy(Myself),16)
  Exists([EVILCUTOFF])
  !Range(NearestEnemyOf(Myself),2)
THEN
  RESPONSE #100
    EquipRanged()  //use your bow, then
    SmallWait(3)
    Continue()
END

//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

IF
  ModalState(DETECTTRAPS)
THEN
  RESPONSE #100
END

IF
  ModalState(TURNUNDEAD)
  Global("GBTurned","LOCALS",1)
  GlobalTimerExpired("GBAutoTurning","LOCALS")
THEN
  RESPONSE #100
    SetGlobal("GBTurned","LOCALS",0)
END

IF
  ModalState(TURNUNDEAD)
THEN
  RESPONSE #100
END

IF
  ModalState(BATTLESONG)
THEN
  RESPONSE #100
END

IF
  ModalState(STEALTH)
THEN
  RESPONSE #100
END

IF
  HotKey(K)
  Global("GBKillMyself","LOCALS",0)
THEN
  RESPONSE #100
    DisplayStringHead(Player1,13573)  // ~  It would be wise for you to leave.  Now.~
    DisplayStringHead(Myself,40115)  // ~Are you sure... you wish me to do this?~
    SetGlobal("GBKillMyself","LOCALS",1)
    DropInventory()
END

IF
  HotKey(K)
  Global("GBKillMyself","LOCALS",1)
THEN
  RESPONSE #100
    DisplayStringHead(Player1,32107)  // ~I am sure.  Good-bye.~
    DisplayStringHead(Myself,741)  // ~Farewell then. Take care.~
    ForceSpell(Myself,DRYAD_TELEPORT)
END

IF
  HotKey(N)
  !Global("GBKillMyself","LOCALS",0)
THEN
  RESPONSE #100
    DisplayStringHead(Player1,35233)  // ~No, don't go.  Just keep quiet.~
    DisplayStringHead(Myself,40148)  // ~As you wish, my <PRO_LADYLORD>.~
    SetGlobal("GBKillMyself","LOCALS",0)
END

IF
  HaveSpell(CLERIC_IRONSKIN)
  CheckStatLT(Myself,1,STONESKINS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_IRONSKIN)
END

IF
  HaveSpell(WIZARD_STONE_SKIN)
  CheckStatLT(Myself,1,STONESKINS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_STONE_SKIN)
END

IF
  HaveSpell(WIZARD_ARMOR)
  !GlobalTimerNotExpired("GBWizArmor","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SetGlobalTimer("GBWizArmor","LOCALS",NINE_HOURS)
    Spell(Myself,WIZARD_ARMOR)
END

IF
  HaveSpell(WIZARD_STRENGTH)
  CheckStatLT(Myself,19,STR)
  CheckStatLT(Myself,50,STREXTRA)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_STRENGTH)
END

IF
  HaveSpell(CLERIC_TRUE_SIGHT)
  Detect([EVILCUTOFF])
  OR(6)
    !See(LastSeenBy(Myself))
    See(NearestEnemyOfType([EVILCUTOFF.0.0.0.0.ILLUSIONARY]))
    StateCheck([EVILCUTOFF],STATE_INVISIBLE)
    StateCheck([EVILCUTOFF],STATE_IMPROVEDINVISIBILITY)
    StateCheck([EVILCUTOFF],STATE_MIRRORIMAGE)
    StateCheck([EVILCUTOFF],STATE_BLUR)
  !HPLT(LastSeenBy(Myself),1)
  !GlobalTimerNotExpired("GBClrTrueSght","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SetGlobalTimer("GBClrTrueSght","LOCALS",ONE_TURN)
    Spell(Myself,CLERIC_TRUE_SIGHT)
END

IF
  HaveSpell(WIZARD_TRUE_SIGHT)
  Detect([EVILCUTOFF])
  OR(6)
    !See(LastSeenBy(Myself))
    See(NearestEnemyOfType([EVILCUTOFF.0.0.0.0.ILLUSIONARY]))
    StateCheck([EVILCUTOFF],STATE_INVISIBLE)
    StateCheck([EVILCUTOFF],STATE_IMPROVEDINVISIBILITY)
    StateCheck([EVILCUTOFF],STATE_MIRRORIMAGE)
    StateCheck([EVILCUTOFF],STATE_BLUR)
  !HPLT(LastSeenBy(Myself),1)
  !GlobalTimerNotExpired("GBWizTrueSght","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SetGlobalTimer("GBWizTrueSght","LOCALS",ONE_TURN)
    Spell(Myself,WIZARD_TRUE_SIGHT)
END

IF
  StateCheck(Player1,STATE_POISONED)
  HaveSpell(CLERIC_SLOW_POISON)
  !StateCheck(Player1,STATE_INVISIBLE)
  !StateCheck(Player1,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player1,CLERIC_SLOW_POISON)
END

IF
  StateCheck(Player2,STATE_POISONED)
  HaveSpell(CLERIC_SLOW_POISON)
  !StateCheck(Player2,STATE_INVISIBLE)
  !StateCheck(Player2,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player2,CLERIC_SLOW_POISON)
END

IF
  StateCheck(Player3,STATE_POISONED)
  HaveSpell(CLERIC_SLOW_POISON)
  !StateCheck(Player3,STATE_INVISIBLE)
  !StateCheck(Player3,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player3,CLERIC_SLOW_POISON)
END

IF
  StateCheck(Player4,STATE_POISONED)
  HaveSpell(CLERIC_SLOW_POISON)
  !StateCheck(Player4,STATE_INVISIBLE)
  !StateCheck(Player4,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player4,CLERIC_SLOW_POISON)
END

IF
  StateCheck(Player5,STATE_POISONED)
  HaveSpell(CLERIC_SLOW_POISON)
  !StateCheck(Player5,STATE_INVISIBLE)
  !StateCheck(Player5,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player5,CLERIC_SLOW_POISON)
END

IF
  StateCheck(Player6,STATE_POISONED)
  HaveSpell(CLERIC_SLOW_POISON)
  !StateCheck(Player6,STATE_INVISIBLE)
  !StateCheck(Player6,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player6,CLERIC_SLOW_POISON)
END

IF
  StateCheck(Player1,STATE_POISONED)
  HaveSpell(CLERIC_NEUTRALIZE_POISON)
  !StateCheck(Player1,STATE_INVISIBLE)
  !StateCheck(Player1,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player1,CLERIC_NEUTRALIZE_POISON)
END

IF
  StateCheck(Player2,STATE_POISONED)
  HaveSpell(CLERIC_NEUTRALIZE_POISON)
  !StateCheck(Player2,STATE_INVISIBLE)
  !StateCheck(Player2,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player2,CLERIC_NEUTRALIZE_POISON)
END

IF
  StateCheck(Player3,STATE_POISONED)
  HaveSpell(CLERIC_NEUTRALIZE_POISON)
  !StateCheck(Player3,STATE_INVISIBLE)
  !StateCheck(Player3,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player3,CLERIC_NEUTRALIZE_POISON)
END

IF
  StateCheck(Player4,STATE_POISONED)
  HaveSpell(CLERIC_NEUTRALIZE_POISON)
  !StateCheck(Player4,STATE_INVISIBLE)
  !StateCheck(Player4,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player4,CLERIC_NEUTRALIZE_POISON)
END

IF
  StateCheck(Player5,STATE_POISONED)
  HaveSpell(CLERIC_NEUTRALIZE_POISON)
  !StateCheck(Player5,STATE_INVISIBLE)
  !StateCheck(Player5,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player5,CLERIC_NEUTRALIZE_POISON)
END

IF
  StateCheck(Player6,STATE_POISONED)
  HaveSpell(CLERIC_NEUTRALIZE_POISON)
  !StateCheck(Player6,STATE_INVISIBLE)
  !StateCheck(Player6,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player6,CLERIC_NEUTRALIZE_POISON)
END

IF
  ActionListEmpty()
  CheckStatGT(Player1,0,200)
  CombatCounter(0)
  HaveSpell(CLERIC_LESSER_RESTORATION)
  See(Player1)
  !HasBounceEffects(Player1)
  !StateCheck(Player1,STATE_INVISIBLE)
  !StateCheck(Player1,STATE_IMPROVEDINVISIBILITY)
  Global("GBHealInProgress","GLOBAL",0)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    SetGlobalTimer("GBHealingNow","GLOBAL",FIVE_ROUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",1)
    Spell(Player1,CLERIC_LESSER_RESTORATION)
    SetGlobal("GBHealInProgress","GLOBAL",0)
END

IF
  ActionListEmpty()
  CheckStatGT(Player2,0,200)
  CombatCounter(0)
  HaveSpell(CLERIC_LESSER_RESTORATION)
  See(Player2)
  !HasBounceEffects(Player2)
  !StateCheck(Player2,STATE_INVISIBLE)
  !StateCheck(Player2,STATE_IMPROVEDINVISIBILITY)
  Global("GBHealInProgress","GLOBAL",0)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    SetGlobalTimer("GBHealingNow","GLOBAL",FIVE_ROUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",1)
    Spell(Player2,CLERIC_LESSER_RESTORATION)
    SetGlobal("GBHealInProgress","GLOBAL",0)
END

IF
  ActionListEmpty()
  CheckStatGT(Player3,0,200)
  CombatCounter(0)
  HaveSpell(CLERIC_LESSER_RESTORATION)
  See(Player3)
  !HasBounceEffects(Player3)
  !StateCheck(Player3,STATE_INVISIBLE)
  !StateCheck(Player3,STATE_IMPROVEDINVISIBILITY)
  Global("GBHealInProgress","GLOBAL",0)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    SetGlobalTimer("GBHealingNow","GLOBAL",FIVE_ROUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",1)
    Spell(Player3,CLERIC_LESSER_RESTORATION)
    SetGlobal("GBHealInProgress","GLOBAL",0)
END

IF
  ActionListEmpty()
  CheckStatGT(Player4,0,200)
  CombatCounter(0)
  HaveSpell(CLERIC_LESSER_RESTORATION)
  See(Player4)
  !HasBounceEffects(Player4)
  !StateCheck(Player4,STATE_INVISIBLE)
  !StateCheck(Player4,STATE_IMPROVEDINVISIBILITY)
  Global("GBHealInProgress","GLOBAL",0)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    SetGlobalTimer("GBHealingNow","GLOBAL",FIVE_ROUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",1)
    Spell(Player4,CLERIC_LESSER_RESTORATION)
    SetGlobal("GBHealInProgress","GLOBAL",0)
END

IF
  ActionListEmpty()
  CheckStatGT(Player5,0,200)
  CombatCounter(0)
  HaveSpell(CLERIC_LESSER_RESTORATION)
  See(Player5)
  !HasBounceEffects(Player5)
  !StateCheck(Player5,STATE_INVISIBLE)
  !StateCheck(Player5,STATE_IMPROVEDINVISIBILITY)
  Global("GBHealInProgress","GLOBAL",0)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    SetGlobalTimer("GBHealingNow","GLOBAL",FIVE_ROUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",1)
    Spell(Player5,CLERIC_LESSER_RESTORATION)
    SetGlobal("GBHealInProgress","GLOBAL",0)
END

IF
  ActionListEmpty()
  CheckStatGT(Player6,0,200)
  CombatCounter(0)
  HaveSpell(CLERIC_LESSER_RESTORATION)
  See(Player6)
  !HasBounceEffects(Player6)
  !StateCheck(Player6,STATE_INVISIBLE)
  !StateCheck(Player6,STATE_IMPROVEDINVISIBILITY)
  Global("GBHealInProgress","GLOBAL",0)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    SetGlobalTimer("GBHealingNow","GLOBAL",FIVE_ROUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",1)
    Spell(Player6,CLERIC_LESSER_RESTORATION)
    SetGlobal("GBHealInProgress","GLOBAL",0)
END

IF
  ActionListEmpty()
  CombatCounter(0)
  CheckStatGT(Myself,0,200)
  HasItemEquiped("restore",Myself)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("restore",Myself)  // ~Restoration~
END

IF
  !Global("GBHealInProgress","GLOBAL",0)
  !GlobalTimerNotExpired("GBHealingNow","GLOBAL")
THEN
  RESPONSE #100
    SetGlobal("GBHealInProgress","GLOBAL",0)
END

IF
  ActionListEmpty()
  RandomNum(10,1)
  CombatCounter(0)
  HPPercentLT(MostDamagedOf(Myself),50)
  HaveSpell(CLERIC_HEAL)
  See(MostDamagedOf(Myself))
  !HasBounceEffects(MostDamagedOf(Myself))
  !StateCheck(MostDamagedOf(Myself),STATE_INVISIBLE)
  !StateCheck(MostDamagedOf(Myself),STATE_IMPROVEDINVISIBILITY)
  Global("GBHealInProgress","GLOBAL",0)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    SetGlobalTimer("GBHealingNow","GLOBAL",FIVE_ROUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",1)
    Spell(MostDamagedOf(Myself),CLERIC_HEAL)
    SetGlobal("GBHealInProgress","GLOBAL",0)
END

IF
  ActionListEmpty()
  RandomNum(10,1)
  CombatCounter(0)
  HPPercentLT(MostDamagedOf(Myself),50)
  HaveSpell(CLERIC_RESURRECTION)
  See(MostDamagedOf(Myself))
  !HasBounceEffects(MostDamagedOf(Myself))
  !StateCheck(MostDamagedOf(Myself),STATE_INVISIBLE)
  !StateCheck(MostDamagedOf(Myself),STATE_IMPROVEDINVISIBILITY)
  Global("GBHealInProgress","GLOBAL",0)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    SetGlobalTimer("GBHealingNow","GLOBAL",FIVE_ROUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",1)
    Spell(MostDamagedOf(Myself),CLERIC_RESURRECTION)
    SetGlobal("GBHealInProgress","GLOBAL",0)
END

IF
  RandomNum(10,1)
  ActionListEmpty()
  CombatCounter(0)
  HPPercentLT(MostDamagedOf(Myself),60)
  HaveSpell(CLERIC_CURE_CRITICAL_WOUNDS)
  See(MostDamagedOf(Myself))
  !HasBounceEffects(MostDamagedOf(Myself))
  !StateCheck(MostDamagedOf(Myself),STATE_INVISIBLE)
  !StateCheck(MostDamagedOf(Myself),STATE_IMPROVEDINVISIBILITY)
  Global("GBHealInProgress","GLOBAL",0)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    SetGlobalTimer("GBHealingNow","GLOBAL",FIVE_ROUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",1)
    Spell(MostDamagedOf(Myself),CLERIC_CURE_CRITICAL_WOUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",0)
END

IF
  RandomNum(10,1)
  ActionListEmpty()
  CombatCounter(0)
  HPPercentLT(MostDamagedOf(Myself),70)
  HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
  See(MostDamagedOf(Myself))
  !HasBounceEffects(MostDamagedOf(Myself))
  !StateCheck(MostDamagedOf(Myself),STATE_INVISIBLE)
  !StateCheck(MostDamagedOf(Myself),STATE_IMPROVEDINVISIBILITY)
  Global("GBHealInProgress","GLOBAL",0)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    SetGlobalTimer("GBHealingNow","GLOBAL",FIVE_ROUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",1)
    Spell(MostDamagedOf(Myself),CLERIC_CURE_SERIOUS_WOUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",0)
END

IF
  ActionListEmpty()
  RandomNum(10,1)
  CombatCounter(0)
  HPPercentLT(MostDamagedOf(Myself),80)
  HaveSpell(CLERIC_CURE_MEDIUM_WOUNDS)
  See(MostDamagedOf(Myself))
  !HasBounceEffects(MostDamagedOf(Myself))
  !StateCheck(MostDamagedOf(Myself),STATE_INVISIBLE)
  !StateCheck(MostDamagedOf(Myself),STATE_IMPROVEDINVISIBILITY)
  Global("GBHealInProgress","GLOBAL",0)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    SetGlobalTimer("GBHealingNow","GLOBAL",FIVE_ROUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",1)
    Spell(MostDamagedOf(Myself),CLERIC_CURE_MEDIUM_WOUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",0)
END

IF
  ActionListEmpty()
  RandomNum(10,1)
  CombatCounter(0)
  HPPercentLT(MostDamagedOf(Myself),90)
  HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)
  See(MostDamagedOf(Myself))
  !HasBounceEffects(MostDamagedOf(Myself))
  !StateCheck(MostDamagedOf(Myself),STATE_INVISIBLE)
  !StateCheck(MostDamagedOf(Myself),STATE_IMPROVEDINVISIBILITY)
  Global("GBHealInProgress","GLOBAL",0)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    SetGlobalTimer("GBHealingNow","GLOBAL",FIVE_ROUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",1)
    Spell(MostDamagedOf(Myself),CLERIC_CURE_LIGHT_WOUNDS)
    SetGlobal("GBHealInProgress","GLOBAL",0)
END

IF
  Heard([GOODCUTOFF],200)
  HaveSpell(CLERIC_RESURRECTION)
  !HasBounceEffects(LastHeardBy(Myself))
  !StateCheck(LastHeardBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastHeardBy(Myself),STATE_IMPROVEDINVISIBILITY)
  InParty(LastHeardBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    Spell(LastHeardBy(Myself),CLERIC_RESURRECTION)
END

IF
  Heard([GOODCUTOFF],200)
  HaveSpell(CLERIC_HEAL)
  !HasBounceEffects(LastHeardBy(Myself))
  !StateCheck(LastHeardBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastHeardBy(Myself),STATE_IMPROVEDINVISIBILITY)
  InParty(LastHeardBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    Spell(LastHeardBy(Myself),CLERIC_HEAL)
END

IF
  Heard([GOODCUTOFF],200)
  HaveSpell(CLERIC_CURE_CRITICAL_WOUNDS)
  !HasBounceEffects(LastHeardBy(Myself))
  !StateCheck(LastHeardBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastHeardBy(Myself),STATE_IMPROVEDINVISIBILITY)
  InParty(LastHeardBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    Spell(LastHeardBy(Myself),CLERIC_CURE_CRITICAL_WOUNDS)
END

IF
  Heard([GOODCUTOFF],200)
  HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
  !HasBounceEffects(LastHeardBy(Myself))
  !StateCheck(LastHeardBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastHeardBy(Myself),STATE_IMPROVEDINVISIBILITY)
  InParty(LastHeardBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    MakeUnselectable(2)
    Spell(LastHeardBy(Myself),CLERIC_CURE_SERIOUS_WOUNDS)
END

IF
  HPPercentLT(Player1Fill,50)
  HasItemEquiped("Rods03",Myself)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("Rods03",Player1Fill)  // ~Rod of Resurrection~
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HPPercentLT(Player2Fill,50)
  HasItemEquiped("Rods03",Myself)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("Rods03",Player2Fill)  // ~Rod of Resurrection~
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HPPercentLT(Player3Fill,50)
  HasItemEquiped("Rods03",Myself)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("Rods03",Player3Fill)  // ~Rod of Resurrection~
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HPPercentLT(Player4Fill,50)
  HasItemEquiped("Rods03",Myself)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("Rods03",Player4Fill)  // ~Rod of Resurrection~
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HPPercentLT(Player5Fill,50)
  HasItemEquiped("Rods03",Myself)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("Rods03",Player5Fill)  // ~Rod of Resurrection~
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HPPercentLT(Player6Fill,50)
  HasItemEquiped("Rods03",Myself)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("Rods03",Player6Fill)  // ~Rod of Resurrection~
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HasItemEquiped("Brac23",Myself)
  Global("UsedBrac23","LOCALS",0)
  HPPercentLT(Player1Fill,50)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("Brac23",Player1Fill)  // ~Blessed Bracers~
    SetGlobal("UsedBrac23","LOCALS",1)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HasItemEquiped("Brac23",Myself)
  Global("UsedBrac23","LOCALS",0)
  HPPercentLT(Player2Fill,50)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("Brac23",Player2Fill)  // ~Blessed Bracers~
    SetGlobal("UsedBrac23","LOCALS",1)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HasItemEquiped("Brac23",Myself)
  Global("UsedBrac23","LOCALS",0)
  HPPercentLT(Player3Fill,50)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("Brac23",Player3Fill)  // ~Blessed Bracers~
    SetGlobal("UsedBrac23","LOCALS",1)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HasItemEquiped("Brac23",Myself)
  Global("UsedBrac23","LOCALS",0)
  HPPercentLT(Player4Fill,50)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("Brac23",Player4Fill)  // ~Blessed Bracers~
    SetGlobal("UsedBrac23","LOCALS",1)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HasItemEquiped("Brac23",Myself)
  Global("UsedBrac23","LOCALS",0)
  HPPercentLT(Player5Fill,50)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("Brac23",Player5Fill)  // ~Blessed Bracers~
    SetGlobal("UsedBrac23","LOCALS",1)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HasItemEquiped("Brac23",Myself)
  Global("UsedBrac23","LOCALS",0)
  HPPercentLT(Player6Fill,50)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("Brac23",Player6Fill)  // ~Blessed Bracers~
    SetGlobal("UsedBrac23","LOCALS",1)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  ActionListEmpty()
  CombatCounter(0)
  HaveSpell(CLERIC_AID)
  See(MostDamagedOf(Myself))
  !StateCheck(LastSeenBy(Myself),STATE_AID)
  !HasBounceEffects(MostDamagedOf(Myself))
  !StateCheck(MostDamagedOf(Myself),STATE_INVISIBLE)
  !StateCheck(MostDamagedOf(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(MostDamagedOf(Myself),CLERIC_AID)
END

IF
  SpellCastOnMe([ANYTHING],CLERIC_PROTECT_FROM_EVIL)
THEN
  RESPONSE #100
    DisplayString(Myself,14769)  // ~Protected from Evil~
    SetGlobalTimer("GBProtFromEvil","LOCALS",ONE_TURN)
END

IF
  SpellCastOnMe([ANYTHING],WIZARD_PROTECTION_FROM_EVIL)
THEN
  RESPONSE #100
    DisplayString(Myself,14769)  // ~Protected from Evil~
    SetGlobalTimer("GBProtFromEvil","LOCALS",ONE_TURN)
END

IF
  Heard([GOODCUTOFF],201)
  Range(LastHeardBy(Myself),10)
THEN
  RESPONSE #100
    DisplayString(Myself,14769)  // ~Protected from Evil~
    SetGlobalTimer("GBProtFromEvil","LOCALS",TWO_HOURS)
END

IF
  ActionListEmpty()
  HaveSpellRES("spcl918")
  CombatCounter(0)
THEN
  RESPONSE #100
    SpellRES("spcl918",Myself)  // ~Alchemy~
END

IF
  ActionListEmpty()
  HaveSpellRES("spcl919")
  CombatCounter(0)
THEN
  RESPONSE #100
    SpellRES("spcl919",Myself)  // ~Scribe Scrolls~
END

IF
  ActionListEmpty()
  HaveSpellRES("spcl921")
  CombatCounter(0)
THEN
  RESPONSE #100
    SpellRES("spcl921",Myself)  // ~Magic Flute~
END

IF
  HotKey(F)
  Global("GBFleetofFoot","LOCALS",0)
THEN
  RESPONSE #100
    DisplayStringHead(Myself,44441)  // ~Run away!  Run away!  Ha ha ha!!~
    SetGlobal("GBFleetofFoot","LOCALS",1)
END

IF
  HotKey(F)
  !Global("GBFleetofFoot","LOCALS",0)
THEN
  RESPONSE #100
    DisplayStringHead(Myself,24713)  // ~I will not hide from such filth as you. Come and die, if you are brave enough!~
    SetGlobal("GBFleetofFoot","LOCALS",0)
END

IF
  !Global("GBFleetofFoot","LOCALS",0)
  GlobalLT("GBFoFRunning","LOCALS",4)
  !InParty(LastAttackerOf(Myself))
  See(NearestEnemyOf(Myself))
  Range(LastAttackerOf(Myself),10)
  HPGT(LastAttackerOf(Myself),1)
  !GlobalTimerNotExpired("GBFleetFootTimer","LOCALS")
THEN
  RESPONSE #100
    DisplayStringHead(Myself,44441)  // ~Run away!  Run away!  Ha ha ha!!~
    SetGlobalTimer("GBFleetFootTimer","LOCALS",TWO_ROUNDS)
    IncrementGlobal("GBFoFRunning","LOCALS",1)
    RandomWalkContinuous()
END

IF
  GlobalTimerNotExpired("GBFleetFootTimer","LOCALS")
  GlobalLT("GBFoFRunning","LOCALS",4)
  !InParty(LastAttackerOf(Myself))
  See(NearestEnemyOf(Myself))
  Range(LastAttackerOf(Myself),10)
  HPGT(LastAttackerOf(Myself),1)
THEN
  RESPONSE #100
    RandomWalkContinuous()
END

IF
  GlobalGT("GBFoFRunning","LOCALS",0)
  CombatCounter(0)
  !Detect([EVILCUTOFF])
THEN
  RESPONSE #100
    SetGlobal("GBFoFRunning","LOCALS",0)
END

IF
  !See(NearestEnemyOf(Myself))
  !Detect([EVILCUTOFF])
  CombatCounter(0)
THEN
  RESPONSE #100
END

IF
  CombatCounter(0)
  Detect([EVILCUTOFF])
  HPGT([EVILCUTOFF],1)
THEN
  RESPONSE #100
    StartCombatCounter()
    Continue()
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  GlobalTimerNotExpired("GBHalfAttack","LOCALS")
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  Global("GBAmmoless","LOCALS",0)
  !HasItemSlot(Myself,SLOT_MISC19)
  HasItemSlot(Myself,SLOT_WEAPON0)
  !GlobalTimerNotExpired("GBWizAlacrity","LOCALS")
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
  RESPONSE #100
    SelectWeaponAbility(SLOT_WEAPON0,0)
    Attack(LastSeenBy(Myself))
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  GlobalTimerNotExpired("GBHalfAttack","LOCALS")
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  OR(3)
    !HasItemSlot(Myself,SLOT_WEAPON0)
    HasItemSlot(Myself,SLOT_MISC19)
    Global("GBAmmoless","LOCALS",1)
  !GlobalTimerNotExpired("GBWizAlacrity","LOCALS")
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
  RESPONSE #100
    EquipMostDamagingMelee()
    Attack(LastSeenBy(Myself))
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  GlobalTimerNotExpired("GBHalfAttack","LOCALS")
  OR(3)
    See(NearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),8)
  !Range(LastAttackerOf(Myself),8)
  Global("GBAmmoless","LOCALS",0)
  !HasItemSlot(Myself,SLOT_MISC19)
  HasItemSlot(Myself,SLOT_WEAPON1)
  !GlobalTimerNotExpired("GBWizAlacrity","LOCALS")
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
  RESPONSE #100
    SelectWeaponAbility(SLOT_WEAPON1,0)
    Attack(LastSeenBy(Myself))
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  GlobalTimerNotExpired("GBHalfAttack","LOCALS")
  OR(3)
    See(NearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),8)
  !Range(LastAttackerOf(Myself),8)
  OR(3)
    !HasItemSlot(Myself,SLOT_WEAPON1)
    HasItemSlot(Myself,SLOT_MISC19)
    Global("GBAmmoless","LOCALS",1)
  !GlobalTimerNotExpired("GBWizAlacrity","LOCALS")
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
  RESPONSE #100
    EquipRanged()
    Attack(LastSeenBy(Myself))
END

IF
  Heard([GOODCUTOFF],203)
  !See(NearestEnemyOf(Myself))
THEN
  RESPONSE #500
    MoveToObject(LastHeardBy(Myself))
END

IF
  HaveSpell(CLERIC_MASS_CURE)
  OR(5)
    HPPercentLT(Player1,50)
    HPPercentLT(Player2,50)
    HPPercentLT(Player3,50)
    HPPercentLT(Player4,50)
    HPPercentLT(Player5,50)
  OR(5)
    HPPercentLT(Player1,50)
    HPPercentLT(Player2,50)
    HPPercentLT(Player3,50)
    HPPercentLT(Player4,50)
    HPPercentLT(Player6,50)
  OR(5)
    HPPercentLT(Player1,50)
    HPPercentLT(Player2,50)
    HPPercentLT(Player3,50)
    HPPercentLT(Player5,50)
    HPPercentLT(Player6,50)
  OR(5)
    HPPercentLT(Player1,50)
    HPPercentLT(Player2,50)
    HPPercentLT(Player4,50)
    HPPercentLT(Player5,50)
    HPPercentLT(Player6,50)
  OR(5)
    HPPercentLT(Player1,50)
    HPPercentLT(Player3,50)
    HPPercentLT(Player4,50)
    HPPercentLT(Player5,50)
    HPPercentLT(Player6,50)
  OR(5)
    HPPercentLT(Player2,50)
    HPPercentLT(Player3,50)
    HPPercentLT(Player4,50)
    HPPercentLT(Player5,50)
    HPPercentLT(Player6,50)
  !CheckStatGT(Myself,35,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_MASS_CURE)
END


IF
  HaveSpell(WIZARD_DEATH_SPELL)
  See(NearestEnemyOfType([0.0.0.OGRE_MAGE]))
  Gender(LastSeenBy(Myself),SUMMONED)
  HasItemEquiped("NISHRUU",LastSeenBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DEATH_SPELL)
END

IF
  HaveSpell(WIZARD_VOCALIZE)
  StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_VOCALIZE)
END

IF
  HaveSpell(WIZARD_MASS_INVISIBILITY)
  See(NearestEnemyOf(Myself))
  !CheckStatLT(LastSeenBy(Myself),2500,XPVALUE)
  !StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(LastSeenBy(Myself),0,SEEINVISIBLE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
  !GlobalTimerNotExpired("GBInvis","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SetGlobalTimer("GBInvis","LOCALS",ONE_TURN)
    Spell(Myself,WIZARD_MASS_INVISIBILITY)
END

IF
  HasItemEquiped("SCRL8W",Myself)
  See(NearestEnemyOf(Myself))
  !CheckStatLT(LastSeenBy(Myself),2500,XPVALUE)
  !StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(LastSeenBy(Myself),0,SEEINVISIBLE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
  !GlobalTimerNotExpired("GBInvis","LOCALS")
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("SCRL8W",Myself)  // ~Mass Invisibility~
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SetGlobalTimer("GBInvis","LOCALS",ONE_TURN)
END

IF
  HaveSpell(WIZARD_SHADOW_DOOR)
  See(NearestEnemyOf(Myself))
  !CheckStatLT(LastSeenBy(Myself),2500,XPVALUE)
  !StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(LastSeenBy(Myself),0,SEEINVISIBLE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
  !GlobalTimerNotExpired("GBInvis","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SetGlobalTimer("GBInvis","LOCALS",ONE_TURN)
    Spell(Myself,WIZARD_SHADOW_DOOR)
END

IF
  HasItemEquiped("SCRL2H",Myself)
  See(NearestEnemyOf(Myself))
  !CheckStatLT(LastSeenBy(Myself),2500,XPVALUE)
  !StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(LastSeenBy(Myself),0,SEEINVISIBLE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
  !GlobalTimerNotExpired("GBInvis","LOCALS")
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("SCRL2H",Myself)  // ~Shadow Door~
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SetGlobalTimer("GBInvis","LOCALS",ONE_TURN)
END

IF
  HaveSpell(WIZARD_IMPROVED_INVISIBILITY)
  See(NearestEnemyOf(Myself))
  !CheckStatLT(LastSeenBy(Myself),2500,XPVALUE)
  !StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(LastSeenBy(Myself),0,SEEINVISIBLE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
  !GlobalTimerNotExpired("GBInvis","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SetGlobalTimer("GBInvis","LOCALS",ONE_TURN)
    Spell(Myself,WIZARD_IMPROVED_INVISIBILITY)
END

IF
  HasItemEquiped("SCRL1Y",Myself)
  See(NearestEnemyOf(Myself))
  !CheckStatLT(LastSeenBy(Myself),2500,XPVALUE)
  !StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(LastSeenBy(Myself),0,SEEINVISIBLE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
  !GlobalTimerNotExpired("GBInvis","LOCALS")
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("SCRL1Y",Myself)  // ~Improved Invisibility~
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SetGlobalTimer("GBInvis","LOCALS",ONE_TURN)
END

IF
  HaveSpell(WIZARD_INVISIBILITY_10_FOOT)
  See(NearestEnemyOf(Myself))
  HPPercentLT(Myself,50)
  !StateCheck(Myself,STATE_INVISIBLE)
  !CheckStatGT(LastSeenBy(Myself),0,SEEINVISIBLE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
  !GlobalTimerNotExpired("GBInvis","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SetGlobalTimer("GBInvis","LOCALS",ONE_TURN)
    Spell(Myself,WIZARD_INVISIBILITY_10_FOOT)
END

IF
  HasItemEquiped("SCRL1J",Myself)
  See(NearestEnemyOf(Myself))
  HPPercentLT(Myself,50)
  !StateCheck(Myself,STATE_INVISIBLE)
  !CheckStatGT(LastSeenBy(Myself),0,SEEINVISIBLE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
  !GlobalTimerNotExpired("GBInvis","LOCALS")
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("SCRL1J",Myself)  // ~Invisibility 10' Radius~
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SetGlobalTimer("GBInvis","LOCALS",ONE_TURN)
END

IF
  HaveSpell(WIZARD_INVISIBILITY)
  HPPercentLT(Myself,50)
  See(NearestEnemyOf(Myself))
  !StateCheck(Myself,STATE_INVISIBLE)
  !CheckStatGT(LastSeenBy(Myself),0,SEEINVISIBLE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
  !GlobalTimerNotExpired("GBInvis","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("GBInvis","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_INVISIBILITY)
END

IF
  HasItemEquiped("SCRL90",Myself)
  HPPercentLT(Myself,50)
  See(NearestEnemyOf(Myself))
  !StateCheck(Myself,STATE_INVISIBLE)
  !CheckStatGT(LastSeenBy(Myself),0,SEEINVISIBLE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
  !GlobalTimerNotExpired("GBInvis","LOCALS")
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("SCRL90",Myself)  // ~Invisibilty~
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SetGlobalTimer("GBInvis","LOCALS",ONE_TURN)
END

IF
  HaveSpell(CLERIC_SANCTUARY)
  HPPercentLT(Myself,50)
  See(NearestEnemyOf(Myself))
  !StateCheck(Myself,STATE_INVISIBLE)
  CheckStatLT(Myself,1,SANCTUARY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_SANCTUARY)
END

IF
  HaveSpell(CLERIC_PIXIE_DUST)
  HPPercentLT(Myself,50)
  See(NearestEnemyOf(Myself))
  !StateCheck(Myself,STATE_INVISIBLE)
  !CheckStatGT(LastSeenBy(Myself),0,SEEINVISIBLE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
  !GlobalTimerNotExpired("GBInvis","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("GBInvis","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_PIXIE_DUST)
END

IF
  HPPercentLT(Myself,75)
  HasItemEquiped("POTN55",Myself)
  !GlobalTimerNotExpired("GBUsedHealPotion","LOCALS")
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("POTN55",Myself)  // ~Potion of Superior Healing~
    SetGlobalTimer("GBUsedHealPotion","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HPPercentLT(Myself,50)
  HasItemEquiped("POTN55",Myself)
THEN
  RESPONSE #100
    ActionOverride(Myself,UseItem("POTN55",Myself))  // ~Potion of Superior Healing~
    SetGlobalTimer("GBUsedHealPotion","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HPPercentLT(Myself,75)
  HasItemEquiped("POTN52",Myself)
  !GlobalTimerNotExpired("GBUsedHealPotion","LOCALS")
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("POTN52",Myself)  // ~Potion of Extra Healing~
    SetGlobalTimer("GBUsedHealPotion","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HPPercentLT(Myself,50)
  HasItemEquiped("POTN52",Myself)
THEN
  RESPONSE #100
    ActionOverride(Myself,UseItem("POTN52",Myself))  // ~Potion of Extra Healing~
    SetGlobalTimer("GBUsedHealPotion","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HaveSpell(WIZARD_PIERCE_SHIELD)
  See(NearestEnemyOf(Myself))
  CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
  HPPercentGT(LastSeenBy(Myself),25)
  !HasBounceEffects(LastSeenBy(Myself))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_PIERCE_SHIELD)
END

IF
  HaveSpell(WIZARD_PIERCE_MAGIC)
  See(NearestEnemyOf(Myself))
  CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
  HPPercentGT(LastSeenBy(Myself),25)
  !HasBounceEffects(LastSeenBy(Myself))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_PIERCE_MAGIC)
END

IF
  HaveSpell(WIZARD_LOWER_RESISTANCE)
  See(NearestEnemyOf(Myself))
  CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
  HPPercentGT(LastSeenBy(Myself),25)
  !HasBounceEffects(LastSeenBy(Myself))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_LOWER_RESISTANCE)
END

IF
  HaveSpell(WIZARD_BREACH)
  See(NearestEnemyOf(Myself))
  OR(3)
    HasItemEquiped("marili",LastSeenBy(Myself))
    Race(LastSeenBy(Myself),DRAGON)
    Race(LastSeenBy(Myself),LICH)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("GBWizBreach","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizBreach","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_BREACH)
END

IF
  HasItemEquiped("WAND18",Myself)
  See(NearestEnemyOf(Myself))
  OR(3)
    HasItemEquiped("marili",LastSeenBy(Myself))
    Race(LastSeenBy(Myself),DRAGON)
    Race(LastSeenBy(Myself),LICH)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("GBWizBreach","LOCALS")
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("WAND18",LastSeenBy(Myself))  // ~Wand of Spell Striking~
    SetGlobalTimer("GBWizBreach","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HaveSpell(CLERIC_MASS_CURE)
  !StateCheck(MostDamagedOf(Myself),STATE_INVISIBLE)
  !StateCheck(MostDamagedOf(Myself),STATE_IMPROVEDINVISIBILITY)
  OR(5)
    HPPercentLT(Player1,85)
    HPPercentLT(Player2,85)
    HPPercentLT(Player3,85)
    HPPercentLT(Player4,85)
    HPPercentLT(Player5,85)
  OR(5)
    HPPercentLT(Player1,85)
    HPPercentLT(Player2,85)
    HPPercentLT(Player3,85)
    HPPercentLT(Player4,85)
    HPPercentLT(Player6,85)
  OR(5)
    HPPercentLT(Player1,85)
    HPPercentLT(Player2,85)
    HPPercentLT(Player3,85)
    HPPercentLT(Player5,85)
    HPPercentLT(Player6,85)
  OR(5)
    HPPercentLT(Player1,85)
    HPPercentLT(Player2,85)
    HPPercentLT(Player4,85)
    HPPercentLT(Player5,85)
    HPPercentLT(Player6,85)
  OR(5)
    HPPercentLT(Player1,85)
    HPPercentLT(Player3,85)
    HPPercentLT(Player4,85)
    HPPercentLT(Player5,85)
    HPPercentLT(Player6,85)
  OR(5)
    HPPercentLT(Player2,85)
    HPPercentLT(Player3,85)
    HPPercentLT(Player4,85)
    HPPercentLT(Player5,85)
    HPPercentLT(Player6,85)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(MostDamagedOf(Myself),CLERIC_MASS_CURE)
END

IF
  StateCheck(Player1,STATE_PANIC)
  HaveSpell(CLERIC_REMOVE_FEAR)
  !StateCheck(Player1,STATE_INVISIBLE)
  !StateCheck(Player1,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player1,CLERIC_REMOVE_FEAR)
END

IF
  StateCheck(Player2,STATE_PANIC)
  HaveSpell(CLERIC_REMOVE_FEAR)
  !StateCheck(Player2,STATE_INVISIBLE)
  !StateCheck(Player2,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player2,CLERIC_REMOVE_FEAR)
END

IF
  StateCheck(Player3,STATE_PANIC)
  HaveSpell(CLERIC_REMOVE_FEAR)
  !StateCheck(Player3,STATE_INVISIBLE)
  !StateCheck(Player3,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Player3,CLERIC_REMOVE_FEAR)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  StateCheck(Player4,STATE_PANIC)
  HaveSpell(CLERIC_REMOVE_FEAR)
  !StateCheck(Player4,STATE_INVISIBLE)
  !StateCheck(Player4,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player4,CLERIC_REMOVE_FEAR)
END

IF
  StateCheck(Player5,STATE_PANIC)
  HaveSpell(CLERIC_REMOVE_FEAR)
  !StateCheck(Player5,STATE_INVISIBLE)
  !StateCheck(Player5,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player5,CLERIC_REMOVE_FEAR)
END

IF
  StateCheck(Player6,STATE_PANIC)
  HaveSpell(CLERIC_REMOVE_FEAR)
  !StateCheck(Player6,STATE_INVISIBLE)
  !StateCheck(Player6,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player6,CLERIC_REMOVE_FEAR)
END

IF
  HaveSpell(CLERIC_REMOVE_PARALYSIS)
  OR(2)
    CheckStatGT(Player1,0,HELD)
    StateCheck(Player1,STATE_HELPLESS)
  !StateCheck(Player1,STATE_INVISIBLE)
  !StateCheck(Player1,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player1,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player1,CLERIC_REMOVE_PARALYSIS)
END

IF
  HaveSpell(CLERIC_REMOVE_PARALYSIS)
  OR(2)
    CheckStatGT(Player2,0,HELD)
    StateCheck(Player2,STATE_HELPLESS)
  !StateCheck(Player2,STATE_INVISIBLE)
  !StateCheck(Player2,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player2,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player2,CLERIC_REMOVE_PARALYSIS)
END

IF
  HaveSpell(CLERIC_REMOVE_PARALYSIS)
  OR(2)
    CheckStatGT(Player3,0,HELD)
    StateCheck(Player3,STATE_HELPLESS)
  !StateCheck(Player3,STATE_INVISIBLE)
  !StateCheck(Player3,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player3,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player3,CLERIC_REMOVE_PARALYSIS)
END

IF
  HaveSpell(CLERIC_REMOVE_PARALYSIS)
  OR(2)
    CheckStatGT(Player4,0,HELD)
    StateCheck(Player4,STATE_HELPLESS)
  !StateCheck(Player4,STATE_INVISIBLE)
  !StateCheck(Player4,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player4,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player4,CLERIC_REMOVE_PARALYSIS)
END

IF
  HaveSpell(CLERIC_REMOVE_PARALYSIS)
  OR(2)
    CheckStatGT(Player5,0,HELD)
    StateCheck(Player5,STATE_HELPLESS)
  !StateCheck(Player5,STATE_INVISIBLE)
  !StateCheck(Player5,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player5,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player5,CLERIC_REMOVE_PARALYSIS)
END

IF
  HaveSpell(CLERIC_REMOVE_PARALYSIS)
  OR(2)
    CheckStatGT(Player6,0,HELD)
    StateCheck(Player6,STATE_HELPLESS)
  !StateCheck(Player6,STATE_INVISIBLE)
  !StateCheck(Player6,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player6,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player6,CLERIC_REMOVE_PARALYSIS)
END

IF
  HaveSpell(CLERIC_FREE_ACTION)
  OR(5)
    CheckStatGT(Player1,0,HELD)
    CheckStatGT(Player1,0,ENTANGLE)
    CheckStatGT(Player1,0,GREASE)
    CheckStatGT(Player1,0,WEB)
    StateCheck(Player1,STATE_SLOWED)
  !StateCheck(Player1,STATE_INVISIBLE)
  !StateCheck(Player1,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player1,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player1,131)
END

IF
  HaveSpell(CLERIC_FREE_ACTION)
  OR(5)
    CheckStatGT(Player2,0,HELD)
    CheckStatGT(Player2,0,ENTANGLE)
    CheckStatGT(Player2,0,GREASE)
    CheckStatGT(Player2,0,WEB)
    StateCheck(Player2,STATE_SLOWED)
  !StateCheck(Player2,STATE_INVISIBLE)
  !StateCheck(Player2,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player2,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player2,CLERIC_FREE_ACTION)
END

IF
  HaveSpell(CLERIC_FREE_ACTION)
  OR(5)
    CheckStatGT(Player3,0,HELD)
    CheckStatGT(Player3,0,ENTANGLE)
    CheckStatGT(Player3,0,GREASE)
    CheckStatGT(Player3,0,WEB)
    StateCheck(Player3,STATE_SLOWED)
  !StateCheck(Player3,STATE_INVISIBLE)
  !StateCheck(Player3,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player3,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player3,CLERIC_FREE_ACTION)
END

IF
  HaveSpell(CLERIC_FREE_ACTION)
  OR(5)
    CheckStatGT(Player4,0,HELD)
    CheckStatGT(Player4,0,ENTANGLE)
    CheckStatGT(Player4,0,GREASE)
    CheckStatGT(Player4,0,WEB)
    StateCheck(Player4,STATE_SLOWED)
  !StateCheck(Player4,STATE_INVISIBLE)
  !StateCheck(Player4,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player4,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player4,CLERIC_FREE_ACTION)
END

IF
  HaveSpell(CLERIC_FREE_ACTION)
  OR(5)
    CheckStatGT(Player5,0,HELD)
    CheckStatGT(Player5,0,ENTANGLE)
    CheckStatGT(Player5,0,GREASE)
    CheckStatGT(Player5,0,WEB)
    StateCheck(Player5,STATE_SLOWED)
  !StateCheck(Player5,STATE_INVISIBLE)
  !StateCheck(Player5,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player5,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player5,CLERIC_FREE_ACTION)
END

IF
  HaveSpell(CLERIC_FREE_ACTION)
  OR(5)
    CheckStatGT(Player6,0,HELD)
    CheckStatGT(Player6,0,ENTANGLE)
    CheckStatGT(Player6,0,GREASE)
    CheckStatGT(Player6,0,WEB)
    StateCheck(Player6,STATE_SLOWED)
  !StateCheck(Player6,STATE_INVISIBLE)
  !StateCheck(Player6,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player6,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player6,CLERIC_FREE_ACTION)
END

IF
  HaveSpell(CLERIC_DISPEL_MAGIC)
  OR(13)
    CheckStatGT(Player1,0,HELD)
    CheckStatGT(Player1,0,ENTANGLE)
    CheckStatGT(Player1,0,GREASE)
    CheckStatGT(Player1,0,WEB)
    StateCheck(Player1,STATE_HELPLESS)
    StateCheck(Player1,STATE_STUNNED)
    StateCheck(Player1,STATE_PANIC)
    StateCheck(Player1,STATE_SLEEPING)
    StateCheck(Player1,STATE_SILENCED)
    StateCheck(Player1,STATE_CHARMED)
    StateCheck(Player1,STATE_SLOWED)
    StateCheck(Player1,STATE_BLIND)
    StateCheck(Player1,STATE_CONFUSED)
  See(Player1)
  !StateCheck(Player1,STATE_INVISIBLE)
  !StateCheck(Player1,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player1,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player1,CLERIC_DISPEL_MAGIC)
END

IF
  HaveSpell(CLERIC_DISPEL_MAGIC)
  OR(13)
    CheckStatGT(Player2,0,HELD)
    CheckStatGT(Player2,0,ENTANGLE)
    CheckStatGT(Player2,0,GREASE)
    CheckStatGT(Player2,0,WEB)
    StateCheck(Player2,STATE_HELPLESS)
    StateCheck(Player2,STATE_STUNNED)
    StateCheck(Player2,STATE_PANIC)
    StateCheck(Player2,STATE_SLEEPING)
    StateCheck(Player2,STATE_SILENCED)
    StateCheck(Player2,STATE_CHARMED)
    StateCheck(Player2,STATE_SLOWED)
    StateCheck(Player2,STATE_BLIND)
    StateCheck(Player2,STATE_CONFUSED)
  See(Player2)
  !StateCheck(Player2,STATE_INVISIBLE)
  !StateCheck(Player2,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player2,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player2,CLERIC_DISPEL_MAGIC)
END

IF
  HaveSpell(CLERIC_DISPEL_MAGIC)
  OR(13)
    CheckStatGT(Player3,0,HELD)
    CheckStatGT(Player3,0,ENTANGLE)
    CheckStatGT(Player3,0,GREASE)
    CheckStatGT(Player3,0,WEB)
    StateCheck(Player3,STATE_HELPLESS)
    StateCheck(Player3,STATE_STUNNED)
    StateCheck(Player3,STATE_PANIC)
    StateCheck(Player3,STATE_SLEEPING)
    StateCheck(Player3,STATE_SILENCED)
    StateCheck(Player3,STATE_CHARMED)
    StateCheck(Player3,STATE_SLOWED)
    StateCheck(Player3,STATE_BLIND)
    StateCheck(Player3,STATE_CONFUSED)
  See(Player3)
  !StateCheck(Player3,STATE_INVISIBLE)
  !StateCheck(Player3,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player3,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player3,CLERIC_DISPEL_MAGIC)
END

IF
  HaveSpell(CLERIC_DISPEL_MAGIC)
  OR(13)
    CheckStatGT(Player4,0,HELD)
    CheckStatGT(Player4,0,ENTANGLE)
    CheckStatGT(Player4,0,GREASE)
    CheckStatGT(Player4,0,WEB)
    StateCheck(Player4,STATE_HELPLESS)
    StateCheck(Player4,STATE_STUNNED)
    StateCheck(Player4,STATE_PANIC)
    StateCheck(Player4,STATE_SLEEPING)
    StateCheck(Player4,STATE_SILENCED)
    StateCheck(Player4,STATE_CHARMED)
    StateCheck(Player4,STATE_SLOWED)
    StateCheck(Player4,STATE_BLIND)
    StateCheck(Player4,STATE_CONFUSED)
  See(Player4)
  !StateCheck(Player4,STATE_INVISIBLE)
  !StateCheck(Player4,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player4,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player4,CLERIC_DISPEL_MAGIC)
END

IF
  HaveSpell(CLERIC_DISPEL_MAGIC)
  OR(13)
    CheckStatGT(Player5,0,HELD)
    CheckStatGT(Player5,0,ENTANGLE)
    CheckStatGT(Player5,0,GREASE)
    CheckStatGT(Player5,0,WEB)
    StateCheck(Player5,STATE_HELPLESS)
    StateCheck(Player5,STATE_STUNNED)
    StateCheck(Player5,STATE_PANIC)
    StateCheck(Player5,STATE_SLEEPING)
    StateCheck(Player5,STATE_SILENCED)
    StateCheck(Player5,STATE_CHARMED)
    StateCheck(Player5,STATE_SLOWED)
    StateCheck(Player5,STATE_BLIND)
    StateCheck(Player5,STATE_CONFUSED)
  See(Player5)
  !StateCheck(Player5,STATE_INVISIBLE)
  !StateCheck(Player5,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player5,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player5,CLERIC_DISPEL_MAGIC)
END

IF
  HaveSpell(CLERIC_DISPEL_MAGIC)
  OR(13)
    CheckStatGT(Player6,0,HELD)
    CheckStatGT(Player6,0,ENTANGLE)
    CheckStatGT(Player6,0,GREASE)
    CheckStatGT(Player6,0,WEB)
    StateCheck(Player6,STATE_HELPLESS)
    StateCheck(Player6,STATE_STUNNED)
    StateCheck(Player6,STATE_PANIC)
    StateCheck(Player6,STATE_SLEEPING)
    StateCheck(Player6,STATE_SILENCED)
    StateCheck(Player6,STATE_CHARMED)
    StateCheck(Player6,STATE_SLOWED)
    StateCheck(Player6,STATE_BLIND)
    StateCheck(Player6,STATE_CONFUSED)
  See(Player6)
  !StateCheck(Player6,STATE_INVISIBLE)
  !StateCheck(Player6,STATE_IMPROVEDINVISIBILITY)
  !Specifics(Player6,201)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player6,CLERIC_DISPEL_MAGIC)
END

IF
  HaveSpell(WIZARD_TIME_STOP)
  See(NearestEnemyOf(Myself))
  !GlobalTimerNotExpired("GBWizTimeStop","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizTimeStop","LOCALS",FIVE_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_TIME_STOP)
END

IF
  HaveSpell(WIZARD_IMPROVED_ALUCRITY)
  See(NearestEnemyOf(Myself))
  !GlobalTimerNotExpired("GBWizAlacrity","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Myself,WIZARD_IMPROVED_ALUCRITY)
    SetGlobalTimer("GBWizAlacrity","LOCALS",FIVE_ROUNDS)
END

IF
  HaveSpell(WIZARD_IMPRISONMENT)
  NumCreatureGT([EVILCUTOFF],2)
  See(NearestEnemyOf(Myself))
  See(SecondNearestEnemyOf(Myself))
  !CheckStatLT(SecondNearestEnemyOf(Myself),10000,XPVALUE)
  !GlobalTimerNotExpired("GBWizImprison","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    Spell(SecondNearestEnemyOf(Myself),WIZARD_IMPRISONMENT)
    SetGlobalTimer("GBWizImprison","LOCALS",THREE_ROUNDS)
    MoveToObject(SecondNearestEnemyOf(Myself))
END

IF
  HaveSpell(CLERIC_FALSE_DAWN)
  See(NearestEnemyOfType([EVILCUTOFF.UNDEAD]))
  Range(LastSeenBy(Myself),8)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_FALSE_DAWN)
END

IF
  HaveSpell(CLERIC_SUNRAY)
  See(NearestEnemyOfType([EVILCUTOFF.UNDEAD]))
  Range(LastSeenBy(Myself),8)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_SUNRAY)
END

IF
  HaveSpell(CLERIC_REPULSE_UNDEAD)
  See(NearestEnemyOfType([EVILCUTOFF.UNDEAD]))
  Range(LastSeenBy(Myself),8)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_REPULSE_UNDEAD)
END

IF
  HaveSpell(CLERIC_CHAOTIC_COMMANDS)
  OR(6)
    See(NearestEnemyOfType([0.0.MIND_FLAYER]))
    See(NearestEnemyOfType([0.0.GITHYANKI]))
    See(NearestEnemyOfType([0.0.UMBERHULK]))
    See(NearestEnemyOfType([0.0.MIND_FLAYER]))
    See(NearestEnemyOfType([0.0.VAMPIRE]))
    See(NearestEnemyOfType([0.0.VAMPYRE]))
  !GlobalTimerNotExpired("GBClrChaoCom","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrChaoCom","LOCALS",TWO_HOURS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_CHAOTIC_COMMANDS)
END

IF
  HaveSpell(WIZARD_DEATH_SPELL)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  OR(2)
    !CheckStatGT(LastSeenBy(Myself),8,LEVEL)
    Gender(LastSeenBy(Myself),SUMMONED)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),TROLL)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DEATH_SPELL)
END

IF
  HaveSpell(WIZARD_HOLD_UNDEAD)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  General(LastSeenBy(Myself),UNDEAD)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_HOLD_UNDEAD)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_BURNING_HANDS)
  See(NearestEnemyOfType([0.0.TROLL]))
  HP(LastSeenBy(Myself),1)
  HasItemEquiped("TROLLDIE",LastSeenBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_BURNING_HANDS)
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(CLERIC_FLAME_BLADE)
  See(NearestEnemyOfType([0.0.TROLL]))
  HP(LastSeenBy(Myself),1)
  HasItemEquiped("TROLLDIE",LastSeenBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
  !HasItemSlot(Myself,SLOT_MISC19)
THEN
  RESPONSE #100
    Spell(LastSeenBy(Myself),CLERIC_FLAME_BLADE)
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WIZARD_CHROMATIC_ORB)
  See(NearestEnemyOfType([0.0.TROLL]))
  HP(LastSeenBy(Myself),1)
  HasItemEquiped("TROLLDIE",LastSeenBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CHROMATIC_ORB)
END

IF
  HaveSpell(WIZARD_AGANNAZAR_SCORCHER)
  See(NearestEnemyOfType([0.0.TROLL]))
  HP(LastSeenBy(Myself),1)
  HasItemEquiped("TROLLDIE",LastSeenBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_AGANNAZAR_SCORCHER)
END

IF
  HaveSpell(WIZARD_MELF_ACID_ARROW)
  See(NearestEnemyOfType([0.0.TROLL]))
  HP(LastSeenBy(Myself),1)
  HasItemEquiped("TROLLDIE",LastSeenBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_MELF_ACID_ARROW)
END

IF
  HaveSpell(WIZARD_FLAME_ARROW)
  See(NearestEnemyOfType([0.0.TROLL]))
  HP(LastSeenBy(Myself),1)
  HasItemEquiped("TROLLDIE",LastSeenBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_FLAME_ARROW)
END

IF
  HaveSpell(CLERIC_FLAME_STRIKE)
  See(NearestEnemyOfType([0.0.TROLL]))
  HP(LastSeenBy(Myself),1)
  HasItemEquiped("TROLLDIE",LastSeenBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_FLAME_STRIKE)
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  See(NearestEnemyOfType([0.0.TROLL]))
  HP(LastSeenBy(Myself),1)
  HasItemEquiped("MELFMET",Myself)
THEN
  RESPONSE #100
    EquipRanged()
    Attack(LastSeenBy(Myself))
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  See(NearestEnemyOfType([0.0.TROLL]))
  HP(LastSeenBy(Myself),1)
  HasItemEquiped("FBLADE",Myself)
THEN
  RESPONSE #100
    EquipMostDamagingMelee()
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WIZARD_SPELL_STRIKE)
  See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("GBMetaMagicAttack","LOCALS")
  !GlobalTimerNotExpired("GBWizSpellStrike","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizSpellStrike","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBMetaMagicAttack","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SPELL_STRIKE)
END

IF
  HaveSpell(WIZARD_PIERCE_SHIELD)
  See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("GBMetaMagicAttack","LOCALS")
  !GlobalTimerNotExpired("GBWizPierceShield","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizPierceShield","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBMetaMagicAttack","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_PIERCE_MAGIC)
END

IF
  HaveSpell(WIZARD_WARDING_WHIP)
  See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("GBMetaMagicAttack","LOCALS")
  !GlobalTimerNotExpired("GBWizWardingWhip","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizWardingWhip","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBMetaMagicAttack","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_WARDING_WHIP)
END

IF
  HaveSpell(WIZARD_SUMMON_HAKEASHAR)
  OR(2)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],5)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SUMMON_HAKEASHAR)
END

IF
  HaveSpell(WIZARD_RUBY_RAY_OF_REVERSAL)
  See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("GBMetaMagicAttack","LOCALS")
  !GlobalTimerNotExpired("GBWizRubyRay","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizRubyRay","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBMetaMagicAttack","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_RUBY_RAY_OF_REVERSAL)
END

IF
  HasItemEquiped("RODS01",Myself)
  See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("GBMetaMagicAttack","LOCALS")
  !GlobalTimerNotExpired("GBWizRubyRay","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("RODS01",LastSeenBy(Myself))  // ~Rod of Absorption~
    SetGlobalTimer("GBWizRubyRay","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBMetaMagicAttack","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HaveSpell(WIZARD_SUMMON_NISHRUU)
  OR(2)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],5)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SUMMON_NISHRUU)
END

IF
  HaveSpell(WIZARD_POWER_WORD_SILENCE)
  OR(2)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_SILENCED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_SILENCE)
END

IF
  HaveSpell(WIZARD_PIERCE_MAGIC)
  See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("GBMetaMagicAttack","LOCALS")
  !GlobalTimerNotExpired("GBWizPierceMagic","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizPierceMagic","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBMetaMagicAttack","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_PIERCE_MAGIC)
END

IF
  HaveSpell(WIZARD_BREACH)
  See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("GBMetaMagicAttack","LOCALS")
  !GlobalTimerNotExpired("GBWizBreach","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizBreach","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBMetaMagicAttack","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_BREACH)
END

IF
  HasItemEquiped("WAND18",Myself)
  See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("GBMetaMagicAttack","LOCALS")
  !GlobalTimerNotExpired("GBWizBeach","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("WAND18",LastSeenBy(Myself))  // ~Wand of Spell Striking~
    SetGlobalTimer("GBWixBreach","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBMetaMagicAttack","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HaveSpell(WIZARD_SECRET_WORD)
  See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("GBMetaMagicAttack","LOCALS")
  !GlobalTimerNotExpired("GBWizSecretWord","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizSecretWord","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBMetaMagicAttack","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SECRET_WORD)
END

IF
  HaveSpell(WIZARD_SPELL_THRUST)
  See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("GBMetaMagicAttack","LOCALS")
  !GlobalTimerNotExpired("GBWizPierceMagic","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizPierceMagic","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBMetaMagicAttack","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SPELL_THRUST)
END

IF
  HaveSpell(WIZARD_DEAFNESS)
  OR(2)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_SILENCED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DEAFNESS)
END

IF
  HaveSpell(WIZARD_BLINDNESS)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_BLIND)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_BLINDNESS)
END

IF
  HaveSpell(CLERIC_CREEPING_DOOM)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_CREEPING_DOOM)
END

IF
  HaveSpell(CLERIC_INSECT_PLAGUE)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_INSECT_PLAGUE)
END

IF
  HaveSpell(CLERIC_SUMMON_INSECTS)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_SUMMON_INSECTS)
END

IF
  HaveSpell(CLERIC_SILENCE_15_FOOT)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_SILENCED)
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_SILENCE_15_FOOT)
END

IF
  HaveSpell(CLERIC_MISCAST_MAGIC)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_SILENCED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_MISCAST_MAGIC)
END

IF
  HaveSpell(CLERIC_DISPEL_MAGIC)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  OR(9)
    StateCheck(LastSeenBy(Myself),STATE_HASTED)
    StateCheck(LastSeenBy(Myself),STATE_BLESS)
    StateCheck(LastSeenBy(Myself),STATE_CHANT)
    StateCheck(LastSeenBy(Myself),STATE_BLUR)
    StateCheck(LastSeenBy(Myself),STATE_MIRRORIMAGE)
    StateCheck(LastSeenBy(Myself),STATE_LUCK)
    StateCheck(LastSeenBy(Myself),STATE_AID)
    CheckStatGT(LastSeenBy(Myself),0,STONESKINS)
    HasBounceEffects(LastSeenBy(Myself))
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_DISPEL_MAGIC)
END

IF
  See(NearestEnemyOfType([EVILCUTOFF.UNDEAD]))
  !GlobalTimerNotExpired("GBTunrnedUndead","LOCALS")
  CheckStatGT(Myself,12,TURNUNDEADLEVEL)
  Range(LastSeenBy(Myself),8)
  !Kit(Myself,16)
  !Class(Myself,DRUID_ALL)
THEN
  RESPONSE #100
    SetGlobalTimer("GBAutoTurning","LOCALS",ONE_ROUND)
    SetGlobalTimer("GBTurnedUndead","LOCALS",THREE_ROUNDS)
    SetGlobal("GBTurned","LOCALS",1)
    Turn()
END

IF
  HaveSpell(WIZARD_WISH)
  See(NearestEnemyOf(Myself))
  !CheckStatLT(LastSeenBy(Myself),10000,XPVALUE)
  CheckStatGT(Myself,14,WIS)
  !GlobalTimerNotExpired("GBWishTimer","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWishTimer","LOCALS",THREE_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_WISH)
END

IF
  HaveSpell(CLERIC_SHIELD_OF_THE_ARCHONS)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBClrShieldArchon","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrShieldArchon","LOCALS",THREE_TURNS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_SHIELD_OF_THE_ARCHONS)
END

IF
  HaveSpell(CLERIC_DEATH_WARD)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBClrDeathWard","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrDeathWard","LOCALS",TWO_HOURS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_DEATH_WARD)
END

IF
  HaveSpell(CLERIC_MAGIC_RESISTANCE)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  CheckStatLT(Myself,40,RESISTMAGIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_MAGIC_RESISTANCE)
END

IF
  HaveSpell(CLERIC_PHYSICAL_MIRROR)
  See(LastAttackerOf(Myself))
  OR(7)
    HasItemEquiped("AROW01",LastSeenBy(Myself))
    HasItemEquiped("AX1H04",LastSeenBy(Myself))
    HasItemEquiped("BOLT01",LastSeenBy(Myself))
    HasItemEquiped("BULL01",LastSeenBy(Myself))
    HasItemEquiped("DAGG05",LastSeenBy(Myself))
    HasItemEquiped("DART01",LastSeenBy(Myself))
    HasItemEquiped("DWBOLT03",LastSeenBy(Myself))
  CheckStatLT(Myself,4,STONESKINS)
  !GlobalTimerNotExpired("GBWizProtMissiles","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizProtMissiles","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_PHYSICAL_MIRROR)
END

IF
  HaveSpell(CLERIC_AURA_OF_FLAMING_DEATH)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  CheckStatLT(Myself,4,STONESKINS)
  Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("GBClrAuraDeath","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrAuraDeath","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_AURA_OF_FLAMING_DEATH)
END

IF
  HaveSpell(CLERIC_GLOBE_OF_BLADES)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  CheckStatLT(Myself,4,STONESKINS)
  Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("GBClrGlobeBlade","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrGlobeBlade","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_GLOBE_OF_BLADES)
END

IF
  HaveSpell(CLERIC_BLADE_BARRIER)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  CheckStatLT(Myself,4,STONESKINS)
  Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("GBClrBladeBarrier","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrBladeBarrier","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BLADE_BARRIER)
END

IF
  HaveSpell(CLERIC_CLOAK_OF_FEAR)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  Range(NearestEnemyOf(Myself),8)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !GlobalTimerNotExpired("GBClrFearCloak","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrFearCloak","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_CLOAK_OF_FEAR)
END

IF
  HaveSpell(CLERIC_REGENERATE)
  See(NearestEnemyOf(Myself))
  !GlobalTimerNotExpired("GBClrRegenerate","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrRegenerate","LOCALS",THREE_TURNS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_REGENERATE)
END

IF
  HaveSpell(CLERIC_PROTECTION_FROM_EVIL_10_FOOT)
  OR(3)
    See(NearestEnemyOfType([0.0.DEMONIC]))
    Gender(NearestEnemyOf(Myself),SUMMONED)
    Alignment(NearestEnemyOf(Myself),MASK_EVIL)
  !GlobalTimerNotExpired("GBProtFromEvil","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBProtFromEvil","LOCALS",TWO_HOURS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_PROTECTION_FROM_EVIL_10_FOOT)
    Shout(201)
END

IF
  HaveSpell(CLERIC_PROTECT_FROM_EVIL)
  OR(3)
    See(NearestEnemyOfType([0.0.DEMONIC]))
    Gender(NearestEnemyOf(Myself),SUMMONED)
    Alignment(NearestEnemyOf(Myself),MASK_EVIL)
  !GlobalTimerNotExpired("GBProtFromEvil","LOCALS")
  !HasItemEquiped("WA2AMU",Myself)
  !HasItemEquipedReal("STAF11",Myself)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBProtFromEvil","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_PROTECT_FROM_EVIL)
END

IF
  HaveSpell(CLERIC_DEFENSIVE_HARMONY)
  See(NearestEnemyOf(Myself))
  !GlobalTimerNotExpired("GBClrDefHarmony","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrDefHarmony","LOCALS",FIVE_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_DEFENSIVE_HARMONY)
END

IF
  HaveSpell(CLERIC_BLESS)
  See(NearestEnemyOf(Myself))
  !StateCheck(Myself,STATE_BLESS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BLESS)
END

IF
  HaveSpell(CLERIC_CHANT)
  See(NearestEnemyOf(Myself))
  !StateCheck(Myself,STATE_CHANT)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_CHANT)
END

IF
  HaveSpell(CLERIC_ARMOR_OF_FAITH)
  See(NearestEnemyOf(Myself))
  !GlobalTimerNotExpired("GBClrArmorFaith","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrArmorFaith","LOCALS",90)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_ARMOR_OF_FAITH)
END

IF
  HaveSpell(CLERIC_BARKSKIN)
  See(NearestEnemyOf(Myself))
  !GlobalTimerNotExpired("GBClrBarkskin","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrBarkskin","LOCALS",90)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BARKSKIN)
END

IF
  HaveSpell(WIZARD_SPELL_TRAP)
  OR(2)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !CheckStatLT(LastSeenBy(Myself),2500,XPVALUE)
  !GlobalTimerNotExpired("GBWizSplTrap","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizSplTrap","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SPELL_TRAP)
END

IF
  HaveSpell(WIZARD_ABSOLUTE_IMMUNITY)
  CheckStatLT(Myself,4,STONESKINS)
  OR(2)
    TookDamage()
    Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("GBWizWeapImmun","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizWeapImmun","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_ABSOLUTE_IMMUNITY)
END

IF
  HaveSpell(WIZARD_PROTECTION_FROM_THE_ELEMENTS)
  OR(5)
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
    See(TenthNearestEnemyOfType([0.0.DRAGON]))
  !GlobalTimerNotExpired("GBWizProtElements","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizProtElements","LOCALS",TWO_HOURS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_PROTECTION_FROM_THE_ELEMENTS)
END

IF
  HaveSpell(WIZARD_PROTECTION_FROM_ENERGY)
  OR(5)
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
    See(TenthNearestEnemyOfType([0.0.DRAGON]))
  !GlobalTimerNotExpired("GBWizProtEng","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizProtEng","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_PROTECTION_FROM_ENERGY)
END

IF
  HaveSpell(WIZARD_IMPROVED_MANTLE)
  CheckStatLT(Myself,4,STONESKINS)
  OR(2)
    TookDamage()
    Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("GBWizWeapImmun","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizWeapImmun","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_IMPROVED_MANTLE)
END

IF
  HaveSpell(WIZARD_SPELL_TURNING)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !GlobalTimerNotExpired("GBWizSplTurn","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizSplTurn","LOCALS",THREE_TURNS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SPELL_TURNING)
END

IF
  HaveSpell(WIZARD_MANTLE)
  CheckStatLT(Myself,4,STONESKINS)
  OR(2)
    TookDamage()
    Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("GBWizWeapImmun","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizWeapImmun","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_MANTLE)
END

IF
  HaveSpell(WIZARD_SPELL_DEFLECTION)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !GlobalTimerNotExpired("GBWizSplDeflect","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizSplDeflect","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SPELL_DEFLECTION)
END

IF
  HaveSpell(WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
  CheckStatLT(Myself,4,STONESKINS)
  OR(2)
    TookDamage()
    Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("GBWizWeapImmun","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizWeapImmun","LOCALS",FOUR_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
END

IF
  HaveSpell(WIZARD_PROTECTION_FROM_MAGIC_ENERGY)
  OR(5)
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
    See(TenthNearestEnemyOfType([0.0.DRAGON]))
  !GlobalTimerNotExpired("GBWizProtMagEng","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizProtMagEng","LOCALS",TWO_HOURS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_PROTECTION_FROM_MAGIC_ENERGY)
END

IF
  HaveSpell(WIZARD_GLOBE_OF_INVULNERABILITY)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !GlobalTimerNotExpired("GBWizGlbInvln","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizGlbInvln","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_GLOBE_OF_INVULNERABILITY)
END

IF
  HaveSpell(WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
  CheckStatLT(Myself,4,STONESKINS)
  OR(2)
    TookDamage()
    Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("GBWizWeapImmun","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizWeapImmun","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
END

IF
  HaveSpell(WIZARD_MINOR_SPELL_TURNING)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !GlobalTimerNotExpired("GBWizMinSplTurn","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizMinSplTurn","LOCALS",THREE_TURNS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_MINOR_SPELL_TURNING)
END

IF
  HaveSpell(WIZARD_SPELL_IMMUNITY)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
    See(NearestEnemyOfType([0.0.BEHOLDER]))
    See(NearestEnemyOfType([0.0.DEMILICH]))
  !GlobalTimerNotExpired("GBSpellImmune","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SetInterrupt(FALSE)
    DisplayString(Myself,5019)  // ~Spell Immunity~
    UnhideGUI()
    PauseGame()
    SetGlobalTimer("GBSpellImmune","LOCALS",90)
    Spell(Myself,WIZARD_SPELL_IMMUNITY)
    PauseGame()
END

IF
  HaveSpell(WIZARD_SPELL_IMMUNITY)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
    See(NearestEnemyOfType([0.0.BEHOLDER]))
    See(NearestEnemyOfType([0.0.DEMILICH]))
  GlobalTimerNotExpired("GBSpellImmune","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SetInterrupt(FALSE)
    DisplayString(Myself,5019)  // ~Spell Immunity~
    UnhideGUI()
    PauseGame()
    SetGlobalTimer("GBSpellImmune","LOCALS",90)
    Spell(Myself,WIZARD_SPELL_IMMUNITY)
    PauseGame()
END

IF
  HaveSpell(WIZARD_SPIRIT_ARMOR)
  See(NearestEnemyOf(Myself))
  OR(2)
    TookDamage()
    Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("GBWizSprtArmor","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizSprtArmor","LOCALS",TWO_HOURS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SPIRIT_ARMOR)
END

IF
  HaveSpell(WIZARD_MINOR_GLOBE_OF_INVULNERABILITY)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !GlobalTimerNotExpired("GBWizMinGlbInvl","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizMinGlbInvl","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_MINOR_GLOBE_OF_INVULNERABILITY)
END

IF
  HaveSpell(WIZARD_IMPROVED_INVISIBILITY)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(Myself,STATE_INVISIBLE)
  !StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_IMPROVED_INVISIBILITY)
END

IF
  HaveSpell(WIZARD_FIRE_SHIELD_RED)
  OR(2)
    TookDamage()
    Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("GBWizRedShld","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizRedShld","LOCALS",90)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_FIRE_SHIELD_RED)
END

IF
  HaveSpell(WIZARD_FIRE_SHIELD_BLUE)
  OR(2)
    TookDamage()
    Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("GBWizBlueShld","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizBlueShld","LOCALS",90)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_FIRE_SHIELD_BLUE)
END

IF
  HaveSpell(WIZARD_MINOR_SPELL_DEFLECTION)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !GlobalTimerNotExpired("GBWizMinSplDef","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizMinSplDef","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_MINOR_SPELL_DEFLECTION)
END

IF
  HaveSpell(WIZARD_HASTE)
  See(NearestEnemyOf(Myself))
  CheckStatLT(Myself,2,FATIGUE)
  !StateCheck(Myself,STATE_HASTED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_HASTE)
END

IF
  HaveSpell(WIZARD_GHOST_ARMOR)
  OR(2)
    TookDamage()
    Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("GBWizGhstArm","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizGhstArm","LOCALS",TWO_HOURS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_GHOST_ARMOR)
END

IF
  HaveSpell(WIZARD_TRUE_DISPEL_MAGIC)
  OR(13)
    CheckStatGT(Player1,0,HELD)
    CheckStatGT(Player1,0,ENTANGLE)
    CheckStatGT(Player1,0,GREASE)
    CheckStatGT(Player1,0,WEB)
    StateCheck(Player1,STATE_HELPLESS)
    StateCheck(Player1,STATE_STUNNED)
    StateCheck(Player1,STATE_PANIC)
    StateCheck(Player1,STATE_SLEEPING)
    StateCheck(Player1,STATE_SILENCED)
    StateCheck(Player1,STATE_CHARMED)
    StateCheck(Player1,STATE_SLOWED)
    StateCheck(Player1,STATE_BLIND)
    StateCheck(Player1,STATE_CONFUSED)
  !StateCheck(Player1,STATE_INVISIBLE)
  !StateCheck(Player1,STATE_IMPROVEDINVISIBILITY)
  See(Player1)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player1,WIZARD_TRUE_DISPEL_MAGIC)
END

IF
  HaveSpell(WIZARD_TRUE_DISPEL_MAGIC)
  OR(13)
    CheckStatGT(Player2,0,HELD)
    CheckStatGT(Player2,0,ENTANGLE)
    CheckStatGT(Player2,0,GREASE)
    CheckStatGT(Player2,0,WEB)
    StateCheck(Player2,STATE_HELPLESS)
    StateCheck(Player2,STATE_STUNNED)
    StateCheck(Player2,STATE_PANIC)
    StateCheck(Player2,STATE_SLEEPING)
    StateCheck(Player2,STATE_SILENCED)
    StateCheck(Player2,STATE_CHARMED)
    StateCheck(Player2,STATE_SLOWED)
    StateCheck(Player2,STATE_BLIND)
    StateCheck(Player2,STATE_CONFUSED)
  !StateCheck(Player2,STATE_INVISIBLE)
  !StateCheck(Player2,STATE_IMPROVEDINVISIBILITY)
  See(Player2)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player2,WIZARD_TRUE_DISPEL_MAGIC)
END

IF
  HaveSpell(WIZARD_TRUE_DISPEL_MAGIC)
  OR(13)
    CheckStatGT(Player3,0,HELD)
    CheckStatGT(Player3,0,ENTANGLE)
    CheckStatGT(Player3,0,GREASE)
    CheckStatGT(Player3,0,WEB)
    StateCheck(Player3,STATE_HELPLESS)
    StateCheck(Player3,STATE_STUNNED)
    StateCheck(Player3,STATE_PANIC)
    StateCheck(Player3,STATE_SLEEPING)
    StateCheck(Player3,STATE_SILENCED)
    StateCheck(Player3,STATE_CHARMED)
    StateCheck(Player3,STATE_SLOWED)
    StateCheck(Player3,STATE_BLIND)
    StateCheck(Player3,STATE_CONFUSED)
  !StateCheck(Player3,STATE_INVISIBLE)
  !StateCheck(Player3,STATE_IMPROVEDINVISIBILITY)
  See(Player3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player3,WIZARD_TRUE_DISPEL_MAGIC)
END

IF
  HaveSpell(WIZARD_TRUE_DISPEL_MAGIC)
  OR(13)
    CheckStatGT(Player4,0,HELD)
    CheckStatGT(Player4,0,ENTANGLE)
    CheckStatGT(Player4,0,GREASE)
    CheckStatGT(Player4,0,WEB)
    StateCheck(Player4,STATE_HELPLESS)
    StateCheck(Player4,STATE_STUNNED)
    StateCheck(Player4,STATE_PANIC)
    StateCheck(Player4,STATE_SLEEPING)
    StateCheck(Player4,STATE_SILENCED)
    StateCheck(Player4,STATE_CHARMED)
    StateCheck(Player4,STATE_SLOWED)
    StateCheck(Player4,STATE_BLIND)
    StateCheck(Player4,STATE_CONFUSED)
  !StateCheck(Player4,STATE_INVISIBLE)
  !StateCheck(Player4,STATE_IMPROVEDINVISIBILITY)
  See(Player4)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player4,WIZARD_TRUE_DISPEL_MAGIC)
END

IF
  HaveSpell(WIZARD_TRUE_DISPEL_MAGIC)
  OR(13)
    CheckStatGT(Player5,0,HELD)
    CheckStatGT(Player5,0,ENTANGLE)
    CheckStatGT(Player5,0,GREASE)
    CheckStatGT(Player5,0,WEB)
    StateCheck(Player5,STATE_HELPLESS)
    StateCheck(Player5,STATE_STUNNED)
    StateCheck(Player5,STATE_PANIC)
    StateCheck(Player5,STATE_SLEEPING)
    StateCheck(Player5,STATE_SILENCED)
    StateCheck(Player5,STATE_CHARMED)
    StateCheck(Player5,STATE_SLOWED)
    StateCheck(Player5,STATE_BLIND)
    StateCheck(Player5,STATE_CONFUSED)
  !StateCheck(Player5,STATE_INVISIBLE)
  !StateCheck(Player5,STATE_IMPROVEDINVISIBILITY)
  See(Player5)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player5,WIZARD_TRUE_DISPEL_MAGIC)
END

IF
  HaveSpell(WIZARD_TRUE_DISPEL_MAGIC)
  OR(13)
    CheckStatGT(Player6,0,HELD)
    CheckStatGT(Player6,0,ENTANGLE)
    CheckStatGT(Player6,0,GREASE)
    CheckStatGT(Player6,0,WEB)
    StateCheck(Player6,STATE_HELPLESS)
    StateCheck(Player6,STATE_STUNNED)
    StateCheck(Player6,STATE_PANIC)
    StateCheck(Player6,STATE_SLEEPING)
    StateCheck(Player6,STATE_SILENCED)
    StateCheck(Player6,STATE_CHARMED)
    StateCheck(Player6,STATE_SLOWED)
    StateCheck(Player6,STATE_BLIND)
    StateCheck(Player6,STATE_CONFUSED)
  !StateCheck(Player6,STATE_INVISIBLE)
  !StateCheck(Player6,STATE_IMPROVEDINVISIBILITY)
  See(Player6)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player6,WIZARD_TRUE_DISPEL_MAGIC)
END

IF
  HaveSpell(WIZARD_RESIST_FEAR)
  StateCheck(Player1,STATE_PANIC)
  !StateCheck(Player1,STATE_INVISIBLE)
  !StateCheck(Player1,STATE_IMPROVEDINVISIBILITY)
  See(Player1)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player1,178)
END

IF
  HaveSpell(WIZARD_RESIST_FEAR)
  StateCheck(Player2,STATE_PANIC)
  !StateCheck(Player2,STATE_INVISIBLE)
  !StateCheck(Player2,STATE_IMPROVEDINVISIBILITY)
  See(Player2)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player2,178)
END

IF
  HaveSpell(WIZARD_RESIST_FEAR)
  StateCheck(Player3,STATE_PANIC)
  !StateCheck(Player3,STATE_INVISIBLE)
  !StateCheck(Player3,STATE_IMPROVEDINVISIBILITY)
  See(Player3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player3,178)
END

IF
  HaveSpell(WIZARD_RESIST_FEAR)
  StateCheck(Player4,STATE_PANIC)
  !StateCheck(Player4,STATE_INVISIBLE)
  !StateCheck(Player4,STATE_IMPROVEDINVISIBILITY)
  See(Player4)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player4,WIZARD_RESIST_FEAR)
END

IF
  HaveSpell(WIZARD_RESIST_FEAR)
  StateCheck(Player5,STATE_PANIC)
  !StateCheck(Player5,STATE_INVISIBLE)
  !StateCheck(Player5,STATE_IMPROVEDINVISIBILITY)
  See(Player5)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player5,WIZARD_RESIST_FEAR)
END

IF
  HaveSpell(WIZARD_RESIST_FEAR)
  StateCheck(Player6,STATE_PANIC)
  !StateCheck(Player6,STATE_INVISIBLE)
  !StateCheck(Player6,STATE_IMPROVEDINVISIBILITY)
  See(Player6)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Player6,WIZARD_RESIST_FEAR)
END

IF
  HaveSpell(WIZARD_MIRROR_IMAGE)
  OR(2)
    TookDamage()
    Range(NearestEnemyOf(Myself),8)
  !StateCheck(Myself,STATE_MIRRORIMAGE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_MIRROR_IMAGE)
END

IF
  HaveSpell(WIZARD_BLUR)
  OR(2)
    TookDamage()
    Range(NearestEnemyOf(Myself),8)
  !StateCheck(Myself,STATE_BLUR)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_BLUR)
END

IF
  HaveSpell(WIZARD_SHIELD)
  OR(2)
    TookDamage()
    Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("GBWizShld","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizShld","LOCALS",FOUR_TURNS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SHIELD)
END

IF
  HaveSpell(WIZARD_PROTECTION_FROM_EVIL)
  OR(3)
    See(NearestEnemyOfType([0.0.DEMONIC]))
    Gender(NearestEnemyOf(Myself),SUMMONED)
    Alignment(NearestEnemyOf(Myself),MASK_EVIL)
  !GlobalTimerNotExpired("GBProtFromEvil","LOCALS")
  !HasItemEquiped("WA2AMU",Myself)
  !HasItemEquipedReal("STAF11",Myself)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBProtFromEvil","LOCALS",THREE_TURNS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_PROTECTION_FROM_EVIL)
END

IF
  HaveSpell(WIZARD_GREATER_MALISON)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !CheckStatGT(LastSeenBy(Myself),15,SAVEVSSPELL)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
  !GlobalTimerNotExpired("GBGreaterMalison","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("GBGreaterMalison","LOCALS",TWO_TURNS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_GREATER_MALISON)
END

IF
  HaveSpell(WIZARD_WAIL_OF_THE_BANSHEE)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),4)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_WAIL_OF_THE_BANSHEE)
END

IF
  HaveSpell(WIZARD_METEOR_SWARM)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_METEOR_SWARM)
END

IF
  HaveSpell(WIZARD_SYMBOL_STUN)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),8)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SYMBOL_STUN)
END

IF
  HaveSpell(WIZARD_SYMBOL_FEAR)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),8)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DEMONIC)
  !Race(LastSeenBy(Myself),TROLL)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SYMBOL_FEAR)
END

IF
  HaveSpell(WIZARD_SYMBOL_DEATH)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),8)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  HPLT(LastSeenBy(Myself),60)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SYMBOL_DEATH)
END

IF
  HaveSpell(WIZARD_INCENDIARY_CLOUD)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTFIRE)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_INCENDIARY_CLOUD)
END

IF
  HaveSpell(CLERIC_STORM_OF_VENGEANCE)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTFIRE)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_STORM_OF_VENGEANCE)
END

IF
  HaveSpell(KAISHAS_CHANGE)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTFIRE)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),KAISHAS_CHANGE)
END

IF
  HaveSpell(WIZARD_DRAGONS_BREATH)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTFIRE)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DRAGONS_BREATH)
END

IF
  HaveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
END

IF
  HaveSpell(WIZARD_SPHERE_OF_CHAOS)
  See(NearestEnemyOf(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  NumCreatureVsPartyGT([EVILCUTOFF],2)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SPHERE_OF_CHAOS)
END

IF
  HaveSpell(WIZARD_DELAYED_BLAST_FIREBALL)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTFIRE)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DELAYED_BLAST_FIREBALL)
END

IF
  HaveSpell(WIZARD_DEATH_FOG)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTACID)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DEATH_FOG)
END

IF
  HaveSpell(WIZARD_CLOUDKILL)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTACID)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CLOUDKILL)
END

IF
  HaveSpell(WIZARD_CHAOS)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CHAOS)
END

IF
  HaveSpell(WIZARD_TELEPORT_FIELD)
  See(NearestEnemyOf(Myself))
  NumCreatureVsPartyGT([EVILCUTOFF],2)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_TELEPORT_FIELD)
END

IF
  HaveSpell(WIZARD_ICE_STORM)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTCOLD)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_ICE_STORM)
END

IF
  HaveSpell(WIZARD_EMOTION_HOPELESSNESS)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_EMOTION_HOPELESSNESS)
END

IF
  HaveSpell(WIZARD_CONFUSION)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CONFUSION)
END

IF
  HaveSpell(WIZARD_SLOW)
  See(TenthNearestEnemyOf(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_SLOWED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SLOW)
END

IF
  HaveSpell(WIZARD_SKULL_TRAP)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SKULL_TRAP)
END

IF
  HaveSpell(WIZARD_REMOVE_MAGIC)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  OR(9)
    StateCheck(LastSeenBy(Myself),STATE_HASTED)
    StateCheck(LastSeenBy(Myself),STATE_BLESS)
    StateCheck(LastSeenBy(Myself),STATE_CHANT)
    StateCheck(LastSeenBy(Myself),STATE_BLUR)
    StateCheck(LastSeenBy(Myself),STATE_MIRRORIMAGE)
    StateCheck(LastSeenBy(Myself),STATE_LUCK)
    StateCheck(LastSeenBy(Myself),STATE_AID)
    CheckStatGT(LastSeenBy(Myself),0,STONESKINS)
    HasBounceEffects(LastSeenBy(Myself))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_REMOVE_MAGIC)
END

IF
  HaveSpell(WIZARD_LIGHTNING_BOLT)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTELECTRICITY)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_LIGHTNING_BOLT)
END

IF
  HaveSpell(WIZARD_FIREBALL)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTFIRE)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_FIREBALL)
END

IF
  HaveSpell(WIZARD_TRUE_DISPEL_MAGIC)
  OR(4)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),15)
  OR(9)
    StateCheck(LastSeenBy(Myself),STATE_HASTED)
    StateCheck(LastSeenBy(Myself),STATE_BLESS)
    StateCheck(LastSeenBy(Myself),STATE_CHANT)
    StateCheck(LastSeenBy(Myself),STATE_BLUR)
    StateCheck(LastSeenBy(Myself),STATE_MIRRORIMAGE)
    StateCheck(LastSeenBy(Myself),STATE_LUCK)
    StateCheck(LastSeenBy(Myself),STATE_AID)
    CheckStatGT(LastSeenBy(Myself),0,STONESKINS)
    HasBounceEffects(LastSeenBy(Myself))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_TRUE_DISPEL_MAGIC)
END

IF
  HaveSpell(WIZARD_WEB)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !Race(LastSeenBy(Myself),SPIDER)
  !Race(LastSeenBy(Myself),ETTERCAP)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),DRAGON)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(LastSeenBy(Myself),0,WEB)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_WEB)
END

IF
  HaveSpell(WIZARD_STINKING_CLOUD)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !Race(LastSeenBy(Myself),MEPHIT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_STINKING_CLOUD)
END

IF
  HaveSpell(WIZARD_HORROR)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_HORROR)
END

IF
  HaveSpell(WIZARD_GLITTERDUST)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_BLIND)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_GLITTERDUST)
END

IF
  HaveSpell(WIZARD_GREASE)
  See(TenthNearestEnemyOf(Myself))
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_SLOWED)
  !CheckStatGT(LastSeenBy(Myself),0,GREASE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_GREASE)
END

IF
  HaveSpell(CLERIC_FIRE_STORM)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTFIRE)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_FIRE_STORM)
END

IF
  HaveSpell(CLERIC_EARTHQUAKE)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_EARTHQUAKE)
END

IF
  HaveSpell(CLERIC_SYMBOL_STUN)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !Range(LastSeenBy(Myself),8)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !Race(LastSeenBy(Myself),WYVERN)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_SYMBOL_STUN)
END

IF
  HaveSpell(CLERIC_SYMBOL_FEAR)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !Range(LastSeenBy(Myself),8)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_SYMBOL_FEAR)
END

IF
  HaveSpell(CLERIC_SYMBOL_DEATH)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  HPLT(LastSeenBy(Myself),60)
  HPGT(Myself,60)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),TROLL)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_SYMBOL_DEATH)
END

IF
  HaveSpell(CLERIC_GREATER_COMMAND)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !Race(LastSeenBy(Myself),WYVERN)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_GREATER_COMMAND)
END

IF
  HaveSpell(CLERIC_HOLY_SMITE)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  Alignment(LastSeenBy(Myself),MASK_EVIL)
  !Alignment(Player1,MASK_EVIL)
  !Alignment(Player2,MASK_EVIL)
  !Alignment(Player3,MASK_EVIL)
  !Alignment(Player4,MASK_EVIL)
  !Alignment(Player5,MASK_EVIL)
  !Alignment(Player6,MASK_EVIL)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_HOLY_SMITE)
END

IF
  HaveSpell(CLERIC_UNHOLY_BLIGHT)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  Alignment(LastSeenBy(Myself),MASK_GOOD)
  !Alignment(Player1,MASK_GOOD)
  !Alignment(Player2,MASK_GOOD)
  !Alignment(Player3,MASK_GOOD)
  !Alignment(Player4,MASK_GOOD)
  !Alignment(Player5,MASK_GOOD)
  !Alignment(Player6,MASK_GOOD)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_UNHOLY_BLIGHT)
END

IF
  HaveSpell(CLERIC_GLYPH_OF_WARDING)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTELECTRICITY)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !CheckStatLT(LastSeenBy(Myself),10,SAVEVSSPELL)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !Range(LastSeenBy(Myself),15)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_GLYPH_OF_WARDING)
END

IF
  HaveSpell(CLERIC_ENTANGLE)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !Range(LastSeenBy(Myself),15)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_ENTANGLE)
END

IF
  HaveSpell(CLERIC_DOOM)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  CheckStatLT(LastSeenBy(Myself),15,SAVEVSSPELL)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_DOOM)
END

IF
  HaveSpell(CLERIC_SUMMON_DEVA)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreature([GOODCUTOFF.0.SOLAR],0)
  NumCreature([GOODCUTOFF.0.ANTISOLAR],0)
  NumCreature([GOODCUTOFF.0.PLANATAR],0)
  NumCreature([GOODCUTOFF.0.DARKPLANATAR],0)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_SUMMON_DEVA)
END

IF
  HaveSpell(CLERIC_SUMMON_FALLEN_DEVA)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreature([GOODCUTOFF.0.SOLAR],0)
  NumCreature([GOODCUTOFF.0.ANTISOLAR],0)
  NumCreature([GOODCUTOFF.0.PLANATAR],0)
  NumCreature([GOODCUTOFF.0.DARKPLANATAR],0)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_SUMMON_FALLEN_DEVA)
END

IF
  HaveSpell(WIZARD_SUMMON_PLANATAR_GOOD)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreature([GOODCUTOFF.0.SOLAR],0)
  NumCreature([GOODCUTOFF.0.ANTISOLAR],0)
  NumCreature([GOODCUTOFF.0.PLANATAR],0)
  NumCreature([GOODCUTOFF.0.DARKPLANATAR],0)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SUMMON_PLANATAR_GOOD)
END

IF
  HaveSpell(WIZARD_SUMMON_PLANATAR_EVIL)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreature([GOODCUTOFF.0.SOLAR],0)
  NumCreature([GOODCUTOFF.0.ANTISOLAR],0)
  NumCreature([GOODCUTOFF.0.PLANATAR],0)
  NumCreature([GOODCUTOFF.0.DARKPLANATAR],0)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SUMMON_PLANATAR_EVIL)
END

IF
  HaveSpell(CLERIC_ELEMENTAL_SWARM)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_ELEMENTAL_SWARM)
END

IF
  HaveSpell(CLERIC_GREATER_ELEMENTAL_SWARM)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_GREATER_ELEMENTAL_SWARM)
END

IF
  HaveSpell(WIZARD_GATE)
  OR(3)
    GlobalTimerNotExpired("GBProtFromEvil","LOCALS")
    HasItemEquiped("WA2AMU",Myself)
    HasItemEquipedReal("STAF11",Myself)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_GATE)
END

IF
  HaveSpell(WIZARD_SUMMON_FIEND)
  OR(3)
    GlobalTimerNotExpired("GBProtFromEvil","LOCALS")
    HasItemEquiped("WA2AMU",Myself)
    HasItemEquipedReal("STAF11",Myself)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SUMMON_FIEND)
END

IF
  HaveSpell(WIZARD_SUMMON_EFREET)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SUMMON_EFREET)
END

IF
  HaveSpell(WIZARD_SUMMON_DJINNI)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SUMMON_DJINNI)
END

IF
  HaveSpell(WIZARD_MORDENKAINENS_SWORD)
  See(NearestEnemyOf(Myself))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_MORDENKAINENS_SWORD)
END

IF
  HaveSpell(WIZARD_CACOFIEND)
  OR(3)
    GlobalTimerNotExpired("GBProtFromEvil","LOCALS")
    HasItemEquiped("WA2AMU",Myself)
    HasItemEquipedReal("STAF11",Myself)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CACOFIEND)
END

IF
  HaveSpell(WIZARD_WYVERN_CALL)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_WYVERN_CALL)
END

IF
  HaveSpell(WIZARD_INVISIBLE_STALKER)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_INVISIBLE_STALKER)
END

IF
  HaveSpell(WIZARD_CONJURE_AIR_ELEMENTAL)
  OR(3)
    GlobalTimerNotExpired("GBProtFromEvil","LOCALS")
    HasItemEquiped("WA2AMU",Myself)
    HasItemEquipedReal("STAF11",Myself)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  CheckStatGT(Myself,0,STONESKINS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_CONJURE_AIR_ELEMENTAL)
END

IF
  HaveSpell(WIZARD_CONJURE_EARTH_ELEMENTAL)
  OR(3)
    GlobalTimerNotExpired("GBProtFromEvil","LOCALS")
    HasItemEquiped("WA2AMU",Myself)
    HasItemEquipedReal("STAF11",Myself)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  CheckStatGT(Myself,0,STONESKINS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_CONJURE_EARTH_ELEMENTAL)
END

IF
  HaveSpell(WIZARD_CONJURE_FIRE_ELEMENTAL)
  OR(3)
    GlobalTimerNotExpired("GBProtFromEvil","LOCALS")
    HasItemEquiped("WA2AMU",Myself)
    HasItemEquipedReal("STAF11",Myself)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  CheckStatGT(Myself,0,STONESKINS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_CONJURE_FIRE_ELEMENTAL)
END

IF
  HaveSpell(WIZARD_CARRION)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CARRION)
END

IF
  HaveSpell(WIZARD_MONSTER_SUMMONING_3)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_MONSTER_SUMMONING_3)
END

IF
  HaveSpell(WIZARD_CONJURE_LESSER_AIR_ELEMENTAL)
  OR(3)
    GlobalTimerNotExpired("GBProtFromEvil","LOCALS")
    HasItemEquiped("WA2AMU",Myself)
    HasItemEquipedReal("STAF11",Myself)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  CheckStatGT(Myself,0,STONESKINS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_CONJURE_LESSER_AIR_ELEMENTAL)
END

IF
  HaveSpell(WIZARD_CONJURE_LESSER_EARTH_ELEMENTAL)
  OR(3)
    GlobalTimerNotExpired("GBProtFromEvil","LOCALS")
    HasItemEquiped("WA2AMU",Myself)
    HasItemEquipedReal("STAF11",Myself)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  CheckStatGT(Myself,0,STONESKINS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_CONJURE_LESSER_EARTH_ELEMENTAL)
END

IF
  HaveSpell(WIZARD_CONJURE_LESSER_FIRE_ELEMENTAL)
  OR(3)
    GlobalTimerNotExpired("GBProtFromEvil","LOCALS")
    HasItemEquiped("WA2AMU",Myself)
    HasItemEquipedReal("STAF11",Myself)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  CheckStatGT(Myself,0,STONESKINS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_CONJURE_LESSER_FIRE_ELEMENTAL)
END

IF
  HaveSpell(WIZARD_ANIMATE_DEAD)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_ANIMATE_DEAD)
END

IF
  HaveSpell(WIZARD_SPIDER_SPAWN)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SPIDER_SPAWN)
END

IF
  HaveSpell(WIZARD_MONSTER_SUMMONING_2)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_MONSTER_SUMMONING_2)
END

IF
  HaveSpell(WIZARD_MONSTER_SUMMONING_1)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_MONSTER_SUMMONING_1)
END

IF
  HaveSpell(CLERIC_GATE)
  OR(3)
    GlobalTimerNotExpired("GBProtFromEvil","LOCALS")
    HasItemEquiped("WA2AMU",Myself)
    HasItemEquipedReal("STAF11",Myself)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_GATE)
END

IF
  HaveSpell(CLERIC_CONJURE_EARTH_ELEMENTAL)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_CONJURE_EARTH_ELEMENTAL)
END

IF
  HaveSpell(CLERIC_CONJURE_FIRE_ELEMENTAL)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_CONJURE_FIRE_ELEMENTAL)
END

IF
  HaveSpell(CLERIC_AERIAL_SERVANT)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_AERIAL_SERVANT)
END

IF
  HaveSpell(CLERIC_CONJURE_ANIMALS)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_CONJURE_ANIMALS)
END

IF
  HaveSpell(CLERIC_ANIMATE_DEAD)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_ANIMATE_DEAD)
END

IF
  HaveSpell(CLERIC_CALL_WOODLAND_BEINGS)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_CALL_WOODLAND_BEINGS)
END

IF
  HaveSpell(CLERIC_ANIMAL_SUMMONING_3)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_ANIMAL_SUMMONING_3)
END

IF
  HaveSpell(CLERIC_ANIMAL_SUMMONING_2)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_ANIMAL_SUMMONING_2)
END

IF
  HaveSpell(CLERIC_ANIMAL_SUMMONING_1)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_ANIMAL_SUMMONING_1)
END

IF
  HasItemEquiped("MISC3C",Myself)
  Global("GBUsedMISC3C","LOCALS",0)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("MISC3C",LastSeenBy(Myself))  // ~Efreeti Bottle~
    SetGlobal("GBUsedMISC3C","LOCALS",1)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HasItemEquiped("MISC3E",Myself)
  Global("GBUsedMISC3E","LOCALS",0)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("MISC3E",LastSeenBy(Myself))  // ~Black Spider Figurine~
    SetGlobal("GBUsedMISC3E","LOCALS",1)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HasItemEquiped("MISC3I",Myself)
  Global("GBUsedMISC3I","LOCALS",0)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("MISC3I",LastSeenBy(Myself))  // ~Silver Horn of Valhalla~
    SetGlobal("GBUsedMISC3I","LOCALS",1)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HasItemEquiped("MISC3J",Myself)
  Global("GBUsedMISC3J","LOCALS",0)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("MISC3J",LastSeenBy(Myself))  // ~Bronze Horn of Valhalla~
    SetGlobal("GBUsedMISC3J","LOCALS",1)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HasItemEquiped("MISC3K",Myself)
  Global("GBUsedMISC3K","LOCALS",0)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("MISC3K",LastSeenBy(Myself))  // ~Iron Horn of Valhalla~
    SetGlobal("GBUsedMISC3K","LOCALS",1)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
END

IF
  HasItemEquiped("WAND10",Myself)
  OR(5)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  NumCreatureLT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("WAND10",LastSeenBy(Myself))  // ~Wand of Monster Summoning~
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
  RESPONSE #25
    Continue()
END

IF
  HaveSpell(CLERIC_IMPLOSION)
  See(NearestEnemyOf(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTFIRE)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_IMPLOSION)
END

IF
  HaveSpell(WIZARD_BIGBYS_CRUSHING_HAND)
  See(NearestEnemyOf(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_BIGBYS_CRUSHING_HAND)
END

IF
  HaveSpell(WIZARD_BIGBYS_CLENCHED_FIST)
  See(NearestEnemyOf(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_BIGBYS_CLENCHED_FIST)
END

IF
  HaveSpell(WIZARD_POWER_WORD_KILL)
  See(NearestEnemyOf(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !HPGT(LastSeenBy(Myself),60)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
  HaveSpell(WIZARD_POWER_WORD_BLIND)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_BLIND)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_BLIND)
END

IF
  HaveSpell(WIZARD_POWER_WORD_STUN)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),BEHOLDER)
  HPLT(LastSeenBy(Myself),90)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_STUN)
END

IF
  HasItemEquiped("WAND04",Myself)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),BEHOLDER)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    UseItem("WAND04",LastSeenBy(Myself))  // ~Wand of Paralyzation ~
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
  RESPONSE #25
    Continue()
END

IF
  HaveSpell(WIZARD_FINGER_OF_DEATH)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_FINGER_OF_DEATH)
END

IF
  HaveSpell(WIZARD_FLESH_TO_STONE)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_FLESH_TO_STONE)
END

IF
  HaveSpell(WIZARD_DISINTEGRATE)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !Race(LastSeenBy(Myself),LICH)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DISINTEGRATE)
END

IF
  HaveSpell(WIZARD_CHAIN_LIGHTNING)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTELECTRICITY)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CHAIN_LIGHTNING)
END

IF
  HaveSpell(WIZARD_HOLD_MONSTER)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_HOLD_MONSTER)
END

IF
  HaveSpell(WIZARD_FEEBLEMIND)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_FEEBLEMIND)
END

IF
  HaveSpell(WIZARD_DOMINATION)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !Race(LastSeenBy(Myself),DRAGON)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DOMINATION)
END

IF
  HaveSpell(WIZARD_POLYMORPH_OTHER)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(LastSeenBy(Myself),0,POLYMORPHED)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_POLYMORPH_OTHER)
END

IF
  HaveSpell(WIZARD_OTILUKES_RESILIENT_SPHERE)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  HPPercentGT(LastSeenBy(Myself),50)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_OTILUKES_RESILIENT_SPHERE)
END

IF
  HaveSpell(WIZARD_CONTAGION)
  See(NearestEnemyOf(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  OR(3)
    CheckStatGT(LastSeenBy(Myself),16,STR)
    CheckStatGT(LastSeenBy(Myself),16,DEX)
    StateCheck(LastSeenBy(Myself),STATE_HASTED)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CONTAGION)
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(WIZARD_ENERGY_BLADES)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !CheckStatGT(LastSeenBy(Myself),25,RESISTELECTRICITY)
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Myself,WIZARD_ENERGY_BLADES)
    EquipRanged()
    Attack(LastSeenBy(Myself))
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(WIZARD_MELF_METEOR)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Myself,WIZARD_MELF_METEOR)
    EquipRanged()
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WIZARD_HOLD_PERSON)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  General(LastSeenBy(Myself),HUMANOID)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_HOLD_PERSON)
END

IF
  HaveSpell(WIZARD_FLAME_ARROW)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTFIRE)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_FLAME_ARROW)
END

IF
  HaveSpell(WIZARD_DIRE_CHARM)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  General(LastSeenBy(Myself),HUMANOID)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DIRE_CHARM)
END

IF
  HaveSpell(WIZARD_RAY_OF_ENFEEBLEMENT)
  See(NearestEnemyOf(Myself))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatLT(LastSeenBy(Myself),17,STR)
  General(LastSeenBy(Myself),HUMANOID)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_RAY_OF_ENFEEBLEMENT)
END

IF
  HaveSpell(WIZARD_POWER_WORD_SLEEP)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  HPLT(LastSeenBy(Myself),20)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_SLEEP)
END

IF
  HaveSpell(WIZARD_SLEEP)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  CheckStatLT(LastSeenBy(Myself),4,LEVEL)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SLEEP)
END

IF
  HaveSpell(WIZARD_MELF_ACID_ARROW)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTACID)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_MELF_ACID_ARROW)
END

IF
  HaveSpell(WIZARD_AGANNAZAR_SCORCHER)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTFIRE)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_AGANNAZAR_SCORCHER)
END

IF
  HaveSpell(WIZARD_SPOOK)
  See(NearestEnemyOf(Myself))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatLT(LastSeenBy(Myself),3,INT)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SPOOK)
END

IF
  HaveSpell(WIZARD_MAGIC_MISSILE)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_MAGIC_MISSILE)
END

IF
  HaveSpell(WIZARD_LARLOCH_MINOR_DRAIN)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_LARLOCH_MINOR_DRAIN)
END

IF
  HaveSpell(WIZARD_CHROMATIC_ORB)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CHROMATIC_ORB)
END

IF
  HaveSpell(WIZARD_CHARM_PERSON)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  General(LastSeenBy(Myself),HUMANOID)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CHARM_PERSON)
END

IF
  HaveSpell(CLERIC_BOLT_OF_GLORY)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_BOLT_OF_GLORY)
END

IF
  HaveSpell(CLERIC_FINGER_OF_DEATH)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),TROLL)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_FINGER_OF_DEATH)
END

IF
  HaveSpell(CLERIC_FLAME_STRIKE)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTFIRE)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_FLAME_STRIKE)
END

IF
  HaveSpell(CLERIC_CALL_LIGHTNING)
  AreaType(OUTDOOR)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTELECTRICITY)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_CALL_LIGHTNING)
END

IF
  HaveSpell(CLERIC_CONFUSION)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_CONFUSION)
END

IF
  HaveSpell(CLERIC_RIGID_THINKING)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_RIGID_THINKING)
END

IF
  HaveSpell(CLERIC_DOLOROUS_DECAY)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  Range(LastSeenBy(Myself),12)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_DOLOROUS_DECAY)
END

IF
  HaveSpell(CLERIC_ENERGY_DRAIN)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  Range(LastSeenBy(Myself),12)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_ENERGY_DRAIN)
END

IF
  HaveSpell(CLERIC_POISON)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  Range(LastSeenBy(Myself),12)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_POISON)
END

IF
  HaveSpell(CLERIC_MENTAL_DOMINATION)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !Race(LastSeenBy(Myself),WYVERN)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_MENTAL_DOMINATION)
END

IF
  HaveSpell(CLERIC_HOLD_PERSON)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  General(LastSeenBy(Myself),HUMANOID)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_HOLD_PERSON)
END

IF
  HaveSpell(CLERIC_HOLD_ANIMAL)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  General(LastSeenBy(Myself),ANIMAL)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_HOLD_ANIMAL)
END

IF
  HaveSpell(CLERIC_COMMAND)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !Race(LastSeenBy(Myself),MEPHIT)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_COMMAND)
END

IF
  HaveSpell(CLERIC_CHARM_PERSON)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  General(LastSeenBy(Myself),HUMANOID)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_CHARM_PERSON)
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(CLERIC_SOL_SEARING_ORB)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Myself,CLERIC_SOL_SEARING_ORB)
    EquipRanged()
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WIZARD_POWER_WORD_KILL)
  See(NearestEnemyOf(Myself))
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !HPGT(LastSeenBy(Myself),60)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
  HaveSpell(WIZARD_POWER_WORD_BLIND)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_BLIND)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_BLIND)
END

IF
  HaveSpell(WIZARD_POWER_WORD_STUN)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),BEHOLDER)
  HPLT(LastSeenBy(Myself),90)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_STUN)
END

IF
  HaveSpell(WIZARD_FINGER_OF_DEATH)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_FINGER_OF_DEATH)
END

IF
  HaveSpell(WIZARD_FLESH_TO_STONE)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_FLESH_TO_STONE)
END

IF
  HaveSpell(WIZARD_DISINTEGRATE)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !Race(LastSeenBy(Myself),LICH)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DISINTEGRATE)
END

IF
  HaveSpell(WIZARD_CHAIN_LIGHTNING)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTELECTRICITY)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CHAIN_LIGHTNING)
END

IF
  HaveSpell(WIZARD_HOLD_MONSTER)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_HOLD_MONSTER)
END

IF
  HaveSpell(WIZARD_FEEBLEMIND)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_FEEBLEMIND)
END

IF
  HaveSpell(WIZARD_DOMINATION)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !Race(LastSeenBy(Myself),DRAGON)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DOMINATION)
END

IF
  HaveSpell(WIZARD_POLYMORPH_OTHER)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(LastSeenBy(Myself),0,POLYMORPHED)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_POLYMORPH_OTHER)
END

IF
  HaveSpell(WIZARD_OTILUKES_RESILIENT_SPHERE)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  HPPercentGT(LastSeenBy(Myself),50)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_OTILUKES_RESILIENT_SPHERE)
END

IF
  HaveSpell(WIZARD_CONTAGION)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  OR(3)
    CheckStatGT(LastSeenBy(Myself),16,STR)
    CheckStatGT(LastSeenBy(Myself),16,DEX)
    StateCheck(LastSeenBy(Myself),STATE_HASTED)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CONTAGION)
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(WIZARD_MELF_METEOR)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Myself,WIZARD_MELF_METEOR)
    EquipRanged()
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WIZARD_HOLD_PERSON)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  General(LastSeenBy(Myself),HUMANOID)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_HOLD_PERSON)
END

IF
  HaveSpell(WIZARD_FLAME_ARROW)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTFIRE)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_FLAME_ARROW)
END

IF
  HaveSpell(WIZARD_DIRE_CHARM)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  General(LastSeenBy(Myself),HUMANOID)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DIRE_CHARM)
END

IF
  HaveSpell(WIZARD_RAY_OF_ENFEEBLEMENT)
  See(NearestEnemyOf(Myself))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatLT(LastSeenBy(Myself),17,STR)
  General(LastSeenBy(Myself),HUMANOID)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_RAY_OF_ENFEEBLEMENT)
END

IF
  HaveSpell(WIZARD_POWER_WORD_SLEEP)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  HPLT(LastSeenBy(Myself),20)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_SLEEP)
END

IF
  HaveSpell(WIZARD_SLEEP)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatLT(LastSeenBy(Myself),4,LEVEL)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SLEEP)
END

IF
  HaveSpell(WIZARD_MELF_ACID_ARROW)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTACID)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_MELF_ACID_ARROW)
END

IF
  HaveSpell(WIZARD_AGANNAZAR_SCORCHER)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTFIRE)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_AGANNAZAR_SCORCHER)
END

IF
  HaveSpell(WIZARD_SPOOK)
  See(NearestEnemyOf(Myself))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatLT(LastSeenBy(Myself),3,INT)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SPOOK)
END

IF
  HaveSpell(WIZARD_MAGIC_MISSILE)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_MAGIC_MISSILE)
END

IF
  HaveSpell(WIZARD_LARLOCH_MINOR_DRAIN)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_LARLOCH_MINOR_DRAIN)
END

IF
  HaveSpell(WIZARD_CHROMATIC_ORB)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CHROMATIC_ORB)
END

IF
  HaveSpell(WIZARD_CHARM_PERSON)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  General(LastSeenBy(Myself),HUMANOID)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CHARM_PERSON)
END

IF
  HaveSpell(WIZARD_IMPRISONMENT)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_IMPRISONMENT)
END

IF
  HaveSpell(WIZARD_SHAPECHANGE)
  See(NearestEnemyOf(Myself))
  CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SHAPECHANGE)
    DisplayString(Myself,4958)  // ~Shape Change~
    UnhideGUI()
    PauseGame()
END

IF
  HaveSpell(WIZARD_POLYMORPH_SELF)
  See(NearestEnemyOf(Myself))
  CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_POLYMORPH_SELF)
    DisplayString(Myself,4958)  // ~Shape Change~
    UnhideGUI()
    PauseGame()
END

IF
  HaveSpell(WIZARD_ENERGY_DRAIN)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_ENERGY_DRAIN)
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(WIZARD_BLACK_BLADE_OF_DISASTER)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Myself,WIZARD_BLACK_BLADE_OF_DISASTER)
    EquipMostDamagingMelee()
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WIZARD_MAZE)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_MAZE)
END

IF
  HaveSpell(WIZARD_PRISMATIC_SPRAY)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_PRISMATIC_SPRAY)
END

IF
  HaveSpell(WIZARD_IMPROVED_HASTE)
  See(NearestEnemyOf(Myself))
  See(Player1)
  !CheckStatGT(LastSeenBy(Myself),0,IMPROVEDHASTE)
  !HasItemEquiped("ring09",LastSeenBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_IMPROVED_HASTE)
END

IF
  HaveSpell(WIZARD_IMPROVED_HASTE)
  See(NearestEnemyOf(Myself))
  See(Player2)
  !CheckStatGT(LastSeenBy(Myself),0,IMPROVEDHASTE)
  !HasItemEquiped("ring09",LastSeenBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_IMPROVED_HASTE)
END

IF
  HaveSpell(WIZARD_IMPROVED_HASTE)
  See(NearestEnemyOf(Myself))
  See(Player3)
  !CheckStatGT(LastSeenBy(Myself),0,IMPROVEDHASTE)
  !HasItemEquiped("ring09",LastSeenBy(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_IMPROVED_HASTE)
END

IF
  HaveSpell(WIZARD_IMPROVED_HASTE)
  See(NearestEnemyOf(Myself))
  See(StrongestOf(Myself))
  !HasItemEquiped("ring09",LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),0,IMPROVEDHASTE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_IMPROVED_HASTE)
END

IF
  HaveSpell(WIZARD_IMPROVED_HASTE)
  See(NearestEnemyOf(Myself))
  !CheckStatGT(Myself,0,IMPROVEDHASTE)
  !HasItemEquiped("ring09",Myself)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_IMPROVED_HASTE)
END

IF
  HaveSpell(WIZARD_SUN_FIRE)
  See(NearestEnemyOf(Myself))
  Range(Nearest([PC]),8)
  !Range(WeakestOf(Myself),8)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTFIRE)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SUN_FIRE)
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(WIZARD_PHANTOM_BLADE)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  OR(2)
    General(LastSeenBy(Myself),UNDEAD)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Myself,WIZARD_PHANTOM_BLADE)
    EquipMostDamagingMelee()
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WIZARD_CONE_OF_COLD)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTCOLD)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CONE_OF_COLD)
END

IF
  HaveSpell(WIZARD_VAMPIRIC_TOUCH)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Range(LastSeenBy(Myself),8)
  !HasBounceEffects(LastSeenBy(Myself))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("GBWizVampToch","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizVampToch","LOCALS",ONE_HOUR)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_VAMPIRIC_TOUCH)
END

IF
  HaveSpell(WIZARD_STRENGTH)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  CheckStatLT(Myself,19,STR)
  CheckStatLT(Myself,50,STREXTRA)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_STRENGTH)
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(WIZARD_GHOUL_TOUCH)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Myself,WIZARD_GHOUL_TOUCH)
    EquipMostDamagingMelee()
    Attack(LastSeenBy(Myself))
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(WIZARD_SHOCKING_GRASP)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),25,RESISTELECTRICITY)
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Myself,WIZARD_SHOCKING_GRASP)
    EquipMostDamagingMelee()
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WIZARD_COLOR_SPRAY)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_COLOR_SPRAY)
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(WIZARD_CHILL_TOUCH)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !Race(LastSeenBy(Myself),WYVERN)
  !Race(LastSeenBy(Myself),KUO-TOA)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Myself,WIZARD_CHILL_TOUCH)
    EquipMostDamagingMelee()
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WIZARD_BURNING_HANDS)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTFIRE)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_BURNING_HANDS)
END

IF
  HaveSpell(CLERIC_NATURE_BEAUTY)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Range(LastSeenBy(Myself),12)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_NATURE_BEAUTY)
END

IF
  HaveSpell(CLERIC_HOLY_WORD)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Alignment(LastSeenBy(Myself),MASK_EVIL)
  !Alignment(Player1,MASK_EVIL)
  !Alignment(Player2,MASK_EVIL)
  !Alignment(Player3,MASK_EVIL)
  !Alignment(Player4,MASK_EVIL)
  !Alignment(Player5,MASK_EVIL)
  !Alignment(Player6,MASK_EVIL)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_HOLY_WORD)
END

IF
  HaveSpell(CLERIC_UNHOLY_WORD)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Alignment(LastSeenBy(Myself),MASK_GOOD)
  !Alignment(Player1,MASK_GOOD)
  !Alignment(Player2,MASK_GOOD)
  !Alignment(Player3,MASK_GOOD)
  !Alignment(Player4,MASK_GOOD)
  !Alignment(Player5,MASK_GOOD)
  !Alignment(Player6,MASK_GOOD)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_UNHOLY_WORD)
END

IF
  HaveSpell(CLERIC_RIGHTEOUS_MAGIC)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !GlobalTimerNotExpired("GBClrRightMag","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrRightMag","LOCALS",90)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_RIGHTEOUS_MAGIC)
END

IF
  HaveSpell(CLERIC_CHAMPIONS_STRENGTH)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !GlobalTimerNotExpired("GBClrChampStr","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrChampStr","LOCALS",ONE_HOUR)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_CHAMPIONS_STRENGTH)
END

IF
  HaveSpell(CLERIC_DRAW_UPON_HOLY_MIGHT)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !GlobalTimerNotExpired("GBClrDUHM","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrDUHM","LOCALS",90)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_DRAW_UPON_HOLY_MIGHT)
END

IF
  HaveSpell(CLERIC_HOLY_POWER)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !GlobalTimerNotExpired("GBClrHolyPow","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrHolyPow","LOCALS",90)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_HOLY_POWER)
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(CLERIC_HARM)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Range(LastSeenBy(Myself),8)
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Myself,CLERIC_HARM)
    Attack(LastSeenBy(Myself))
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(CLERIC_SLAY_LIVING)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Range(LastSeenBy(Myself),8)
  !HasItemSlot(Myself,SLOT_MISC19)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),TROLL)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Myself,CLERIC_SLAY_LIVING)
    Attack(LastSeenBy(Myself))
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(CLERIC_CAUSE_CRITICAL_WOUNDS)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Range(LastSeenBy(Myself),8)
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Myself,CLERIC_CAUSE_CRITICAL_WOUNDS)
    Attack(LastSeenBy(Myself))
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(CLERIC_CAUSE_SERIOUS_WOUNDS)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Range(LastSeenBy(Myself),8)
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    Spell(Myself,CLERIC_CAUSE_SERIOUS_WOUNDS)
    Attack(LastSeenBy(Myself))
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(CLERIC_SPIRITUAL_HAMMER)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Range(LastSeenBy(Myself),8)
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_SPIRITUAL_HAMMER)
END

IF
  CheckStatGT(Myself,0,NUMBEROFATTACKS)
  HaveSpell(CLERIC_FLAME_BLADE)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Range(LastSeenBy(Myself),8)
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_FLAME_BLADE)
END

IF
  HaveSpell(CLERIC_SHILLELAGH)
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Range(LastSeenBy(Myself),8)
  !HasItemSlot(Myself,SLOT_MISC19)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_SHILLELAGH)
END

IF
  HaveSpell(WIZARD_TENSERS_TRANSFORMATION)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  OR(2)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    HPPercentGT(Myself,50)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_TENSERS_TRANSFORMATION)
END

IF
  HaveSpell(WARRIOR_WHIRLWIND)
  See(NearestEnemyOf(Myself))
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBWhirlwind","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWhirlwind","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WARRIOR_WHIRLWIND)
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WARRIOR_GREATER_WHIRLWIND)
  See(NearestEnemyOf(Myself))
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBWhirlwind","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWhirlwind","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WARRIOR_GREATER_WHIRLWIND)
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WARRIOR_DEATHBLOW)
  NumCreatureVsPartyGT([EVILCUTOFF],4)
  See(NearestEnemyOf(Myself))
  !CheckStatGT(LastSeenBy(Myself),8,LEVEL)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBDeathblow","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBDeathblow","LOCALS",THREE_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WARRIOR_DEATHBLOW)
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WARRIOR_GREATER_DEATHBLOW)
  NumCreatureVsPartyGT([EVILCUTOFF],4)
  See(NearestEnemyOf(Myself))
  !CheckStatGT(LastSeenBy(Myself),12,LEVEL)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBGrtDeathblow","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBGrtDeathblow","LOCALS",THREE_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WARRIOR_GREATER_DEATHBLOW)
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WARRIOR_RESIST_MAGIC)
  OR(2)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  CheckStatLT(Myself,50,RESISTMAGIC)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WARRIOR_RESIST_MAGIC)
END

IF
  HaveSpell(WARRIOR_CRITICAL_STRIKE)
  See(NearestEnemyOf(Myself))
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBCritStrike","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBCritStrike","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WARRIOR_CRITICAL_STRIKE)
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WARRIOR_POWER_ATTACK)
  See(NearestEnemyOf(Myself))
  !HasBounceEffects(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !GlobalTimerNotExpired("GBPowerAttack","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBPowerAttack","LOCALS",THREE_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WARRIOR_POWER_ATTACK)
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WARRIOR_HARDINESS)
  See(NearestEnemyOf(Myself))
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBHardiness","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHardiness","LOCALS",THREE_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WARRIOR_HARDINESS)
END

IF
  HaveSpell(WARRIOR_WAR_CRY)
  NumCreatureVsPartyGT([EVILCUTOFF],4)
  See(NearestEnemyOf(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),BEHOLDER)
  !GlobalTimerNotExpired("GBWarCry","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWarCry","LOCALS",THREE_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WARRIOR_WAR_CRY)
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(WARRIOR_SMITE)
  See(NearestEnemyOf(Myself))
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBWarSmite","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWarSmite","LOCALS",THREE_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,WARRIOR_SMITE)
    Attack(LastSeenBy(Myself))
END

IF
  HPPercentLT(Myself,75)
  HaveSpellRES("spin101")
  !HasBounceEffects(Myself)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SpellRES("spin101",Myself)  // ~Cure Light Wounds~
END

IF
  StateCheck(Myself,STATE_POISONED)
  HaveSpellRES("spin102")
  !HasBounceEffects(Myself)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SpellRES("spin102",Myself)  // ~Slow Poison~
END

IF
  HaveSpellRES("spin103")
  See(NearestEnemyOf(Myself))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !Range(LastAttackerOf(Myself),8)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  !GlobalTimerNotExpired("GBClrDUHM","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBClrDUHM","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SpellRES("spin103",Myself)  // ~Draw Upon Holy Might~
END

IF
  HaveSpellRES("spin104")
  See(TenthNearestEnemyOf(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SpellRES("spin104",LastSeenBy(Myself))  // ~Larloch's Minor Drain~
END

IF
  HaveSpellRES("spin105")
  See(TenthNearestEnemyOf(Myself))
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !HasItemEquiped("lich",LastSeenBy(Myself))
  !HasItemEquiped("rakring",LastSeenBy(Myself))
  !General(LastSeenBy(Myself),UNDEAD)
  !Race(LastSeenBy(Myself),SLIME)
  !Race(LastSeenBy(Myself),DRAGON)
  !Race(LastSeenBy(Myself),TROLL)
  !Race(LastSeenBy(Myself),RAKSHASA)
  !Race(LastSeenBy(Myself),DEMONIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SpellRES("spin105",LastSeenBy(Myself))  // ~Horror~
END

IF
  HaveSpellRES("spin106")
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  !HasBounceEffects(LastSeenBy(Myself))
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("GBWizVampToch","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBWizVampToch","LOCALS",ONE_HOUR)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    SpellRES("spin106",LastSeenBy(Myself))  // ~Vampiric Touch~
END

IF
  HaveSpell(ROGUE_EVASION)
  TookDamage()
  See(NearestEnemyOf(Myself))
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBEvasion","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBEvasion","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,ROGUE_EVASION)
END

IF
  HaveSpell(ROGUE_GREATER_EVASION)
  TookDamage()
  See(NearestEnemyOf(Myself))
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBEvasion","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBEvasion","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,ROGUE_GREATER_EVASION)
END

IF
  HaveSpell(ROGUE_ASSASINATION)
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBAssassination","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBAssassination","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,ROGUE_ASSASINATION)
    EquipMostDamagingMelee()
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(ROGUE_AVOID_DEATH)
  OR(2)
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBAvoidDeath","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBAvoidDeath","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,ROGUE_AVOID_DEATH)
END

IF
  Kit(Myself,1073741824)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBBarbRage","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBBarbRage","LOCALS",90)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,BARBARIAN_RAGE)
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(BERSERKER_RAGE)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBBarbRage","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBBarbRage","LOCALS",90)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,BERSERKER_RAGE)
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(KENSAI_KIA)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBKensaiKia","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBKensaiKia","LOCALS",ONE_TURN)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,KENSAI_KIA)
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(ASSASSIN_POISON)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,ASSASSIN_POISON)
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(ARCHER_CALL_SHOT)
  OR(3)
    See(TenthNearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !GlobalTimerNotExpired("GBArcherShot","LOCALS")
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBArcherShot","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,ARCHER_CALL_SHOT)
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(MINSC_BERSERK)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Range(LastSeenBy(Myself),8)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,MINSC_BERSERK)
    EquipMostDamagingMelee()
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(RANGER_CHARM_ANIMAL)
  See(NearestEnemyOf(Myself))
  General(LastSeenBy(Myself),ANIMAL)
  NumCreatureVsPartyGT([EVILCUTOFF],3)
  Range(LastSeenBy(Myself),8)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),RANGER_CHARM_ANIMAL)
END

IF
  HaveSpell(MONK_STUNNING_BLOW)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  Range(LastSeenBy(Myself),8)
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,MONK_STUNNING_BLOW)
    EquipMostDamagingMelee()
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(MONK_QUIVERING_PALM)
  OR(3)
    See(NearestEnemyOf(Myself))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,MONK_QUIVERING_PALM)
    EquipMostDamagingMelee()
    Attack(LastSeenBy(Myself))
END

IF
  HaveSpell(MONK_LAY_ON_HANDS)
  HPPercentLT(Myself,75)
  See(NearestEnemyOf(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,MONK_LAY_ON_HANDS)
END

IF
  HaveSpell(PALADIN_LAY_ON_HANDS)
  HPPercentLT(Myself,75)
  See(NearestEnemyOf(Myself))
  !CheckStatGT(Myself,35,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("GBHalfAttack","LOCALS",ONE_ROUND)
    Spell(Myself,PALADIN_LAY_ON_HANDS)
END

IF
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  Global("GBAmmoless","LOCALS",0)
  !HasItemSlot(Myself,SLOT_MISC19)
  HasItemSlot(Myself,SLOT_WEAPON0)
  !GlobalTimerNotExpired("GBWizAlacrity","LOCALS")
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
  RESPONSE #100
    SelectWeaponAbility(SLOT_WEAPON0,0)
    Attack(LastSeenBy(Myself))
END

IF
  See(NearestEnemyOf(Myself))
  Range(LastSeenBy(Myself),8)
  OR(3)
    !HasItemSlot(Myself,SLOT_WEAPON0)
    HasItemSlot(Myself,SLOT_MISC19)
    Global("GBAmmoless","LOCALS",1)
  !GlobalTimerNotExpired("GBWizAlacrity","LOCALS")
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
  RESPONSE #100
    EquipMostDamagingMelee()
    Attack(LastSeenBy(Myself))
END

IF
  OR(3)
    See(NearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),8)
  !Range(LastAttackerOf(Myself),8)
  Global("GBAmmoless","LOCALS",0)
  !HasItemSlot(Myself,SLOT_MISC19)
  HasItemSlot(Myself,SLOT_WEAPON1)
  !GlobalTimerNotExpired("GBWizAlacrity","LOCALS")
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
  RESPONSE #100
    SelectWeaponAbility(SLOT_WEAPON1,0)
    Attack(LastSeenBy(Myself))
END

IF
  OR(3)
    See(NearestEnemyOf(Myself))
    See(TenthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([0.0.0.LONG_BOW]))
  !Range(LastSeenBy(Myself),8)
  !Range(LastAttackerOf(Myself),8)
  OR(3)
    !HasItemSlot(Myself,SLOT_WEAPON1)
    HasItemSlot(Myself,SLOT_MISC19)
    Global("GBAmmoless","LOCALS",1)
  !GlobalTimerNotExpired("GBWizAlacrity","LOCALS")
  !InParty(LastSeenBy(Myself))
  !Class(LastSeenBy(Myself),INNOCENT)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
  RESPONSE #100
    EquipRanged()
    Attack(LastSeenBy(Myself))
END

IF
  See([GOODBUTRED.MONSTER.DEMONIC.TANARI.0.SUMMONED_DEMON])
  AttackedBy(LastSeenBy(Myself),DEFAULT)
THEN
  RESPONSE #100
    ChangeEnemyAlly(LastSeenBy(Myself),ENEMY)
END

