Merge remote-tracking branch 'scrawl/openmw-0.28' into openmw-28

actorid
Marc Zinnschlag 11 years ago
commit 3b75f6676c

@ -169,9 +169,17 @@ namespace MWMechanics
}
}
void ActiveSpells::purgeAll()
void ActiveSpells::purgeAll(float chance)
{
mSpells.clear();
for (TContainer::iterator it = mSpells.begin(); it != mSpells.end(); )
{
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
if (roll < chance)
mSpells.erase(it++);
else
++it;
}
mSpellsChanged = true;
}
void ActiveSpells::purgeEffect(short effectId)
@ -187,6 +195,6 @@ namespace MWMechanics
effectIt++;
}
}
mSpellsChanged = true;
}
}

@ -82,8 +82,8 @@ namespace MWMechanics
/// Remove all active effects with this id
void purgeEffect (short effectId);
/// Remove all active effects
void purgeAll ();
/// Remove all active effects, if roll succeeds (for each effect)
void purgeAll (float chance);
bool isSpellActive (std::string id) const;
///< case insensitive

@ -236,7 +236,7 @@ namespace MWMechanics
else if (effectId == ESM::MagicEffect::CureCorprusDisease)
target.getClass().getCreatureStats(target).getSpells().purgeCorprusDisease();
else if (effectId == ESM::MagicEffect::Dispel)
target.getClass().getCreatureStats(target).getActiveSpells().purgeAll();
target.getClass().getCreatureStats(target).getActiveSpells().purgeAll(magnitude);
else if (effectId == ESM::MagicEffect::RemoveCurse)
target.getClass().getCreatureStats(target).getSpells().purgeCurses();

Loading…
Cancel
Save