openmw-tes3coop/apps/openmw-mp/Script/Functions/Items.cpp

71 lines
2 KiB
C++
Raw Normal View History

//
// Created by koncord on 02.03.16.
//
2016-08-30 04:19:49 +00:00
#include "Items.hpp"
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <components/misc/stringops.hpp>
2016-08-30 04:19:49 +00:00
void ItemFunctions::AddItem(unsigned short pid, const char* itemName, unsigned short count) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
2016-08-30 04:19:49 +00:00
LOG_MESSAGE(Log::LOG_WARN, "%s", "stub");
}
2016-08-30 04:19:49 +00:00
void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *itemName, unsigned short count) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
player->EquipedItem(slot)->refid = itemName;
player->EquipedItem(slot)->count = count;
}
2016-08-30 04:19:49 +00:00
void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept
{
2016-08-30 04:19:49 +00:00
LOG_MESSAGE(Log::LOG_WARN, "%s", "stub");
//ItemFunctions::EquipItem(pid, slot, "", 0);
}
2016-08-30 04:19:49 +00:00
const char *ItemFunctions::GetItemSlot(unsigned short pid, unsigned short slot) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->EquipedItem(slot)->refid.c_str();
}
2016-08-30 04:19:49 +00:00
bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* itemName)
{
Player *player;
GET_PLAYER(pid, player, false);
2016-08-17 15:04:35 +00:00
for (int slot = 0; slot < 27; slot ++)
if (Misc::StringUtils::ciEqual(player->EquipedItem(slot)->refid, itemName))
return true;
return false;
2016-08-30 04:19:49 +00:00
}
void ItemFunctions::RemoveItem(unsigned short pid, const char* itemName, unsigned short count) noexcept
{
LOG_MESSAGE(Log::LOG_WARN, "%s", "stub");
}
void ItemFunctions::GetItemCount(unsigned short pid, const char* itemName) noexcept
{
LOG_MESSAGE(Log::LOG_WARN, "%s", "stub");
}
void ItemFunctions::SendEquipment(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, false);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, true);
}