Quick, Easy MagicEffect Script Question

Post » Tue Feb 18, 2014 8:21 pm

I want to create a new custom magic effect, using a Script archetype. I want to be able to add this effect to any arbitrary spell's Effect list, with a magnitude/duration. This same magnitude should affect the way the Papyrus script behaves.

Say, for example, I want to make a spell that increases the target's speed multiplier by X for Y seconds. My script would go something like:

Spoiler
ScriptName myEffect extends ActiveMagicEffectEvent OnEffectStart(Actor akTarget, Actor akCaster)           akTarget.ModAV("SpeedMult", X)EndEvent

Now, I'm guessing that the ModAV call will make my effect go away when the duration is over, and I could use OnEffectFinish to clean up anything I start if I don't have a handy ModAV function, but I'm not sure. I also have no idea how to pass X into my script.

User avatar
Elena Alina
 
Posts: 3415
Joined: Sun Apr 01, 2007 7:24 am

Post » Wed Feb 19, 2014 3:15 am

You actually don't need a script to do that. You can pick the archetype "Peak Value Modifier" and then choose "Speed Mult" associate item. But if you prefer a script go ahead.

OnEffectFinish is a bit useless because the effects usually "end" before that event is called. If that makes sense. So don't worry about it. Check "Recovery" and that should handle the restoration of the character's speed when the effect ends.

X can be any number you want but I don't know what the maximum for speed is. I've gone as high as 200.0

User avatar
Katie Louise Ingram
 
Posts: 3437
Joined: Sat Nov 18, 2006 2:10 am

Post » Tue Feb 18, 2014 2:30 pm

Sorry I wasn't clear with my example. I want to modify a variable I declare in my script itself, not an already existing actor value that would show up in the archetype list. A better example would have been:

Spoiler
ScriptName myEffect extends ActiveMagicEffectInt Property myInt autoEvent OnEffectStart(Actor akTarget, Actor akCaster)       myInt=X      doSomethingCool(akTarget, myInt)EndEvent

I really do need a script, I was just inadvertently misleading with how I explained my use case.

User avatar
Brooke Turner
 
Posts: 3319
Joined: Wed Nov 01, 2006 11:13 am

Post » Tue Feb 18, 2014 8:38 pm

You might be able to pass your variable in by setting the magnitude of your effect in the spell and then using SKSE's GetMagnitude() function inside the OnEffectStart() event to grab whatever magnitude was passed in. I've never tried it on a Script-Archetype spell but I assume it should still work.

Script type effects will not be "cleaned up" automatically when the effect finishes, because the game wont have any clue what the purpose of your variable is or what you've done to it. That only works for pre-defined effect archetypes.

User avatar
Rachael
 
Posts: 3412
Joined: Sat Feb 17, 2007 2:10 pm

Post » Tue Feb 18, 2014 11:51 am

There's a GetMagnitude() function under magic effects with SKSE?

*hunts some more*

I'll be darned. None of the documentation I was looking at listed that one.

Whelp, I knew it was an easy question. Thanks.

User avatar
SamanthaLove
 
Posts: 3565
Joined: Mon Dec 11, 2006 3:54 am


Return to V - Skyrim