2016-08-30 04:19:49 +00:00
|
|
|
//
|
|
|
|
// Created by koncord on 30.08.16.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef OPENMW_ITEMS_HPP
|
|
|
|
#define OPENMW_ITEMS_HPP
|
|
|
|
|
|
|
|
#define ITEMAPI \
|
2016-11-17 22:52:17 +00:00
|
|
|
{"GetEquipmentSize", ItemFunctions::GetEquipmentSize},\
|
|
|
|
{"GetInventorySize", ItemFunctions::GetInventorySize},\
|
2016-09-30 09:30:05 +00:00
|
|
|
\
|
2016-11-17 22:52:17 +00:00
|
|
|
{"EquipItem", ItemFunctions::EquipItem},\
|
|
|
|
{"UnequipItem", ItemFunctions::UnequipItem},\
|
2016-11-17 21:07:29 +00:00
|
|
|
\
|
2016-11-17 22:52:17 +00:00
|
|
|
{"AddItem", ItemFunctions::AddItem}, \
|
|
|
|
{"RemoveItem", ItemFunctions::RemoveItem}, \
|
2016-11-17 21:07:29 +00:00
|
|
|
\
|
2016-11-17 22:52:17 +00:00
|
|
|
{"HasItemEquipped", ItemFunctions::HasItemEquipped},\
|
|
|
|
\
|
|
|
|
{"GetEquipmentItemId", ItemFunctions::GetEquipmentItemId},\
|
|
|
|
{"GetEquipmentItemCount", ItemFunctions::GetEquipmentItemCount},\
|
|
|
|
{"GetEquipmentItemHealth", ItemFunctions::GetEquipmentItemHealth},\
|
|
|
|
\
|
|
|
|
{"GetInventoryItemId", ItemFunctions::GetInventoryItemId},\
|
|
|
|
{"GetInventoryItemCount", ItemFunctions::GetInventoryItemCount},\
|
|
|
|
{"GetInventoryItemHealth", ItemFunctions::GetInventoryItemHealth},\
|
|
|
|
\
|
|
|
|
{"SendEquipment", ItemFunctions::SendEquipment},\
|
|
|
|
{"SendInventory", ItemFunctions::SendInventory}
|
2016-08-30 04:19:49 +00:00
|
|
|
|
|
|
|
class ItemFunctions
|
|
|
|
{
|
|
|
|
public:
|
2016-11-17 22:52:17 +00:00
|
|
|
|
|
|
|
static int GetEquipmentSize() noexcept;
|
|
|
|
static unsigned int GetInventorySize(unsigned short pid) noexcept;
|
2016-11-17 21:07:29 +00:00
|
|
|
|
2016-11-16 17:28:22 +00:00
|
|
|
static void EquipItem(unsigned short pid, unsigned short slot, const char* itemName, unsigned int count, int health) noexcept;
|
|
|
|
static void UnequipItem(unsigned short pid, unsigned short slot) noexcept;
|
2016-11-17 22:52:17 +00:00
|
|
|
|
|
|
|
static void AddItem(unsigned short pid, const char* itemName, unsigned int count, int health) noexcept;
|
|
|
|
static void RemoveItem(unsigned short pid, const char* itemName, unsigned short count) noexcept;
|
|
|
|
|
2016-11-16 17:28:22 +00:00
|
|
|
static bool HasItemEquipped(unsigned short pid, const char* itemName);
|
2016-09-30 09:30:05 +00:00
|
|
|
|
2016-11-17 22:52:17 +00:00
|
|
|
static const char *GetEquipmentItemId(unsigned short pid, unsigned short slot) noexcept;
|
|
|
|
static int GetEquipmentItemCount(unsigned short pid, unsigned short slot) noexcept;
|
|
|
|
static int GetEquipmentItemHealth(unsigned short pid, unsigned short slot) noexcept;
|
|
|
|
|
|
|
|
static const char *GetInventoryItemId(unsigned short pid, unsigned int i) noexcept;
|
|
|
|
static int GetInventoryItemCount(unsigned short pid, unsigned int i) noexcept;
|
|
|
|
static int GetInventoryItemHealth(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
```
2016-10-22 18:57:37 +00:00
|
|
|
|
2016-11-16 17:28:22 +00:00
|
|
|
static void SendEquipment(unsigned short pid) noexcept;
|
|
|
|
static void SendInventory(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
```
2016-10-22 18:57:37 +00:00
|
|
|
private:
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //OPENMW_ITEMS_HPP
|