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-09-30 09:30:05 +00:00
|
|
|
{"AddItem", ItemFunctions::AddItem},\
|
|
|
|
{"RemoveItem", ItemFunctions::RemoveItem},\
|
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
|
|
|
{"GetItemCount", ItemFunctions::GetItemCount2},\
|
2016-09-30 09:30:05 +00:00
|
|
|
{"EquipItem", ItemFunctions::EquipItem},\
|
|
|
|
{"UnequipItem", ItemFunctions::UnequipItem},\
|
|
|
|
{"GetItemSlot", ItemFunctions::GetItemSlot},\
|
|
|
|
{"HasItemEquipped", ItemFunctions::HasItemEquipped},\
|
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
|
|
|
{"GetItemName", ItemFunctions::GetItemName},\
|
|
|
|
{"GetItemHealth", ItemFunctions::GetItemHealth},\
|
|
|
|
{"GetInventorySize", ItemFunctions::GetInventorySize},\
|
2016-09-30 09:30:05 +00:00
|
|
|
\
|
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
|
|
|
{"SendEquipment", ItemFunctions::SendEquipment},\
|
|
|
|
{"SendInventory", ItemFunctions::SendInventory}\
|
2016-08-30 04:19:49 +00:00
|
|
|
|
|
|
|
class ItemFunctions
|
|
|
|
{
|
|
|
|
public:
|
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
|
|
|
static void AddItem(unsigned short pid, const char* itemName, unsigned int count, int health) noexcept;
|
2016-08-30 04:19:49 +00:00
|
|
|
static void RemoveItem(unsigned short pid, const char* itemName, unsigned short count) noexcept;
|
|
|
|
static void GetItemCount(unsigned short pid, const char* itemName) 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
|
|
|
static void EquipItem(unsigned short pid, unsigned short slot, const char* itemName, unsigned int count, int health) noexcept;
|
2016-08-30 04:19:49 +00:00
|
|
|
static void UnequipItem(unsigned short pid, unsigned short slot) noexcept;
|
|
|
|
static bool HasItemEquipped(unsigned short pid, const char* itemName);
|
|
|
|
static const char *GetItemSlot(unsigned short pid, unsigned short slot) noexcept;
|
2016-09-30 09:30:05 +00:00
|
|
|
|
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
|
|
|
static const char *GetItemName(unsigned short pid, unsigned int i) noexcept;
|
|
|
|
static int GetItemCount2(unsigned short pid, unsigned int i) noexcept;
|
|
|
|
static int GetItemHealth(unsigned short pid, unsigned int i) noexcept;
|
|
|
|
static unsigned int GetInventorySize(unsigned short pid) noexcept;
|
|
|
|
|
2016-09-30 09:30:05 +00:00
|
|
|
static void SendEquipment(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
|
|
|
static void SendInventory(unsigned short pid) noexcept;
|
|
|
|
private:
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //OPENMW_ITEMS_HPP
|