IF
  OR(3)
    !Exists("d0qpwima")
    Dead("d0qpwima")
    !InMyArea("d0qpwima")
  !Allegiance(Myself,ENEMY)
  !StateCheck(Myself,STATE_REALLY_DEAD)
  Global("GTFO","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("GTFO","LOCALS",1)
    ReallyForceSpell(Myself,DRYAD_TELEPORT)
END

IF
  Exists("d0qpwima")
  !Detect("d0qpwima")
  !Dead("d0qpwima")
  OR(2)
    !Allegiance(Myself,ENEMY)
    !See(NearestEnemyOf(Myself))
THEN
  RESPONSE #100
    MoveToObject("d0qpwima")
END

IF
  OR(3)
    AttackedBy([GOODCUTOFF],DEFAULT)
    HitBy([GOODCUTOFF],CRUSHING)
    Global("D0AttackedCowls","AR0500",1)
  !Allegiance(Myself,ENEMY)
THEN
  RESPONSE #100
    SetGlobal("D0AttackedCowls","AR0500",1)
    Enemy()
END

IF
  StateCheck(Myself,STATE_SILENCED)
THEN
  RESPONSE #100
    ForceSpell(Myself,WIZARD_VOCALIZE)
END

IF
  Allegiance(Myself,ENEMY)
  Global("cowledwizard","LOCALS",0)
THEN
  RESPONSE #100
    ReallyForceSpell(Myself,WIZARD_SPELL_DEFLECTION)
    Wait(1)
    DisplayString(Myself,31247) // Tattoo of Power - Spell Immunity
    ReallyForceSpell(Myself,WIZARD_SPELL_IMMUNITY_INVOCATION)
    SetGlobal("cowledwizard","LOCALS",1)
END

IF
  Allegiance(Myself,ENEMY)
  Global("cowledwizard","LOCALS",1)
  CheckStatLT(Myself,1,STONESKINS)
THEN
  RESPONSE #100
    DisplayString(Myself,29736) // Contingency - Stoneskin
    ReallyForceSpell(Myself,WIZARD_STONE_SKIN)
    SetGlobal("cowledwizard","LOCALS",2)
END

IF
  OR(2)
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
    See("d0qpwima")
  HaveSpell(WIZARD_PIERCE_MAGIC)
  OR(2)
    HasBounceEffects(LastSeenBy(Myself))
    HasImmunityEffects(LastSeenBy(Myself))
THEN
  RESPONSE #100
    Spell(LastSeenBy(Myself),WIZARD_PIERCE_MAGIC)
END

IF
  OR(2)
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
    See("d0qpwima")
  !StateCheck(LastSeenBy(Myself),STATE_SILENCED)
  HaveSpell(WIZARD_POWER_WORD_SILENCE)
  RandomNum(2,1)
THEN
  RESPONSE #100
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_SILENCE)
END

IF
  OR(2)
    See(SecondNearestEnemyOf(Myself))
    See("d0qpwima")
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  HaveSpell(WIZARD_POWER_WORD_STUN)
  RandomNumGT(4,2)
THEN
  RESPONSE #100
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_STUN)
END

IF
  Allegiance(Myself,ENEMY)
  HaveSpell(WIZARD_STONE_SKIN)
  CheckStatLT(Myself,1,STONESKINS)
THEN
  RESPONSE #100
    Spell(Myself,WIZARD_STONE_SKIN)
END

IF
  OR(2)
    See("d0qpwima")
    See(ThirdNearestEnemyOf(Myself))
  HaveSpell(WIZARD_DISPEL_MAGIC)
  !Range(LastSeenBy(Myself),10)
THEN
  RESPONSE #100
    Spell(LastSeenBy(Myself),WIZARD_DISPEL_MAGIC)
END

IF
  Allegiance(Myself,ENEMY)
  See([GOODCUTOFF.0.0.0.0.SUMMONED])
  HaveSpell(WIZARD_DEATH_SPELL)
THEN
  RESPONSE #100
    DisplayString(Myself,31024) // Magic Tattoo - Mirror Image
    Spell(LastSeenBy(Myself),WIZARD_DEATH_SPELL)
END

IF
  OR(2)
    See(NearestEnemyOf(Myself))
    See("d0qpwima")
  HaveSpell(WIZARD_MAGIC_MISSILE)
THEN
  RESPONSE #100
    Spell(NearestEnemyOf(Myself),WIZARD_MAGIC_MISSILE)
END

IF
  OR(2)
    See(NearestEnemyOf(Myself))
    See("d0qpwima")
  HaveSpell(WIZARD_AGANNAZAR_SCORCHER)
THEN
  RESPONSE #100
    Spell(NearestEnemyOf(Myself),WIZARD_AGANNAZAR_SCORCHER)
END

IF
  See(NearestEnemyOf(Myself))
  HaveSpell(WIZARD_PHANTOM_BLADE)
  HaveSpell(WIZARD_MIRROR_IMAGE)
THEN
  RESPONSE #100
    Spell(Myself,WIZARD_MIRROR_IMAGE)
    Spell(Myself,WIZARD_PHANTOM_BLADE)
    AttackReevaluate(NearestEnemyOf(Myself),30)
END

IF
  See(NearestEnemyOf(Myself))
THEN
  RESPONSE #100
    EquipMostDamagingMelee()
    AttackReevaluate(NearestEnemyOf(Myself),30)
END
