Jump to content

Help with Remaining Magicka Value Script


xcube2402

Recommended Posts

Hello,

 

I'm not sure, but there may already be a similar question about this. Sorry if I'm posting up a question that has already been answered.

 

I'm creating a toggle buff script, along with damage magicka (instead of using up magicka to use spell, you lose it over time) and stunted magicka (to prevent player from regenerating magicka while the buff is up), but the problem I'm having is that I can't get the condition in the script to detect the player's remaining magicka as 0 in order to deactivate the spell other than reusing the same spell. What command am I supposed to use in order to get this done?

Edited by xcube2402
Link to comment
Share on other sites

My guess is that the script will not detect it because magicka isn't as 0 for long enough for the script to notice.

 

First thing you can do is change the "==" to "<=".

The evaluation should now pass if magicka goes to 0 or less (which I'm not sure is possible anyway, but it's a first step).

 

Also, make sure that the evaluation is in the ScriptEffectUpdate block of the spell. This block will run every frame for the entire duration of the spell, whereas the other blocks will only run once.

 

 

Thats all I can think of just now. If that doesn't work then post your script - maybe there is a little logic error hiding in all the code.

Link to comment
Share on other sites

* I could change "==" to "<=" since there has been some occurrence of having a negative value for health, magicka, and fatigue.

 

* I used "ScriptEffectUpdate" like you said, but it still doesn't read the player's remaining magicka. Could I have done something wrong in the script?

 

* I think the problem is the "GetActorValue" command, but I can't find any other command that would match what I'm looking for.

 

Scriptname Togglebreathscript

 

Begin ScriptEffectStart

 

If ( IsSpellTarget Togglebreath == 0 )

addSpell Togglebreath

else

removeSpell Togglebreath

endif

End

 

Begin ScriptEffectUpdate

 

if (GetActorValue Magicka <= 0 )

removespell Togglebreath

endif

End

 

* Thanks for your help WarRatsG

Edited by xcube2402
Link to comment
Share on other sites

You will need to change "Togglebreath" to another spell, since that is the editor ID of a spell I created while working on the script. The ScriptEffectUpdate section doesn't do anything when I tested the script out, since I don't know what I can do in order to detect the player's remaining magicka. Edited by xcube2402
Link to comment
Share on other sites

* I could change "==" to "<=" since there has been some occurrence of having a negative value for health, magicka, and fatigue.

Begin ScriptEffectUpdate

 

if (GetActorValue Magicka == 0 )

removespell Togglebreath

endif

End

 

Make sure you change it to

GetActorValue Magicka <= 0

 

And trust me, there is nothing wrong with the GetActorValue command.

 

Doesn't addspell, and IsSpellTarget require a reference to act upon?

 

If no reference is given, a function will act on the calling object. For an object, this is the object being scripted; for a magic effect, this is the NPC that has been hit by the spell. Quests always require references.

Link to comment
Share on other sites

Sorry, forgot to change the symbol to "<=" in the post. The part of deactivating the spell effect when the player's magicka is not working when all of the player's magicka is gone, since it reads the player's maximum magicka instead. If I can get drain magicka effect to accumulate over time like damage magicka, then the script should work perfectly, but I'm not sure what can be done to get that accomplished.

 

- Sorry about doubting GetActorValue, since it does work, but only with the player's maximum magicka.

Edited by xcube2402
Link to comment
Share on other sites

Sorry, forgot to change the symbol to "<=" in the post. The part of deactivating the spell effect when the player's magicka is not working when all of the player's magicka is gone, since it reads the player's maximum magicka instead. If I can get drain magicka effect to accumulate over time like damage magicka, then the script should work perfectly, but I'm not sure what can be done to get that accomplished.

 

Drain magicka will not accumulate, unless you manually alter it's magnitude with script (requires OBSE)

Unless you add several Drain Magicka spells to the target over time, which I personally would not recommend. You would be better off using Damage Magicka.

 

- Sorry about doubting GetActorValue, since it does work, but only with the player's maximum magicka.

 

Not quite - your thinking of GetBaseActorValue. Here is a quote from the CS Wiki on GetActorValue:

 

"Returns the current, modified value of the specified stat."

 

 

Hope this helps :)

Edited by WarRatsG
Link to comment
Share on other sites

  • Recently Browsing   0 members

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