Jump to content

Photo

Need help with script: add spells when armor is equipped

spells spell script armor ring magic

  • Please log in to reply
17 replies to this topic

#1
FafnirEtherion

FafnirEtherion

    Resident poster

  • Members
  • PipPipPipPipPip
  • 2,591 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 ^^ !



#2
Masterofnet

Masterofnet

    Fan

  • Banned
  • PipPipPip
  • 406 posts

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.creationk...:Script_Objects

https://www.creation...php?title=While


Edited by Masterofnet, 17 February 2017 - 11:25 PM.


#3
FafnirEtherion

FafnirEtherion

    Resident poster

  • Members
  • PipPipPipPipPip
  • 2,591 posts

These items are adding passive effects to the character, not usable, castable spells :/ !

 

But thanks for the links ! These will be useful



#4
FrankFamily

FrankFamily

    The Evil Blacksmith

  • Supporter
  • PipPipPipPipPip
  • 6,937 posts

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


#5
Masterofnet

Masterofnet

    Fan

  • Banned
  • PipPipPip
  • 406 posts

I have used onequip and onuneqpup extensively and have never had it fail.   The silver swords had some issues but those were caused by the script itself not the event.   Can anyone confirm onequip/onunequip failing to trigger?


Edited by Masterofnet, 19 February 2017 - 06:05 AM.


#6
FrankFamily

FrankFamily

    The Evil Blacksmith

  • Supporter
  • PipPipPipPipPip
  • 6,937 posts

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.



#7
Undivide

Undivide

    Neighborhood Spaceman

  • Supporter
  • PipPipPip
  • 697 posts

I've had on(un)equip fail to trigger for me a few times in the past as well.



#8
Masterofnet

Masterofnet

    Fan

  • Banned
  • PipPipPip
  • 406 posts

Interesting,  I used to use a script that kept track of ever piece of armor a player equipped and unequipped.  The purpose of it was to prevent the player from un-equipping armor during combat.  It never failed once.  Thanks for the information.



#9
lofgren

lofgren

    Resident poster

  • Supporter
  • PipPipPipPipPip
  • 3,261 posts
OnEquip will fail if you have multiple copies of the same form in your inventory. It will only fire for the first one you acquired.

#10
Masterofnet

Masterofnet

    Fan

  • Banned
  • PipPipPip
  • 406 posts

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?






Also tagged with one or more of these keywords: spells, spell, script, armor, ring, magic

Page loaded in: 1.190 seconds