Hello,
I have a potion that I am working on which uses a script. And that script is not working. I am hoping someone knows what I am doing wrong.
The potion is intended to give a timed effect, with the end result similar to the Perk: Avoid Death. The idea being you can drink the potion, and for the next X period of time if a hit brings you to less than 10% of your health, it will heal you.
Overall, I have this working just fine.
What I cannot get to work is that once the it heals you, I want the overall potions effect to be dispelled.
The potion has a magic effect as normal. The magic effect runs the script. The script then does an OnHit event to cast the healing spell - and hopefully to ultimately dispel its own magic effect.
The script's code is:
Scriptname GBobMagicItemPotionAvoidDeath extends ActiveMagicEffect ; based upon Avoid Death perk and script in Vanilla SkyrimSpell Property HealSpell Auto float Property PercentHealth = 100.0 Auto MagicEffect Property EffectToDispel Auto; ready to heal youEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked ); ; debug.trace(self + " Enter Bleedout"); ; cast heal spell PercentHealth = GetTargetActor().GetAVPercentage("Health") If (PercentHealth < 0.1) HealSpell.Cast(GetTargetActor()) if (GetTargetActor().hasMagicEffect(EffectToDispel)=1) GetTargetActor().EffectToDispel.Dispel() endif EndIfendEvent
The lines:
if (GetTargetActor().hasMagicEffect(EffectToDispel)=1)
GetTargetActor().EffectToDispel.Dispel()
endif
... are the overall problem that I cannot get to work as it does not compile. I believe I am using the whole MagicEffect and dispel incorrectly, but cannot find a good reference or example on how to do it.
Essentially, it is this ActiveMagicEffect that I want to remove (dispel, etc) immediately after the healing spell is cast.
Does anyone have any advice?
Thanks in advance!