Jump to content

[LE] Dispel Magic Effect When Magicka Drops Below X


gitsas

Recommended Posts

Hi everyone, I'm new to scripting and for the love of God I just cant figure out how to solve this one. I'd really appreciate your help!

 

I've created a togglable Heal (Lesser Power, Voice). It Heals the Caster for 10p per Second while draining 10p Magicka per second. I want the spell to Dispel when Magicka drops below a certain number or when the user runs out of Magicka.

 

 

 

So far the spell works perfectly, It's toggleable, it Heals, and it Drains Magicka as planned. I've used this script:

 

Scriptname toggleability extends activemagiceffect  

Spell Property AbilityToBeToggled Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)

If akTarget.HasSpell(AbilityToBeToggled)
akTarget.DispelSpell(AbilityToBeToggled)
akTarget.RemoveSpell(AbilityToBeToggled)

Else

akTarget.AddSpell(AbilityToBeToggled, False)
EndIf

EndEvent

The problem is this: When Magicka depletes, the spell is still active. It keeps draining Magicka instead of ending.

 

 

I've tried adding an additional script:

Scriptname AAAOutOfMagicka extends activemagiceffect 

Event OnEffectStart(Actor akTarget, Actor akCaster)
akTarget.GetActorValue("Magicka")


If akTarget.GetActorValue("Magicka") < 10
akTarget.DispelAllSpells()


EndIf
EndEvent

The Script compiles, but it doesn't work, the spell is still active.

 

I was thinking maybe a While Loop would be the answer but I don't know how to go about it.

 

I'd appreciate your help!

Edited by gitsas
Link to comment
Share on other sites

You can put the condition directly on your ability spell in the creation kit. Put GetActorValue Magicka >= 10. Then in your script you can use OnEffectFinish to dispel your spell. I wouldn't use DispellAllSpells as that dispels all active spells on the target.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...