GetSpellEffects returns true for active abilities (Fixes #2530)

openmw-36
scrawl 10 years ago
parent ac88326909
commit 9d86e5b028

@ -143,6 +143,20 @@ namespace MWMechanics
return mSelectedSpell; return mSelectedSpell;
} }
bool Spells::isSpellActive(const std::string &id) const
{
TContainer::const_iterator found = mSpells.find(id);
if (found != mSpells.end())
{
const ESM::Spell *spell =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (id);
return (spell->mData.mType==ESM::Spell::ST_Ability || spell->mData.mType==ESM::Spell::ST_Blight ||
spell->mData.mType==ESM::Spell::ST_Disease || spell->mData.mType==ESM::Spell::ST_Curse);
}
return false;
}
bool Spells::hasCommonDisease() const bool Spells::hasCommonDisease() const
{ {
for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter)

@ -98,6 +98,9 @@ namespace MWMechanics
const std::string getSelectedSpell() const; const std::string getSelectedSpell() const;
///< May return an empty string. ///< May return an empty string.
bool isSpellActive(const std::string& id) const;
///< Are we under the effects of the given spell ID?
bool hasCommonDisease() const; bool hasCommonDisease() const;
bool hasBlightDisease() const; bool hasBlightDisease() const;

@ -595,7 +595,8 @@ namespace MWScript
std::string id = runtime.getStringLiteral(runtime[0].mInteger); std::string id = runtime.getStringLiteral(runtime[0].mInteger);
runtime.pop(); runtime.pop();
runtime.push(ptr.getClass().getCreatureStats(ptr).getActiveSpells().isSpellActive(id)); const MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
runtime.push(stats.getActiveSpells().isSpellActive(id) || stats.getSpells().isSpellActive(id));
} }
}; };

Loading…
Cancel
Save