1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-20 19:41:36 +00:00

Merge branch 'theprojectileswereswords' into 'master'

Fix price enchantment price calculation to use the correct item count

Closes #7472

See merge request OpenMW/openmw!3227
This commit is contained in:
psi29a 2023-08-04 09:05:02 +00:00
commit 2a4440e5b1
4 changed files with 17 additions and 16 deletions

View file

@ -66,6 +66,7 @@
Bug #7428: AutoCalc flag is not used to calculate enchantment costs Bug #7428: AutoCalc flag is not used to calculate enchantment costs
Bug #7450: Evading obstacles does not work for actors missing certain animations Bug #7450: Evading obstacles does not work for actors missing certain animations
Bug #7459: Icons get stacked on the cursor when picking up multiple items simultaneously 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 #3537: Shader-based water ripples
Feature #5492: Let rain and snow collide with statics Feature #5492: Let rain and snow collide with statics
Feature #6447: Add LOD support to Object Paging Feature #6447: Add LOD support to Object Paging

View file

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

View file

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

View file

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