mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 16:53:54 +00:00
Merge remote-tracking branch 'scrawl/openmw-0.28' into openmw-28
This commit is contained in:
commit
3b75f6676c
3 changed files with 14 additions and 6 deletions
|
@ -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…
Reference in a new issue