OnEquip

From GECK
Jump to: navigation, search

This block will be run once when the scripted object is equipped by the specified Actor. If no parameter is used, the block will be run whenever the object is equipped by any actor.

Syntax

 begin OnEquip ActorID 

Example

 begin OnEquip 
 begin OnEquip player 

Notes

  • This block will run on already equipped ammo when loading into a save, at least for the player.
  • This block will run on an already equipped throwable weapon when loading into a save, at least for the player.
  • This block will run when reloading a weapon that uses Ammo - the ammo is considered as being re-equipped, not the weapon.
  • This block will not run when "reloading" a throwable weapon, i.e. after one is thrown and the next is getting ready.
  • This block will run when you attempt to equip a broken item (weapon or armor). This can cause problems if the item script relies on the OnUnequip block to reverse an effect of the OnEquip. Since the item never actually gets equipped, you'll have to get it repaired and then equip/unequip it to fire the OnUnequip block. Or use GetCurrentHealth to prevent your OnEquip code from executing when attempting to equip a broken item.
  • This block will run when a non-equippable item is selected (left-clicked) in the inventory menu. Note that a message appears in the upper left corner of the screen: "This item cannot be equipped."
    • You can make this message blank by replacing the game setting sCantEquipGeneric with a space. The blank message will still be displayed, and will cause the normal delay to other messages, but no text will appear. Don't delete the string completely - it can prevent other messages from displaying.
  • This block will not run when ingestibles are consumed by the player. Instead, use a MenuMode block inside a script effect for the item.
  • This block will not run when an item is equipped via script using the EquipItem function. However, an OnUnequip block will run when the object is unequipped using UnequipItem. A common problem with this is that any actions taken/reversed using these two block types can malfunction if the item is equipped and unequipped via script. JIPLN has an EquipItemAlt function which will trigger the OnEquip block.
  • To get the actor reference which is equipping the item, use GetContainer.

See Also