OnEquip

From the Fallout3 GECK Wiki
Jump to navigation Jump to search

Link to TES4 Construction Set Wiki: OnEquip.

Syntax:

 begin OnEquip ActorID 

Example:

 begin OnEquip 
 begin OnEquip player 

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.

Notes[edit | edit source]

  • 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.
  • 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 potions, poisons, or ingredients are consumed by the player. Instead, use a MenuMode block inside a script effect for the item.
  • This block will not run when a book is equipped in combat if reading during combat is disallowed.
  • This block will not run when an enchanted scroll is equipped. However, if the scroll has a unique enchantment, you can fake an OnEquip block (requires OBSE):
begin MenuMode 1002
	;Activate the formula if the player selects it (in their inventory)
	;if IsInPlayerPossesion ;Keep track of this with onAdd/onDrop blocks
		if (GetPlayerSpell == GetEnchantment)
			;Make the player select a different scroll
			;Note that selecting a spell will prevent
			;the player from equipping a scroll until
			;they de-select the scroll in their spell menu
			player.AddItemNS AnotherScroll 1
			SelectPlayerSpell AnotherScroll
			player.RemoveItemNS AnotherScroll 1
			;Open the formula - run your code here
		endif
	;endif
end
  • 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. OBSE 18 has an EquipItem2/EquipItem2NS function which will trigger the OnEquip block.

See Also[edit | edit source]