2012-07-22 18:29:54 +04:00
|
|
|
#include "creaturestats.hpp"
|
|
|
|
|
2012-09-13 10:45:32 +02:00
|
|
|
#include <algorithm>
|
2022-07-16 16:37:31 +02:00
|
|
|
#include <type_traits>
|
2012-09-13 10:45:32 +02:00
|
|
|
|
2022-01-22 15:58:41 +01:00
|
|
|
#include <components/esm3/creaturestats.hpp>
|
|
|
|
#include <components/esm3/esmreader.hpp>
|
|
|
|
#include <components/esm3/esmwriter.hpp>
|
2022-09-05 19:35:15 +02:00
|
|
|
#include <components/esm3/loadmgef.hpp>
|
2014-02-16 15:56:36 +01:00
|
|
|
|
2021-10-25 16:54:50 +02:00
|
|
|
#include "../mwworld/class.hpp"
|
2012-10-01 19:17:04 +04:00
|
|
|
#include "../mwworld/esmstore.hpp"
|
2018-09-15 19:38:21 +04:00
|
|
|
#include "../mwworld/player.hpp"
|
2012-09-13 10:45:32 +02:00
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
2012-07-22 18:29:54 +04:00
|
|
|
namespace MWMechanics
|
2012-11-15 20:00:27 +01:00
|
|
|
{
|
2014-04-29 15:27:49 +02:00
|
|
|
int CreatureStats::sActorId = 0;
|
|
|
|
|
2012-09-15 17:12:42 +02:00
|
|
|
CreatureStats::CreatureStats()
|
2022-09-22 21:26:05 +03:00
|
|
|
: mDrawState(DrawState::Nothing)
|
|
|
|
, mDead(false)
|
|
|
|
, mDeathAnimationFinished(false)
|
|
|
|
, mDied(false)
|
|
|
|
, mMurdered(false)
|
|
|
|
, mFriendlyHits(0)
|
|
|
|
, mTalkedTo(false)
|
|
|
|
, mAlarmed(false)
|
|
|
|
, mAttacked(false)
|
|
|
|
, mKnockdown(false)
|
|
|
|
, mKnockdownOneFrame(false)
|
|
|
|
, mKnockdownOverOneFrame(false)
|
|
|
|
, mHitRecovery(false)
|
|
|
|
, mBlock(false)
|
|
|
|
, mMovementFlags(0)
|
|
|
|
, mFallHeight(0)
|
|
|
|
, mLastRestock(0, 0)
|
|
|
|
, mGoldPool(0)
|
|
|
|
, mActorId(-1)
|
|
|
|
, mHitAttemptActorId(-1)
|
|
|
|
, mDeathAnimation(-1)
|
|
|
|
, mTimeOfDeath()
|
|
|
|
, mSideMovementAngle(0)
|
|
|
|
, mLevel(0)
|
2022-02-01 18:47:20 +00:00
|
|
|
, mAttackingOrSpell(false)
|
2012-09-15 17:12:42 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-04 13:32:35 +02:00
|
|
|
const AiSequence& CreatureStats::getAiSequence() const
|
|
|
|
{
|
|
|
|
return mAiSequence;
|
|
|
|
}
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2012-09-04 13:32:35 +02:00
|
|
|
AiSequence& CreatureStats::getAiSequence()
|
|
|
|
{
|
2012-11-15 20:00:27 +01:00
|
|
|
return mAiSequence;
|
2012-09-04 13:32:35 +02:00
|
|
|
}
|
2012-11-15 20:00:27 +01:00
|
|
|
|
|
|
|
float CreatureStats::getFatigueTerm() const
|
2012-09-13 10:45:32 +02:00
|
|
|
{
|
2015-03-08 17:42:07 +13:00
|
|
|
float max = getFatigue().getModified();
|
|
|
|
float current = getFatigue().getCurrent();
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
float normalised = std::floor(max) == 0 ? 1 : std::max(0.0f, current / max);
|
2012-09-13 10:45:32 +02:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
const MWWorld::Store<ESM::GameSetting>& gmst
|
2023-04-20 21:07:53 +02:00
|
|
|
= MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2018-08-29 18:38:12 +03:00
|
|
|
static const float fFatigueBase = gmst.find("fFatigueBase")->mValue.getFloat();
|
|
|
|
static const float fFatigueMult = gmst.find("fFatigueMult")->mValue.getFloat();
|
2015-11-27 02:10:10 +01:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
return fFatigueBase - fFatigueMult * (1 - normalised);
|
2012-09-13 10:45:32 +02:00
|
|
|
}
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
const AttributeValue& CreatureStats::getAttribute(int index) const
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
if (index < 0 || index > 7)
|
|
|
|
{
|
2012-09-13 10:52:34 +02:00
|
|
|
throw std::runtime_error("attribute index is out of range");
|
|
|
|
}
|
2015-06-21 17:27:52 +02:00
|
|
|
return mAttributes[index];
|
2012-09-13 10:52:34 +02:00
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
const DynamicStat<float>& CreatureStats::getHealth() const
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
|
|
|
return mDynamic[0];
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
const DynamicStat<float>& CreatureStats::getMagicka() const
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
|
|
|
return mDynamic[1];
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
const DynamicStat<float>& CreatureStats::getFatigue() const
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
|
|
|
return mDynamic[2];
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
const Spells& CreatureStats::getSpells() const
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
|
|
|
return mSpells;
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
const ActiveSpells& CreatureStats::getActiveSpells() const
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
|
|
|
return mActiveSpells;
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
const MagicEffects& CreatureStats::getMagicEffects() const
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
|
|
|
return mMagicEffects;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CreatureStats::getLevel() const
|
|
|
|
{
|
|
|
|
return mLevel;
|
|
|
|
}
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
Stat<int> CreatureStats::getAiSetting(AiSetting index) const
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
2022-07-16 16:37:31 +02:00
|
|
|
return mAiSettings[static_cast<std::underlying_type_t<AiSetting>>(index)];
|
2012-09-13 10:52:34 +02:00
|
|
|
}
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
const DynamicStat<float>& CreatureStats::getDynamic(int index) const
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
if (index < 0 || index > 2)
|
|
|
|
{
|
2012-09-13 10:52:34 +02:00
|
|
|
throw std::runtime_error("dynamic stat index is out of range");
|
|
|
|
}
|
|
|
|
return mDynamic[index];
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
Spells& CreatureStats::getSpells()
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
|
|
|
return mSpells;
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
ActiveSpells& CreatureStats::getActiveSpells()
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
|
|
|
return mActiveSpells;
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
MagicEffects& CreatureStats::getMagicEffects()
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
|
|
|
return mMagicEffects;
|
|
|
|
}
|
|
|
|
|
2018-12-23 15:18:33 +04:00
|
|
|
void CreatureStats::setAttribute(int index, float base)
|
2013-12-28 17:19:35 +01:00
|
|
|
{
|
2014-01-03 01:59:15 +01:00
|
|
|
AttributeValue current = getAttribute(index);
|
2013-12-28 17:19:35 +01:00
|
|
|
current.setBase(base);
|
|
|
|
setAttribute(index, current);
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::setAttribute(int index, const AttributeValue& value)
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
if (index < 0 || index > 7)
|
|
|
|
{
|
2012-09-13 10:52:34 +02:00
|
|
|
throw std::runtime_error("attribute index is out of range");
|
|
|
|
}
|
2013-12-28 17:19:35 +01:00
|
|
|
|
2015-06-21 17:27:52 +02:00
|
|
|
const AttributeValue& currentValue = mAttributes[index];
|
2013-12-28 17:19:35 +01:00
|
|
|
|
2014-01-03 01:59:15 +01:00
|
|
|
if (value != currentValue)
|
2013-12-28 17:19:35 +01:00
|
|
|
{
|
2015-06-21 17:27:52 +02:00
|
|
|
mAttributes[index] = value;
|
2014-12-02 01:19:35 +01:00
|
|
|
|
2014-11-28 14:45:35 +01:00
|
|
|
if (index == ESM::Attribute::Intelligence)
|
2021-10-25 16:54:50 +02:00
|
|
|
recalculateMagicka();
|
2022-09-22 21:26:05 +03:00
|
|
|
else if (index == ESM::Attribute::Strength || index == ESM::Attribute::Willpower
|
|
|
|
|| index == ESM::Attribute::Agility || index == ESM::Attribute::Endurance)
|
2014-11-28 14:45:35 +01:00
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
float strength = getAttribute(ESM::Attribute::Strength).getModified();
|
|
|
|
float willpower = getAttribute(ESM::Attribute::Willpower).getModified();
|
|
|
|
float agility = getAttribute(ESM::Attribute::Agility).getModified();
|
|
|
|
float endurance = getAttribute(ESM::Attribute::Endurance).getModified();
|
2014-11-28 14:45:35 +01:00
|
|
|
DynamicStat<float> fatigue = getFatigue();
|
2018-07-16 13:08:34 +04:00
|
|
|
float currentToBaseRatio = fatigue.getBase() > 0 ? (fatigue.getCurrent() / fatigue.getBase()) : 0;
|
2022-02-10 20:32:59 +01:00
|
|
|
fatigue.setBase(std::max(0.f, strength + willpower + agility + endurance));
|
2021-06-27 13:14:23 +02:00
|
|
|
fatigue.setCurrent(fatigue.getBase() * currentToBaseRatio, false, true);
|
2014-11-28 14:45:35 +01:00
|
|
|
setFatigue(fatigue);
|
|
|
|
}
|
2013-12-28 17:19:35 +01:00
|
|
|
}
|
2012-09-13 10:52:34 +02:00
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::setHealth(const DynamicStat<float>& value)
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
setDynamic(0, value);
|
2012-09-13 10:52:34 +02:00
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::setMagicka(const DynamicStat<float>& value)
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
setDynamic(1, value);
|
2012-09-13 10:52:34 +02:00
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::setFatigue(const DynamicStat<float>& value)
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
setDynamic(2, value);
|
2012-09-13 10:52:34 +02:00
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::setDynamic(int index, const DynamicStat<float>& value)
|
2012-10-19 13:10:06 +02:00
|
|
|
{
|
|
|
|
if (index < 0 || index > 2)
|
|
|
|
throw std::runtime_error("dynamic stat index is out of range");
|
2012-10-23 13:54:36 +02:00
|
|
|
|
2012-10-19 13:10:06 +02:00
|
|
|
mDynamic[index] = value;
|
2012-10-23 13:54:36 +02:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
if (index == 0 && mDynamic[index].getCurrent() < 1)
|
2013-03-18 10:46:45 +01:00
|
|
|
{
|
2016-02-27 12:53:07 +01:00
|
|
|
if (!mDead)
|
|
|
|
mTimeOfDeath = MWBase::Environment::get().getWorld()->getTimeStamp();
|
|
|
|
|
2012-10-19 18:56:22 +02:00
|
|
|
mDead = true;
|
2015-02-01 22:04:49 +01:00
|
|
|
|
2014-11-27 20:44:41 +01:00
|
|
|
mDynamic[index].setCurrent(0);
|
2013-03-18 10:46:45 +01:00
|
|
|
}
|
2012-10-19 13:10:06 +02:00
|
|
|
}
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2012-09-13 10:52:34 +02:00
|
|
|
void CreatureStats::setLevel(int level)
|
|
|
|
{
|
|
|
|
mLevel = level;
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::modifyMagicEffects(const MagicEffects& effects)
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
2023-05-23 19:06:08 +02:00
|
|
|
bool recalc = effects.getOrDefault(ESM::MagicEffect::FortifyMaximumMagicka).getModifier()
|
|
|
|
!= mMagicEffects.getOrDefault(ESM::MagicEffect::FortifyMaximumMagicka).getModifier();
|
2014-08-17 03:57:26 +02:00
|
|
|
mMagicEffects.setModifiers(effects);
|
2022-09-22 21:26:05 +03:00
|
|
|
if (recalc)
|
2021-10-25 16:54:50 +02:00
|
|
|
recalculateMagicka();
|
2012-09-13 10:52:34 +02:00
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::setAiSetting(AiSetting index, Stat<int> value)
|
2012-09-13 10:52:34 +02:00
|
|
|
{
|
2022-07-16 16:37:31 +02:00
|
|
|
mAiSettings[static_cast<std::underlying_type_t<AiSetting>>(index)] = value;
|
2012-09-13 10:52:34 +02:00
|
|
|
}
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::setAiSetting(AiSetting index, int base)
|
2014-01-05 01:34:35 +01:00
|
|
|
{
|
2014-01-08 01:24:06 +01:00
|
|
|
Stat<int> stat = getAiSetting(index);
|
|
|
|
stat.setBase(base);
|
2014-01-05 01:34:35 +01:00
|
|
|
setAiSetting(index, stat);
|
|
|
|
}
|
|
|
|
|
2015-08-20 18:12:37 +12:00
|
|
|
bool CreatureStats::isParalyzed() const
|
|
|
|
{
|
2023-05-23 19:06:08 +02:00
|
|
|
return mMagicEffects.getOrDefault(ESM::MagicEffect::Paralyze).getMagnitude() > 0;
|
2015-08-20 18:12:37 +12:00
|
|
|
}
|
|
|
|
|
2012-10-19 18:56:22 +02:00
|
|
|
bool CreatureStats::isDead() const
|
|
|
|
{
|
|
|
|
return mDead;
|
|
|
|
}
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2016-06-12 00:04:50 +02:00
|
|
|
bool CreatureStats::isDeathAnimationFinished() const
|
|
|
|
{
|
|
|
|
return mDeathAnimationFinished;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreatureStats::setDeathAnimationFinished(bool finished)
|
|
|
|
{
|
|
|
|
mDeathAnimationFinished = finished;
|
|
|
|
}
|
|
|
|
|
2014-09-05 17:17:45 +02:00
|
|
|
void CreatureStats::notifyDied()
|
|
|
|
{
|
|
|
|
mDied = true;
|
|
|
|
}
|
|
|
|
|
2013-03-18 10:46:45 +01:00
|
|
|
bool CreatureStats::hasDied() const
|
|
|
|
{
|
|
|
|
return mDied;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreatureStats::clearHasDied()
|
|
|
|
{
|
|
|
|
mDied = false;
|
|
|
|
}
|
|
|
|
|
2014-06-17 03:54:41 +02:00
|
|
|
bool CreatureStats::hasBeenMurdered() const
|
|
|
|
{
|
|
|
|
return mMurdered;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreatureStats::notifyMurder()
|
|
|
|
{
|
|
|
|
mMurdered = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreatureStats::clearHasBeenMurdered()
|
|
|
|
{
|
|
|
|
mMurdered = false;
|
|
|
|
}
|
|
|
|
|
2012-10-19 18:56:22 +02:00
|
|
|
void CreatureStats::resurrect()
|
|
|
|
{
|
|
|
|
if (mDead)
|
|
|
|
{
|
2022-02-10 20:32:59 +01:00
|
|
|
mDynamic[0].setCurrent(mDynamic[0].getBase());
|
2015-12-09 01:52:20 +01:00
|
|
|
mDead = false;
|
2016-06-12 00:04:50 +02:00
|
|
|
mDeathAnimationFinished = false;
|
2012-10-19 18:56:22 +02:00
|
|
|
}
|
|
|
|
}
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2012-11-09 18:16:29 +01:00
|
|
|
bool CreatureStats::hasCommonDisease() const
|
|
|
|
{
|
|
|
|
return mSpells.hasCommonDisease();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CreatureStats::hasBlightDisease() const
|
|
|
|
{
|
|
|
|
return mSpells.hasBlightDisease();
|
|
|
|
}
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2012-11-10 13:20:41 +01:00
|
|
|
int CreatureStats::getFriendlyHits() const
|
|
|
|
{
|
|
|
|
return mFriendlyHits;
|
|
|
|
}
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2012-11-10 13:20:41 +01:00
|
|
|
void CreatureStats::friendlyHit()
|
|
|
|
{
|
|
|
|
++mFriendlyHits;
|
|
|
|
}
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2012-11-10 13:20:41 +01:00
|
|
|
bool CreatureStats::hasTalkedToPlayer() const
|
|
|
|
{
|
|
|
|
return mTalkedTo;
|
|
|
|
}
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2012-11-10 13:20:41 +01:00
|
|
|
void CreatureStats::talkedToPlayer()
|
|
|
|
{
|
|
|
|
mTalkedTo = true;
|
|
|
|
}
|
2012-11-15 20:00:27 +01:00
|
|
|
|
|
|
|
bool CreatureStats::isAlarmed() const
|
|
|
|
{
|
|
|
|
return mAlarmed;
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::setAlarmed(bool alarmed)
|
2012-11-15 20:00:27 +01:00
|
|
|
{
|
|
|
|
mAlarmed = alarmed;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CreatureStats::getAttacked() const
|
|
|
|
{
|
|
|
|
return mAttacked;
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::setAttacked(bool attacked)
|
2012-11-15 20:00:27 +01:00
|
|
|
{
|
|
|
|
mAttacked = attacked;
|
|
|
|
}
|
|
|
|
|
2013-07-31 12:25:14 -07:00
|
|
|
float CreatureStats::getEvasion() const
|
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
float evasion = (getAttribute(ESM::Attribute::Agility).getModified() / 5.0f)
|
|
|
|
+ (getAttribute(ESM::Attribute::Luck).getModified() / 10.0f);
|
2013-07-31 12:25:14 -07:00
|
|
|
evasion *= getFatigueTerm();
|
2023-05-23 19:06:08 +02:00
|
|
|
evasion += std::min(100.f, mMagicEffects.getOrDefault(ESM::MagicEffect::Sanctuary).getMagnitude());
|
2013-07-31 12:25:14 -07:00
|
|
|
|
|
|
|
return evasion;
|
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void CreatureStats::setLastHitObject(const ESM::RefId& objectid)
|
2013-07-26 08:08:52 -07:00
|
|
|
{
|
|
|
|
mLastHitObject = objectid;
|
|
|
|
}
|
|
|
|
|
2022-03-28 11:40:46 +00:00
|
|
|
void CreatureStats::clearLastHitObject()
|
|
|
|
{
|
2023-02-17 19:20:29 +01:00
|
|
|
mLastHitObject = ESM::RefId();
|
2022-03-28 11:40:46 +00:00
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& CreatureStats::getLastHitObject() const
|
2013-07-26 08:08:52 -07:00
|
|
|
{
|
|
|
|
return mLastHitObject;
|
|
|
|
}
|
2013-11-10 15:40:31 +01:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void CreatureStats::setLastHitAttemptObject(const ESM::RefId& objectid)
|
2014-12-11 22:25:41 +01:00
|
|
|
{
|
|
|
|
mLastHitAttemptObject = objectid;
|
|
|
|
}
|
|
|
|
|
2022-04-30 18:32:10 +02:00
|
|
|
void CreatureStats::clearLastHitAttemptObject()
|
|
|
|
{
|
2023-02-17 19:20:29 +01:00
|
|
|
mLastHitAttemptObject = ESM::RefId();
|
2022-04-30 18:32:10 +02:00
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& CreatureStats::getLastHitAttemptObject() const
|
2014-12-11 22:25:41 +01:00
|
|
|
{
|
|
|
|
return mLastHitAttemptObject;
|
|
|
|
}
|
|
|
|
|
2017-02-06 21:32:36 +09:00
|
|
|
void CreatureStats::setHitAttemptActorId(int actorId)
|
2017-02-02 02:15:10 +09:00
|
|
|
{
|
2017-02-06 21:32:36 +09:00
|
|
|
mHitAttemptActorId = actorId;
|
2017-02-02 02:15:10 +09:00
|
|
|
}
|
|
|
|
|
2017-02-06 21:32:36 +09:00
|
|
|
int CreatureStats::getHitAttemptActorId() const
|
2017-02-02 02:15:10 +09:00
|
|
|
{
|
2017-02-06 21:32:36 +09:00
|
|
|
return mHitAttemptActorId;
|
2017-02-02 02:15:10 +09:00
|
|
|
}
|
|
|
|
|
2013-12-27 21:21:18 +01:00
|
|
|
void CreatureStats::addToFallHeight(float height)
|
|
|
|
{
|
|
|
|
mFallHeight += height;
|
|
|
|
}
|
|
|
|
|
2019-12-12 15:20:23 +03:00
|
|
|
float CreatureStats::getFallHeight() const
|
|
|
|
{
|
|
|
|
return mFallHeight;
|
|
|
|
}
|
|
|
|
|
2018-09-15 19:38:21 +04:00
|
|
|
float CreatureStats::land(bool isPlayer)
|
2013-12-27 21:21:18 +01:00
|
|
|
{
|
2018-09-15 19:38:21 +04:00
|
|
|
if (isPlayer)
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setJumping(false);
|
|
|
|
|
2013-12-27 21:21:18 +01:00
|
|
|
float height = mFallHeight;
|
|
|
|
mFallHeight = 0;
|
|
|
|
return height;
|
|
|
|
}
|
2013-12-28 17:19:35 +01:00
|
|
|
|
2021-10-25 16:54:50 +02:00
|
|
|
void CreatureStats::recalculateMagicka()
|
2013-12-28 17:19:35 +01:00
|
|
|
{
|
2021-10-25 16:54:50 +02:00
|
|
|
auto world = MWBase::Environment::get().getWorld();
|
|
|
|
float intelligence = getAttribute(ESM::Attribute::Intelligence).getModified();
|
2014-01-13 01:42:19 +01:00
|
|
|
|
2021-10-25 16:54:50 +02:00
|
|
|
float base = 1.f;
|
|
|
|
const auto& player = world->getPlayerPtr();
|
|
|
|
if (this == &player.getClass().getCreatureStats(player))
|
|
|
|
base = world->getStore().get<ESM::GameSetting>().find("fPCbaseMagickaMult")->mValue.getFloat();
|
|
|
|
else
|
|
|
|
base = world->getStore().get<ESM::GameSetting>().find("fNPCbaseMagickaMult")->mValue.getFloat();
|
|
|
|
|
2023-05-23 19:06:08 +02:00
|
|
|
double magickaFactor = base
|
|
|
|
+ mMagicEffects.getOrDefault(EffectKey(ESM::MagicEffect::FortifyMaximumMagicka)).getMagnitude() * 0.1;
|
2021-10-25 16:54:50 +02:00
|
|
|
|
|
|
|
DynamicStat<float> magicka = getMagicka();
|
|
|
|
float currentToBaseRatio = magicka.getBase() > 0 ? magicka.getCurrent() / magicka.getBase() : 0;
|
2022-02-10 20:32:59 +01:00
|
|
|
magicka.setBase(magickaFactor * intelligence);
|
2021-10-25 16:54:50 +02:00
|
|
|
magicka.setCurrent(magicka.getBase() * currentToBaseRatio, false, true);
|
|
|
|
setMagicka(magicka);
|
2014-09-18 03:47:45 +02:00
|
|
|
}
|
|
|
|
|
2014-01-13 01:42:19 +01:00
|
|
|
void CreatureStats::setKnockedDown(bool value)
|
|
|
|
{
|
|
|
|
mKnockdown = value;
|
2022-09-22 21:26:05 +03:00
|
|
|
if (!value) // Resets the "OverOneFrame" flag
|
2014-04-27 20:54:22 -04:00
|
|
|
setKnockedDownOverOneFrame(false);
|
2014-01-13 01:42:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CreatureStats::getKnockedDown() const
|
|
|
|
{
|
|
|
|
return mKnockdown;
|
|
|
|
}
|
|
|
|
|
2014-04-27 20:54:22 -04:00
|
|
|
void CreatureStats::setKnockedDownOneFrame(bool value)
|
|
|
|
{
|
|
|
|
mKnockdownOneFrame = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CreatureStats::getKnockedDownOneFrame() const
|
|
|
|
{
|
|
|
|
return mKnockdownOneFrame;
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::setKnockedDownOverOneFrame(bool value)
|
|
|
|
{
|
2014-04-27 20:54:22 -04:00
|
|
|
mKnockdownOverOneFrame = value;
|
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
bool CreatureStats::getKnockedDownOverOneFrame() const
|
|
|
|
{
|
2014-04-27 20:54:22 -04:00
|
|
|
return mKnockdownOverOneFrame;
|
|
|
|
}
|
|
|
|
|
2014-01-13 01:42:19 +01:00
|
|
|
void CreatureStats::setHitRecovery(bool value)
|
|
|
|
{
|
|
|
|
mHitRecovery = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CreatureStats::getHitRecovery() const
|
|
|
|
{
|
|
|
|
return mHitRecovery;
|
|
|
|
}
|
2014-01-15 07:47:21 +01:00
|
|
|
|
2014-01-21 01:01:21 +01:00
|
|
|
void CreatureStats::setBlock(bool value)
|
|
|
|
{
|
|
|
|
mBlock = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CreatureStats::getBlock() const
|
|
|
|
{
|
|
|
|
return mBlock;
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
bool CreatureStats::getMovementFlag(Flag flag) const
|
2014-01-15 07:47:21 +01:00
|
|
|
{
|
2015-03-06 23:19:57 +13:00
|
|
|
return (mMovementFlags & flag) != 0;
|
2014-01-15 07:47:21 +01:00
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::setMovementFlag(Flag flag, bool state)
|
2014-01-15 07:47:21 +01:00
|
|
|
{
|
|
|
|
if (state)
|
|
|
|
mMovementFlags |= flag;
|
|
|
|
else
|
|
|
|
mMovementFlags &= ~flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CreatureStats::getStance(Stance flag) const
|
|
|
|
{
|
|
|
|
switch (flag)
|
|
|
|
{
|
|
|
|
case Stance_Run:
|
2022-09-22 21:26:05 +03:00
|
|
|
return getMovementFlag(Flag_Run) || getMovementFlag(Flag_ForceRun);
|
2014-01-15 07:47:21 +01:00
|
|
|
case Stance_Sneak:
|
2022-09-22 21:26:05 +03:00
|
|
|
return getMovementFlag(Flag_Sneak) || getMovementFlag(Flag_ForceSneak);
|
2014-04-04 08:10:35 -04:00
|
|
|
default:
|
|
|
|
return false;
|
2014-01-15 07:47:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-17 19:36:48 +03:00
|
|
|
DrawState CreatureStats::getDrawState() const
|
2014-01-19 09:43:41 +01:00
|
|
|
{
|
|
|
|
return mDrawState;
|
|
|
|
}
|
|
|
|
|
2022-07-17 19:36:48 +03:00
|
|
|
void CreatureStats::setDrawState(DrawState state)
|
2014-01-19 09:43:41 +01:00
|
|
|
{
|
|
|
|
mDrawState = state;
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::writeState(ESM::CreatureStats& state) const
|
2014-02-16 15:56:36 +01:00
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
for (int i = 0; i < ESM::Attribute::Length; ++i)
|
|
|
|
mAttributes[i].writeState(state.mAttributes[i]);
|
2014-02-16 15:56:36 +01:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
mDynamic[i].writeState(state.mDynamic[i]);
|
2014-05-12 21:04:02 +02:00
|
|
|
|
2014-05-17 14:30:31 +02:00
|
|
|
state.mTradeTime = mLastRestock.toEsm();
|
2014-05-12 21:04:02 +02:00
|
|
|
state.mGoldPool = mGoldPool;
|
|
|
|
|
|
|
|
state.mDead = mDead;
|
2016-06-12 00:04:50 +02:00
|
|
|
state.mDeathAnimationFinished = mDeathAnimationFinished;
|
2014-05-12 21:04:02 +02:00
|
|
|
state.mDied = mDied;
|
2014-06-17 03:54:41 +02:00
|
|
|
state.mMurdered = mMurdered;
|
2015-01-30 22:22:47 +01:00
|
|
|
// The vanilla engine does not store friendly hits in the save file. Since there's no other mechanism
|
|
|
|
// that ever resets the friendly hits (at least not to my knowledge) this should be regarded a feature
|
|
|
|
// rather than a bug.
|
2022-09-22 21:26:05 +03:00
|
|
|
// state.mFriendlyHits = mFriendlyHits;
|
2014-05-12 21:04:02 +02:00
|
|
|
state.mTalkedTo = mTalkedTo;
|
|
|
|
state.mAlarmed = mAlarmed;
|
|
|
|
state.mAttacked = mAttacked;
|
|
|
|
// TODO: rewrite. does this really need 3 separate bools?
|
|
|
|
state.mKnockdown = mKnockdown;
|
|
|
|
state.mKnockdownOneFrame = mKnockdownOneFrame;
|
|
|
|
state.mKnockdownOverOneFrame = mKnockdownOverOneFrame;
|
|
|
|
state.mHitRecovery = mHitRecovery;
|
|
|
|
state.mBlock = mBlock;
|
|
|
|
state.mMovementFlags = mMovementFlags;
|
2014-05-14 22:16:39 +02:00
|
|
|
state.mFallHeight = mFallHeight; // TODO: vertical velocity (move from PhysicActor to CreatureStats?)
|
2014-05-12 21:04:02 +02:00
|
|
|
state.mLastHitObject = mLastHitObject;
|
2014-12-11 22:25:41 +01:00
|
|
|
state.mLastHitAttemptObject = mLastHitAttemptObject;
|
2021-10-31 11:57:33 +01:00
|
|
|
state.mRecalcDynamicStats = false;
|
2022-07-17 19:36:48 +03:00
|
|
|
state.mDrawState = static_cast<int>(mDrawState);
|
2014-05-12 21:04:02 +02:00
|
|
|
state.mLevel = mLevel;
|
2014-05-14 09:47:49 +02:00
|
|
|
state.mActorId = mActorId;
|
2014-05-26 19:56:32 +02:00
|
|
|
state.mDeathAnimation = mDeathAnimation;
|
2016-02-27 12:53:07 +01:00
|
|
|
state.mTimeOfDeath = mTimeOfDeath.toEsm();
|
2022-09-22 21:26:05 +03:00
|
|
|
// state.mHitAttemptActorId = mHitAttemptActorId;
|
2014-05-12 21:04:02 +02:00
|
|
|
|
|
|
|
mSpells.writeState(state.mSpells);
|
2014-05-14 22:16:39 +02:00
|
|
|
mActiveSpells.writeState(state.mActiveSpells);
|
2014-06-12 23:27:04 +02:00
|
|
|
mAiSequence.writeState(state.mAiSequence);
|
2014-08-17 04:58:58 +02:00
|
|
|
mMagicEffects.writeState(state.mMagicEffects);
|
2014-06-15 21:19:37 +02:00
|
|
|
|
2021-08-27 20:07:50 +02:00
|
|
|
state.mSummonedCreatures = mSummonedCreatures;
|
2014-06-15 21:19:37 +02:00
|
|
|
state.mSummonGraveyard = mSummonGraveyard;
|
|
|
|
|
|
|
|
state.mHasAiSettings = true;
|
2022-09-22 21:26:05 +03:00
|
|
|
for (int i = 0; i < 4; ++i)
|
|
|
|
mAiSettings[i].writeState(state.mAiSettings[i]);
|
2021-12-24 23:17:50 +01:00
|
|
|
|
|
|
|
state.mMissingACDT = false;
|
2014-02-16 15:56:36 +01:00
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::readState(const ESM::CreatureStats& state)
|
2014-02-16 15:56:36 +01:00
|
|
|
{
|
2021-12-24 23:17:50 +01:00
|
|
|
if (!state.mMissingACDT)
|
2021-08-17 12:29:28 +10:00
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
for (int i = 0; i < ESM::Attribute::Length; ++i)
|
|
|
|
mAttributes[i].readState(state.mAttributes[i]);
|
2014-02-16 15:56:36 +01:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
mDynamic[i].readState(state.mDynamic[i]);
|
2021-08-17 12:29:28 +10:00
|
|
|
|
|
|
|
mGoldPool = state.mGoldPool;
|
|
|
|
mTalkedTo = state.mTalkedTo;
|
|
|
|
mAttacked = state.mAttacked;
|
|
|
|
}
|
2014-05-12 21:04:02 +02:00
|
|
|
|
2014-05-17 14:30:31 +02:00
|
|
|
mLastRestock = MWWorld::TimeStamp(state.mTradeTime);
|
2014-05-12 21:04:02 +02:00
|
|
|
|
|
|
|
mDead = state.mDead;
|
2016-06-12 00:04:50 +02:00
|
|
|
mDeathAnimationFinished = state.mDeathAnimationFinished;
|
2014-05-12 21:04:02 +02:00
|
|
|
mDied = state.mDied;
|
2014-06-17 03:54:41 +02:00
|
|
|
mMurdered = state.mMurdered;
|
2014-05-12 21:04:02 +02:00
|
|
|
mAlarmed = state.mAlarmed;
|
|
|
|
// TODO: rewrite. does this really need 3 separate bools?
|
|
|
|
mKnockdown = state.mKnockdown;
|
|
|
|
mKnockdownOneFrame = state.mKnockdownOneFrame;
|
|
|
|
mKnockdownOverOneFrame = state.mKnockdownOverOneFrame;
|
|
|
|
mHitRecovery = state.mHitRecovery;
|
|
|
|
mBlock = state.mBlock;
|
|
|
|
mMovementFlags = state.mMovementFlags;
|
|
|
|
mFallHeight = state.mFallHeight;
|
|
|
|
mLastHitObject = state.mLastHitObject;
|
2014-12-11 22:25:41 +01:00
|
|
|
mLastHitAttemptObject = state.mLastHitAttemptObject;
|
2022-07-17 19:36:48 +03:00
|
|
|
mDrawState = DrawState(state.mDrawState);
|
2014-05-12 21:04:02 +02:00
|
|
|
mLevel = state.mLevel;
|
2014-05-14 09:47:49 +02:00
|
|
|
mActorId = state.mActorId;
|
2014-05-26 19:56:32 +02:00
|
|
|
mDeathAnimation = state.mDeathAnimation;
|
2016-02-27 12:53:07 +01:00
|
|
|
mTimeOfDeath = MWWorld::TimeStamp(state.mTimeOfDeath);
|
2022-09-22 21:26:05 +03:00
|
|
|
// mHitAttemptActorId = state.mHitAttemptActorId;
|
2014-05-12 21:04:02 +02:00
|
|
|
|
2019-09-30 20:27:42 +04:00
|
|
|
mSpells.readState(state.mSpells, this);
|
2014-05-14 22:16:39 +02:00
|
|
|
mActiveSpells.readState(state.mActiveSpells);
|
2014-06-12 23:27:04 +02:00
|
|
|
mAiSequence.readState(state.mAiSequence);
|
2014-08-17 04:58:58 +02:00
|
|
|
mMagicEffects.readState(state.mMagicEffects);
|
2014-06-15 21:19:37 +02:00
|
|
|
|
2021-08-27 20:07:50 +02:00
|
|
|
mSummonedCreatures = state.mSummonedCreatures;
|
2014-06-15 21:19:37 +02:00
|
|
|
mSummonGraveyard = state.mSummonGraveyard;
|
|
|
|
|
|
|
|
if (state.mHasAiSettings)
|
2022-09-22 21:26:05 +03:00
|
|
|
for (int i = 0; i < 4; ++i)
|
2014-06-15 21:19:37 +02:00
|
|
|
mAiSettings[i].readState(state.mAiSettings[i]);
|
2022-09-22 21:26:05 +03:00
|
|
|
if (state.mRecalcDynamicStats)
|
2021-10-25 16:54:50 +02:00
|
|
|
recalculateMagicka();
|
2014-02-16 15:56:36 +01:00
|
|
|
}
|
2014-03-27 01:23:56 -04:00
|
|
|
|
2014-05-17 14:30:31 +02:00
|
|
|
void CreatureStats::setLastRestockTime(MWWorld::TimeStamp tradeTime)
|
2014-03-27 01:23:56 -04:00
|
|
|
{
|
2014-05-17 14:30:31 +02:00
|
|
|
mLastRestock = tradeTime;
|
2014-03-27 01:23:56 -04:00
|
|
|
}
|
|
|
|
|
2014-05-17 14:30:31 +02:00
|
|
|
MWWorld::TimeStamp CreatureStats::getLastRestockTime() const
|
2014-03-27 01:23:56 -04:00
|
|
|
{
|
2014-05-17 14:30:31 +02:00
|
|
|
return mLastRestock;
|
2014-03-27 01:23:56 -04:00
|
|
|
}
|
|
|
|
|
2014-04-27 20:54:22 -04:00
|
|
|
void CreatureStats::setGoldPool(int pool)
|
2014-03-27 01:23:56 -04:00
|
|
|
{
|
|
|
|
mGoldPool = pool;
|
|
|
|
}
|
2014-04-27 20:54:22 -04:00
|
|
|
int CreatureStats::getGoldPool() const
|
2014-03-27 01:23:56 -04:00
|
|
|
{
|
|
|
|
return mGoldPool;
|
|
|
|
}
|
2014-04-29 15:27:49 +02:00
|
|
|
|
|
|
|
int CreatureStats::getActorId()
|
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
if (mActorId == -1)
|
2014-04-29 15:27:49 +02:00
|
|
|
mActorId = sActorId++;
|
|
|
|
|
|
|
|
return mActorId;
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
bool CreatureStats::matchesActorId(int id) const
|
2014-04-29 15:27:49 +02:00
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
return mActorId != -1 && id == mActorId;
|
2014-04-29 15:27:49 +02:00
|
|
|
}
|
2014-04-29 19:56:33 +02:00
|
|
|
|
|
|
|
void CreatureStats::cleanup()
|
|
|
|
{
|
|
|
|
sActorId = 0;
|
|
|
|
}
|
2014-05-14 09:47:49 +02:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::writeActorIdCounter(ESM::ESMWriter& esm)
|
2014-05-14 09:47:49 +02:00
|
|
|
{
|
|
|
|
esm.startRecord(ESM::REC_ACTC);
|
|
|
|
esm.writeHNT("COUN", sActorId);
|
|
|
|
esm.endRecord(ESM::REC_ACTC);
|
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
void CreatureStats::readActorIdCounter(ESM::ESMReader& esm)
|
2014-05-14 09:47:49 +02:00
|
|
|
{
|
|
|
|
esm.getHNT(sActorId, "COUN");
|
|
|
|
}
|
2014-05-26 19:56:32 +02:00
|
|
|
|
2016-05-19 21:37:24 +02:00
|
|
|
signed char CreatureStats::getDeathAnimation() const
|
2014-05-26 19:56:32 +02:00
|
|
|
{
|
|
|
|
return mDeathAnimation;
|
|
|
|
}
|
|
|
|
|
2016-05-19 21:37:24 +02:00
|
|
|
void CreatureStats::setDeathAnimation(signed char index)
|
2014-05-26 19:56:32 +02:00
|
|
|
{
|
|
|
|
mDeathAnimation = index;
|
|
|
|
}
|
2014-06-15 21:19:37 +02:00
|
|
|
|
2016-02-27 12:53:07 +01:00
|
|
|
MWWorld::TimeStamp CreatureStats::getTimeOfDeath() const
|
|
|
|
{
|
|
|
|
return mTimeOfDeath;
|
|
|
|
}
|
|
|
|
|
2021-08-27 20:07:50 +02:00
|
|
|
std::multimap<int, int>& CreatureStats::getSummonedCreatureMap()
|
2014-06-15 21:19:37 +02:00
|
|
|
{
|
|
|
|
return mSummonedCreatures;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<int>& CreatureStats::getSummonedCreatureGraveyard()
|
|
|
|
{
|
|
|
|
return mSummonGraveyard;
|
|
|
|
}
|
2012-07-22 18:29:54 +04:00
|
|
|
}
|