Jump to content

[LE] Need help with script: add spells when armor is equipped


Recommended Posts

Hey guys !

 

I am working on a new Skyrim mod ( want a preview ? ;) ) , but I have no idea how to script whatsoever ! Tutorials weren't as useful as I thought they would be, so I ask here if somehow could help me how to script a very simple script :

 

Basically, I would want to add some spells to the player once he equips a piece of armor, and remove the spells as he removes the armor...

 

I've seen so many mods using this king of script, but I can't seem to replicate it :/

 

Any help would be greatly appreciated !
Thanks for reading, guys ^^ !

Link to comment
Share on other sites

All you have to do is take a look at the scripts on the Silver Swords or the Ring of Namira, The Ebony Mail, Hircine's Ring etc.

 

This should also be useful if you are working with Scripts.

 

http://www.creationkit.com/index.php?title=Category:Script_Objects

https://www.creationkit.com/index.php?title=While

Edited by Masterofnet
Link to comment
Share on other sites

Look a bit further, you can literaly change "perk" for "spell" in the silver sword script and thats it.

 

That said, i personally prefer to put that in a magic effect instead of in the item itself because onequip/onunequip sometimes fail to trigger. Straight copy from my paladin mod, this attached to a magic effect on the item's enchantment.

scriptName FFPAASpellAdder extends ActiveMagicEffect

spell property SpellToAdd auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
	akTarget.AddSpell(SpellToAdd, true)
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	akTarget.RemoveSpell(SpellToAdd)
EndEvent
Link to comment
Share on other sites

From having used it for sensitive stuff that depend on a perfect execution of both events i can say that they sometimes fail to trigger, causing issues (missmatch between having the spell/perk it adds and the object being actually equipped or not). With a perk you can always just add a condition to it so that its only active while said item is equipped, as a second check but for other stuff it can get messy. If you are adding an enchantment tying it to oneffectstart/finish is much safer.

 

But, its a recommendation, feel free to believe or not.

Link to comment
Share on other sites

So if you are considering using OnEquip on an item that is not unique you could possibly run into problems. That explains why it has never failed on me. Also, I need to clarify my early statement regarding the armor. I was not using onequip and on unequip.

 

I was using

OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
and I can tell you it does not miss.
What if you have the event on a quest alias? Would that be a possible issue if it was not a unique item?
Link to comment
Share on other sites

  • Recently Browsing   0 members

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