|
|
|
@ -235,28 +235,31 @@ namespace MWMechanics
|
|
|
|
|
class AttributeValue
|
|
|
|
|
{
|
|
|
|
|
int mBase;
|
|
|
|
|
int mFortified;
|
|
|
|
|
int mModifier; // net effect of Fortified, Drain & Absorb
|
|
|
|
|
int mModifier;
|
|
|
|
|
float mDamage; // needs to be float to allow continuous damage
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
AttributeValue() : mBase(0), mFortified(0), mModifier(0), mDamage(0) {}
|
|
|
|
|
AttributeValue() : mBase(0), mModifier(0), mDamage(0) {}
|
|
|
|
|
|
|
|
|
|
int getModified() const { return std::max(0, mBase - (int) mDamage + mModifier); }
|
|
|
|
|
int getBase() const { return mBase; }
|
|
|
|
|
int getModifier() const { return mModifier; }
|
|
|
|
|
|
|
|
|
|
void setBase(int base) { mBase = std::max(0, base); }
|
|
|
|
|
void setModifiers(float fortify, float drain, float absorb);
|
|
|
|
|
|
|
|
|
|
void damage(float damage) { mDamage = std::min(mDamage + damage, (float)(mBase + mFortified)); }
|
|
|
|
|
void setModifier(int mod) { mModifier = mod; }
|
|
|
|
|
|
|
|
|
|
// Maximum attribute damage is limited to the modified value.
|
|
|
|
|
// Note: I think MW applies damage directly to mModified, since you can also
|
|
|
|
|
// "restore" drained attributes. We need to rewrite the magic effect system to support this.
|
|
|
|
|
void damage(float damage) { mDamage += std::min(damage, (float)getModified()); }
|
|
|
|
|
void restore(float amount) { mDamage -= std::min(mDamage, amount); }
|
|
|
|
|
|
|
|
|
|
float getDamage() const { return mDamage; }
|
|
|
|
|
|
|
|
|
|
void writeState (ESM::StatState<int>& state) const;
|
|
|
|
|
|
|
|
|
|
void readState (const ESM::StatState<int>& state);
|
|
|
|
|
|
|
|
|
|
friend bool operator== (const AttributeValue& left, const AttributeValue& right);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class SkillValue : public AttributeValue
|
|
|
|
@ -270,16 +273,13 @@ namespace MWMechanics
|
|
|
|
|
void writeState (ESM::StatState<int>& state) const;
|
|
|
|
|
|
|
|
|
|
void readState (const ESM::StatState<int>& state);
|
|
|
|
|
|
|
|
|
|
friend bool operator== (const SkillValue& left, const SkillValue& right);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inline bool operator== (const AttributeValue& left, const AttributeValue& right)
|
|
|
|
|
{
|
|
|
|
|
return left.getBase() == right.getBase()
|
|
|
|
|
&& left.mFortified == right.mFortified
|
|
|
|
|
&& left.getModifier() == right.getModifier()
|
|
|
|
|
&& left.mDamage == right.mDamage;
|
|
|
|
|
&& left.getDamage() == right.getDamage();
|
|
|
|
|
}
|
|
|
|
|
inline bool operator!= (const AttributeValue& left, const AttributeValue& right)
|
|
|
|
|
{
|
|
|
|
@ -288,8 +288,9 @@ namespace MWMechanics
|
|
|
|
|
|
|
|
|
|
inline bool operator== (const SkillValue& left, const SkillValue& right)
|
|
|
|
|
{
|
|
|
|
|
// delegate to base class for most of the work
|
|
|
|
|
return (static_cast<const AttributeValue&>(left) == right)
|
|
|
|
|
return left.getBase() == right.getBase()
|
|
|
|
|
&& left.getModifier() == right.getModifier()
|
|
|
|
|
&& left.getDamage() == right.getDamage()
|
|
|
|
|
&& left.getProgress() == right.getProgress();
|
|
|
|
|
}
|
|
|
|
|
inline bool operator!= (const SkillValue& left, const SkillValue& right)
|
|
|
|
|