Is there a test for enchantments?

Post » Thu Jun 21, 2012 1:50 pm

This is one of those things that should be simple but doesn't seem to be. Is there a simple way to test for a particular enchantment being applied to a target in a script?

For example, if the player is under the effects of Blessing Of Talos, how can I find out via scripting? You'd think there'd be a ObjectRef.HasEnchantment(EnchantmentProperty), but there isn't.
User avatar
Setal Vara
 
Posts: 3390
Joined: Thu Nov 16, 2006 1:24 pm

Post » Thu Jun 21, 2012 11:56 pm

That's because you're using the wrong terminology. Enchantments are magic effects which are cast by armor and weapons. Spells are groupings of magic effects triggered by a player action and animation.

You want either Actor.HasMagicEffect(akEffect), or Actor.HasMagicEffectWithKeyword(akKeyword).
User avatar
Spencey!
 
Posts: 3221
Joined: Thu Aug 17, 2006 12:18 am

Post » Thu Jun 21, 2012 10:36 pm

If you look at the Blessings applied by the various altars, you'll see that they are Enchantment effects. There are spells associated with them, but neither HasMagicEffect nor HasSpell picks them up and they have no keywords. I could add a keyword to them, but that would break compatibility with mods that modify the Blessings, which I'd rather avoid.
User avatar
Danielle Brown
 
Posts: 3380
Joined: Wed Sep 27, 2006 6:03 am

Post » Thu Jun 21, 2012 11:45 am

Shrine of Kynareth
Blessing of Kynareth: Increases your stamina by 25 points.
Fortify Stamina, 25 pts for 8 hours
Cure Disease

EnchReligiousKynareth
Fortify Stamina, 10 pts for 0 secs.

I am moderately certain the enchantments you are looking at are actually for the divine fetish necklaces. (There are other definitions of the word fetish, and I'm a Religious Anthropology Major. So nyeah on you, dirty minds!)

I did a little more digging; the keyword associated with all of these altars is MagicBlessing. Using that, I pulled up the ten spell effects that use it:

FortifySneakFFSelf - Nocturnal
FortifySpeechcraftFFSelf - Dibella
FortifyShoutTimerFFSelf - Talos
FortifyBlockFFSelf - Stendarr
FortifyRestorationFFSelf - Mara
FortifyStaminaFFSelf - Kynareth
FortifyMagickaFFSelf - Julianos
FortifyHealthFFSelf - Arkay
FortifyStaminaRateFFSelf - Unused
FortifyPersuasionFFSelf - Zenithar
FortifyMagickaRateFFSelf - Akatosh

Those altars are the only things that use these effects. There are many similar effects, but these ones are theirs.

Therefore,

if Actor.HasMagicEffect(akEffect).

:biggrin:
User avatar
Dan Wright
 
Posts: 3308
Joined: Mon Jul 16, 2007 8:40 am

Post » Thu Jun 21, 2012 11:01 pm

Huh! I could have sworn those spells used no keywords. I assumed the MagicEffects were generic and not specific to the blessings, looks like I was dead wrong. Thanks! I'm taking a break from Elemental Mastery and working on a (relatively) simple spell that has different effects based on what blessing you're under but I couldn't figure out how to detect it! Sadly, it looks like this will still render it incompatible with mods that change the blessings. I can check for the MagicBlessing keyword but it won't tell me what Divine it's from.

What's aggravating is that the GAME knows... if you check Active Effects it'll tell you your Voice Recharge is reduced by 20% due to Blessing of Talos, but there doesn't seem to be any way to actually retrieve that info via Papyrus...

And I actually learned the word fetish thanks to Tintin comics ;)
User avatar
Robert Devlin
 
Posts: 3521
Joined: Mon Jul 23, 2007 2:19 pm

Post » Thu Jun 21, 2012 3:12 pm

Psst. -taptap-

Each of those magic effects is -completely- unique, meaning that you can do a check for the Magic Effect, rather than for its Keyword.
User avatar
louise fortin
 
Posts: 3327
Joined: Wed Apr 04, 2007 4:51 am

Post » Thu Jun 21, 2012 12:19 pm

I understand, and that will work perfectly with Vanilla. I was hoping there was a way to get the name of the Spell providing the MagicEffect so that I could maintain compatibility with mods that change the Blessing effects. That said, thanks a lot for listing out the effects and their respective Divines... saves me a lot of digging! :)
User avatar
Roddy
 
Posts: 3564
Joined: Fri Jun 15, 2007 11:50 pm

Post » Thu Jun 21, 2012 9:01 pm

Oh, I get you.

Well, from a quick look at a search for 'blessing' on Nexus... you wouldn't be losing compatibility with anything worth losing sleep over. Unless you're really going for that one that makes Akatosh shrines turn into Game Genies.
User avatar
Alyce Argabright
 
Posts: 3403
Joined: Mon Aug 20, 2007 8:11 pm


Return to V - Skyrim