IF
	!InParty(Myself)
	See(Player1)
	Global("TsolakResurrected","GLOBAL",1)
THEN
	RESPONSE #100
 
		StartDialogueNoSet(Player1)
		SetGlobal("TsolakResurrected","GLOBAL",2)
END


IF
  !InParty(Myself)
	//HPLT(Myself,10)
	Die()
THEN
	RESPONSE #100
		DropInventory()
		Kill(Myself)
			DestroySelf()
		CreateCreature("GASFORM4",[-1.-1],S)
		ActionOverride("GASFORM4",EscapeArea())
		// SetGlobalTimer("VampireResurrectTimer","LOCALS",FOUR_HOURS)
		//ReallyForceSpellDead(Myself,VAMPIRE_BAT_FORM_CHANGE)
END

IF
!InParty(Myself)
	!HasItemEquiped("ohhcloak",Myself) // Cloak of Dragomir
	!HasItemEquiped("ohhkork",Myself) // Korkorran
	TimeGT(5)
	TimeLT(DUSK_END)
	AreaType(OUTDOOR)
THEN
	RESPONSE #100
		//DropInventory()
		Kill(Myself)
			DestroySelf()
		CreateCreature("GASFORM4",[-1.-1],S)
		ActionOverride("GASFORM4",EscapeArea())
END

IF
	!GlobalTimerNotExpired("bd_cast","locals")
	Detect(Myself)
	OR(2)
		DifficultyGT(EASY)
		Allegiance(Myself,GOODCUTOFF)
	!GlobalTimerNotExpired("VAMPIRE_DOMINATION","locals")
	OR(4)
		!See(NearestEnemyOfType([0.0.0.FIGHTER_ALL]))
		StateCheck(NearestEnemyOfType([0.0.0.FIGHTER_ALL]),STATE_DISABLED)
		CheckSpellState(NearestEnemyOfType([0.0.0.FIGHTER_ALL]),STATE_ENRAGED)
		Race(NearestEnemyOfType([0.0.0.FIGHTER_ALL]),ELF)
	OR(4)
		!See(SecondNearestEnemyOfType([0.0.0.FIGHTER_ALL]))
		StateCheck(SecondNearestEnemyOfType([0.0.0.FIGHTER_ALL]),STATE_DISABLED)
		CheckSpellState(SecondNearestEnemyOfType([0.0.0.FIGHTER_ALL]),STATE_ENRAGED)
		Race(SecondNearestEnemyOfType([0.0.0.FIGHTER_ALL]),ELF)
	OR(4)
		!See(ThirdNearestEnemyOfType([0.0.0.FIGHTER_ALL]))
		StateCheck(ThirdNearestEnemyOfType([0.0.0.FIGHTER_ALL]),STATE_DISABLED)
		CheckSpellState(ThirdNearestEnemyOfType([0.0.0.FIGHTER_ALL]),STATE_ENRAGED)
		Race(ThirdNearestEnemyOfType([0.0.0.FIGHTER_ALL]),ELF)
	OR(4)
		!See(NearestEnemyOfType([0.0.0.RANGER_ALL]))
		StateCheck(NearestEnemyOfType([0.0.0.RANGER_ALL]),STATE_DISABLED)
		CheckSpellState(NearestEnemyOfType([0.0.0.RANGER_ALL]),STATE_ENRAGED)
		Race(NearestEnemyOfType([0.0.0.RANGER_ALL]),ELF)
	OR(4)
		!See(SecondNearestEnemyOfType([0.0.0.RANGER_ALL]))
		StateCheck(SecondNearestEnemyOfType([0.0.0.RANGER_ALL]),STATE_DISABLED)
		CheckSpellState(SecondNearestEnemyOfType([0.0.0.RANGER_ALL]),STATE_ENRAGED)
		Race(SecondNearestEnemyOfType([0.0.0.RANGER_ALL]),ELF)
	OR(4)
		!See(ThirdNearestEnemyOfType([0.0.0.RANGER_ALL]))
		StateCheck(ThirdNearestEnemyOfType([0.0.0.RANGER_ALL]),STATE_DISABLED)
		CheckSpellState(ThirdNearestEnemyOfType([0.0.0.RANGER_ALL]),STATE_ENRAGED)
		Race(ThirdNearestEnemyOfType([0.0.0.RANGER_ALL]),ELF)
	False()
THEN
	RESPONSE #100
		NoAction()
END

IF
	!GlobalTimerNotExpired("bd_cast","locals")
	OR(2)
		DifficultyGT(EASY)
		Allegiance(Myself,GOODCUTOFF)
	!GlobalTimerNotExpired("VAMPIRE_DOMINATION","locals")
	See(LastSeenBy)
	!Range(LastSeenBy,0)
	!StateCheck(LastSeenBy,STATE_REALLY_DEAD)
	!StateCheck(LastSeenBy,STATE_DISABLED)
	!CheckSpellState(LastSeenBy,STATE_ENRAGED)
	!Race(LastSeenBy,ELF)
THEN
	RESPONSE #100
		SetGlobalTimer("VAMPIRE_DOMINATION","locals",TWO_ROUNDS)
		SetGlobalTimer("bd_cast","locals",ONE_ROUND)
		SpellNoDec(LastSeenBy,VAMPIRE_DOMINATION)
	RESPONSE #35
		Continue()
END

IF
	!GlobalTimerNotExpired("bd_cast","locals")
	Detect(Myself)
	!GlobalTimerNotExpired("VAMPIRE_DOMINATION","locals")
	OR(5)
		!See(NearestEnemyOf(Myself))
		RandomNumGT(4,2)
		StateCheck(NearestEnemyOf(Myself),STATE_DISABLED)
		CheckSpellState(NearestEnemyOf(Myself),STATE_ENRAGED)
		Race(NearestEnemyOf(Myself),ELF)
	OR(5)
		!See(SecondNearestEnemyOf(Myself))
		RandomNumGT(4,3)
		StateCheck(SecondNearestEnemyOf(Myself),STATE_DISABLED)
		CheckSpellState(SecondNearestEnemyOf(Myself),STATE_ENRAGED)
		Race(SecondNearestEnemyOf(Myself),ELF)
	OR(4)
		!See(ThirdNearestEnemyOf(Myself))
		StateCheck(ThirdNearestEnemyOf(Myself),STATE_DISABLED)
		CheckSpellState(ThirdNearestEnemyOf(Myself),STATE_ENRAGED)
		Race(ThirdNearestEnemyOf(Myself),ELF)
	OR(4)
		!See(FourthNearestEnemyOf(Myself))
		StateCheck(FourthNearestEnemyOf(Myself),STATE_DISABLED)
		CheckSpellState(FourthNearestEnemyOf(Myself),STATE_ENRAGED)
		Race(FourthNearestEnemyOf(Myself),ELF)
	OR(4)
		!See(FifthNearestEnemyOf(Myself))
		StateCheck(FifthNearestEnemyOf(Myself),STATE_DISABLED)
		CheckSpellState(FifthNearestEnemyOf(Myself),STATE_ENRAGED)
		Race(FifthNearestEnemyOf(Myself),ELF)
	OR(4)
		!See(NearestEnemyOf(Myself))
		StateCheck(NearestEnemyOf(Myself),STATE_DISABLED)
		CheckSpellState(NearestEnemyOf(Myself),STATE_ENRAGED)
		Race(NearestEnemyOf(Myself),ELF)
	OR(4)
		!See(SecondNearestEnemyOf(Myself))
		StateCheck(SecondNearestEnemyOf(Myself),STATE_DISABLED)
		CheckSpellState(SecondNearestEnemyOf(Myself),STATE_ENRAGED)
		Race(SecondNearestEnemyOf(Myself),ELF)
	False()
THEN
	RESPONSE #100
		NoAction()
END

IF
	!GlobalTimerNotExpired("bd_cast","locals")
	!GlobalTimerNotExpired("VAMPIRE_DOMINATION","locals")
	See(LastSeenBy)
	!Range(LastSeenBy,0)
	!StateCheck(LastSeenBy,STATE_REALLY_DEAD)
	!StateCheck(LastSeenBy,STATE_DISABLED)
	!CheckSpellState(LastSeenBy,STATE_ENRAGED)
	!Race(LastSeenBy,ELF)
THEN
	RESPONSE #100
		SetGlobalTimer("VAMPIRE_DOMINATION","locals",TWO_ROUNDS)
		SetGlobalTimer("bd_cast","locals",ONE_ROUND)
		SpellNoDec(LastSeenBy,VAMPIRE_DOMINATION)
	RESPONSE #35
		Continue()
END

IF
	Detect(Myself)
	OR(2)
		!See(NearestEnemyOf(Myself))
		!WeaponEffectiveVs(NearestEnemyOf(Myself),MAINHAND)
	OR(2)
		!See(SecondNearestEnemyOf(Myself))
		!WeaponEffectiveVs(SecondNearestEnemyOf(Myself),MAINHAND)
	OR(2)
		!See(ThirdNearestEnemyOf(Myself))
		!WeaponEffectiveVs(ThirdNearestEnemyOf(Myself),MAINHAND)
	OR(2)
		!See(FourthNearestEnemyOf(Myself))
		!WeaponEffectiveVs(FourthNearestEnemyOf(Myself),MAINHAND)
	OR(2)
		!See(FifthNearestEnemyOf(Myself))
		!WeaponEffectiveVs(FifthNearestEnemyOf(Myself),MAINHAND)
	OR(2)
		!See(SixthNearestEnemyOf(Myself))
		!WeaponEffectiveVs(SixthNearestEnemyOf(Myself),MAINHAND)
	OR(2)
		!See(SeventhNearestEnemyOf(Myself))
		!WeaponEffectiveVs(SeventhNearestEnemyOf(Myself),MAINHAND)
	OR(2)
		!See(EighthNearestEnemyOf(Myself))
		!WeaponEffectiveVs(EighthNearestEnemyOf(Myself),MAINHAND)
	OR(2)
		!See(NinthNearestEnemyOf(Myself))
		!WeaponEffectiveVs(NinthNearestEnemyOf(Myself),MAINHAND)
	OR(2)
		!See(TenthNearestEnemyOf(Myself))
		!WeaponEffectiveVs(TenthNearestEnemyOf(Myself),MAINHAND)
	False()
THEN
	RESPONSE #100
		NoAction()
END

IF
	See(LastSeenBy)
	!Range(LastSeenBy,0)
	!StateCheck(LastSeenBy,STATE_REALLY_DEAD)
	WeaponEffectiveVs(LastSeenBy,MAINHAND)
THEN
	RESPONSE #100
		EquipMostDamagingMelee()
		AttackReevaluate(LastSeenBy,30)
END

