From d4c1bd81b6bab00a33d5f1b9e9d0f6dc21ff5bd3 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Mon, 8 Apr 2019 20:22:10 +0300 Subject: [PATCH] Use dice rolls instead of chance for spell magnitude (bug #4945) --- CHANGELOG.md | 1 + apps/openmw/mwmechanics/spellcasting.cpp | 3 +-- apps/openmw/mwmechanics/spells.cpp | 5 ++++- apps/openmw/mwworld/inventorystore.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5dcf5def..a297ad151 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 072c65ba1..22cdeb2df 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -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()) diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index 3214b3fc9..125ac7690 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -94,7 +94,10 @@ namespace MWMechanics for (unsigned int i=0; imEffects.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(delta); + } } } diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index a8fa91680..08a30c78f 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -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(delta); + // Try resisting each effect params[i].mMultiplier = MWMechanics::getEffectMultiplier(effect.mEffectID, actor, actor); ++i; }