openmw-tes3coop/apps/openmw/mwmechanics/creaturestats.hpp

201 lines
5 KiB
C++
Raw Normal View History

#ifndef GAME_MWMECHANICS_CREATURESTATS_H
#define GAME_MWMECHANICS_CREATURESTATS_H
#include <set>
#include <string>
2012-07-22 14:29:54 +00:00
#include <stdexcept>
#include "stat.hpp"
#include "magiceffects.hpp"
#include "spells.hpp"
#include "activespells.hpp"
#include "aisequence.hpp"
namespace MWMechanics
{
2012-07-22 14:29:54 +00:00
/// \brief Common creature stats
///
///
class CreatureStats
{
AttributeValue mAttributes[8];
2012-09-15 15:12:42 +00:00
DynamicStat<float> mDynamic[3]; // health, magicka, fatigue
2010-09-15 13:32:35 +00:00
int mLevel;
Spells mSpells;
ActiveSpells mActiveSpells;
MagicEffects mMagicEffects;
Stat<int> mAiSettings[4];
AiSequence mAiSequence;
2012-09-15 15:12:42 +00:00
float mLevelHealthBonus;
bool mDead;
2013-03-18 09:46:45 +00:00
bool mDied;
int mFriendlyHits;
bool mTalkedTo;
bool mAlarmed;
bool mAttacked;
bool mHostile;
2013-07-13 21:24:52 +00:00
bool mAttackingOrSpell;//for the player, this is true if the left mouse button is pressed, false if not.
2012-09-15 15:12:42 +00:00
float mFallHeight;
int mAttackType;
2012-09-15 15:12:42 +00:00
2013-07-26 15:08:52 +00:00
std::string mLastHitObject; // The last object to hit this actor
// Do we need to recalculate stats derived from attributes or other factors?
bool mRecalcDynamicStats;
std::map<std::string, MWWorld::TimeStamp> mUsedPowers;
2013-08-09 12:14:58 +00:00
protected:
bool mIsWerewolf;
AttributeValue mWerewolfAttributes[8];
2013-08-09 12:14:58 +00:00
2012-07-22 14:29:54 +00:00
public:
2012-09-15 15:12:42 +00:00
CreatureStats();
2012-07-22 14:29:54 +00:00
bool needToRecalcDynamicStats();
void addToFallHeight(float height);
/// Reset the fall height
/// @return total fall height
float land();
2013-11-10 22:21:26 +00:00
bool canUsePower (const std::string& power) const;
void usePower (const std::string& power);
const AttributeValue & getAttribute(int index) const;
2012-07-22 14:29:54 +00:00
2012-09-15 15:12:42 +00:00
const DynamicStat<float> & getHealth() const;
2012-07-22 14:29:54 +00:00
2012-09-15 15:12:42 +00:00
const DynamicStat<float> & getMagicka() const;
2012-07-22 14:29:54 +00:00
2012-09-15 15:12:42 +00:00
const DynamicStat<float> & getFatigue() const;
2012-07-22 14:29:54 +00:00
const DynamicStat<float> & getDynamic (int index) const;
2012-07-22 14:29:54 +00:00
const Spells & getSpells() const;
const ActiveSpells & getActiveSpells() const;
const MagicEffects & getMagicEffects() const;
2013-08-04 02:29:44 +00:00
bool getAttackingOrSpell() const;
2013-07-13 21:24:52 +00:00
2012-07-22 14:29:54 +00:00
int getLevel() const;
Spells & getSpells();
ActiveSpells & getActiveSpells();
MagicEffects & getMagicEffects();
void setAttribute(int index, const AttributeValue &value);
// Shortcut to set only the base
void setAttribute(int index, int base);
2012-07-22 14:29:54 +00:00
2012-09-15 15:12:42 +00:00
void setHealth(const DynamicStat<float> &value);
2012-07-22 14:29:54 +00:00
2012-09-15 15:12:42 +00:00
void setMagicka(const DynamicStat<float> &value);
2012-07-22 14:29:54 +00:00
2012-09-15 15:12:42 +00:00
void setFatigue(const DynamicStat<float> &value);
2012-07-22 14:29:54 +00:00
void setDynamic (int index, const DynamicStat<float> &value);
2012-07-22 14:29:54 +00:00
void setSpells(const Spells &spells);
void setActiveSpells(const ActiveSpells &active);
void setMagicEffects(const MagicEffects &effects);
2013-08-04 02:29:44 +00:00
void setAttackingOrSpell(bool attackingOrSpell);
2013-07-13 21:24:52 +00:00
enum AttackType
{
AT_Slash,
AT_Thrust,
AT_Chop
};
void setAttackType(int attackType) { mAttackType = attackType; }
int getAttackType() { return mAttackType; }
2012-07-22 14:29:54 +00:00
void setLevel(int level);
enum AiSetting
{
AI_Hello,
AI_Fight,
AI_Flee,
AI_Alarm
};
void setAiSetting (AiSetting index, Stat<int> value);
void setAiSetting (AiSetting index, int base);
Stat<int> getAiSetting (AiSetting index) const;
const AiSequence& getAiSequence() const;
AiSequence& getAiSequence();
float getFatigueTerm() const;
///< Return effective fatigue
2012-09-15 15:12:42 +00:00
float getLevelHealthBonus() const;
void levelUp();
void updateHealth();
///< Calculate health based on endurance and strength.
/// Called at character creation and at level up.
bool isDead() const;
2013-03-18 09:46:45 +00:00
bool hasDied() const;
void clearHasDied();
void resurrect();
2012-11-09 17:16:29 +00:00
bool hasCommonDisease() const;
bool hasBlightDisease() const;
int getFriendlyHits() const;
///< Number of friendly hits received.
void friendlyHit();
///< Increase number of friendly hits by one.
bool hasTalkedToPlayer() const;
///< Has this creature talked with the player before?
void talkedToPlayer();
bool isAlarmed() const;
void setAlarmed (bool alarmed);
bool getAttacked() const;
void setAttacked (bool attacked);
bool isHostile() const;
void setHostile (bool hostile);
bool getCreatureTargetted() const;
2013-07-26 15:08:52 +00:00
2013-07-31 19:25:14 +00:00
float getEvasion() const;
2013-07-26 15:08:52 +00:00
void setLastHitObject(const std::string &objectid);
const std::string &getLastHitObject() const;
// Note, this is just a cache to avoid checking the whole container store every frame TODO: Put it somewhere else?
std::set<int> mBoundItems;
// Same as above
std::map<int, std::string> mSummonedCreatures;
};
}
#endif