Difference between revisions of "OnEquip"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Dev akm
imported>Thalassicus
Line 19: Line 19:
if (GetPlayerSpell == GetEnchantment)
if (GetPlayerSpell == GetEnchantment)
;Make the player select a different scroll
;Make the player select a different scroll
;Note that selecting a spell will prevent the player from equipping a scroll until
;Note that selecting a spell will prevent the player from equipping a scroll until
;they de-select the scroll in their spell menu
;they de-select the scroll in their spell menu
message " "
player.AddItemNS AnotherScroll 1
message " "
player.AddItem AnotherScroll 1
SelectPlayerSpell AnotherScroll
SelectPlayerSpell AnotherScroll
player.RemoveItem AnotherScroll 1
player.RemoveItemNS AnotherScroll 1
;Open the formula - run your code here
;Open the formula - run your code here
endif
endif

Revision as of 06:58, 27 December 2009

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

  • 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.

See Also