IF
  OR(5)
    AttackedBy([GOODCUTOFF],DEFAULT)
    HitBy([GOODCUTOFF],CRUSHING)
    Die()
    Heard([ANYONE],151)
    Global("D0MaeVarHostile","GLOBAL",1)
  !Allegiance(Myself,ENEMY)
THEN
  RESPONSE #100
    Shout(151)
    Enemy()
    Continue()
END

IF
  Allegiance(Myself,ENEMY)
  See([GOODCUTOFF])
  ActionListEmpty()
THEN
  RESPONSE #100
    Shout(151)
    Continue()
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  !StateCheck(Myself,STATE_INVISIBLE)
  !StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
  !ModalState(STEALTH)
  !GlobalTimerNotExpired("Hide","LOCALS")
  HasItem("potn10",Myself)
THEN
  RESPONSE #100
    SetGlobalTimer("Cast","LOCALS",6)
    DisplayStringHead(Myself,46150) // quaffs a potion
    UseItem("potn10",Myself)
END

IF
  !See(NearestEnemyOf(Myself))
  !GlobalTimerNotExpired("Hide","LOCALS")
  RandomNum(5,1)
THEN
  RESPONSE #100
    SetGlobalTimer("Hide","LOCALS",12)
    Hide()
    RandomWalk()
END

IF
  !See(NearestEnemyOf(Myself))
  !GlobalTimerNotExpired("Hide","LOCALS")
  RandomNum(5,2)
THEN
  RESPONSE #100
    SetGlobalTimer("Hide","LOCALS",12)
    Hide()
    MoveToPoint([1057.368])
END

IF
  !See(NearestEnemyOf(Myself))
  !GlobalTimerNotExpired("Hide","LOCALS")
  RandomNum(5,3)
THEN
  RESPONSE #100
    SetGlobalTimer("Hide","LOCALS",12)
    Hide()
    MoveToPoint([856.234])
END

IF
  !See(NearestEnemyOf(Myself))
  !GlobalTimerNotExpired("Hide","LOCALS")
  RandomNum(5,4)
THEN
  RESPONSE #100
    SetGlobalTimer("Hide","LOCALS",12)
    Hide()
    MoveToPoint([727.283])
END

IF
  !See(NearestEnemyOf(Myself))
  !GlobalTimerNotExpired("Hide","LOCALS")
  RandomNum(5,5)
THEN
  RESPONSE #100
    SetGlobalTimer("Hide","LOCALS",12)
    Hide()
    MoveToPoint([1006.456])
END

IF
  !See(NearestEnemyOf(Myself))
  !Range("Maevar",25)
THEN
  RESPONSE #100
    MoveToObject("Maevar")
END

IF
  !See(NearestEnemyOf(Myself))
THEN
  RESPONSE #100
    RandomWalk()
END

IF
//  OR(4)
  OR(3)
    !See(LastSeenBy(Myself))
    !GlobalTimerNotExpired("D0_ATTACK","LOCALS")
    StateCheck(Myself,STATE_CHARMED)
//    InMyGroup(LastSeenBy(Myself))
  See(NearestEnemyOf(Myself))
  OR(2)
    StateCheck(NearestEnemyOf(Myself),STATE_HELPLESS)
    RandomNumGT(10,3)
  See(SecondNearestEnemyOf(Myself))
  OR(2)
    StateCheck(SecondNearestEnemyOf(Myself),STATE_HELPLESS)
    RandomNumGT(10,4)
  See(ThirdNearestEnemyOf(Myself))
  OR(2)
    StateCheck(ThirdNearestEnemyOf(Myself),STATE_HELPLESS)
    RandomNumGT(10,5)
  See(FourthNearestEnemyOf(Myself))
  OR(2)
    StateCheck(FourthNearestEnemyOf(Myself),STATE_HELPLESS)
    RandomNumGT(10,3)
  See(FifthNearestEnemyOf(Myself))
  OR(2)
    StateCheck(FifthNearestEnemyOf(Myself),STATE_HELPLESS)
    RandomNumGT(10,3)
  See(SixthNearestEnemyOf(Myself))
  OR(2)
    StateCheck(SixthNearestEnemyOf(Myself),STATE_HELPLESS)
    RandomNumGT(10,3)
  See(TenthNearestEnemyOf(Myself))
  OR(2)
    StateCheck(TenthNearestEnemyOf(Myself),STATE_HELPLESS)
    RandomNumGT(10,3)
  !See(NearestEnemyOfType([GOODCUTOFF.0.0.SORCERER]))
  !See(NearestEnemyOfType([GOODCUTOFF.0.0.MAGE_ALL]))
  !See(NearestEnemyOfType([GOODCUTOFF.0.0.CLERIC_ALL]))
  !See(NearestEnemyOfType([GOODCUTOFF.0.0.BARD_ALL]))
  !See(NearestEnemyOfType([GOODCUTOFF.0.0.DRUID_ALL]))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(3)
    GlobalTimerNotExpired("Hide","LOCALS")
    StateCheck(Myself,STATE_INVISIBLE)
    StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
  See(LastSeenBy(Myself))
THEN
  RESPONSE #100
    SetGlobalTimer("D0_ATTACK","LOCALS",6)
    EquipMostDamagingMelee()
    Attack(NearestEnemyOf(Myself))
  RESPONSE #100
    Continue()
END

IF
  Allegiance(Myself,ENEMY)
  Allegiance(LastSeenBy(Myself),GOODCUTOFF)
  OR(2)
    !Range(LastSeenBy(Myself),7)
    Range(LastSeenBy(Myself),7)
  OR(2)
    Range(NearestEnemyOf(Myself),7)
    Range(LastSeenBy(Myself),7)
THEN
  RESPONSE #100
    SetGlobalTimer("D0_ATTACK","LOCALS",6)
    EquipMostDamagingMelee()
    Attack(NearestEnemyOf(Myself))
  RESPONSE #100
    Continue()
END

IF
  Allegiance(Myself,ENEMY)
  Allegiance(LastSeenBy(Myself),GOODCUTOFF)
  Global("D0_MOVE","LOCALS",0)
  GlobalTimerExpired("D0_ATTACK","LOCALS")
THEN
  RESPONSE #100
    SetGlobal("D0_MOVE","LOCALS",1)
    RandomWalkContinuous()
END

IF
  Allegiance(Myself,ENEMY)
  Allegiance(LastSeenBy(Myself),GOODCUTOFF)
  !Range(NearestEnemyOf(Myself),7)
THEN
  RESPONSE #100
    SetGlobalTimer("D0_ATTACK","LOCALS",6)
    SetGlobal("D0_MOVE","LOCALS",0)
    EquipRanged()
    Attack(LastSeenBy(Myself))
END

IF
  Allegiance(Myself,ENEMY)
  Allegiance(LastSeenBy(Myself),GOODCUTOFF)
  Range(LastSeenBy(Myself),7)
THEN
  RESPONSE #100
    SetGlobalTimer("D0_ATTACK","LOCALS",6)
    EquipMostDamagingMelee()
    Attack(LastSeenBy(Myself))
END

IF
  Allegiance(Myself,ENEMY)
  Allegiance(LastSeenBy(Myself),GOODCUTOFF)
  !Range(LastSeenBy(Myself),7)
THEN
  RESPONSE #100
    SetGlobalTimer("D0_ATTACK","LOCALS",6)
    EquipMostDamagingMelee()
    Attack(NearestEnemyOf(Myself))
END
