forked from teamnwah/openmw-tes3coop
Ignore item condition when determining value, except in trade (Fixes #1557)
This commit is contained in:
parent
869fa08a32
commit
4aab4e1c26
6 changed files with 20 additions and 7 deletions
|
@ -168,7 +168,7 @@ namespace MWClass
|
|||
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||
ptr.get<ESM::Armor>();
|
||||
|
||||
return ref->mBase->mData.mValue * (static_cast<float>(getItemHealth(ptr)) / getItemMaxHealth(ptr));
|
||||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
void Armor::registerSelf()
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace MWClass
|
|||
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
|
||||
ptr.get<ESM::Lockpick>();
|
||||
|
||||
return ref->mBase->mData.mValue * (static_cast<float>(getItemHealth(ptr)) / getItemMaxHealth(ptr));
|
||||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
void Lockpick::registerSelf()
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace MWClass
|
|||
MWWorld::LiveCellRef<ESM::Probe> *ref =
|
||||
ptr.get<ESM::Probe>();
|
||||
|
||||
return ref->mBase->mData.mValue * (static_cast<float>(getItemHealth(ptr)) / getItemMaxHealth(ptr));
|
||||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
void Probe::registerSelf()
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace MWClass
|
|||
MWWorld::LiveCellRef<ESM::Repair> *ref =
|
||||
ptr.get<ESM::Repair>();
|
||||
|
||||
return ref->mBase->mData.mValue * (static_cast<float>(getItemHealth(ptr)) / getItemMaxHealth(ptr));
|
||||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
void Repair::registerSelf()
|
||||
|
|
|
@ -154,7 +154,7 @@ namespace MWClass
|
|||
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||
ptr.get<ESM::Weapon>();
|
||||
|
||||
return ref->mBase->mData.mValue * (static_cast<float>(getItemHealth(ptr)) / getItemMaxHealth(ptr));
|
||||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
void Weapon::registerSelf()
|
||||
|
|
|
@ -23,6 +23,19 @@
|
|||
#include "countdialog.hpp"
|
||||
#include "dialogue.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
int getEffectiveValue (MWWorld::Ptr item, int count)
|
||||
{
|
||||
int price = item.getClass().getValue(item) * count;
|
||||
if (item.getClass().hasItemHealth(item))
|
||||
price *= (static_cast<float>(item.getClass().getItemHealth(item)) / item.getClass().getItemMaxHealth(item));
|
||||
return price;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
const float TradeWindow::sBalanceChangeInitialPause = 0.5;
|
||||
|
@ -465,7 +478,7 @@ namespace MWGui
|
|||
|
||||
void TradeWindow::sellToNpc(const MWWorld::Ptr& item, int count, bool boughtItem)
|
||||
{
|
||||
int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, item.getClass().getValue(item) * count, boughtItem);
|
||||
int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(item, count), boughtItem);
|
||||
|
||||
mCurrentBalance += diff;
|
||||
mCurrentMerchantOffer += diff;
|
||||
|
@ -475,7 +488,7 @@ namespace MWGui
|
|||
|
||||
void TradeWindow::buyFromNpc(const MWWorld::Ptr& item, int count, bool soldItem)
|
||||
{
|
||||
int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, item.getClass().getValue(item) * count, !soldItem);
|
||||
int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(item, count), !soldItem);
|
||||
|
||||
mCurrentBalance -= diff;
|
||||
mCurrentMerchantOffer -= diff;
|
||||
|
|
Loading…
Reference in a new issue