Here's the whole larger script:
Scriptname BBVamps_VampireResurrectionScript extends activemagiceffect float Property ToleranceTime autofloat Property FireWaitTime autofloat Property RegularWaitTime autoKeyword Property WeapMaterialSilver autoKeyword Property DLC1DawnguardItem autoKeyword Property DaedricArtifact autoKeyword Property WeapTypeSword autoKeyword Property MagicDamageFire autoSpell Property DLC1SunFire autoSpell Property DLC1SunFireLeft autoSpell Property DLC1SunCloakDamage autoSpell Property DLC1VampiresBane autoSpell Property BaneoftheUndead autoSpell Property DA09DawnbreakerBaneofUndead autoSpell Property DisintegrationSpell autoSpell Property ResurrectionSpell autoProjectile Property SilverBoltProjectile autoVisualEffect Property RecoveryEffect autoActor Vampirebool NoResurrectionfloat WaitTimeEvent OnEffectStart(Actor akTarget, Actor akCaster)Vampire = akTargetNoResurrection = falseendEventEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)if akSource.HasKeyword(WeapMaterialSilver) == True ;prevents resurrection when hit with Silver weaponsUnRegisterForUpdate()NoResurrection = true;Debug.Trace("NoResurrection set to true") RegisterForUpdate(ToleranceTime)elseif akSource.HasKeyword(DLC1DawnguardItem) == True ;prevents resurrection when hit with DawnguardWeaponsUnRegisterForUpdate()NoResurrection = true;Debug.Trace("NoResurrection set to true") RegisterForUpdate(ToleranceTime)elseif (akSource.HasKeyword(DaedricArtifact) == True) && (akSource.HasKeyword(WeapTypeSword) == True) ;prevents resurrection when hit with DawnbreakerUnRegisterForUpdate()NoResurrection = true Debug.Trace("NoResurrection set to true")RegisterForUpdate(ToleranceTime)elseif (akSource == DLC1SunFire) || (akSource == DLC1SunFireLeft) ;for Sun Fire SpellUnRegisterForUpdate()NoResurrection = true ;Debug.Trace("NoResurrection set to true")RegisterForUpdate(ToleranceTime)elseif akSource == DLC1SunCloakDamage ;for Stendarrs Aura SpellUnRegisterForUpdate()NoResurrection = true ;Debug.Trace("NoResurrection set to true")RegisterForUpdate(ToleranceTime)elseif akSource == DLC1VampiresBane ;for Vampires Bane SpellUnRegisterForUpdate()NoResurrection = true ;Debug.Trace("NoResurrection set to true")RegisterForUpdate(ToleranceTime);elseif (akSource == BaneoftheUndead) || (akSource == DA09DawnbreakerBaneofUndead) ;for Bane of Undead Spells;not necessary since these spells already have a disintegrate script;UnRegisterForUpdate();NoResurrection = true ;Debug.Trace("NoResurrection set to true");RegisterForUpdate(ToleranceTime)elseif akProjectile == SilverBoltProjectileUnRegisterForUpdate()NoResurrection = true ;Debug.Trace("NoResurrection set to true")RegisterForUpdate(ToleranceTime)else;do nothingendifendEventEvent OnUpdate()NoResurrection = false;Debug.Trace("NoResurrection set to false")endEventEvent OnDying(Actor akKiller)if NoResurrection == trueDisintegrationSpell.Cast(Vampire, Vampire)elseif Vampire.HasMagicEffectWithKeyword(MagicDamageFire)WaitTime = FireWaitTimeRecoveryEffect.Play(Vampire)Utility.Wait(WaitTime)RecoveryEffect.Stop(Vampire)ResurrectionSpell.Cast(Vampire, Vampire)elseWaitTime = RegularWaitTimeRecoveryEffect.Play(Vampire)Utility.Wait(WaitTime)RecoveryEffect.Stop(Vampire)ResurrectionSpell.Cast(Vampire, Vampire)endifendifendEvent
Here's what it does when I have it attached to a MagicEffect that is part of an Ability, that is attached to a Vampire:
When the Vampire is hit by a Silver weapon, Dawnguard weapon, Dawnbreaker, damaging Restoration Spell, etc, it runs an UnregisterForUpdate() line, which is not really important yet since there is no RegisterForUpdate() or RegisterForSingleUpdate() to cancel yet. It also sets the NoResurrection bool to true, and Registers for an Update in 5 seconds (ToleranceTime). If another similar event occurs before that Update, then the UnregisterForUpdate() line cancels the previous RegisterForSingleUpdate(), keeps the NoResurrection true, and Registers for another single update in 5 seconds. If another hit from those sources doesn't occur within the 5 seconds, then the OnUpdate event reverts the NoResurrection bool to false. On dying, if the bool is true, then the Vampire disintegrates; if it is false, then the Vampire will resurrect after WaitTime. Everything works, except for the part with the SilverBolt projectile; it just won't set the bool to true, so the Vampire ends up resurrecting instead of disintegrating. If the script seems correct to you, then I'll try looking for any mistakes I made, but I've spent hours trying to find something wrong and I just can't.