forked from teamnwah/openmw-tes3coop
Dispel only effects from spells (bug #3995)
This commit is contained in:
parent
1bdcecc32e
commit
1e983604db
4 changed files with 24 additions and 3 deletions
|
@ -222,10 +222,23 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActiveSpells::purgeAll(float chance)
|
void ActiveSpells::purgeAll(float chance, bool spellOnly)
|
||||||
{
|
{
|
||||||
for (TContainer::iterator it = mSpells.begin(); it != mSpells.end(); )
|
for (TContainer::iterator it = mSpells.begin(); it != mSpells.end(); )
|
||||||
{
|
{
|
||||||
|
const std::string spellId = it->first;
|
||||||
|
|
||||||
|
// if spellOnly is true, dispell only spells. Leave potions, enchanted items etc.
|
||||||
|
if (spellOnly)
|
||||||
|
{
|
||||||
|
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(spellId);
|
||||||
|
if (!spell || spell->mData.mType != ESM::Spell::ST_Spell)
|
||||||
|
{
|
||||||
|
++it;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Misc::Rng::roll0to99() < chance)
|
if (Misc::Rng::roll0to99() < chance)
|
||||||
mSpells.erase(it++);
|
mSpells.erase(it++);
|
||||||
else
|
else
|
||||||
|
|
|
@ -89,7 +89,7 @@ namespace MWMechanics
|
||||||
void purgeEffect (short effectId, const std::string& sourceId);
|
void purgeEffect (short effectId, const std::string& sourceId);
|
||||||
|
|
||||||
/// Remove all active effects, if roll succeeds (for each effect)
|
/// Remove all active effects, if roll succeeds (for each effect)
|
||||||
void purgeAll (float chance);
|
void purgeAll(float chance, bool spellOnly = false);
|
||||||
|
|
||||||
/// Remove all effects with CASTER_LINKED flag that were cast by \a casterActorId
|
/// Remove all effects with CASTER_LINKED flag that were cast by \a casterActorId
|
||||||
void purge (int casterActorId);
|
void purge (int casterActorId);
|
||||||
|
|
|
@ -673,7 +673,7 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
else if (target.getClass().isActor() && effectId == ESM::MagicEffect::Dispel)
|
else if (target.getClass().isActor() && effectId == ESM::MagicEffect::Dispel)
|
||||||
{
|
{
|
||||||
target.getClass().getCreatureStats(target).getActiveSpells().purgeAll(magnitude);
|
target.getClass().getCreatureStats(target).getActiveSpells().purgeAll(magnitude, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (target.getClass().isActor() && target == getPlayer())
|
else if (target.getClass().isActor() && target == getPlayer())
|
||||||
|
|
|
@ -25,6 +25,14 @@ namespace
|
||||||
const MWMechanics::ActiveSpells& activeSpells = actor.getClass().getCreatureStats(actor).getActiveSpells();
|
const MWMechanics::ActiveSpells& activeSpells = actor.getClass().getCreatureStats(actor).getActiveSpells();
|
||||||
for (MWMechanics::ActiveSpells::TIterator it = activeSpells.begin(); it != activeSpells.end(); ++it)
|
for (MWMechanics::ActiveSpells::TIterator it = activeSpells.begin(); it != activeSpells.end(); ++it)
|
||||||
{
|
{
|
||||||
|
// if the effect filter is not specified, take in account only spells effects. Leave potions, enchanted items etc.
|
||||||
|
if (effectFilter == -1)
|
||||||
|
{
|
||||||
|
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(it->first);
|
||||||
|
if (!spell || spell->mData.mType != ESM::Spell::ST_Spell)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const MWMechanics::ActiveSpells::ActiveSpellParams& params = it->second;
|
const MWMechanics::ActiveSpells::ActiveSpellParams& params = it->second;
|
||||||
for (std::vector<MWMechanics::ActiveSpells::ActiveEffect>::const_iterator effectIt = params.mEffects.begin();
|
for (std::vector<MWMechanics::ActiveSpells::ActiveEffect>::const_iterator effectIt = params.mEffects.begin();
|
||||||
effectIt != params.mEffects.end(); ++effectIt)
|
effectIt != params.mEffects.end(); ++effectIt)
|
||||||
|
|
Loading…
Reference in a new issue