ScriptName CreateNPCVampire extends ActiveMagicEffect

Actor Property Player Auto Hidden
PlayerVampireQuestScript Property PlayerVampireQuest  Auto
GlobalVariable Property EnableVampireBloodPoints Auto
GlobalVariable Property CreateVampire Auto
GlobalVariable Property VampireTurnNPCAnimation Auto
Idle Property IdleHandCut Auto
Sound Property UIHealthHeartbeatALP Auto
MagicEffect Property TurnOnCreateVampire Auto
Spell Property BleedingSpell Auto

EVENT OnEffectStart(Actor akTarget, Actor akCaster)

	If VampireTurnNPCAnimation.GetValue() == 0
		Game.DisablePlayerControls(false, true, false, false, false, false)
		Utility.Wait(2.0)
		
		Game.GetPlayer().PlayIdle(IdleHandCut)
		Utility.Wait(4.0)
		BleedingSpell.Cast(Game.GetPlayer(),Game.GetPlayer())
	EndIf	
	
	Int instanceID = UIHealthHeartbeatALP.play(Game.GetPlayer())    
	Sound.SetInstanceVolume(instanceID, 2.5)		
	;Utility.Wait(7.0)  
	;Sound.StopInstance(instanceID) 	
	
	Player = akCaster
	CreateVampire.SetValue(10000)

	If EnableVampireBloodPoints.GetValue() == 10000
		PlayerVampireQuest.VampireBloodPoints(20)
	EndIf

	If VampireTurnNPCAnimation.GetValue() == 0	
		Utility.Wait(2.0)	
		Game.EnablePlayerControls()
		Utility.Wait(1.0)
		Game.SetPlayerAIDriven(False)
	EndIf
	
	While Game.GetPlayer().HasMagicEffect(TurnOnCreateVampire)
	EndWhile
	Sound.StopInstance(instanceID) 	
	
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	
	CreateVampire.SetValue(0)
			
EndEvent
