Difference between revisions of "OnUnequipped - ObjectReference"

m
no edit summary
imported>Plplecuyer
 
imported>Gurgate
m
 
(One intermediate revision by the same user not shown)
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. This example will apply a spell, but you could use it to apply perks dynamically (probably still only to the player) as well.
<source lang="papyrus">
Spell Property OurSpecialAbility Auto
{A Constant Effect, Ability Spell. Is Special.}
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. this can probs technically be skipped.
        ;; but lets be double sure it did not fall off.
        Who.AddSpell(OurSpecialAbility)
    Else
        ;; remove.
        Who.RemoveSpell(OurSpecialAbility)
    EndIf
    Return
EndEvent
</source>


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