1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 21:53:51 +00:00

Issue #68: added dead flag to CreatureStats

This commit is contained in:
Marc Zinnschlag 2012-10-19 18:56:22 +02:00
parent a8f294c9ae
commit 7884a927c9
2 changed files with 29 additions and 5 deletions

View file

@ -10,7 +10,7 @@
namespace MWMechanics
{
CreatureStats::CreatureStats()
: mLevelHealthBonus(0.f)
: mLevel (0), mHello (0), mFight (0), mFlee (0), mAlarm (0), mLevelHealthBonus(0.f), mDead (false)
{
}
@ -156,17 +156,17 @@ namespace MWMechanics
void CreatureStats::setHealth(const DynamicStat<float> &value)
{
mDynamic[0] = value;
setDynamic (0, value);
}
void CreatureStats::setMagicka(const DynamicStat<float> &value)
{
mDynamic[1] = value;
setDynamic (1, value);
}
void CreatureStats::setFatigue(const DynamicStat<float> &value)
{
mDynamic[2] = value;
setDynamic (2, value);
}
void CreatureStats::setDynamic (int index, const DynamicStat<float> &value)
@ -175,6 +175,9 @@ namespace MWMechanics
throw std::runtime_error("dynamic stat index is out of range");
mDynamic[index] = value;
if (index==2 && mDynamic[index].getCurrent()<1)
mDead = true;
}
void CreatureStats::setLevel(int level)
@ -211,4 +214,21 @@ namespace MWMechanics
{
mAlarm = value;
}
bool CreatureStats::isDead() const
{
return mDead;
}
void CreatureStats::resurrect()
{
if (mDead)
{
if (mDynamic[0].getCurrent()<1)
mDynamic[0].setCurrent (1);
if (mDynamic[0].getCurrent()>=1)
mDead = false;
}
}
}

View file

@ -29,8 +29,8 @@ namespace MWMechanics
int mFlee;
int mAlarm;
AiSequence mAiSequence;
float mLevelHealthBonus;
bool mDead;
public:
CreatureStats();
@ -105,6 +105,10 @@ namespace MWMechanics
// small hack to allow the fact that Health permanently increases by 10% of endurance on each level up
void increaseLevelHealthBonus(float value);
float getLevelHealthBonus() const;
bool isDead() const;
void resurrect();
};
}