Jump to content

Papyrus - How do I lower values with a magic effect?


GomuGomu64

Recommended Posts

After my Hunger script has failed in two attempts, I was pointed in the direction of making a magiceffect that would decrease a given value over a period of time. Thing is, I need this magiceffect to be active whenever the game is started. I figured out how to attach a script to a quest (Which would allow it to be started at run-time), but I don't know how I would attach a magiceffect script to it, as the magiceffect script needs to be like so :

 

scriptName Hunger extends MagicEffect

 

But to place it in a quest...

 

scriptName Hunger extends Quest

 

So, if I made a script in a run-time quest that does

RegisterForUpdateGameTime(1)

 

How would I attach a script that does

 

Event onMagicEffect()

 

Thanks in advance.

Link to comment
Share on other sites

Not sure that's the best way to go about it. Magic effects need to be applied to something in order to function. So you would first create your magic effect, set it to manipulate a given actor value over a period of time (all done in CK), then you need to create an Ability spell and attach that effect to it.

Then you add that spell to the player via Game.getPlayer().addSpell(MySpell, abVerbose = false) [set abVerbose to false if you don't want UI notifications that the spell has been added]

 

In my opinion, as far as ticking scripts go, it is much better to use GlobalVariables and just straightforward manipulate them via scripts using one of the update events (I personally use onUpdateGameTime() event so that it stays synced with any mods that may change the timescale)

GlobalVariables are nice because you can manipulate them from multiple scripts - for example when you need to update your hunger levels when the player eats some food.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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