OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
npcstats.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWMECHANICS_NPCSTATS_H
2 #define GAME_MWMECHANICS_NPCSTATS_H
3 
4 #include <map>
5 #include <set>
6 #include <string>
7 #include <vector>
8 
9 #include "creaturestats.hpp"
10 
11 namespace ESM
12 {
13  struct Class;
14  struct NpcStats;
15 }
16 
17 namespace MWMechanics
18 {
20 
21  class NpcStats : public CreatureStats
22  {
24  SkillValue mSkill[ESM::Skill::Length]; // SkillValue.mProgress used by the player only
25 
27  int mCrimeId;
28 
29  // ----- used by the player only, maybe should be moved at some point -------
30  int mBounty;
33  std::map<std::string, int> mFactionRank;
34  std::set<std::string> mExpelled;
35  std::map<std::string, int> mFactionReputation;
36  int mLevelProgress; // 0-10
37  std::vector<int> mSkillIncreases; // number of skill increases for each attribute (resets after leveling up)
38  std::vector<int> mSpecIncreases; // number of skill increases for each specialization (accumulates throughout the entire game)
39  std::set<std::string> mUsedIds;
40  // ---------------------------------------------------------------------------
41 
44 
46 
47  public:
48 
49  NpcStats();
50 
51  int getBaseDisposition() const;
52  void setBaseDisposition(int disposition);
53 
54  int getReputation() const;
55  void setReputation(int reputation);
56 
57  int getCrimeId() const;
58  void setCrimeId(int id);
59 
60  const SkillValue& getSkill (int index) const;
61  SkillValue& getSkill (int index);
62  void setSkill(int index, const SkillValue& value);
63 
64  const std::map<std::string, int>& getFactionRanks() const;
66  void raiseRank(const std::string& faction);
68  void lowerRank(const std::string& faction);
70  void joinFaction(const std::string& faction);
71 
72  const std::set<std::string>& getExpelled() const { return mExpelled; }
73  bool getExpelled(const std::string& factionID) const;
74  void expell(const std::string& factionID);
75  void clearExpelled(const std::string& factionID);
76 
77  bool isInFaction (const std::string& faction) const;
78 
79  float getSkillProgressRequirement (int skillIndex, const ESM::Class& class_) const;
80 
81  void useSkill (int skillIndex, const ESM::Class& class_, int usageType = -1, float extraFactor=1.f);
83 
84  void increaseSkill (int skillIndex, const ESM::Class& class_, bool preserveProgress);
85 
86  int getLevelProgress() const;
87 
88  int getLevelupAttributeMultiplier(int attribute) const;
89 
90  int getSkillIncreasesForSpecialization(int spec) const;
91 
92  void levelUp();
93 
94  void updateHealth();
97 
98  void flagAsUsed (const std::string& id);
100 
101  bool hasBeenUsed (const std::string& id) const;
103 
104  int getBounty() const;
105 
106  void setBounty (int bounty);
107 
108  int getFactionReputation (const std::string& faction) const;
109 
110  void setFactionReputation (const std::string& faction, int value);
111 
112  bool hasSkillsForRank (const std::string& factionId, int rank) const;
113 
114  bool isWerewolf() const;
115 
116  void setWerewolf(bool set);
117 
118  int getWerewolfKills() const;
119 
121  void addWerewolfKill();
122 
123  float getTimeToStartDrowning() const;
126  void setTimeToStartDrowning(float time);
127 
128  void writeState (ESM::NpcStats& state) const;
129 
130  void readState (const ESM::NpcStats& state);
131  };
132 }
133 
134 #endif
void setBaseDisposition(int disposition)
Definition: npcstats.cpp:45
int mReputation
Definition: npcstats.hpp:26
void addWerewolfKill()
Increments mWerewolfKills by 1.
Definition: npcstats.cpp:433
int getWerewolfKills() const
Definition: npcstats.cpp:428
std::set< std::string > mExpelled
Definition: npcstats.hpp:34
int getCrimeId() const
Definition: npcstats.cpp:367
void increaseSkill(int skillIndex, const ESM::Class &class_, bool preserveProgress)
Definition: npcstats.cpp:224
int getLevelupAttributeMultiplier(int attribute) const
Definition: npcstats.cpp:316
void setCrimeId(int id)
Definition: npcstats.cpp:372
NpcStats()
Definition: npcstats.cpp:26
int mDisposition
Definition: npcstats.hpp:23
void useSkill(int skillIndex, const ESM::Class &class_, int usageType=-1, float extraFactor=1.f)
Increase skill by usage.
Definition: npcstats.cpp:198
float mTimeToStartDrowning
Countdown to getting damage while underwater.
Definition: npcstats.hpp:43
Common creature stats.
Definition: creaturestats.hpp:25
float getTimeToStartDrowning() const
Definition: npcstats.cpp:438
void levelUp()
Definition: npcstats.cpp:287
Definition: loadskil.hpp:74
int getBaseDisposition() const
Definition: npcstats.cpp:40
void lowerRank(const std::string &faction)
Lower the rank in this faction by 1, if such a rank exists.
Definition: npcstats.cpp:92
void flagAsUsed(const std::string &id)
Definition: npcstats.cpp:337
std::map< std::string, int > mFactionReputation
Definition: npcstats.hpp:35
void setSkill(int index, const SkillValue &value)
Definition: npcstats.cpp:66
bool hasBeenUsed(const std::string &id) const
Definition: npcstats.cpp:342
void setWerewolf(bool set)
Definition: npcstats.cpp:416
std::map< std::string, int > mFactionRank
Used for the player only; NPCs have maximum one faction defined in their NPC record.
Definition: npcstats.hpp:33
const std::set< std::string > & getExpelled() const
Definition: npcstats.hpp:72
std::vector< int > mSkillIncreases
Definition: npcstats.hpp:37
void expell(const std::string &factionID)
Definition: npcstats.cpp:115
void writeState(ESM::NpcStats &state) const
Definition: npcstats.cpp:448
void joinFaction(const std::string &faction)
Join this faction, setting the initial rank to 0.
Definition: npcstats.cpp:102
bool isWerewolf() const
Definition: npcstats.cpp:411
void updateHealth()
Definition: npcstats.cpp:308
bool hasSkillsForRank(const std::string &factionId, int rank) const
Definition: npcstats.cpp:377
void readState(const ESM::NpcStats &state)
Definition: npcstats.cpp:488
int getSkillIncreasesForSpecialization(int spec) const
Definition: npcstats.cpp:332
bool isInFaction(const std::string &faction) const
Definition: npcstats.cpp:132
void setBounty(int bounty)
Definition: npcstats.cpp:352
const std::map< std::string, int > & getFactionRanks() const
Definition: npcstats.cpp:74
int getLevelProgress() const
Definition: npcstats.cpp:282
void clearExpelled(const std::string &factionID)
Definition: npcstats.cpp:127
Additional stats for NPCs.
Definition: npcstats.hpp:21
std::vector< int > mSpecIncreases
Definition: npcstats.hpp:38
int getReputation() const
Definition: npcstats.cpp:357
int mLevelProgress
Definition: npcstats.hpp:36
Definition: loadclas.hpp:18
Definition: stat.hpp:137
std::set< std::string > mUsedIds
Definition: npcstats.hpp:39
int getBounty() const
Definition: npcstats.cpp:347
void raiseRank(const std::string &faction)
Increase the rank in this faction by 1, if such a rank exists.
Definition: npcstats.cpp:79
SkillValue mSkill[ESM::Skill::Length]
Definition: npcstats.hpp:24
void setTimeToStartDrowning(float time)
Definition: npcstats.cpp:443
const SkillValue & getSkill(int index) const
Definition: npcstats.cpp:50
int getFactionReputation(const std::string &faction) const
Definition: npcstats.cpp:137
Definition: npcstats.hpp:17
void setReputation(int reputation)
Definition: npcstats.cpp:362
bool mIsWerewolf
Definition: npcstats.hpp:45
int mCrimeId
Definition: npcstats.hpp:27
int mWerewolfKills
Definition: npcstats.hpp:31
int mBounty
Definition: npcstats.hpp:30
void setFactionReputation(const std::string &faction, int value)
Definition: npcstats.cpp:147
float getSkillProgressRequirement(int skillIndex, const ESM::Class &class_) const
Definition: npcstats.cpp:152