Correct Dispel effect (use magnitude as chance)

actorid
scrawl 11 years ago
parent 94d2ec8e4e
commit 596e0c8a49

@ -169,9 +169,16 @@ 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;
}

@ -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