1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 13:49:55 +00:00
openmw-tes3mp/apps/openmw/mwgui/companionitemmodel.cpp
2013-05-11 18:38:27 +02:00

34 lines
1 KiB
C++

#include "companionitemmodel.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwworld/class.hpp"
namespace MWGui
{
CompanionItemModel::CompanionItemModel(const MWWorld::Ptr &actor)
: InventoryItemModel(actor)
{
}
void CompanionItemModel::copyItem (const ItemStack& item, size_t count)
{
if (mActor.getTypeName() == typeid(ESM::NPC).name())
{
MWMechanics::NpcStats& stats = MWWorld::Class::get(mActor).getNpcStats(mActor);
stats.modifyProfit(MWWorld::Class::get(item.mBase).getValue(item.mBase) * count);
}
InventoryItemModel::copyItem(item, count);
}
void CompanionItemModel::removeItem (const ItemStack& item, size_t count)
{
if (mActor.getTypeName() == typeid(ESM::NPC).name())
{
MWMechanics::NpcStats& stats = MWWorld::Class::get(mActor).getNpcStats(mActor);
stats.modifyProfit(-MWWorld::Class::get(item.mBase).getValue(item.mBase) * count);
}
InventoryItemModel::removeItem(item, count);
}
}