2016-08-30 04:19:49 +00:00
|
|
|
#include "Items.hpp"
|
2017-08-18 04:13:08 +00:00
|
|
|
|
|
|
|
#include <components/misc/stringops.hpp>
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
2017-08-18 04:13:08 +00:00
|
|
|
|
|
|
|
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <apps/openmw-mp/Networking.hpp>
|
2016-11-17 21:07:29 +00:00
|
|
|
#include <apps/openmw/mwworld/inventorystore.hpp>
|
2016-01-12 03:41:44 +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
|
|
|
using namespace mwmp;
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2018-10-02 23:26:47 +00:00
|
|
|
void ItemFunctions::ClearInventoryChanges(unsigned short pid) noexcept
|
2017-07-07 06:25:48 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
|
|
|
player->inventoryChanges.items.clear();
|
|
|
|
}
|
|
|
|
|
2016-11-17 22:52:17 +00:00
|
|
|
int ItemFunctions::GetEquipmentSize() noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2016-11-17 22:52:17 +00:00
|
|
|
return MWWorld::InventoryStore::Slots;
|
|
|
|
}
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2020-07-07 13:41:03 +00:00
|
|
|
unsigned int ItemFunctions::GetEquipmentChangesSize(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
Player* player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
|
|
|
return player->equipmentIndexChanges.size();
|
|
|
|
}
|
|
|
|
|
2017-01-20 10:43:05 +00:00
|
|
|
unsigned int ItemFunctions::GetInventoryChangesSize(unsigned short pid) noexcept
|
2016-11-17 22:52:17 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
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
|
|
|
|
2019-10-26 11:01:08 +00:00
|
|
|
return player->inventoryChanges.items.size();
|
2016-08-30 04:19:49 +00:00
|
|
|
}
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2018-08-21 07:06:40 +00:00
|
|
|
unsigned int ItemFunctions::GetInventoryChangesAction(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
|
|
|
return player->inventoryChanges.action;
|
|
|
|
}
|
|
|
|
|
2018-10-01 15:29:50 +00:00
|
|
|
void ItemFunctions::SetInventoryChangesAction(unsigned short pid, unsigned char action) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
|
|
|
player->inventoryChanges.action = action;
|
|
|
|
}
|
|
|
|
|
2018-07-26 19:37:04 +00:00
|
|
|
void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *refId, unsigned int count,
|
|
|
|
int charge, double enchantmentCharge) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
2018-04-20 19:46:16 +00:00
|
|
|
player->equipmentItems[slot].refId = refId;
|
|
|
|
player->equipmentItems[slot].count = count;
|
|
|
|
player->equipmentItems[slot].charge = charge;
|
|
|
|
player->equipmentItems[slot].enchantmentCharge = enchantmentCharge;
|
|
|
|
|
2018-07-03 10:34:41 +00:00
|
|
|
if (!Utils::vectorContains(player->equipmentIndexChanges, slot))
|
2018-04-20 19:46:16 +00:00
|
|
|
player->equipmentIndexChanges.push_back(slot);
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|
|
|
|
|
2016-11-16 17:28:22 +00:00
|
|
|
void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2016-11-17 23:50:55 +00:00
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
2017-12-23 11:16:38 +00:00
|
|
|
ItemFunctions::EquipItem(pid, slot, "", 0, -1, -1);
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|
|
|
|
|
2018-10-01 15:29:50 +00:00
|
|
|
void ItemFunctions::AddItemChange(unsigned short pid, const char* refId, unsigned int count, int charge,
|
2018-07-26 19:37:04 +00:00
|
|
|
double enchantmentCharge, const char* soul) noexcept
|
2016-11-17 21:07:29 +00:00
|
|
|
{
|
2016-11-17 22:52:17 +00:00
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
|
|
|
Item item;
|
2017-02-07 11:50:28 +00:00
|
|
|
item.refId = refId;
|
2016-11-17 22:52:17 +00:00
|
|
|
item.count = count;
|
2017-02-05 12:56:27 +00:00
|
|
|
item.charge = charge;
|
2017-12-23 11:16:38 +00:00
|
|
|
item.enchantmentCharge = enchantmentCharge;
|
2018-07-26 19:37:04 +00:00
|
|
|
item.soul = soul;
|
2016-11-17 22:52:17 +00:00
|
|
|
|
2017-07-07 06:25:48 +00:00
|
|
|
player->inventoryChanges.items.push_back(item);
|
2016-11-20 02:06:33 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 11:50:28 +00:00
|
|
|
bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* refId)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, false);
|
|
|
|
|
2016-11-17 22:52:17 +00:00
|
|
|
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++)
|
2018-04-20 19:46:16 +00:00
|
|
|
if (Misc::StringUtils::ciEqual(player->equipmentItems[slot].refId, refId))
|
2016-01-12 03:41:44 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
2016-08-30 04:19:49 +00:00
|
|
|
}
|
|
|
|
|
2020-07-07 13:41:03 +00:00
|
|
|
int ItemFunctions::GetEquipmentChangesSlot(unsigned short pid, unsigned int changeIndex) noexcept
|
|
|
|
{
|
|
|
|
Player* player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
|
|
|
|
|
|
|
return player->equipmentIndexChanges[changeIndex];
|
|
|
|
}
|
|
|
|
|
2017-02-07 11:50:28 +00:00
|
|
|
const char *ItemFunctions::GetEquipmentItemRefId(unsigned short pid, unsigned short slot) noexcept
|
2016-08-30 04:19:49 +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
|
|
|
Player *player;
|
2016-11-17 22:52:17 +00:00
|
|
|
GET_PLAYER(pid, player, 0);
|
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
|
|
|
|
2018-04-20 19:46:16 +00:00
|
|
|
return player->equipmentItems[slot].refId.c_str();
|
2016-08-30 04:19:49 +00:00
|
|
|
}
|
2016-11-17 22:52:17 +00:00
|
|
|
|
|
|
|
int ItemFunctions::GetEquipmentItemCount(unsigned short pid, unsigned short slot) noexcept
|
2016-08-30 04:19:49 +00:00
|
|
|
{
|
2016-11-17 22:52:17 +00:00
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
2018-04-20 19:46:16 +00:00
|
|
|
return player->equipmentItems[slot].count;
|
2016-09-30 09:30:05 +00:00
|
|
|
}
|
|
|
|
|
2017-02-05 12:56:27 +00:00
|
|
|
int ItemFunctions::GetEquipmentItemCharge(unsigned short pid, unsigned short slot) 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
|
|
|
{
|
|
|
|
Player *player;
|
2016-11-17 22:52:17 +00:00
|
|
|
GET_PLAYER(pid, player, 0);
|
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
|
|
|
|
2018-04-20 19:46:16 +00:00
|
|
|
return player->equipmentItems[slot].charge;
|
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
|
|
|
}
|
|
|
|
|
2018-01-17 06:09:57 +00:00
|
|
|
double ItemFunctions::GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept
|
2017-12-23 11:16:38 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
2018-04-20 19:46:16 +00:00
|
|
|
return player->equipmentItems[slot].enchantmentCharge;
|
2017-12-23 11:16:38 +00:00
|
|
|
}
|
|
|
|
|
2018-07-24 17:14:51 +00:00
|
|
|
const char *ItemFunctions::GetInventoryItemRefId(unsigned short pid, unsigned int index) 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
|
|
|
{
|
|
|
|
Player *player;
|
2016-11-17 22:52:17 +00:00
|
|
|
GET_PLAYER(pid, player, "");
|
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
|
|
|
|
2019-10-26 11:01:08 +00:00
|
|
|
if (index >= player->inventoryChanges.items.size())
|
2016-11-17 22:52:17 +00:00
|
|
|
return "invalid";
|
|
|
|
|
2018-07-24 17:14:51 +00:00
|
|
|
return player->inventoryChanges.items.at(index).refId.c_str();
|
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
|
|
|
}
|
|
|
|
|
2018-07-24 17:14:51 +00:00
|
|
|
int ItemFunctions::GetInventoryItemCount(unsigned short pid, unsigned int index) 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
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
2018-07-24 17:14:51 +00:00
|
|
|
return player->inventoryChanges.items.at(index).count;
|
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
|
|
|
}
|
|
|
|
|
2018-07-24 17:14:51 +00:00
|
|
|
int ItemFunctions::GetInventoryItemCharge(unsigned short pid, unsigned int index) 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
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
2018-07-24 17:14:51 +00:00
|
|
|
return player->inventoryChanges.items.at(index).charge;
|
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
|
|
|
}
|
|
|
|
|
2018-07-24 17:14:51 +00:00
|
|
|
double ItemFunctions::GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int index) noexcept
|
2017-12-23 11:16:38 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
2018-07-24 17:14:51 +00:00
|
|
|
return player->inventoryChanges.items.at(index).enchantmentCharge;
|
2017-12-23 11:16:38 +00:00
|
|
|
}
|
|
|
|
|
2018-07-26 19:37:04 +00:00
|
|
|
const char *ItemFunctions::GetInventoryItemSoul(unsigned short pid, unsigned int index) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, "");
|
|
|
|
|
2019-10-26 11:01:08 +00:00
|
|
|
if (index >= player->inventoryChanges.items.size())
|
2018-07-26 19:37:04 +00:00
|
|
|
return "invalid";
|
|
|
|
|
|
|
|
return player->inventoryChanges.items.at(index).soul.c_str();
|
|
|
|
}
|
|
|
|
|
2018-08-09 15:25:20 +00:00
|
|
|
const char *ItemFunctions::GetUsedItemRefId(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, "");
|
|
|
|
|
|
|
|
return player->usedItem.refId.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
int ItemFunctions::GetUsedItemCount(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
|
|
|
return player->usedItem.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ItemFunctions::GetUsedItemCharge(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
|
|
|
return player->usedItem.charge;
|
|
|
|
}
|
|
|
|
|
|
|
|
double ItemFunctions::GetUsedItemEnchantmentCharge(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
|
|
|
return player->usedItem.enchantmentCharge;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *ItemFunctions::GetUsedItemSoul(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, "");
|
|
|
|
|
|
|
|
return player->usedItem.soul.c_str();
|
|
|
|
}
|
|
|
|
|
2016-11-16 17:28:22 +00:00
|
|
|
void ItemFunctions::SendEquipment(unsigned short pid) noexcept
|
2016-09-30 09:30:05 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
2018-07-07 15:29:31 +00:00
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_EQUIPMENT);
|
|
|
|
packet->setPlayer(player);
|
|
|
|
|
|
|
|
packet->Send(false);
|
|
|
|
packet->Send(true);
|
2018-04-20 19:46:16 +00:00
|
|
|
|
|
|
|
player->equipmentIndexChanges.clear();
|
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
|
|
|
|
2018-07-07 17:08:59 +00:00
|
|
|
void ItemFunctions::SendInventoryChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) 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
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
2017-01-20 04:00:14 +00:00
|
|
|
|
2018-07-07 15:29:31 +00:00
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_INVENTORY);
|
|
|
|
packet->setPlayer(player);
|
|
|
|
|
2018-07-07 17:08:59 +00:00
|
|
|
if (!skipAttachedPlayer)
|
2018-07-07 15:29:31 +00:00
|
|
|
packet->Send(false);
|
|
|
|
if (sendToOtherPlayers)
|
|
|
|
packet->Send(true);
|
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
|
|
|
}
|
2018-08-09 15:25:20 +00:00
|
|
|
|
|
|
|
void ItemFunctions::SendItemUse(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ITEM_USE);
|
|
|
|
packet->setPlayer(player);
|
|
|
|
|
|
|
|
packet->Send(false);
|
|
|
|
}
|
2018-10-01 15:29:50 +00:00
|
|
|
|
|
|
|
// All methods below are deprecated versions of methods from above
|
|
|
|
|
2018-10-02 23:26:47 +00:00
|
|
|
void ItemFunctions::InitializeInventoryChanges(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
ClearInventoryChanges(pid);
|
|
|
|
}
|
|
|
|
|
2018-10-01 15:29:50 +00:00
|
|
|
void ItemFunctions::AddItem(unsigned short pid, const char* refId, unsigned int count, int charge,
|
|
|
|
double enchantmentCharge, const char* soul) noexcept
|
|
|
|
{
|
|
|
|
AddItemChange(pid, refId, count, charge, enchantmentCharge, soul);
|
|
|
|
}
|