Difference between revisions of "OnUnequipped - ObjectReference"

no edit summary
imported>Plplecuyer
 
imported>Gurgate
Line 22: Line 22:
endEvent
endEvent
</source>
</source>
Because all item bonuses and enchants are disabled when in power armor, this event also will be emitted if the script is on an item normally equipped by the actor when the actor enters a power armor frame. You can use this to your advantage to bring effects back that are lost while in the power armor. Take this example which can re-apply an ability spell upon entering power armor. You can use this as an alternative to enchanting the item.
<source lang="papyrus">
Spell Property OurSpecialAbility Auto
Event OnEquipped(Actor Who)
{when this item is equipped apply our special ability
spell instead of an enchantment.}
    Who.AddSpell(OurSpecialAbility)
    Return
EndEvent
Event OnUnequipped(Actor Who)
{when this item is removed check if it was beacuse they
entered a power armor frame. if so, reapply the effect.}
    If(Who.IsInPowerArmor())
        ;; reapply.
        Who.AddSpell(OurSpecialAbility)
    Else
        ;; remove.
        Who.RemoveSpell(OurSpecialAbility)
    EndIf
    Return
EndEvent
</source>


== Notes ==
== Notes ==
Anonymous user