Scriptname DraugrFXScript extends  ActiveMagicEffect
{Attaches and manages fx}



import utility
import form

;===============================================

Actor selfRef
ActorBase myActorBase
VisualEffect Property DraugrMaleEyeGlowFX Auto
VisualEffect Property DraugrFemaleEyeGlowFX Auto

EVENT OnEffectStart(Actor Target, Actor Caster)	
	selfRef = caster
	
	;Added by USKP to prevent this effect from appearing on the player.
	If selfRef == Game.GetPlayer()
		selfRef = None
	EndIf
	If selfRef == None
		Dispel()
		return
	EndIf
	
	;USKP 2.0.3 - Don't bother with any of this if the dumb zombie isn't loaded!
	If selfRef.Is3DLoaded()
		myActorBase = selfRef.GetLeveledActorBase()		
		
		Int mySex = myActorBase.GetSex()
		If (selfRef.GetSleepState() == 3)
			; Debug.Trace("Draugr is sleeping! 3")
		Elseif mySex == 0 ; If sex is male (only one currently working) play glow eye art
			DraugrMaleEyeGlowFX.Play(selfRef, -1)
		ElseIf mySex == 1 ; If sex is female (currently not returned) play debug text to say this is now working
			DraugrFemaleEyeGlowFX.Play(selfRef, -1)
		EndIf
	EndIf
ENDEVENT

Event OnGetUp(ObjectReference akFurniture)
	; Debug.Trace("Draugr just got up from " )
	;Added by USKP to prevent this effect from appearing on the player.
	if selfRef == None
		Return
	EndIf
	
	; USKP 2.0.1 - Sanity check because the actorbase property isn't always valid when this runs.
	If myActorBase
		Int mySex = myActorBase.GetSex()
		If mySex == 0
			DraugrMaleEyeGlowFX.Play(selfRef, -1)
		ElseIf mySex == 1
			DraugrFemaleEyeGlowFX.Play(selfRef, -1)
		EndIf
	EndIf
EndEvent

Event OnDying(Actor myKiller)
	utility.Wait(3.0)
	StopEyes()
EndEvent

EVENT onDeath(actor myKiller)
	StopEyes()
ENDEVENT

Function StopEyes()
	if selfRef
		DraugrMaleEyeGlowFX.Stop(selfRef)
		DraugrFemaleEyeGlowFX.Stop(selfRef)
	EndIf
EndFunction