IF
  Global("CloseCombat","LOCALS",1)
  GlobalTimerExpired("attacked","LOCALS")
THEN
  RESPONSE #100
    SetGlobal("CloseCombat","LOCALS",0)
    SetGlobalTimer("SafeForAWhile","LOCALS",6)
END

IF
  Global("CloseCombat","LOCALS",0)
  Global("safe","LOCALS",0)
  GlobalTimerExpired("SafeForAWhile","LOCALS")
THEN
  RESPONSE #100
    SetGlobal("safe","LOCALS",1)
END

IF
  Global("CloseCombat","LOCALS",0)
  OR(2)
    HitBy([ANYONE],CRUSHING)
    AttackedBy([ANYONE],DEFAULT)
  Range(NearestEnemyOf(Myself),8)
THEN
  RESPONSE #100
    SetGlobal("CloseCombat","LOCALS",1)
    SetGlobal("safe","LOCALS",0)
    SetGlobalTimer("attacked","LOCALS",5)
END

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

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

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

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

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

IF
  Allegiance(Myself,EVILCUTOFF)
  !See(Player1)
  !See(Player2)
  !See(Player3)
  !See(Player4)
  !See(Player5)
  !See(Player6)
  GlobalTimerExpired("attacked","LOCALS")
THEN
  RESPONSE #16
    MoveToObject(Player1)
  RESPONSE #16
    MoveToObject(Player2)
  RESPONSE #17
    MoveToObject(Player3)
  RESPONSE #17
    MoveToObject(Player4)
  RESPONSE #17
    MoveToObject(Player5)
  RESPONSE #17
    MoveToObject(Player6)
END

IF
  Allegiance(Myself,GOODCUTOFF)
  !See(NearestEnemyOf(Myself))
  !CombatCounter(0)
THEN
  RESPONSE #100
    MoveToObject(Player1)
END

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

IF
  Allegiance(Myself,EVILCUTOFF)
  !Allegiance(LastSeenBy(Myself),GOODCUTOFF)
  !InParty(LastSeenBy(Myself))
  See(NearestEnemyOf(Myself))
THEN
  RESPONSE #100
    AttackOneRound(NearestEnemyOf(Myself))
END

IF
  Allegiance(Myself,GOODCUTOFF)
  !Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  See(NearestEnemyOf(Myself))
THEN
  RESPONSE #100
    AttackOneRound(NearestEnemyOf(Myself))
END

IF
  HasItem("POTN55",Myself)  // ~Potion of Superior Healing~
  !GlobalTimerNotExpired("Spell","LOCALS")
  HPPercentLT(Myself,50)
THEN
  RESPONSE #100
    SetGlobalTimer("Spell","LOCALS",6)
    UseItem("POTN55",Myself)  // ~Potion of Superior Healing~
END

IF
  CheckStatLT(Myself,40,RESISTCRUSHING)
  OR(2)
    HPPercentLT(Myself,100)
    Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("Hardiness","LOCALS")
  !GlobalTimerNotExpired("Spell","LOCALS")
  HaveSpellRES("SPCL907")
THEN
  RESPONSE #100
    SetGlobalTimer("Hardiness","LOCALS",60)
    SetGlobalTimer("Spell","LOCALS",6)
    SpellRES("SPCL907",Myself)  // ~Hardiness~
END

IF
  Range(NearestEnemyOf(Myself),8)
  !GlobalTimerNotExpired("Spell","LOCALS")
  HaveSpellRES("SPCL900")
  !DifficultyLT(EASY)
THEN
  RESPONSE #100
    SetGlobalTimer("Spell","LOCALS",6)
    SpellRES("SPCL900",Myself)  // ~Whirlwind Attack~
END

IF
  Allegiance(Myself,EVILCUTOFF)
  See(NearestEnemyOf(Myself))
  See(LastSeenBy([EVILCUTOFF]))
  RandomNumGT(5,2)
  See(WorstAC(Myself))
  RandomNumGT(7,3)
  See([GOODCUTOFF.0.HUMAN])
  False()
THEN
  RESPONSE #100
END

IF
  Allegiance(Myself,GOODCUTOFF)
  See(NearestEnemyOf(Myself))
  See(LastSeenBy([GOODCUTOFF]))
  RandomNumGT(5,2)
  See(WorstAC(Myself))
  RandomNumGT(7,3)
  See([EVILCUTOFF.0.DEMONIC])
  False()
THEN
  RESPONSE #100
END

IF
  Allegiance(Myself,EVILCUTOFF)
  RandomNumGT(4,1)
  See([GOODCUTOFF.HUMANOID])
  CheckStatLT(LastSeenBy(Myself),-4,ARMORCLASS)
  HPGT(LastSeenBy(Myself),41)
  !Class(LastSeenBy(Myself),SORCERER)
  See(SecondNearestEnemyOfType([0.HUMANOID]))
  CheckStatLT(LastSeenBy(Myself),-4,ARMORCLASS)
  HPGT(LastSeenBy(Myself),41)
  !Class(LastSeenBy(Myself),SORCERER)
  See(ThirdNearestEnemyOfType([0.HUMANOID]))
  CheckStatLT(LastSeenBy(Myself),-4,ARMORCLASS)
  HPGT(LastSeenBy(Myself),41)
  !Class(LastSeenBy(Myself),SORCERER)
  See(FourthNearestEnemyOfType([0.HUMANOID]))
  CheckStatLT(LastSeenBy(Myself),-4,ARMORCLASS)
  HPGT(LastSeenBy(Myself),41)
  !Class(LastSeenBy(Myself),SORCERER)
  See(FifthNearestEnemyOfType([0.HUMANOID]))
  CheckStatLT(LastSeenBy(Myself),-4,ARMORCLASS)
  HPGT(LastSeenBy(Myself),41)
  !Class(LastSeenBy(Myself),SORCERER)
  See(NearestEnemyOfType([0.HUMANOID]))
  CheckStatLT(LastSeenBy(Myself),-8,ARMORCLASS)
  HPGT(LastSeenBy(Myself),61)
  !Class(LastSeenBy(Myself),LONG_BOW)
  See(SecondNearestEnemyOfType([0.HUMANOID]))
  CheckStatLT(LastSeenBy(Myself),-8,ARMORCLASS)
  HPGT(LastSeenBy(Myself),61)
  !Class(LastSeenBy(Myself),LONG_BOW)
  See(ThirdNearestEnemyOfType([0.HUMANOID]))
  CheckStatLT(LastSeenBy(Myself),-8,ARMORCLASS)
  HPGT(LastSeenBy(Myself),61)
  !Class(LastSeenBy(Myself),LONG_BOW)
  See(FourthNearestEnemyOfType([0.HUMANOID]))
  CheckStatLT(LastSeenBy(Myself),-8,ARMORCLASS)
  HPGT(LastSeenBy(Myself),61)
  !Class(LastSeenBy(Myself),LONG_BOW)
  See(FifthNearestEnemyOfType([0.HUMANOID]))
  CheckStatLT(LastSeenBy(Myself),-8,ARMORCLASS)
  HPGT(LastSeenBy(Myself),61)
  !Class(LastSeenBy(Myself),LONG_BOW)
  See(NearestEnemyOfType([0.HUMANOID]))
  !Class(LastSeenBy(Myself),CLERIC_ALL)
  !Class(LastSeenBy(Myself),DRUID_ALL)
  !Class(LastSeenBy(Myself),BARD_ALL)
  CheckStatLT(LastSeenBy(Myself),-11,ARMORCLASS)
  See(SecondNearestEnemyOfType([0.HUMANOID]))
  !Class(LastSeenBy(Myself),CLERIC_ALL)
  !Class(LastSeenBy(Myself),DRUID_ALL)
  !Class(LastSeenBy(Myself),BARD_ALL)
  CheckStatLT(LastSeenBy(Myself),-11,ARMORCLASS)
  See(ThirdNearestEnemyOfType([0.HUMANOID]))
  !Class(LastSeenBy(Myself),CLERIC_ALL)
  !Class(LastSeenBy(Myself),DRUID_ALL)
  !Class(LastSeenBy(Myself),BARD_ALL)
  CheckStatLT(LastSeenBy(Myself),-11,ARMORCLASS)
  See(FourthNearestEnemyOfType([0.HUMANOID]))
  !Class(LastSeenBy(Myself),CLERIC_ALL)
  !Class(LastSeenBy(Myself),DRUID_ALL)
  !Class(LastSeenBy(Myself),BARD_ALL)
  CheckStatLT(LastSeenBy(Myself),-11,ARMORCLASS)
  See(FifthNearestEnemyOfType([0.HUMANOID]))
  !Class(LastSeenBy(Myself),CLERIC_ALL)
  !Class(LastSeenBy(Myself),DRUID_ALL)
  !Class(LastSeenBy(Myself),BARD_ALL)
  CheckStatLT(LastSeenBy(Myself),-11,ARMORCLASS)
  See([GOODCUTOFF.HUMANOID])
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
END

IF
  Allegiance(Myself,EVILCUTOFF)
  RandomNumGT(4,1)
  See(NearestEnemyOf(Myself))
  CheckStatLT(LastSeenBy(Myself),-4,ARMORCLASS)
  HPGT(LastSeenBy(Myself),41)
  !Class(LastSeenBy(Myself),SORCERER)
  See(ThirdNearestEnemyOf(Myself))
  CheckStatLT(LastSeenBy(Myself),-4,ARMORCLASS)
  HPGT(LastSeenBy(Myself),41)
  !Class(LastSeenBy(Myself),SORCERER)
  See(FifthNearestEnemyOf(Myself))
  CheckStatLT(LastSeenBy(Myself),-4,ARMORCLASS)
  HPGT(LastSeenBy(Myself),41)
  !Class(LastSeenBy(Myself),SORCERER)
  See(NearestEnemyOf(Myself))
  CheckStatLT(LastSeenBy(Myself),-8,ARMORCLASS)
  HPGT(LastSeenBy(Myself),61)
  !Class(LastSeenBy(Myself),LONG_BOW)
  See(ThirdNearestEnemyOf(Myself))
  CheckStatLT(LastSeenBy(Myself),-8,ARMORCLASS)
  HPGT(LastSeenBy(Myself),61)
  !Class(LastSeenBy(Myself),LONG_BOW)
  See(FifthNearestEnemyOf(Myself))
  CheckStatLT(LastSeenBy(Myself),-8,ARMORCLASS)
  HPGT(LastSeenBy(Myself),61)
  !Class(LastSeenBy(Myself),LONG_BOW)
  See(NearestEnemyOf(Myself))
  !Class(LastSeenBy(Myself),CLERIC_ALL)
  !Class(LastSeenBy(Myself),DRUID_ALL)
  !Class(LastSeenBy(Myself),BARD_ALL)
  CheckStatLT(LastSeenBy(Myself),-11,ARMORCLASS)
  See(ThirdNearestEnemyOf(Myself))
  !Class(LastSeenBy(Myself),CLERIC_ALL)
  !Class(LastSeenBy(Myself),DRUID_ALL)
  !Class(LastSeenBy(Myself),BARD_ALL)
  CheckStatLT(LastSeenBy(Myself),-11,ARMORCLASS)
  See(FifthNearestEnemyOf(Myself))
  !Class(LastSeenBy(Myself),CLERIC_ALL)
  !Class(LastSeenBy(Myself),DRUID_ALL)
  !Class(LastSeenBy(Myself),BARD_ALL)
  CheckStatLT(LastSeenBy(Myself),-11,ARMORCLASS)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
END

IF
  HasItemEquiped("MAGE01",LastSeenBy(Myself))
  !HasItemEquiped("STALKER",LastSeenBy(Myself))
THEN
  RESPONSE #100
    MoveToObject(Player1)
END

IF
  Allegiance(Myself,EVILCUTOFF)
  OR(2)
    Allegiance(LastSeenBy(Myself),GOODCUTOFF)
    InParty(LastSeenBy(Myself))
  !Range(NearestEnemyOf(Myself),7)
  !HasItemEquiped("shld24",LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),0,122)
  CheckStatLT(LastSeenBy(Myself),100,RESISTMISSILE)
THEN
  RESPONSE #80
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #20
     EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
END

IF
  Allegiance(Myself,GOODCUTOFF)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  !Range(NearestEnemyOf(Myself),7)
  !HasItemEquiped("shld24",LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),0,122)
  CheckStatLT(LastSeenBy(Myself),100,RESISTMISSILE)
THEN
  RESPONSE #80
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #20
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
END

IF
  Allegiance(Myself,EVILCUTOFF)
  OR(2)
    Allegiance(LastSeenBy(Myself),GOODCUTOFF)
    InParty(LastSeenBy(Myself))
  OR(2)
    Range(NearestEnemyOf(Myself),7)
    Global("CloseCombat","LOCALS",1)
  Range(LastSeenBy(Myself),13)
  CheckStatLT(LastSeenBy(Myself),100,RESISTSLASHING)
THEN
  RESPONSE #100
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
END

IF
  Allegiance(Myself,GOODCUTOFF)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  OR(2)
    Range(NearestEnemyOf(Myself),7)
    Global("CloseCombat","LOCALS",1)
  Range(LastSeenBy(Myself),13)
  CheckStatLT(LastSeenBy(Myself),100,RESISTSLASHING)
THEN
  RESPONSE #100
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
END

IF
  Allegiance(Myself,EVILCUTOFF)
  OR(2)
    Allegiance(LastSeenBy(Myself),GOODCUTOFF)
    InParty(LastSeenBy(Myself))
  OR(2)
    Range(NearestEnemyOf(Myself),7)
    Global("CloseCombat","LOCALS",1)
  !Range(LastSeenBy(Myself),13)
  !StateCheck(Myself,STATE_SLOWED)
  CheckStatLT(LastSeenBy(Myself),100,RESISTSLASHING)
THEN
  RESPONSE #40
    EquipMostDamagingMelee()
    AttackOneRound(NearestEnemyOf(Myself))
  RESPONSE #60
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
END

IF
  Allegiance(Myself,GOODCUTOFF)
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
  OR(2)
    Range(NearestEnemyOf(Myself),7)
    Global("CloseCombat","LOCALS",1)
  !Range(LastSeenBy(Myself),13)
  !StateCheck(Myself,STATE_SLOWED)
  CheckStatLT(LastSeenBy(Myself),100,RESISTSLASHING)
THEN
  RESPONSE #40
     EquipMostDamagingMelee()
    AttackOneRound(NearestEnemyOf(Myself))
  RESPONSE #60
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
END

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

