DropObject - ObjectReference

From the CreationKit Wiki
Jump to navigation Jump to search

Member of: ObjectReference Script

Drops the specified object from this object's inventory.

Syntax[edit | edit source]

ObjectReference Function DropObject(Form akObject, int aiCount = 1) native

Parameters[edit | edit source]

  • akObject: The object to drop from the inventory.
  • aiCount: How many to drop
    • Default: 1

Return Value[edit | edit source]

The object that was dropped.

Examples[edit | edit source]

; Drops one chest from the player's inventory, and unlocks it
Game.GetPlayer().DropObject(ChestProperty).Lock(false)


; Drops one hundred arrows from the player's inventory
Game.GetPlayer().DropObject(ArrowProperty, 100)

Notes[edit | edit source]

  • If a number greater than 1 is used for aiCount, the objects dropped will be stacked. In order to drop individual items, DropObject must be called for each instance of the item.
  • If akObject is equipped, the game will first search for unequipped items in inventory to drop. Only when there are no more unequipped items will it drop the equipped items.
  • If akObject is a permanently-persistent reference, DropObject will not return a Form ID value for the ObjectReference, even though it still physically drops the object from the inventory. If you need to run further ObjectReference Functions onto the dropped object, you will need to refer to that object's reference ID directly.
  • If akObject is an ObjectReference, even one which was just received by i.e. OnItemAdded(), DropObject() will fail with an error in the script log: "cannot be dropped, it has no 3d." You can instead use itemRef.MoveTo(containerRef) to pull a specific reference out of inventory, but note that if itemRef is a weapon and containerRef is an actor (such as the player), the actor may be wounded unless you give MoveTo() a sufficient offset.

See Also[edit | edit source]