Scriptname VampireTelekinesis2Script extends activemagiceffect

Sound Property MAGAlterationTelekinesisThrowSD Auto
Spell Property VampireRankTelekinesis2 Auto

GlobalVariable Property RECASTVampireUnholyGrasp Auto
GlobalVariable Property VampireAbilityTimers Auto
GlobalVariable Property VampireUnholyGraspToggle Auto
PlayerVampireQuestScript Property PlayerVampireQuest  Auto
GlobalVariable Property EnableVampireBloodPoints Auto

EVENT OnEffectStart(Actor akTKTarget, Actor akTKCaster)

	If VampireUnholyGraspToggle.GetValue() == 0
	
		VampireUnholyGraspToggle.SetValue(1)
			
		If EnableVampireBloodPoints.GetValue() == 10000 && RECASTVampireUnholyGrasp.GetValue() == 0
			PlayerVampireQuest.VampireBloodPoints(30)
		EndIf		
	
	Else
	
		Game.GetPlayer().DispelSpell(VampireRankTelekinesis2)
		VampireUnholyGraspToggle.SetValue(0)		
		
	EndIf

		
EndEvent

Event OnEffectFinish(Actor akTKTarget, Actor akTKCaster)
	
		Int instanceID2 = MAGAlterationTelekinesisThrowSD.Play(Game.GetPlayer())
		Sound.SetInstanceVolume(instanceID2, 0.7)
		
		If RECASTVampireUnholyGrasp.GetValue() <= 1
			RECASTVampireUnholyGrasp.SetValue(1)
		EndIf

		If RECASTVampireUnholyGrasp.GetValue() == 1		
			If VampireAbilityTimers.GetValue() == 0
				Debug.Notification("You need to wait before attempting Unholy Grasp again")				
				Utility.WaitGameTime(3.0)
				Utility.Wait(0.1)
				If Game.GetPlayer().HasSpell(VampireRankTelekinesis2)				
					Debug.Notification("Unholy Grasp is available for use")
				EndIf	
			EndIf	
			RECASTVampireUnholyGrasp.SetValue(0)
		
		EndIf
		
		VampireUnholyGraspToggle.SetValue(0)
	
EndEvent
