forked from mirror/openmw-tes3mp
Issue #68: simplified the dynamic stats interface
This commit is contained in:
parent
3f833af46a
commit
bdca5aff87
7 changed files with 78 additions and 64 deletions
|
@ -55,9 +55,9 @@ namespace MWClass
|
|||
data->mCreatureStats.getAttribute(5).set (ref->base->mData.mEndurance);
|
||||
data->mCreatureStats.getAttribute(6).set (ref->base->mData.mPersonality);
|
||||
data->mCreatureStats.getAttribute(7).set (ref->base->mData.mLuck);
|
||||
data->mCreatureStats.getHealth().set (ref->base->mData.mHealth);
|
||||
data->mCreatureStats.getMagicka().set (ref->base->mData.mMana);
|
||||
data->mCreatureStats.getFatigue().set (ref->base->mData.mFatigue);
|
||||
data->mCreatureStats.setHealth (ref->base->mData.mHealth);
|
||||
data->mCreatureStats.setMagicka (ref->base->mData.mMana);
|
||||
data->mCreatureStats.setFatigue (ref->base->mData.mFatigue);
|
||||
|
||||
data->mCreatureStats.setLevel(ref->base->mData.mLevel);
|
||||
|
||||
|
|
|
@ -89,9 +89,9 @@ namespace MWClass
|
|||
data->mCreatureStats.getAttribute(5).set (ref->base->mNpdt52.mEndurance);
|
||||
data->mCreatureStats.getAttribute(6).set (ref->base->mNpdt52.mPersonality);
|
||||
data->mCreatureStats.getAttribute(7).set (ref->base->mNpdt52.mLuck);
|
||||
data->mCreatureStats.getHealth().set (ref->base->mNpdt52.mHealth);
|
||||
data->mCreatureStats.getMagicka().set (ref->base->mNpdt52.mMana);
|
||||
data->mCreatureStats.getFatigue().set (ref->base->mNpdt52.mFatigue);
|
||||
data->mCreatureStats.setHealth (ref->base->mNpdt52.mHealth);
|
||||
data->mCreatureStats.setMagicka (ref->base->mNpdt52.mMana);
|
||||
data->mCreatureStats.setFatigue (ref->base->mNpdt52.mFatigue);
|
||||
|
||||
data->mCreatureStats.setLevel(ref->base->mNpdt52.mLevel);
|
||||
}
|
||||
|
|
|
@ -73,13 +73,17 @@ namespace MWMechanics
|
|||
double magickaFactor =
|
||||
creatureStats.getMagicEffects().get (EffectKey (84)).mMagnitude * 0.1 + 0.5;
|
||||
|
||||
creatureStats.getHealth().setBase(
|
||||
static_cast<int> (0.5 * (strength + endurance)) + creatureStats.getLevelHealthBonus ());
|
||||
DynamicStat<float> health = creatureStats.getHealth();
|
||||
health.setBase (static_cast<int> (0.5 * (strength + endurance)) + creatureStats.getLevelHealthBonus ());
|
||||
creatureStats.setHealth (health);
|
||||
|
||||
creatureStats.getMagicka().setBase(
|
||||
static_cast<int> (intelligence + magickaFactor * intelligence));
|
||||
|
||||
creatureStats.getFatigue().setBase(strength+willpower+agility+endurance);
|
||||
DynamicStat<float> magicka = creatureStats.getMagicka();
|
||||
magicka.setBase (static_cast<int> (intelligence + magickaFactor * intelligence));
|
||||
creatureStats.setMagicka (magicka);
|
||||
|
||||
DynamicStat<float> fatigue = creatureStats.getFatigue();
|
||||
fatigue.setBase (strength+willpower+agility+endurance);
|
||||
creatureStats.setFatigue (fatigue);
|
||||
}
|
||||
|
||||
void Actors::calculateRestoration (const MWWorld::Ptr& ptr, float duration)
|
||||
|
@ -92,8 +96,10 @@ namespace MWMechanics
|
|||
bool stunted = stats.getMagicEffects ().get(MWMechanics::EffectKey(136)).mMagnitude > 0;
|
||||
|
||||
int endurance = stats.getAttribute (ESM::Attribute::Endurance).getModified ();
|
||||
stats.getHealth().setCurrent(stats.getHealth ().getCurrent ()
|
||||
+ 0.1 * endurance);
|
||||
|
||||
DynamicStat<float> health = stats.getHealth();
|
||||
health.setCurrent (health.getCurrent() + 0.1 * endurance);
|
||||
stats.setHealth (health);
|
||||
|
||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||
|
||||
|
@ -109,13 +115,19 @@ namespace MWMechanics
|
|||
|
||||
float x = fFatigueReturnBase + fFatigueReturnMult * (1 - normalizedEncumbrance);
|
||||
x *= fEndFatigueMult * endurance;
|
||||
stats.getFatigue ().setCurrent (stats.getFatigue ().getCurrent () + 3600 * x);
|
||||
|
||||
|
||||
DynamicStat<float> fatigue = stats.getFatigue();
|
||||
fatigue.setCurrent (fatigue.getCurrent() + 3600 * x);
|
||||
stats.setFatigue (fatigue);
|
||||
|
||||
if (!stunted)
|
||||
{
|
||||
float fRestMagicMult = store.gameSettings.find("fRestMagicMult")->getFloat ();
|
||||
stats.getMagicka().setCurrent (stats.getMagicka ().getCurrent ()
|
||||
+ fRestMagicMult * stats.getAttribute(ESM::Attribute::Intelligence).getModified ());
|
||||
|
||||
DynamicStat<float> magicka = stats.getMagicka();
|
||||
magicka.setCurrent (magicka.getCurrent()
|
||||
+ fRestMagicMult * stats.getAttribute(ESM::Attribute::Intelligence).getModified());
|
||||
stats.setMagicka (magicka);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,14 +149,16 @@ namespace MWMechanics
|
|||
|
||||
// dynamic stats
|
||||
MagicEffects effects = creatureStats.getMagicEffects();
|
||||
creatureStats.getHealth().setModifier(
|
||||
effects.get(EffectKey(80)).mMagnitude - effects.get(EffectKey(18)).mMagnitude);
|
||||
|
||||
creatureStats.getMagicka().setModifier(
|
||||
effects.get(EffectKey(81)).mMagnitude - effects.get(EffectKey(19)).mMagnitude);
|
||||
|
||||
creatureStats.getFatigue().setModifier(
|
||||
effects.get(EffectKey(82)).mMagnitude - effects.get(EffectKey(20)).mMagnitude);
|
||||
|
||||
for (int i=0; i<3; ++i)
|
||||
{
|
||||
DynamicStat<float> stat = creatureStats.getDynamic (i);
|
||||
|
||||
stat.setModifier (
|
||||
effects.get (EffectKey(80+i)).mMagnitude - effects.get (EffectKey(18+i)).mMagnitude);
|
||||
|
||||
creatureStats.setDynamic (i, stat);
|
||||
}
|
||||
}
|
||||
|
||||
Actors::Actors() : mDuration (0) {}
|
||||
|
|
|
@ -118,22 +118,7 @@ namespace MWMechanics
|
|||
return mAttributes[index];
|
||||
}
|
||||
|
||||
DynamicStat<float> &CreatureStats::getHealth()
|
||||
{
|
||||
return mDynamic[0];
|
||||
}
|
||||
|
||||
DynamicStat<float> &CreatureStats::getMagicka()
|
||||
{
|
||||
return mDynamic[1];
|
||||
}
|
||||
|
||||
DynamicStat<float> &CreatureStats::getFatigue()
|
||||
{
|
||||
return mDynamic[2];
|
||||
}
|
||||
|
||||
DynamicStat<float> &CreatureStats::getDynamic(int index)
|
||||
const DynamicStat<float> &CreatureStats::getDynamic(int index) const
|
||||
{
|
||||
if (index < 0 || index > 2) {
|
||||
throw std::runtime_error("dynamic stat index is out of range");
|
||||
|
@ -184,6 +169,14 @@ namespace MWMechanics
|
|||
mDynamic[2] = value;
|
||||
}
|
||||
|
||||
void CreatureStats::setDynamic (int index, const DynamicStat<float> &value)
|
||||
{
|
||||
if (index < 0 || index > 2)
|
||||
throw std::runtime_error("dynamic stat index is out of range");
|
||||
|
||||
mDynamic[index] = value;
|
||||
}
|
||||
|
||||
void CreatureStats::setLevel(int level)
|
||||
{
|
||||
mLevel = level;
|
||||
|
|
|
@ -43,6 +43,8 @@ namespace MWMechanics
|
|||
|
||||
const DynamicStat<float> & getFatigue() const;
|
||||
|
||||
const DynamicStat<float> & getDynamic (int index) const;
|
||||
|
||||
const Spells & getSpells() const;
|
||||
|
||||
const ActiveSpells & getActiveSpells() const;
|
||||
|
@ -59,24 +61,14 @@ namespace MWMechanics
|
|||
|
||||
int getAlarm() const;
|
||||
|
||||
|
||||
Stat<int> & getAttribute(int index);
|
||||
|
||||
DynamicStat<float> & getHealth();
|
||||
|
||||
DynamicStat<float> & getMagicka();
|
||||
|
||||
DynamicStat<float> & getFatigue();
|
||||
|
||||
DynamicStat<float> & getDynamic(int index);
|
||||
|
||||
Spells & getSpells();
|
||||
|
||||
ActiveSpells & getActiveSpells();
|
||||
|
||||
MagicEffects & getMagicEffects();
|
||||
|
||||
|
||||
void setAttribute(int index, const Stat<int> &value);
|
||||
|
||||
void setHealth(const DynamicStat<float> &value);
|
||||
|
@ -85,6 +77,8 @@ namespace MWMechanics
|
|||
|
||||
void setFatigue(const DynamicStat<float> &value);
|
||||
|
||||
void setDynamic (int index, const DynamicStat<float> &value);
|
||||
|
||||
void setSpells(const Spells &spells);
|
||||
|
||||
void setActiveSpells(const ActiveSpells &active);
|
||||
|
|
|
@ -153,12 +153,14 @@ namespace MWMechanics
|
|||
// forced update and current value adjustments
|
||||
mActors.updateActor (ptr, 0);
|
||||
|
||||
creatureStats.getHealth().setCurrent(creatureStats.getHealth().getModified());
|
||||
creatureStats.getMagicka().setCurrent(creatureStats.getMagicka().getModified());
|
||||
creatureStats.getFatigue().setCurrent(creatureStats.getFatigue().getModified());
|
||||
for (int i=0; i<2; ++i)
|
||||
{
|
||||
DynamicStat<float> stat = creatureStats.getDynamic (i);
|
||||
stat.setCurrent (stat.getModified());
|
||||
creatureStats.setDynamic (i, stat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MechanicsManager::MechanicsManager()
|
||||
: mUpdatePlayer (true), mClassSelected (false),
|
||||
mRaceSelected (false)
|
||||
|
|
|
@ -188,10 +188,12 @@ namespace MWScript
|
|||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Class::get(ptr)
|
||||
.getCreatureStats(ptr)
|
||||
.getDynamic(mIndex)
|
||||
.setModified(value, 0);
|
||||
MWMechanics::DynamicStat<float> stat (MWWorld::Class::get (ptr).getCreatureStats (ptr)
|
||||
.getDynamic (mIndex));
|
||||
|
||||
stat.setModified (value, 0);
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setDynamic (mIndex, stat);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -215,10 +217,14 @@ namespace MWScript
|
|||
|
||||
Interpreter::Type_Integer current = stats.getDynamic(mIndex).getCurrent();
|
||||
|
||||
stats.getDynamic(mIndex).setModified(
|
||||
diff + stats.getDynamic(mIndex).getModified(), 0);
|
||||
MWMechanics::DynamicStat<float> stat (MWWorld::Class::get (ptr).getCreatureStats (ptr)
|
||||
.getDynamic (mIndex));
|
||||
|
||||
stats.getDynamic(mIndex).setCurrent(diff + current);
|
||||
stat.setModified (diff + stat.getModified(), 0);
|
||||
|
||||
stat.setCurrent (diff + current);
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setDynamic (mIndex, stat);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -242,7 +248,12 @@ namespace MWScript
|
|||
|
||||
Interpreter::Type_Integer current = stats.getDynamic(mIndex).getCurrent();
|
||||
|
||||
stats.getDynamic(mIndex).setCurrent (diff + current);
|
||||
MWMechanics::DynamicStat<float> stat (MWWorld::Class::get (ptr).getCreatureStats (ptr)
|
||||
.getDynamic (mIndex));
|
||||
|
||||
stat.setCurrent (diff + current);
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setDynamic (mIndex, stat);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue