Use dice rolls instead of chance for spell magnitude (bug #4945)

pull/2311/head
Capostrophic 5 years ago
parent e9f6c11cc9
commit d4c1bd81b6

@ -53,6 +53,7 @@
Bug #4927: Spell effect having both a skill and an attribute assigned is a fatal error
Bug #4938: Strings from subrecords with actually empty headers can't be empty
Bug #4942: Hand-to-Hand attack type is chosen randomly when "always use best attack" is turned off
Bug #4945: Poor random magic magnitude distribution
Bug #4947: Player character doesn't use lip animation
Bug #4948: Footstep sounds while levitating on ground level
Bug #4963: Enchant skill progress is incorrect

@ -534,8 +534,7 @@ namespace MWMechanics
if (magnitudeMult > 0 && !absorbed)
{
float random = Misc::Rng::rollClosedProbability();
float magnitude = effectIt->mMagnMin + (effectIt->mMagnMax - effectIt->mMagnMin) * random;
float magnitude = effectIt->mMagnMin + Misc::Rng::rollDice(effectIt->mMagnMax - effectIt->mMagnMin + 1);
magnitude *= magnitudeMult;
if (!target.getClass().isActor())

@ -94,7 +94,10 @@ namespace MWMechanics
for (unsigned int i=0; i<spell->mEffects.mList.size();++i)
{
if (spell->mEffects.mList[i].mMagnMin != spell->mEffects.mList[i].mMagnMax)
random[i] = Misc::Rng::rollClosedProbability();
{
int delta = spell->mEffects.mList[i].mMagnMax - spell->mEffects.mList[i].mMagnMin;
random[i] = Misc::Rng::rollDice(delta + 1) / static_cast<float>(delta);
}
}
}

@ -637,15 +637,15 @@ void MWWorld::InventoryStore::updateMagicEffects(const Ptr& actor)
bool existed = (mPermanentMagicEffectMagnitudes.find((**iter).getCellRef().getRefId()) != mPermanentMagicEffectMagnitudes.end());
if (!existed)
{
// Roll some dice, one for each effect
params.resize(enchantment.mEffects.mList.size());
for (unsigned int i=0; i<params.size();++i)
params[i].mRandom = Misc::Rng::rollClosedProbability();
// Try resisting each effect
int i=0;
for (const ESM::ENAMstruct& effect : enchantment.mEffects.mList)
{
int delta = effect.mMagnMax - effect.mMagnMin;
// Roll some dice, one for each effect
params[i].mRandom = Misc::Rng::rollDice(delta + 1) / static_cast<float>(delta);
// Try resisting each effect
params[i].mMultiplier = MWMechanics::getEffectMultiplier(effect.mEffectID, actor, actor);
++i;
}

Loading…
Cancel
Save