1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-31 14:36:39 +00:00

Fix enchantment points value

This commit is contained in:
scrawl 2013-04-29 10:19:09 +02:00
parent 11a45b3034
commit 78596cad83
14 changed files with 22 additions and 21 deletions

View file

@ -375,12 +375,12 @@ namespace MWClass
return MWWorld::Ptr(&cell.mArmors.insert(*ref), &cell); return MWWorld::Ptr(&cell.mArmors.insert(*ref), &cell);
} }
short Armor::getEnchantmentPoints (const MWWorld::Ptr& ptr) const float Armor::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
{ {
MWWorld::LiveCellRef<ESM::Armor> *ref = MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>(); ptr.get<ESM::Armor>();
return ref->mBase->mData.mEnchant; return ref->mBase->mData.mEnchant/10.f;
} }
bool Armor::canSell (const MWWorld::Ptr& item, int npcServices) const bool Armor::canSell (const MWWorld::Ptr& item, int npcServices) const

View file

@ -77,7 +77,7 @@ namespace MWClass
virtual std::string getModel(const MWWorld::Ptr &ptr) const; virtual std::string getModel(const MWWorld::Ptr &ptr) const;
virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const; virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const; virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
}; };

View file

@ -176,12 +176,12 @@ namespace MWClass
return MWWorld::Ptr(&cell.mBooks.insert(*ref), &cell); return MWWorld::Ptr(&cell.mBooks.insert(*ref), &cell);
} }
short Book::getEnchantmentPoints (const MWWorld::Ptr& ptr) const float Book::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
{ {
MWWorld::LiveCellRef<ESM::Book> *ref = MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>(); ptr.get<ESM::Book>();
return ref->mBase->mData.mEnchant; return ref->mBase->mData.mEnchant/10.f;
} }
bool Book::canSell (const MWWorld::Ptr& item, int npcServices) const bool Book::canSell (const MWWorld::Ptr& item, int npcServices) const

View file

@ -58,7 +58,7 @@ namespace MWClass
virtual std::string getModel(const MWWorld::Ptr &ptr) const; virtual std::string getModel(const MWWorld::Ptr &ptr) const;
virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const; virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const; virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
}; };

View file

@ -295,12 +295,12 @@ namespace MWClass
return MWWorld::Ptr(&cell.mClothes.insert(*ref), &cell); return MWWorld::Ptr(&cell.mClothes.insert(*ref), &cell);
} }
short Clothing::getEnchantmentPoints (const MWWorld::Ptr& ptr) const float Clothing::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
{ {
MWWorld::LiveCellRef<ESM::Clothing> *ref = MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>(); ptr.get<ESM::Clothing>();
return ref->mBase->mData.mEnchant; return ref->mBase->mData.mEnchant/10.f;
} }
bool Clothing::canSell (const MWWorld::Ptr& item, int npcServices) const bool Clothing::canSell (const MWWorld::Ptr& item, int npcServices) const

View file

@ -71,7 +71,7 @@ namespace MWClass
virtual std::string getModel(const MWWorld::Ptr &ptr) const; virtual std::string getModel(const MWWorld::Ptr &ptr) const;
virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const; virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const; virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
}; };

View file

@ -428,12 +428,12 @@ namespace MWClass
return MWWorld::Ptr(&cell.mWeapons.insert(*ref), &cell); return MWWorld::Ptr(&cell.mWeapons.insert(*ref), &cell);
} }
short Weapon::getEnchantmentPoints (const MWWorld::Ptr& ptr) const float Weapon::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
{ {
MWWorld::LiveCellRef<ESM::Weapon> *ref = MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); ptr.get<ESM::Weapon>();
return ref->mBase->mData.mEnchant; return ref->mBase->mData.mEnchant/10.f;
} }
bool Weapon::canSell (const MWWorld::Ptr& item, int npcServices) const bool Weapon::canSell (const MWWorld::Ptr& item, int npcServices) const

View file

@ -79,7 +79,7 @@ namespace MWClass
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const; virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const; virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
}; };
} }

View file

@ -57,8 +57,9 @@ namespace MWGui
void EnchantingDialog::updateLabels() void EnchantingDialog::updateLabels()
{ {
mEnchantmentPoints->setCaption(boost::lexical_cast<std::string>(mEnchanting.getEnchantCost()) std::stringstream enchantCost;
+ " / " + boost::lexical_cast<std::string>(mEnchanting.getMaxEnchantValue())); enchantCost << std::setprecision(1) << std::fixed << mEnchanting.getEnchantCost();
mEnchantmentPoints->setCaption(enchantCost.str() + " / " + boost::lexical_cast<std::string>(mEnchanting.getMaxEnchantValue()));
mCharge->setCaption(boost::lexical_cast<std::string>(mEnchanting.getGemCharge())); mCharge->setCaption(boost::lexical_cast<std::string>(mEnchanting.getGemCharge()));

View file

@ -134,7 +134,7 @@ namespace MWMechanics
} }
} }
int Enchanting::getEnchantCost() const float Enchanting::getEnchantCost() const
{ {
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
float cost = 0; float cost = 0;
@ -193,7 +193,7 @@ namespace MWMechanics
return soul->mData.mSoul; return soul->mData.mSoul;
} }
int Enchanting::getMaxEnchantValue() const float Enchanting::getMaxEnchantValue() const
{ {
if (itemEmpty()) if (itemEmpty())
return 0; return 0;

View file

@ -35,9 +35,9 @@ namespace MWMechanics
bool create(); //Return true if created, false if failed. bool create(); //Return true if created, false if failed.
void nextEnchantType(); //Set enchant type to next possible type (for mOldItemPtr object) void nextEnchantType(); //Set enchant type to next possible type (for mOldItemPtr object)
int getEnchantType() const; int getEnchantType() const;
int getEnchantCost() const; float getEnchantCost() const;
int getEnchantPrice() const; int getEnchantPrice() const;
int getMaxEnchantValue() const; float getMaxEnchantValue() const;
int getGemCharge() const; int getGemCharge() const;
float getEnchantChance() const; float getEnchantChance() const;
bool soulEmpty() const; //Return true if empty bool soulEmpty() const; //Return true if empty

View file

@ -132,7 +132,7 @@ namespace MWWorld
return 0; return 0;
} }
short Class::getEnchantmentPoints (const MWWorld::Ptr& ptr) const float Class::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
{ {
throw std::runtime_error ("class does not support enchanting"); throw std::runtime_error ("class does not support enchanting");
} }

View file

@ -231,7 +231,7 @@ namespace MWWorld
///< @return the enchantment ID if the object is enchanted, otherwise an empty string ///< @return the enchantment ID if the object is enchanted, otherwise an empty string
/// (default implementation: return empty string) /// (default implementation: return empty string)
virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const; virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
///< @return the number of enchantment points available for possible enchanting ///< @return the number of enchantment points available for possible enchanting
virtual void adjustScale(const MWWorld::Ptr& ptr,float& scale) const; virtual void adjustScale(const MWWorld::Ptr& ptr,float& scale) const;

View file

@ -48,7 +48,7 @@ struct Weapon
short mType; short mType;
short mHealth; short mHealth;
float mSpeed, mReach; float mSpeed, mReach;
short mEnchant; // Enchantment points short mEnchant; // Enchantment points. The real value is mEnchant/10.f
unsigned char mChop[2], mSlash[2], mThrust[2]; // Min and max unsigned char mChop[2], mSlash[2], mThrust[2]; // Min and max
int mFlags; int mFlags;
}; // 32 bytes }; // 32 bytes