OnUnequipped - ObjectReference

Revision as of 23:47, 11 June 2016 by imported>Gurgate

Member of: ObjectReference Script

Event called when the object reference has been unequipped by an actor.

Syntax

Event OnUnequipped(Actor akActor)

Parameters

  • akActor: The actor that unequipped this object.

Examples

Event OnUnequipped(Actor akActor)
  if akActor == Game.GetPlayer()
    Debug.Trace("We were unequipped from the player!")
  endIf
endEvent

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.

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


Notes

When an object is unequipped it may still be inside a container, which means that you cannot call most native functions on it.

See Also