OnUnequipped - ObjectReference

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search

Member of: ObjectReference Script

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

Syntax[edit | edit source]

Event OnUnequipped(Actor akActor)

Parameters[edit | edit source]

  • akActor: The actor that unequipped this object.

Examples[edit | edit source]

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. This example will apply a spell, but you could use it to apply perks dynamically (probably still only to the player) as well.

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


Notes[edit | edit source]

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[edit | edit source]