Talk:EquipItem

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

Actually, the delay discussed here is nothing to do with the EquipItem command but rather how low it takes an object to really be added to your inventory. This can actually be a variable number of frames depending on whether the item is scripted, added in multiples, and perhaps other scripts running it that frame. Since the equip flag is relative to a base object, I find the best way to do this is:

 if doOnce == 0
   if player.GetItemCount MyAddedObjectID
      player.EquipItem MyAddedObjectID 1
      set doOnce to 1
   endif
 endif

In fact the doOnce variable may be unnecessary - this is only an example code fragment. It is also of note that the forced-equip option only applies to the player when attempting to unequip in play. It does not prevent scripted UnequipItem or other EquipItem commands from executing correctly. Btw, this info. is particular useful for anyone trying to force-equip potions. Guidobot 15:05, 15 March 2007 (EDT)

You're right, Guido. Thanks for the correction. Scruggs 17:11, 15 March 2007 (EDT)
I've never had to worry about a delay. In fact, it's kind-of nice because I can add/unequip and run the onUnEquip block in the same frame. Maybe it's because I'm only adding/equipping to a persistent NPC that's in the same cell? Do you only need a delay with the player?
--Haama 09:41, 28 July 2007 (EDT)

EquipItem on NPCs in an unloaded cell[edit source]

EquipItem does not behave as expected if the NPC is in an unloaded cell.

The game engine marks the item as equipped, but does not unequip other similar items. All stay marked as equipped (verifiable with GetEquipped and OBSE's GetEquippedItems). Only when the NPC is loaded, the game engine decides which one to actually equip, which may or may not be the last one you force-equipped with EquipItem.

The same phenomenon occurs before the NPC is loaded for the first time ever: all equippable items will show as equipped. Only when the NPC is loaded for the first time, the engine decides which one to actually equip and 'unmarks' the others (if any).

Example: NPC created in the CS with five different pants in his inventory.

  • Before the player meets the NPC, all five pants are reported as equipped
  • Player goes to the NPC cell - one pant reported as equipped (say, Pants01)
  • Player leaves the cell
  • After cell is unloaded, script EquipItem Pants02 and Pants03 - All three pants are reported as equipped
  • Player goes to the NPC cell again - one pant reported as equipped (most likely the same as before)

Of course, this does not affect the player (always loaded) and non-persistent NPCs (cant EquipItem on them if not loaded)

QQuix 12:37, 24 December 2009 (EST)