IF
	Global("D0Ormand","GLOBAL",4)
	!Allegiance(Myself,ENEMY)
THEN
	RESPONSE #100
		Enemy()
END

IF
	Global("D0Ormand","GLOBAL",5)
THEN
	RESPONSE #100
		EscapeArea()
END

IF
	OnCreation()
THEN
	RESPONSE #100
		FaceObject(Player1)
		Continue()
END

IF
	Global("SpawnItems","LOCALS",0)
THEN
	RESPONSE #100
		SetGlobal("SpawnItems","LOCALS",1)
		CreateItem("potn52",1,0,0)
		Continue()
	RESPONSE #150
		SetGlobal("SpawnItems","LOCALS",1)
		CreateItem("potn52",2,0,0)
		Continue()
END

IF
	!Allegiance(Myself,ENEMY)
THEN
	RESPONSE #100
		NoAction()
END

IF
	Allegiance(Myself,ENEMY)
	!See(NearestEnemyOf(Myself))
	!LOS([GOODCUTOFF],30)
	!Detect([GOODCUTOFF])
	!StateCheck(Player1,STATE_INVISIBLE)
THEN
	RESPONSE #100
		MoveToObject(Player1)
END

IF
	Allegiance(Myself,ENEMY)
	!See(NearestEnemyOf(Myself))
	!LOS([GOODCUTOFF],30)
	!Detect([GOODCUTOFF])
	!StateCheck(Player2,STATE_INVISIBLE)
THEN
	RESPONSE #100
		MoveToObject(Player2)
END

IF
	Allegiance(Myself,ENEMY)
	!See(NearestEnemyOf(Myself))
	!LOS([GOODCUTOFF],30)
	!Detect([GOODCUTOFF])
	!StateCheck(Player3,STATE_INVISIBLE)
THEN
	RESPONSE #100
		MoveToObject(Player3)
END

IF
	Allegiance(Myself,ENEMY)
	!See(NearestEnemyOf(Myself))
	!LOS([GOODCUTOFF],30)
	!Detect([GOODCUTOFF])
	!StateCheck(Player4,STATE_INVISIBLE)
THEN
	RESPONSE #100
		MoveToObject(Player4)
END

IF
	Allegiance(Myself,ENEMY)
	!See(NearestEnemyOf(Myself))
	!LOS([GOODCUTOFF],30)
	!Detect([GOODCUTOFF])
	!StateCheck(Player5,STATE_INVISIBLE)
THEN
	RESPONSE #100
		MoveToObject(Player5)
END

IF
	Allegiance(Myself,ENEMY)
	!See(NearestEnemyOf(Myself))
	!LOS([GOODCUTOFF],30)
	!Detect([GOODCUTOFF])
	!StateCheck(Player6,STATE_INVISIBLE)
THEN
	RESPONSE #100
		MoveToObject(Player6)
END

IF
	HitBy([ANYONE],POISON)
	!StateCheck(Myself,STATE_POISONED)
	Class(LastHitter(Myself),MAGE_ALL)
	!See(NearestEnemyOf(Myself))
THEN
	RESPONSE #100
		RandomWalkContinuous()
END

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

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	HPPercentLT(Myself,15)
	HaveSpell(CLERIC_SANCTUARY)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(Myself,CLERIC_SANCTUARY)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	HPPercentLT(Myself,50)
	HasItem("potn52",Myself)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		UseItem("potn52",Myself)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	HPPercentLT(Myself,35)
	HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(Myself,CLERIC_CURE_MEDIUM_WOUNDS)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	HPPercentLT(NearestMyGroupOfType,35)
	HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(NearestMyGroupOfType,CLERIC_CURE_MEDIUM_WOUNDS)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	HPPercentLT(Myself,25)
	HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(Myself,CLERIC_CURE_LIGHT_WOUNDS)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	HPPercentLT(NearestMyGroupOfType,25)
	HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(NearestMyGroupOfType,CLERIC_CURE_LIGHT_WOUNDS)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	See(NearestEnemyOf(Myself))
	HaveSpell(CLERIC_CALL_LIGHTNING)
	RandomNum(6,1)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(NearestEnemyOf(Myself),CLERIC_CALL_LIGHTNING)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	See(SecondNearestEnemyOf(Myself))
	HaveSpell(CLERIC_CALL_LIGHTNING)
	RandomNum(6,2)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(SecondNearestEnemyOf(Myself),CLERIC_CALL_LIGHTNING)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	See(ThirdNearestEnemyOf(Myself))
	HaveSpell(CLERIC_CALL_LIGHTNING)
	RandomNum(6,3)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(ThirdNearestEnemyOf(Myself),CLERIC_CALL_LIGHTNING)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	See(FourthNearestEnemyOf(Myself))
	HaveSpell(CLERIC_CALL_LIGHTNING)
	RandomNum(6,4)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(FourthNearestEnemyOf(Myself),CLERIC_CALL_LIGHTNING)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	See(FifthNearestEnemyOf(Myself))
	HaveSpell(CLERIC_CALL_LIGHTNING)
	RandomNum(6,5)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(FifthNearestEnemyOf(Myself),CLERIC_CALL_LIGHTNING)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	See(SecondNearestEnemyOf(Myself))
	See([PC])
	HaveSpell(CLERIC_ENTANGLE)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell([PC],CLERIC_ENTANGLE)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	See([PC])
	HaveSpell(CLERIC_HOLD_PERSON)
	RandomNumGT(4,2)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell([PC],CLERIC_HOLD_PERSON)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	See(NearestEnemyOf(Myself))
	HaveSpell(CLERIC_ARMOR_OF_FAITH)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(Myself,CLERIC_ARMOR_OF_FAITH)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	See(NearestMyGroupOfType)
	HaveSpell(CLERIC_REMOVE_FEAR)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(NearestMyGroupOfType,CLERIC_REMOVE_FEAR)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	!AttackedBy([ANYONE],DEFAULT)
	See(NearestMyGroupOfType)
	HaveSpell(CLERIC_BARKSKIN)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(NearestMyGroupOfType,CLERIC_BARKSKIN)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	!AttackedBy([ANYONE],DEFAULT)
	See(NearestMyGroupOfType)
	HaveSpell(CLERIC_CHANT)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(NearestMyGroupOfType,CLERIC_CHANT)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	!AttackedBy([ANYONE],DEFAULT)
	See(NearestMyGroupOfType)
	HaveSpell(CLERIC_FLAME_BLADE)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(NearestMyGroupOfType,CLERIC_FLAME_BLADE)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	See([GOODCUTOFF.ANIMAL])
	HaveSpell(RANGER_CHARM_ANIMAL)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		Spell(LastSeenBy(Myself),RANGER_CHARM_ANIMAL)
END

IF
	OR(4)
		!See(LastSeenBy(Myself))
		!GlobalTimerNotExpired("D0_ATTACK","LOCALS")
		StateCheck(Myself,STATE_CHARMED)
		InMyGroup(LastSeenBy(Myself))
	Detect(Myself)
	False()
THEN
	RESPONSE #100
		Continue()
END

IF
	OR(4)
		!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
END


IF
	!Range(LastSeenBy(Myself),7)
	Range(NearestEnemyOf(Myself),7)
	See(NearestEnemyOf(Myself))
THEN
	RESPONSE #100
		SetGlobalTimer("D0_ATTACK","LOCALS",5)
		EquipMostDamagingMelee()
		Attack(NearestEnemyOf(Myself))
END

IF
	See(LastSeenBy(Myself))
	!Range(LastSeenBy(Myself),0)
THEN
	RESPONSE #100
		SetGlobalTimer("D0_ATTACK","LOCALS",5)
		EquipMostDamagingMelee()
		Attack(LastSeenBy(Myself))
END
