OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
activespells.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWMECHANICS_ACTIVESPELLS_H
2 #define GAME_MWMECHANICS_ACTIVESPELLS_H
3 
4 #include <map>
5 #include <vector>
6 #include <string>
7 
10 
11 #include "../mwworld/timestamp.hpp"
12 
13 #include "magiceffects.hpp"
14 
15 namespace MWMechanics
16 {
22  {
23  public:
24 
26 
28  {
29  std::vector<ActiveEffect> mEffects;
31  std::string mDisplayName;
32 
33  // The caster that inflicted this spell on us
35  };
36 
37  typedef std::multimap<std::string, ActiveSpellParams > TContainer;
38  typedef TContainer::const_iterator TIterator;
39 
40  void readState (const ESM::ActiveSpells& state);
41  void writeState (ESM::ActiveSpells& state) const;
42 
43  TIterator begin() const;
44 
45  TIterator end() const;
46 
47  private:
48 
51  mutable bool mSpellsChanged;
53 
54  void update() const;
55 
56  void rebuildEffects() const;
57 
59  void mergeEffects(std::vector<ActiveEffect>& addTo, const std::vector<ActiveEffect>& from);
60 
61  double timeToExpire (const TIterator& iterator) const;
64 
65  const TContainer& getActiveSpells() const;
66 
67  public:
68 
69  ActiveSpells();
70 
79  void addSpell (const std::string& id, bool stack, std::vector<ActiveEffect> effects,
80  const std::string& displayName, int casterActorId);
81 
83  void removeEffects (const std::string& id);
84 
86  void purgeEffect (short effectId);
87 
89  void purgeEffect (short effectId, const std::string& sourceId);
90 
92  void purgeAll (float chance);
93 
95  void purge (int casterActorId);
96 
98  void clear();
99 
100  bool isSpellActive (const std::string& id) const;
102 
103  const MagicEffects& getMagicEffects() const;
104 
106 
107  };
108 }
109 
110 #endif
Definition: magiceffects.hpp:73
void writeState(ESM::ActiveSpells &state) const
Definition: activespells.cpp:291
const MagicEffects & getMagicEffects() const
Definition: activespells.cpp:94
std::vector< ActiveEffect > mEffects
Definition: activespells.hpp:29
bool mSpellsChanged
Definition: activespells.hpp:51
Definition: activespells.hpp:18
void readState(const ESM::ActiveSpells &state)
Definition: activespells.cpp:306
void clear()
Remove all spells.
Definition: activespells.cpp:285
Effects currently affecting a NPC or creature.
Definition: magiceffects.hpp:83
ESM::ActiveEffect ActiveEffect
Definition: activespells.hpp:25
const TContainer & getActiveSpells() const
Definition: activespells.cpp:144
Definition: activespells.hpp:27
void purge(int casterActorId)
Remove all effects with CASTER_LINKED flag that were cast by casterActorId.
Definition: activespells.cpp:269
TIterator end() const
Definition: activespells.cpp:105
void visitEffectSources(MWMechanics::EffectSourceVisitor &visitor) const
Definition: activespells.cpp:204
MWWorld::TimeStamp mLastUpdate
Definition: activespells.hpp:52
void addSpell(const std::string &id, bool stack, std::vector< ActiveEffect > effects, const std::string &displayName, int casterActorId)
addSpell
Definition: activespells.cpp:149
ActiveSpells()
Definition: activespells.cpp:89
std::string mDisplayName
Definition: activespells.hpp:31
bool isSpellActive(const std::string &id) const
case insensitive
Definition: activespells.cpp:134
void purgeAll(float chance)
Remove all active effects, if roll succeeds (for each effect)
Definition: activespells.cpp:225
void mergeEffects(std::vector< ActiveEffect > &addTo, const std::vector< ActiveEffect > &from)
Add any effects that are in "from" and not in "addTo" to "addTo".
Definition: activespells.cpp:177
TContainer::const_iterator TIterator
Definition: activespells.hpp:38
void purgeEffect(short effectId)
Remove all active effects with this effect id.
Definition: activespells.cpp:237
void update() const
Definition: activespells.cpp:15
MWWorld::TimeStamp mTimeStamp
Definition: activespells.hpp:30
TContainer mSpells
Definition: activespells.hpp:49
void removeEffects(const std::string &id)
Removes the active effects from this spell/potion/.. with id.
Definition: activespells.cpp:198
Definition: activespells.hpp:27
In-game time stamp.
Definition: timestamp.hpp:14
MagicEffects mEffects
Definition: activespells.hpp:50
int mCasterActorId
Definition: activespells.hpp:34
TIterator begin() const
Definition: activespells.cpp:100
void rebuildEffects() const
Definition: activespells.cpp:64
Lasting spell effects.
Definition: activespells.hpp:21
double timeToExpire(const TIterator &iterator) const
Definition: activespells.cpp:110
std::multimap< std::string, ActiveSpellParams > TContainer
Definition: activespells.hpp:37