mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 16:20:21 +00:00
Adjust fix for maximum attribute damage limit
This commit is contained in:
parent
36141b0c53
commit
3d5c1d1190
@ -515,8 +515,8 @@ namespace MWMechanics
|
|||||||
for(int i = 0;i < ESM::Attribute::Length;++i)
|
for(int i = 0;i < ESM::Attribute::Length;++i)
|
||||||
{
|
{
|
||||||
AttributeValue stat = creatureStats.getAttribute(i);
|
AttributeValue stat = creatureStats.getAttribute(i);
|
||||||
stat.setModifiers(effects.get(EffectKey(ESM::MagicEffect::FortifyAttribute, i)).getMagnitude(),
|
stat.setModifier(effects.get(EffectKey(ESM::MagicEffect::FortifyAttribute, i)).getMagnitude() -
|
||||||
effects.get(EffectKey(ESM::MagicEffect::DrainAttribute, i)).getMagnitude(),
|
effects.get(EffectKey(ESM::MagicEffect::DrainAttribute, i)).getMagnitude() -
|
||||||
effects.get(EffectKey(ESM::MagicEffect::AbsorbAttribute, i)).getMagnitude());
|
effects.get(EffectKey(ESM::MagicEffect::AbsorbAttribute, i)).getMagnitude());
|
||||||
|
|
||||||
stat.damage(effects.get(EffectKey(ESM::MagicEffect::DamageAttribute, i)).getMagnitude() * duration);
|
stat.damage(effects.get(EffectKey(ESM::MagicEffect::DamageAttribute, i)).getMagnitude() * duration);
|
||||||
@ -782,8 +782,8 @@ namespace MWMechanics
|
|||||||
for(int i = 0;i < ESM::Skill::Length;++i)
|
for(int i = 0;i < ESM::Skill::Length;++i)
|
||||||
{
|
{
|
||||||
SkillValue& skill = npcStats.getSkill(i);
|
SkillValue& skill = npcStats.getSkill(i);
|
||||||
skill.setModifiers(effects.get(EffectKey(ESM::MagicEffect::FortifySkill, i)).getMagnitude(),
|
skill.setModifier(effects.get(EffectKey(ESM::MagicEffect::FortifySkill, i)).getMagnitude() -
|
||||||
effects.get(EffectKey(ESM::MagicEffect::DrainSkill, i)).getMagnitude(),
|
effects.get(EffectKey(ESM::MagicEffect::DrainSkill, i)).getMagnitude() -
|
||||||
effects.get(EffectKey(ESM::MagicEffect::AbsorbSkill, i)).getMagnitude());
|
effects.get(EffectKey(ESM::MagicEffect::AbsorbSkill, i)).getMagnitude());
|
||||||
|
|
||||||
skill.damage(effects.get(EffectKey(ESM::MagicEffect::DamageSkill, i)).getMagnitude() * duration);
|
skill.damage(effects.get(EffectKey(ESM::MagicEffect::DamageSkill, i)).getMagnitude() * duration);
|
||||||
|
@ -15,12 +15,6 @@ void MWMechanics::AttributeValue::readState (const ESM::StatState<int>& state)
|
|||||||
mDamage = state.mDamage;
|
mDamage = state.mDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWMechanics::AttributeValue::setModifiers(float fortify, float drain, float absorb)
|
|
||||||
{
|
|
||||||
mFortified = static_cast<int>(fortify);
|
|
||||||
mModifier = mFortified - static_cast<int>(drain + absorb);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MWMechanics::SkillValue::writeState (ESM::StatState<int>& state) const
|
void MWMechanics::SkillValue::writeState (ESM::StatState<int>& state) const
|
||||||
{
|
{
|
||||||
AttributeValue::writeState (state);
|
AttributeValue::writeState (state);
|
||||||
@ -31,4 +25,4 @@ void MWMechanics::SkillValue::readState (const ESM::StatState<int>& state)
|
|||||||
{
|
{
|
||||||
AttributeValue::readState (state);
|
AttributeValue::readState (state);
|
||||||
mProgress = state.mProgress;
|
mProgress = state.mProgress;
|
||||||
}
|
}
|
||||||
|
@ -235,28 +235,31 @@ namespace MWMechanics
|
|||||||
class AttributeValue
|
class AttributeValue
|
||||||
{
|
{
|
||||||
int mBase;
|
int mBase;
|
||||||
int mFortified;
|
int mModifier;
|
||||||
int mModifier; // net effect of Fortified, Drain & Absorb
|
|
||||||
float mDamage; // needs to be float to allow continuous damage
|
float mDamage; // needs to be float to allow continuous damage
|
||||||
|
|
||||||
public:
|
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 getModified() const { return std::max(0, mBase - (int) mDamage + mModifier); }
|
||||||
int getBase() const { return mBase; }
|
int getBase() const { return mBase; }
|
||||||
int getModifier() const { return mModifier; }
|
int getModifier() const { return mModifier; }
|
||||||
|
|
||||||
void setBase(int base) { mBase = std::max(0, base); }
|
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); }
|
void restore(float amount) { mDamage -= std::min(mDamage, amount); }
|
||||||
|
|
||||||
|
float getDamage() const { return mDamage; }
|
||||||
|
|
||||||
void writeState (ESM::StatState<int>& state) const;
|
void writeState (ESM::StatState<int>& state) const;
|
||||||
|
|
||||||
void readState (const ESM::StatState<int>& state);
|
void readState (const ESM::StatState<int>& state);
|
||||||
|
|
||||||
friend bool operator== (const AttributeValue& left, const AttributeValue& right);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SkillValue : public AttributeValue
|
class SkillValue : public AttributeValue
|
||||||
@ -270,16 +273,13 @@ namespace MWMechanics
|
|||||||
void writeState (ESM::StatState<int>& state) const;
|
void writeState (ESM::StatState<int>& state) const;
|
||||||
|
|
||||||
void readState (const ESM::StatState<int>& state);
|
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)
|
inline bool operator== (const AttributeValue& left, const AttributeValue& right)
|
||||||
{
|
{
|
||||||
return left.getBase() == right.getBase()
|
return left.getBase() == right.getBase()
|
||||||
&& left.mFortified == right.mFortified
|
|
||||||
&& left.getModifier() == right.getModifier()
|
&& left.getModifier() == right.getModifier()
|
||||||
&& left.mDamage == right.mDamage;
|
&& left.getDamage() == right.getDamage();
|
||||||
}
|
}
|
||||||
inline bool operator!= (const AttributeValue& left, const AttributeValue& right)
|
inline bool operator!= (const AttributeValue& left, const AttributeValue& right)
|
||||||
{
|
{
|
||||||
@ -288,8 +288,9 @@ namespace MWMechanics
|
|||||||
|
|
||||||
inline bool operator== (const SkillValue& left, const SkillValue& right)
|
inline bool operator== (const SkillValue& left, const SkillValue& right)
|
||||||
{
|
{
|
||||||
// delegate to base class for most of the work
|
return left.getBase() == right.getBase()
|
||||||
return (static_cast<const AttributeValue&>(left) == right)
|
&& left.getModifier() == right.getModifier()
|
||||||
|
&& left.getDamage() == right.getDamage()
|
||||||
&& left.getProgress() == right.getProgress();
|
&& left.getProgress() == right.getProgress();
|
||||||
}
|
}
|
||||||
inline bool operator!= (const SkillValue& left, const SkillValue& right)
|
inline bool operator!= (const SkillValue& left, const SkillValue& right)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user