Item functions

class ItemFunctions

Public Static Functions

void ClearInventoryChanges(unsigned short pid)

Clear the last recorded inventory changes for a player.

This is used to initialize the sending of new PlayerInventory packets.

Return
void
Parameters
  • pid: The player ID whose inventory changes should be used.

int GetEquipmentSize()

Get the number of slots used for equipment.

The number is 19 before any dehardcoding is done in OpenMW.

Return
The number of slots.

unsigned int GetInventoryChangesSize(unsigned short pid)

Get the number of indexes in a player’s latest inventory changes.

Return
The number of indexes.
Parameters
  • pid: The player ID whose inventory changes should be used.

unsigned int GetInventoryChangesAction(unsigned short pid)

Get the action type used in a player’s latest inventory changes.

Return
The action type (0 for SET, 1 for ADD, 2 for REMOVE).
Parameters
  • pid: The player ID whose inventory changes should be used.

void SetInventoryChangesAction(unsigned short pid, unsigned char action)

Set the action type in a player’s inventory changes.

Return
void
Parameters
  • pid: The player ID whose inventory changes should be used.
  • action: The action (0 for SET, 1 for ADD, 2 for REMOVE).

void EquipItem(unsigned short pid, unsigned short slot, const char *refId, unsigned int count, int charge, double enchantmentCharge = -1)

Equip an item in a certain slot of the equipment of a player.

Return
void
Parameters
  • pid: The player ID.
  • slot: The equipment slot.
  • refId: The refId of the item.
  • count: The count of the item.
  • charge: The charge of the item.
  • enchantmentCharge: The enchantment charge of the item.

void UnequipItem(unsigned short pid, unsigned short slot)

Unequip the item in a certain slot of the equipment of a player.

Return
void
Parameters
  • pid: The player ID.
  • slot: The equipment slot.

void AddItemChange(unsigned short pid, const char *refId, unsigned int count, int charge, double enchantmentCharge, const char *soul)

Add an item change to a player’s inventory changes.

Return
void
Parameters
  • pid: The player ID.
  • refId: The refId of the item.
  • count: The count of the item.
  • charge: The charge of the item.
  • enchantmentCharge: The enchantment charge of the item.
  • soul: The soul of the item.

bool HasItemEquipped(unsigned short pid, const char *refId)

Check whether a player has equipped an item with a certain refId in any slot.

Return
Whether the player has the item equipped.
Parameters
  • pid: The player ID.
  • refId: The refId of the item.

const char *GetEquipmentItemRefId(unsigned short pid, unsigned short slot)

Get the refId of the item in a certain slot of the equipment of a player.

Return
The refId.
Parameters
  • pid: The player ID.
  • slot: The slot of the equipment item.

int GetEquipmentItemCount(unsigned short pid, unsigned short slot)

Get the count of the item in a certain slot of the equipment of a player.

Return
The item count.
Parameters
  • pid: The player ID.
  • slot: The slot of the equipment item.

int GetEquipmentItemCharge(unsigned short pid, unsigned short slot)

Get the charge of the item in a certain slot of the equipment of a player.

Return
The charge.
Parameters
  • pid: The player ID.
  • slot: The slot of the equipment item.

double GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot)

Get the enchantment charge of the item in a certain slot of the equipment of a player.

Return
The enchantment charge.
Parameters
  • pid: The player ID.
  • slot: The slot of the equipment item.

const char *GetInventoryItemRefId(unsigned short pid, unsigned int index)

Get the refId of the item at a certain index in a player’s latest inventory changes.

Return
The refId.
Parameters
  • pid: The player ID whose inventory changes should be used.
  • index: The index of the inventory item.

int GetInventoryItemCount(unsigned short pid, unsigned int index)

Get the count of the item at a certain index in a player’s latest inventory changes.

Return
The item count.
Parameters
  • pid: The player ID whose inventory changes should be used.
  • index: The index of the inventory item.

int GetInventoryItemCharge(unsigned short pid, unsigned int index)

Get the charge of the item at a certain index in a player’s latest inventory changes.

Return
The charge.
Parameters
  • pid: The player ID whose inventory changes should be used.
  • index: The index of the inventory item.

double GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int index)

Get the enchantment charge of the item at a certain index in a player’s latest inventory changes.

Return
The enchantment charge.
Parameters
  • pid: The player ID whose inventory changes should be used.
  • index: The index of the inventory item.

const char *GetInventoryItemSoul(unsigned short pid, unsigned int index)

Get the soul of the item at a certain index in a player’s latest inventory changes.

Return
The soul.
Parameters
  • pid: The player ID whose inventory changes should be used.
  • index: The index of the inventory item.

const char *GetUsedItemRefId(unsigned short pid)

Get the refId of the item last used by a player.

Return
The refId.
Parameters
  • pid: The player ID.

int GetUsedItemCount(unsigned short pid)

Get the count of the item last used by a player.

Return
The item count.
Parameters
  • pid: The player ID.

int GetUsedItemCharge(unsigned short pid)

Get the charge of the item last used by a player.

Return
The charge.
Parameters
  • pid: The player ID.

double GetUsedItemEnchantmentCharge(unsigned short pid)

Get the enchantment charge of the item last used by a player.

Return
The enchantment charge.
Parameters
  • pid: The player ID.

const char *GetUsedItemSoul(unsigned short pid)

Get the soul of the item last used by a player.

Return
The soul.
Parameters
  • pid: The player ID.

void SendEquipment(unsigned short pid)

Send a PlayerEquipment packet with a player’s equipment.

It is always sent to all players.

Return
void
Parameters
  • pid: The player ID whose equipment should be sent.

void SendInventoryChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer)

Send a PlayerInventory packet with a player’s recorded inventory changes.

Return
void
Parameters
  • pid: The player ID whose inventory changes should be used.
  • sendToOtherPlayers: Whether this packet should be sent to players other than the player attached to the packet (false by default).
  • skipAttachedPlayer: Whether the packet should skip being sent to the player attached to the packet (false by default).

void SendItemUse(unsigned short pid)

Send a PlayerItemUse causing a player to use their recorded usedItem.

Return
void
Parameters
  • pid: The player ID affected.