1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-28 19:21:04 +00:00

Make Set/Mod[DynamicStat] work with negative values as in vanilla

This commit is contained in:
Evil Eye 2022-02-10 20:31:27 +01:00
parent 5aef14eccd
commit 4e52c96cf5
2 changed files with 12 additions and 13 deletions

View File

@ -179,7 +179,7 @@ namespace MWGui
void StatsWindow::setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value) void StatsWindow::setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value)
{ {
int current = static_cast<int>(value.getCurrent()); int current = static_cast<int>(value.getCurrent());
int modified = static_cast<int>(value.getModified()); int modified = static_cast<int>(value.getModified(false));
// Fatigue can be negative // Fatigue can be negative
if (id != "FBar") if (id != "FBar")

View File

@ -218,8 +218,8 @@ namespace MWScript
MWMechanics::DynamicStat<float> stat (ptr.getClass().getCreatureStats (ptr) MWMechanics::DynamicStat<float> stat (ptr.getClass().getCreatureStats (ptr)
.getDynamic (mIndex)); .getDynamic (mIndex));
stat.setModified (value, 0); stat.setBase(value);
stat.setCurrent(value); stat.setCurrent(value, true);
ptr.getClass().getCreatureStats (ptr).setDynamic (mIndex, stat); ptr.getClass().getCreatureStats (ptr).setDynamic (mIndex, stat);
} }
@ -259,19 +259,18 @@ namespace MWScript
} }
} }
MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats (ptr); MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
Interpreter::Type_Float current = stats.getDynamic(mIndex).getCurrent(); MWMechanics::DynamicStat<float> stat = stats.getDynamic(mIndex);
MWMechanics::DynamicStat<float> stat (ptr.getClass().getCreatureStats (ptr) float current = stat.getCurrent();
.getDynamic (mIndex)); float base = diff + stat.getBase();
if(mIndex != 2)
base = std::max(base, 0.f);
stat.setBase(base);
stat.setCurrent(diff + current, true);
stat.setModified (diff + stat.getModified(), 0); stats.setDynamic (mIndex, stat);
stat.setCurrentModified (diff + stat.getCurrentModified());
stat.setCurrent (diff + current);
ptr.getClass().getCreatureStats (ptr).setDynamic (mIndex, stat);
} }
}; };