Fix price enchantment price calculation to use the correct item count

macos_ci_fix
Evil Eye 10 months ago
parent 3a1ae9df58
commit b082afd5b0

@ -62,6 +62,7 @@
Bug #7415: Unbreakable lock discrepancies
Bug #7428: AutoCalc flag is not used to calculate enchantment costs
Bug #7459: Icons get stacked on the cursor when picking up multiple items simultaneously
Bug #7472: Crash when enchanting last projectiles
Feature #3537: Shader-based water ripples
Feature #5492: Let rain and snow collide with statics
Feature #6447: Add LOD support to Object Paging

@ -357,9 +357,7 @@ namespace MWGui
}
}
int result = mEnchanting.create();
if (result == 1)
if (mEnchanting.create())
{
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("enchant success"));
MWBase::Environment::get().getWindowManager()->messageBox("#{sEnchantmentMenu12}");

@ -104,13 +104,13 @@ namespace MWMechanics
const ESM::RefId& newItemId
= mOldItemPtr.getClass().applyEnchantment(mOldItemPtr, enchantmentPtr->mId, getGemCharge(), mNewItemName);
if (!mSelfEnchanting)
payForEnchantment(count);
// Add the new item to player inventory and remove the old one
store.remove(mOldItemPtr, count);
store.add(newItemId, count);
if (!mSelfEnchanting)
payForEnchantment();
return true;
}
@ -277,7 +277,7 @@ namespace MWMechanics
return getEffectiveEnchantmentCastCost(static_cast<float>(baseCost), player);
}
int Enchanting::getEnchantPrice() const
int Enchanting::getEnchantPrice(int count) const
{
if (mEnchanter.isEmpty())
return 0;
@ -289,7 +289,7 @@ namespace MWMechanics
->mValue.getFloat();
int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(
mEnchanter, static_cast<int>(getEnchantPoints() * priceMultipler), true);
price *= getEnchantItemsCount() * getTypeMultiplier();
price *= count * getTypeMultiplier();
return std::max(1, price);
}
@ -390,15 +390,16 @@ namespace MWMechanics
return 1.f;
}
void Enchanting::payForEnchantment() const
void Enchanting::payForEnchantment(int count) const
{
const MWWorld::Ptr& player = getPlayer();
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
store.remove(MWWorld::ContainerStore::sGoldId, getEnchantPrice());
int price = getEnchantPrice(count);
store.remove(MWWorld::ContainerStore::sGoldId, price);
// add gold to NPC trading gold pool
CreatureStats& enchanterStats = mEnchanter.getClass().getCreatureStats(mEnchanter);
enchanterStats.setGoldPool(enchanterStats.getGoldPool() + getEnchantPrice());
enchanterStats.setGoldPool(enchanterStats.getGoldPool() + price);
}
}

@ -27,6 +27,11 @@ namespace MWMechanics
int mWeaponType;
const ESM::Enchantment* getRecord(const ESM::Enchantment& newEnchantment) const;
int getBaseCastCost() const; // To be saved in the enchantment's record
int getEnchantItemsCount() const;
float getTypeMultiplier() const;
void payForEnchantment(int count) const;
int getEnchantPrice(int count) const;
public:
Enchanting();
@ -42,18 +47,14 @@ namespace MWMechanics
void nextCastStyle(); // Set enchant type to next possible type (for mOldItemPtr object)
int getCastStyle() const;
float getEnchantPoints(bool precise = true) const;
int getBaseCastCost() const; // To be saved in the enchantment's record
int getEffectiveCastCost()
const; // Effective cost taking player Enchant skill into account, used for preview purposes in the UI
int getEnchantPrice() const;
int getEnchantPrice() const { return getEnchantPrice(getEnchantItemsCount()); }
int getMaxEnchantValue() const;
int getGemCharge() const;
int getEnchantChance() const;
int getEnchantItemsCount() const;
float getTypeMultiplier() const;
bool soulEmpty() const; // Return true if empty
bool itemEmpty() const; // Return true if empty
void payForEnchantment() const;
};
}
#endif

Loading…
Cancel
Save