mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-12 13:13:27 +00:00
Fix price enchantment price calculation to use the correct item count
This commit is contained in:
parent
3a1ae9df58
commit
b082afd5b0
@ -62,6 +62,7 @@
|
|||||||
Bug #7415: Unbreakable lock discrepancies
|
Bug #7415: Unbreakable lock discrepancies
|
||||||
Bug #7428: AutoCalc flag is not used to calculate enchantment costs
|
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 #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
|
||||||
|
@ -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}");
|
||||||
|
@ -104,13 +104,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +277,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;
|
||||||
@ -289,7 +289,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,15 +390,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user