1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-28 14:39:41 +00:00

Make offered price caps barter-specific (bug #5028)

This commit is contained in:
Capostrophic 2019-05-09 20:42:22 +03:00
parent e0af6532ec
commit 9d191055bf
3 changed files with 15 additions and 4 deletions

View file

@ -87,6 +87,7 @@
Bug #5001: Possible data race in the Animation::setAlpha() Bug #5001: Possible data race in the Animation::setAlpha()
Bug #5004: Werewolves shield their eyes during storm Bug #5004: Werewolves shield their eyes during storm
Bug #5018: Spell tooltips don't support purely negative magnitudes Bug #5018: Spell tooltips don't support purely negative magnitudes
Bug #5028: Offered price caps are not trading-specific
Feature #1774: Handle AvoidNode Feature #1774: Handle AvoidNode
Feature #2229: Improve pathfinding AI Feature #2229: Improve pathfinding AI
Feature #3025: Analogue gamepad movement controls Feature #3025: Analogue gamepad movement controls

View file

@ -468,16 +468,26 @@ namespace MWGui
int merchantOffer = 0; int merchantOffer = 0;
// The offered price must be capped at 75% of the base price to avoid exploits
// connected to buying and selling the same item.
// This value has been determined by researching the limitations of the vanilla formula
// and may not be sufficient if getBarterOffer behavior has been changed.
std::vector<ItemStack> playerBorrowed = playerTradeModel->getItemsBorrowedToUs(); std::vector<ItemStack> playerBorrowed = playerTradeModel->getItemsBorrowedToUs();
for (const ItemStack& itemStack : playerBorrowed) for (const ItemStack& itemStack : playerBorrowed)
{ {
merchantOffer -= MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(itemStack.mBase, itemStack.mCount), true); const int basePrice = getEffectiveValue(itemStack.mBase, itemStack.mCount);
const int cap = static_cast<int>(std::max(1.f, 0.75f * basePrice)); // Minimum buying price -- 75% of the base
const int buyingPrice = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, basePrice, true);
merchantOffer -= std::max(cap, buyingPrice);
} }
std::vector<ItemStack> merchantBorrowed = mTradeModel->getItemsBorrowedToUs(); std::vector<ItemStack> merchantBorrowed = mTradeModel->getItemsBorrowedToUs();
for (const ItemStack& itemStack : merchantBorrowed) for (const ItemStack& itemStack : merchantBorrowed)
{ {
merchantOffer += MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(itemStack.mBase, itemStack.mCount), false); const int basePrice = getEffectiveValue(itemStack.mBase, itemStack.mCount);
const int cap = static_cast<int>(std::min(1.f, 0.75f * basePrice)); // Maximum selling price -- 75% of the base
const int sellingPrice = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, basePrice, false);
merchantOffer += std::min(cap, sellingPrice);
} }
int diff = merchantOffer - mCurrentMerchantOffer; int diff = merchantOffer - mCurrentMerchantOffer;

View file

@ -676,8 +676,8 @@ namespace MWMechanics
float f = std::min(0.2f * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f); float f = std::min(0.2f * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f);
float pcTerm = (clampedDisposition - 50 + a + b + c) * playerStats.getFatigueTerm(); float pcTerm = (clampedDisposition - 50 + a + b + c) * playerStats.getFatigueTerm();
float npcTerm = (d + e + f) * sellerStats.getFatigueTerm(); float npcTerm = (d + e + f) * sellerStats.getFatigueTerm();
float buyTerm = 0.01f * std::max(75.f, (100 - 0.5f * (pcTerm - npcTerm))); float buyTerm = 0.01f * (100 - 0.5f * (pcTerm - npcTerm));
float sellTerm = 0.01f * std::min(75.f, (50 - 0.5f * (npcTerm - pcTerm))); float sellTerm = 0.01f * (50 - 0.5f * (npcTerm - pcTerm));
int offerPrice = int(basePrice * (buying ? buyTerm : sellTerm)); int offerPrice = int(basePrice * (buying ? buyTerm : sellTerm));
return std::max(1, offerPrice); return std::max(1, offerPrice);
} }