|
|
|
//
|
|
|
|
// Created by koncord on 30.08.16.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef OPENMW_ITEMS_HPP
|
|
|
|
#define OPENMW_ITEMS_HPP
|
|
|
|
|
|
|
|
#define ITEMAPI \
|
|
|
|
{"GetEquipmentSize", ItemFunctions::GetEquipmentSize},\
|
|
|
|
{"GetInventoryChangesSize", ItemFunctions::GetInventoryChangesSize},\
|
|
|
|
\
|
|
|
|
{"EquipItem", ItemFunctions::EquipItem},\
|
|
|
|
{"UnequipItem", ItemFunctions::UnequipItem},\
|
|
|
|
\
|
|
|
|
{"AddItem", ItemFunctions::AddItem},\
|
|
|
|
{"RemoveItem", ItemFunctions::RemoveItem},\
|
|
|
|
{"ClearInventory", ItemFunctions::ClearInventory},\
|
|
|
|
\
|
|
|
|
{"HasItemEquipped", ItemFunctions::HasItemEquipped},\
|
|
|
|
\
|
|
|
|
{"GetEquipmentItemRefId", ItemFunctions::GetEquipmentItemRefId},\
|
|
|
|
{"GetEquipmentItemCount", ItemFunctions::GetEquipmentItemCount},\
|
|
|
|
{"GetEquipmentItemCharge", ItemFunctions::GetEquipmentItemCharge},\
|
|
|
|
\
|
|
|
|
{"GetInventoryItemRefId", ItemFunctions::GetInventoryItemRefId},\
|
|
|
|
{"GetInventoryItemCount", ItemFunctions::GetInventoryItemCount},\
|
|
|
|
{"GetInventoryItemCharge", ItemFunctions::GetInventoryItemCharge},\
|
|
|
|
\
|
|
|
|
{"SendEquipment", ItemFunctions::SendEquipment},\
|
|
|
|
{"SendInventoryChanges", ItemFunctions::SendInventoryChanges}
|
|
|
|
|
|
|
|
class ItemFunctions
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
static int GetEquipmentSize() noexcept;
|
|
|
|
static unsigned int GetInventoryChangesSize(unsigned short pid) noexcept;
|
|
|
|
|
|
|
|
static void EquipItem(unsigned short pid, unsigned short slot, const char* refId, unsigned int count, int charge) noexcept;
|
|
|
|
static void UnequipItem(unsigned short pid, unsigned short slot) noexcept;
|
|
|
|
|
|
|
|
static void AddItem(unsigned short pid, const char* refId, unsigned int count, int charge) noexcept;
|
|
|
|
static void RemoveItem(unsigned short pid, const char* refId, unsigned short count) noexcept;
|
|
|
|
static void ClearInventory(unsigned short pid) noexcept;
|
|
|
|
|
|
|
|
static bool HasItemEquipped(unsigned short pid, const char* refId);
|
|
|
|
|
|
|
|
static const char *GetEquipmentItemRefId(unsigned short pid, unsigned short slot) noexcept;
|
|
|
|
static int GetEquipmentItemCount(unsigned short pid, unsigned short slot) noexcept;
|
|
|
|
static int GetEquipmentItemCharge(unsigned short pid, unsigned short slot) noexcept;
|
|
|
|
|
|
|
|
static const char *GetInventoryItemRefId(unsigned short pid, unsigned int i) noexcept;
|
|
|
|
static int GetInventoryItemCount(unsigned short pid, unsigned int i) noexcept;
|
|
|
|
static int GetInventoryItemCharge(unsigned short pid, unsigned int i) noexcept;
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
8 years ago
|
|
|
|
|
|
|
static void SendEquipment(unsigned short pid) noexcept;
|
|
|
|
static void SendInventoryChanges(unsigned short pid) noexcept;
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
8 years ago
|
|
|
private:
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //OPENMW_ITEMS_HPP
|