OpenMW
|
00001 #ifndef GAME_MWMECHANICS_CREATURESTATS_H 00002 #define GAME_MWMECHANICS_CREATURESTATS_H 00003 00004 #include <set> 00005 #include <string> 00006 #include <stdexcept> 00007 00008 #include "stat.hpp" 00009 #include "magiceffects.hpp" 00010 #include "spells.hpp" 00011 #include "activespells.hpp" 00012 #include "aisequence.hpp" 00013 00014 namespace MWMechanics 00015 { 00019 class CreatureStats 00020 { 00021 Stat<int> mAttributes[8]; 00022 DynamicStat<float> mDynamic[3]; // health, magicka, fatigue 00023 int mLevel; 00024 Spells mSpells; 00025 ActiveSpells mActiveSpells; 00026 MagicEffects mMagicEffects; 00027 int mAiSettings[4]; 00028 AiSequence mAiSequence; 00029 float mLevelHealthBonus; 00030 bool mDead; 00031 bool mDied; 00032 int mFriendlyHits; 00033 bool mTalkedTo; 00034 bool mAlarmed; 00035 bool mAttacked; 00036 bool mHostile; 00037 bool mAttackingOrSpell;//for the player, this is true if the left mouse button is pressed, false if not. 00038 00039 float mFallHeight; 00040 00041 int mAttackType; 00042 00043 std::string mLastHitObject; // The last object to hit this actor 00044 00045 // Do we need to recalculate stats derived from attributes or other factors? 00046 bool mRecalcDynamicStats; 00047 00048 std::map<std::string, MWWorld::TimeStamp> mUsedPowers; 00049 00050 protected: 00051 bool mIsWerewolf; 00052 Stat<int> mWerewolfAttributes[8]; 00053 00054 public: 00055 CreatureStats(); 00056 00057 bool needToRecalcDynamicStats(); 00058 00059 void addToFallHeight(float height); 00060 00063 float land(); 00064 00065 bool canUsePower (const std::string& power) const; 00066 void usePower (const std::string& power); 00067 00068 const Stat<int> & getAttribute(int index) const; 00069 00070 const DynamicStat<float> & getHealth() const; 00071 00072 const DynamicStat<float> & getMagicka() const; 00073 00074 const DynamicStat<float> & getFatigue() const; 00075 00076 const DynamicStat<float> & getDynamic (int index) const; 00077 00078 const Spells & getSpells() const; 00079 00080 const ActiveSpells & getActiveSpells() const; 00081 00082 const MagicEffects & getMagicEffects() const; 00083 00084 bool getAttackingOrSpell() const; 00085 00086 int getLevel() const; 00087 00088 int getAiSetting (int index) const; 00090 00091 Spells & getSpells(); 00092 00093 ActiveSpells & getActiveSpells(); 00094 00095 MagicEffects & getMagicEffects(); 00096 00097 void setAttribute(int index, const Stat<int> &value); 00098 // Shortcut to set only the base 00099 void setAttribute(int index, int base); 00100 00101 void setHealth(const DynamicStat<float> &value); 00102 00103 void setMagicka(const DynamicStat<float> &value); 00104 00105 void setFatigue(const DynamicStat<float> &value); 00106 00107 void setDynamic (int index, const DynamicStat<float> &value); 00108 00109 void setSpells(const Spells &spells); 00110 00111 void setActiveSpells(const ActiveSpells &active); 00112 00113 void setMagicEffects(const MagicEffects &effects); 00114 00115 void setAttackingOrSpell(bool attackingOrSpell); 00116 00117 enum AttackType 00118 { 00119 AT_Slash, 00120 AT_Thrust, 00121 AT_Chop 00122 }; 00123 void setAttackType(int attackType) { mAttackType = attackType; } 00124 int getAttackType() { return mAttackType; } 00125 00126 void setLevel(int level); 00127 00128 void setAiSetting (int index, int value); 00130 00131 const AiSequence& getAiSequence() const; 00132 00133 AiSequence& getAiSequence(); 00134 00135 float getFatigueTerm() const; 00137 00138 float getLevelHealthBonus() const; 00139 00140 void levelUp(); 00141 00142 void updateHealth(); 00145 00146 bool isDead() const; 00147 00148 bool hasDied() const; 00149 00150 void clearHasDied(); 00151 00152 void resurrect(); 00153 00154 bool hasCommonDisease() const; 00155 00156 bool hasBlightDisease() const; 00157 00158 int getFriendlyHits() const; 00160 00161 void friendlyHit(); 00163 00164 bool hasTalkedToPlayer() const; 00166 00167 void talkedToPlayer(); 00168 00169 bool isAlarmed() const; 00170 00171 void setAlarmed (bool alarmed); 00172 00173 bool getAttacked() const; 00174 00175 void setAttacked (bool attacked); 00176 00177 bool isHostile() const; 00178 00179 void setHostile (bool hostile); 00180 00181 bool getCreatureTargetted() const; 00182 00183 float getEvasion() const; 00184 00185 void setLastHitObject(const std::string &objectid); 00186 const std::string &getLastHitObject() const; 00187 00188 // Note, this is just a cache to avoid checking the whole container store every frame TODO: Put it somewhere else? 00189 std::set<int> mBoundItems; 00190 // Same as above 00191 std::map<int, std::string> mSummonedCreatures; 00192 }; 00193 } 00194 00195 #endif