forked from mirror/openmw-tes3mp
moved selected spell from NpcStats to Spells
This commit is contained in:
parent
26a529111c
commit
52c7ee3b6a
3 changed files with 25 additions and 4 deletions
|
@ -12,7 +12,8 @@ namespace MWMechanics
|
|||
///
|
||||
/// For non-NPC-specific stats, see the CreatureStats struct.
|
||||
///
|
||||
/// \note For technical reasons the spell list is also handled by CreatureStats.
|
||||
/// \note For technical reasons the spell list and the currently selected spell is also handled by
|
||||
/// CreatureStats, even though they are actually NPC stats.
|
||||
|
||||
struct NpcStats
|
||||
{
|
||||
|
@ -28,8 +29,6 @@ namespace MWMechanics
|
|||
bool mSneak;
|
||||
bool mCombat;
|
||||
|
||||
std::string mSelectedSpell; // can be an empty string (no spell selected)
|
||||
|
||||
NpcStats() : mForceRun (false), mForceSneak (false), mRun (false), mSneak (false),
|
||||
mCombat (false) {}
|
||||
};
|
||||
|
|
|
@ -43,6 +43,9 @@ namespace MWMechanics
|
|||
|
||||
if (iter!=mSpells.end())
|
||||
mSpells.erase (iter);
|
||||
|
||||
if (spellId==mSelectedSpell)
|
||||
mSelectedSpell.clear();
|
||||
}
|
||||
|
||||
MagicEffects Spells::getMagicEffects (const MWWorld::Environment& environment) const
|
||||
|
@ -65,4 +68,14 @@ namespace MWMechanics
|
|||
{
|
||||
mSpells.clear();
|
||||
}
|
||||
|
||||
void Spells::setSelectedSpell (const std::string& spellId)
|
||||
{
|
||||
mSelectedSpell = spellId;
|
||||
}
|
||||
|
||||
const std::string Spells::getSelectedSpell() const
|
||||
{
|
||||
return mSelectedSpell;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace MWMechanics
|
|||
private:
|
||||
|
||||
std::vector<std::string> mSpells;
|
||||
std::string mSelectedSpell;
|
||||
|
||||
void addSpell (const ESM::Spell *, MagicEffects& effects) const;
|
||||
|
||||
|
@ -42,15 +43,23 @@ namespace MWMechanics
|
|||
TIterator end() const;
|
||||
|
||||
void add (const std::string& spell);
|
||||
/// \note Adding a spell that is already listed in *this is a no-op.
|
||||
///< Adding a spell that is already listed in *this is a no-op.
|
||||
|
||||
void remove (const std::string& spell);
|
||||
///< If the spell to be removed is the selected spell, the selected spell will be changed to
|
||||
/// no spell (empty string).
|
||||
|
||||
MagicEffects getMagicEffects (const MWWorld::Environment& environment) const;
|
||||
///< Return sum of magic effects resulting from abilities, blights, deseases and curses.
|
||||
|
||||
void clear();
|
||||
///< Remove all spells of al types.
|
||||
|
||||
void setSelectedSpell (const std::string& spellId);
|
||||
///< This function does not verify, if the spell is available.
|
||||
|
||||
const std::string getSelectedSpell() const;
|
||||
///< May return an empty string.
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue