ScriptName VampireRaiseThrallTimerScript extends ActiveMagicEffect

GlobalVariable Property RECASTVampireRaiseThrall Auto
GlobalVariable Property VampireAbilityTimers Auto
Spell Property VampireRaiseThrall01 Auto
Spell Property VampireRaiseThrall02 Auto
Spell Property VampireRaiseThrall03 Auto
Spell Property VampireRaiseThrall04 Auto
Spell Property VampireRaiseThrall05 Auto
PlayerVampireQuestScript Property PlayerVampireQuest  Auto
GlobalVariable Property EnableVampireBloodPoints Auto
GlobalVariable Property  VampireRaiseThrallToggle Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)

	If VampireRaiseThrallToggle.GetValue() == 0	
	
		If VampireAbilityTimers.GetValue() == 0	
			VampireRaiseThrallToggle.SetValue(1)
		EndIf	
	
		If EnableVampireBloodPoints.GetValue() == 10000 && RECASTVampireRaiseThrall.GetValue() == 0
			PlayerVampireQuest.VampireBloodPoints(20)
		EndIf		
	
	Else
		
		Utility.Wait(4.0)
	
		Game.GetPlayer().DispelSpell(VampireRaiseThrall01)
		Game.GetPlayer().DispelSpell(VampireRaiseThrall02)
		Game.GetPlayer().DispelSpell(VampireRaiseThrall03)
		Game.GetPlayer().DispelSpell(VampireRaiseThrall04)
		Game.GetPlayer().DispelSpell(VampireRaiseThrall05)
		
		VampireRaiseThrallToggle.SetValue(0)		
		
	EndIf	
	
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)

	If RECASTVampireRaiseThrall.GetValue() <= 1
		RECASTVampireRaiseThrall.SetValue(1)
	EndIf

	If RECASTVampireRaiseThrall.GetValue() == 1
	
		RECASTVampireRaiseThrall.SetValue(2)	
		If VampireAbilityTimers.GetValue() == 0	
			Debug.Notification("You need to wait before attempting to raise the dead again")	
			Utility.WaitGameTime(5)
			Utility.Wait(0.1)
			If Game.GetPlayer().HasSpell(VampireRaiseThrall01) || Game.GetPlayer().HasSpell(VampireRaiseThrall02) || Game.GetPlayer().HasSpell(VampireRaiseThrall03) || Game.GetPlayer().HasSpell(VampireRaiseThrall04) || Game.GetPlayer().HasSpell(VampireRaiseThrall05)
				Debug.Notification("Vampire's Servant is available for use")
			EndIf	
		EndIf	
		RECASTVampireRaiseThrall.SetValue(0)
		
	EndIf		
		
	VampireRaiseThrallToggle.SetValue(0)	
		
EndEvent
