IF
	See([ANYONE])
	!Allegiance(Myself,ENEMY)
THEN
	RESPONSE #100
		Enemy()
END

IF
	Detect(Myself)
	False()
THEN
	RESPONSE #100
		Continue()
END

IF
	See([ANYONE])
	See(NearestEnemyOf(Myself))
	RandomNumGT(10,6)
	See(SecondNearestEnemyOf(Myself))
	RandomNumGT(11,7)
	See(ThirdNearestEnemyOf(Myself))
	RandomNumGT(12,8)
	See(FourthNearestEnemyOf(Myself))
	RandomNumGT(13,9)
	See(FifthNearestEnemyOf(Myself))
	RandomNumGT(14,10)
	See(SixthNearestEnemyOf(Myself))
	False()
THEN
	RESPONSE #100
		Continue()
END

IF
	OR(2)
		See([0.0.DEMONIC.0.0.0.LAWFUL_EVIL])
		See([0.0.IMP.0.0.0.LAWFUL_EVIL])
	False()
THEN
	RESPONSE #100
		Continue()
END

IF
	!AreaCheck("ar3003")
	!AreaCheck("ar3004")
	!AreaCheck("ar3005")
	!AreaCheck("ar3006")
	!AreaCheck("ar3007")
	!AreaCheck("ar3008")
	!AreaCheck("ar3009")
	!AreaCheck("ar3010")
	!AreaCheck("ar3011")
	!AreaCheck("ar3012")
	!AreaCheck("ar3013")
	!AreaCheck("ar3014")
	!AreaCheck("ar3015")
	!GlobalTimerNotExpired("Cast","LOCALS")
	!GlobalTimerNotExpired("Gate","LOCALS")
	See(LastSeenBy(Myself))
	!Range(LastSeenBy(Myself),0)
	OR(2)
		GlobalLT("GateN","LOCALS",4)
		!GlobalTimerNotExpired("Gate2","LOCALS")
THEN
	RESPONSE #100
		SetGlobalTimer("Gate","LOCALS",360)
		SetGlobalTimer("Gate2","LOCALS",ONE_DAY)
		SetGlobalTimer("Cast","LOCALS",2)
		IncrementGlobal("GateN","LOCALS",1)
		CreateCreatureObjectEffect("TANARI01","SPUNHOLY",Myself)
		CreateCreatureObjectEffect("TANARI01","SPUNHOLY",Myself)
	RESPONSE #100
		SetGlobalTimer("Gate","LOCALS",360)
		SetGlobalTimer("Gate2","LOCALS",ONE_DAY)
		SetGlobalTimer("Cast","LOCALS",2)
		IncrementGlobal("GateN","LOCALS",1)
		CreateCreatureObjectEffect("DEMNAB01","SPUNHOLY",Myself)
		CreateCreatureObjectEffect("TANARI01","SPUNHOLY",Myself)
	RESPONSE #100
		SetGlobalTimer("Gate","LOCALS",360)
		SetGlobalTimer("Gate2","LOCALS",ONE_DAY)
		SetGlobalTimer("Cast","LOCALS",2)
		IncrementGlobal("GateN","LOCALS",1)
		CreateCreatureObjectEffect("DEMNAB01","SPUNHOLY",Myself)
		CreateCreatureObjectEffect("DEMNAB01","SPUNHOLY",Myself)
	RESPONSE #100
		SetGlobalTimer("Gate","LOCALS",360)
		SetGlobalTimer("Gate2","LOCALS",ONE_DAY)
		SetGlobalTimer("Cast","LOCALS",2)
		IncrementGlobal("GateN","LOCALS",1)
		CreateCreatureObjectEffect("DEMBAL02","SPUNHOLY",Myself)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	See(LastSeenBy(Myself))
	!Range(LastSeenBy(Myself),0)
	RandomNum(2,1)
	Global("A1","LOCALS",0)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		SetGlobal("A1","LOCALS",1)
		ForceSpell(LastSeenBy(Myself),WIZARD_CHAIN_LIGHTNING)
	RESPONSE #150
		SetGlobalTimer("Cast","LOCALS",6)
		SetGlobal("A1","LOCALS",1)
		ForceSpell(LastSeenBy(Myself),CLERIC_FIRE_STORM)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	See(LastSeenBy(Myself))
	!Range(LastSeenBy(Myself),0)
	RandomNumGT(4,2)
	GlobalLT("A2","LOCALS",3)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		IncrementGlobal("A2","LOCALS",1)
		ForceSpell(LastSeenBy(Myself),WIZARD_POWER_WORD_STUN)
END

IF
	!GlobalTimerNotExpired("Cast","LOCALS")
	See(LastSeenBy(Myself))
	!Range(LastSeenBy(Myself),0)
	GlobalLT("A3","LOCALS",3)
THEN
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		IncrementGlobal("A3","LOCALS",1)
		ForceSpell(LastSeenBy(Myself),WIZARD_FIREBALL)
	RESPONSE #100
		SetGlobalTimer("Cast","LOCALS",6)
		IncrementGlobal("A3","LOCALS",1)
		ForceSpell(LastSeenBy(Myself),WIZARD_LIGHTNING_BOLT)
END

IF
	See(LastSeenBy(Myself))
	!Range(LastSeenBy(Myself),0)
THEN
	RESPONSE #100
		AttackOneRound(LastSeenBy(Myself))
END
