From bbcdfd4078275cbb5e3060e5b04645567b2297d3 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Thu, 6 Sep 2018 21:49:50 +0200 Subject: [PATCH 1/3] Implements vanilla's off-by-one error, fixing #4611 --- apps/openmw/mwgui/spellcreationdialog.cpp | 4 +++- apps/openmw/mwgui/spellcreationdialog.hpp | 1 + apps/openmw/mwmechanics/spellcasting.cpp | 9 ++++++--- apps/openmw/mwmechanics/spellcasting.hpp | 4 ++-- files/settings-default.cfg | 3 +++ 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 65d66f9e2..bd54d47ee 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -449,11 +449,13 @@ namespace MWGui const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + static const bool vanillaCost = Settings::Manager::getBool("expensive spells", "Game"); + for (std::vector::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) { const ESM::ENAMstruct& effect = *it; - y += std::max(1.f, MWMechanics::calcEffectCost(effect)); + y += std::max(1.f, MWMechanics::calcEffectCost(effect, vanillaCost)); if (effect.mRange == ESM::RT_Target) y *= 1.5; diff --git a/apps/openmw/mwgui/spellcreationdialog.hpp b/apps/openmw/mwgui/spellcreationdialog.hpp index ec90fa3ce..084c3e1e1 100644 --- a/apps/openmw/mwgui/spellcreationdialog.hpp +++ b/apps/openmw/mwgui/spellcreationdialog.hpp @@ -3,6 +3,7 @@ #include #include +#include #include "windowbase.hpp" #include "referenceinterface.hpp" diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index b857c6d7e..83af249da 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -49,13 +49,13 @@ namespace MWMechanics return schoolSkillMap[school]; } - float calcEffectCost(const ESM::ENAMstruct& effect) + float calcEffectCost(const ESM::ENAMstruct& effect, const bool customSpellCost) { const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get().find(effect.mEffectID); - return calcEffectCost(effect, magicEffect); + return calcEffectCost(effect, magicEffect, customSpellCost); } - float calcEffectCost(const ESM::ENAMstruct& effect, const ESM::MagicEffect* magicEffect) + float calcEffectCost(const ESM::ENAMstruct& effect, const ESM::MagicEffect* magicEffect, const bool customSpellCost) { int minMagn = 1; int maxMagn = 1; @@ -68,6 +68,9 @@ namespace MWMechanics int duration = 0; if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration)) duration = effect.mDuration; + //The wonders of vanilla spellmaking + if (customSpellCost && duration < 1) + duration = 1; static const float fEffectCostMult = MWBase::Environment::get().getWorld()->getStore() .get().find("fEffectCostMult")->mValue.getFloat(); diff --git a/apps/openmw/mwmechanics/spellcasting.hpp b/apps/openmw/mwmechanics/spellcasting.hpp index 2844e7f23..836473653 100644 --- a/apps/openmw/mwmechanics/spellcasting.hpp +++ b/apps/openmw/mwmechanics/spellcasting.hpp @@ -25,8 +25,8 @@ namespace MWMechanics ESM::Skill::SkillEnum spellSchoolToSkill(int school); - float calcEffectCost(const ESM::ENAMstruct& effect); - float calcEffectCost(const ESM::ENAMstruct& effect, const ESM::MagicEffect* magicEffect); + float calcEffectCost(const ESM::ENAMstruct& effect, const bool customSpellCost = false); + float calcEffectCost(const ESM::ENAMstruct& effect, const ESM::MagicEffect* magicEffect, const bool customSpellCost = false); bool isSummoningEffect(int effectId); diff --git a/files/settings-default.cfg b/files/settings-default.cfg index c2ac2eb1c..352b86f65 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -229,6 +229,9 @@ barter disposition change is permanent = false # (0 means it does not factor it in, 1 means it factors into werewolves damage calculation and # 2 means werewolves are ignored) strength influences hand to hand = 0 + +# Makes custom spells cost the same as in vanilla +expensive spells = true [General] From 6705e5aae455219e908ffb3870f4c5d1872a5d4f Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Sat, 8 Sep 2018 11:21:43 +0200 Subject: [PATCH 2/3] forget about the setting till #2887 is implemented at least --- apps/openmw/mwgui/spellcreationdialog.cpp | 4 +--- apps/openmw/mwgui/spellcreationdialog.hpp | 1 - apps/openmw/mwmechanics/spellcasting.cpp | 11 ++++------- apps/openmw/mwmechanics/spellcasting.hpp | 4 ++-- files/settings-default.cfg | 5 +---- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index bd54d47ee..65d66f9e2 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -449,13 +449,11 @@ namespace MWGui const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - static const bool vanillaCost = Settings::Manager::getBool("expensive spells", "Game"); - for (std::vector::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) { const ESM::ENAMstruct& effect = *it; - y += std::max(1.f, MWMechanics::calcEffectCost(effect, vanillaCost)); + y += std::max(1.f, MWMechanics::calcEffectCost(effect)); if (effect.mRange == ESM::RT_Target) y *= 1.5; diff --git a/apps/openmw/mwgui/spellcreationdialog.hpp b/apps/openmw/mwgui/spellcreationdialog.hpp index 084c3e1e1..ec90fa3ce 100644 --- a/apps/openmw/mwgui/spellcreationdialog.hpp +++ b/apps/openmw/mwgui/spellcreationdialog.hpp @@ -3,7 +3,6 @@ #include #include -#include #include "windowbase.hpp" #include "referenceinterface.hpp" diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 83af249da..14dfac283 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -49,13 +49,13 @@ namespace MWMechanics return schoolSkillMap[school]; } - float calcEffectCost(const ESM::ENAMstruct& effect, const bool customSpellCost) + float calcEffectCost(const ESM::ENAMstruct& effect) { const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get().find(effect.mEffectID); - return calcEffectCost(effect, magicEffect, customSpellCost); + return calcEffectCost(effect, magicEffect); } - float calcEffectCost(const ESM::ENAMstruct& effect, const ESM::MagicEffect* magicEffect, const bool customSpellCost) + float calcEffectCost(const ESM::ENAMstruct& effect, const ESM::MagicEffect* magicEffect) { int minMagn = 1; int maxMagn = 1; @@ -65,12 +65,9 @@ namespace MWMechanics maxMagn = effect.mMagnMax; } - int duration = 0; + int duration = 1; if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration)) duration = effect.mDuration; - //The wonders of vanilla spellmaking - if (customSpellCost && duration < 1) - duration = 1; static const float fEffectCostMult = MWBase::Environment::get().getWorld()->getStore() .get().find("fEffectCostMult")->mValue.getFloat(); diff --git a/apps/openmw/mwmechanics/spellcasting.hpp b/apps/openmw/mwmechanics/spellcasting.hpp index 836473653..2844e7f23 100644 --- a/apps/openmw/mwmechanics/spellcasting.hpp +++ b/apps/openmw/mwmechanics/spellcasting.hpp @@ -25,8 +25,8 @@ namespace MWMechanics ESM::Skill::SkillEnum spellSchoolToSkill(int school); - float calcEffectCost(const ESM::ENAMstruct& effect, const bool customSpellCost = false); - float calcEffectCost(const ESM::ENAMstruct& effect, const ESM::MagicEffect* magicEffect, const bool customSpellCost = false); + float calcEffectCost(const ESM::ENAMstruct& effect); + float calcEffectCost(const ESM::ENAMstruct& effect, const ESM::MagicEffect* magicEffect); bool isSummoningEffect(int effectId); diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 352b86f65..09672aaac 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -228,10 +228,7 @@ barter disposition change is permanent = false # Uses the MCP formula (damage * (strength / 40)) to factor Strength into hand-to-hand combat. # (0 means it does not factor it in, 1 means it factors into werewolves damage calculation and # 2 means werewolves are ignored) -strength influences hand to hand = 0 - -# Makes custom spells cost the same as in vanilla -expensive spells = true +strength influences hand to hand = 0 [General] From d39c4729d205a0dee9285ea72eee389f1dc3eb23 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Sat, 8 Sep 2018 21:14:47 +0200 Subject: [PATCH 3/3] add changelog entry --- CHANGELOG.md | 1 + files/settings-default.cfg | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c11d92900..4042326d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -109,6 +109,7 @@ Bug #4604: Picking up gold from the ground only makes 1 grabbed Bug #4607: Scaling for animated collision shapes is applied twice Bug #4608: Falling damage is applied twice + Bug #4611: Instant magic effects have 0 duration in custom spell cost calculations unlike vanilla Bug #4614: Crash due to division by zero when FlipController has no textures Bug #4615: Flicker effects for light sources are handled incorrectly Bug #4617: First person sneaking offset is not applied while the character is in air diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 09672aaac..c2ac2eb1c 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -228,7 +228,7 @@ barter disposition change is permanent = false # Uses the MCP formula (damage * (strength / 40)) to factor Strength into hand-to-hand combat. # (0 means it does not factor it in, 1 means it factors into werewolves damage calculation and # 2 means werewolves are ignored) -strength influences hand to hand = 0 +strength influences hand to hand = 0 [General]