From da9d8582017fe358c426831c3567236098e6171f Mon Sep 17 00:00:00 2001 From: Jordan Ayers Date: Mon, 29 Sep 2014 20:59:10 -0500 Subject: [PATCH 1/3] Add 'const' to a spell helper function. --- apps/openmw/mwmechanics/spells.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/spells.hpp b/apps/openmw/mwmechanics/spells.hpp index 7caeba6e8..ab799ffe1 100644 --- a/apps/openmw/mwmechanics/spells.hpp +++ b/apps/openmw/mwmechanics/spells.hpp @@ -74,7 +74,7 @@ namespace MWMechanics TIterator end() const; - bool hasSpell(const std::string& spell) { return mSpells.find(Misc::StringUtils::lowerCase(spell)) != mSpells.end(); } + bool hasSpell(const std::string& spell) const { return mSpells.find(Misc::StringUtils::lowerCase(spell)) != mSpells.end(); } void add (const std::string& spell); ///< Adding a spell that is already listed in *this is a no-op. From a9a0930b855b76ef6af00ce01e3f163c7f880b33 Mon Sep 17 00:00:00 2001 From: Jordan Ayers Date: Wed, 1 Oct 2014 19:24:54 -0500 Subject: [PATCH 2/3] Disease check: Reuse corprus check from spells.hpp. --- apps/openmw/mwmechanics/disease.hpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/apps/openmw/mwmechanics/disease.hpp b/apps/openmw/mwmechanics/disease.hpp index fa97f1541..21dd82054 100644 --- a/apps/openmw/mwmechanics/disease.hpp +++ b/apps/openmw/mwmechanics/disease.hpp @@ -33,18 +33,8 @@ namespace MWMechanics if (actor.getClass().getCreatureStats(actor).getSpells().hasSpell(spell->mId)) continue; - bool hasCorprusEffect = false; - for (std::vector::const_iterator effectIt = spell->mEffects.mList.begin(); effectIt != spell->mEffects.mList.end(); ++effectIt) - { - if (effectIt->mEffectID == ESM::MagicEffect::Corprus) - { - hasCorprusEffect = true; - break; - } - } - float resist = 0.f; - if (hasCorprusEffect) + if (spells.hasCorprusEffect(spell)) resist = 1.f - 0.01 * (actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::ResistCorprusDisease).getMagnitude() - actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::WeaknessToCorprusDisease).getMagnitude()); else if (spell->mData.mType == ESM::Spell::ST_Disease) From 3bc91c66e66820a5da0b79614f93090ff94d3623 Mon Sep 17 00:00:00 2001 From: Jordan Ayers Date: Wed, 1 Oct 2014 19:27:10 -0500 Subject: [PATCH 3/3] Disease Check: Shorten the resistance calculations. --- apps/openmw/mwmechanics/disease.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwmechanics/disease.hpp b/apps/openmw/mwmechanics/disease.hpp index 21dd82054..a973c0e35 100644 --- a/apps/openmw/mwmechanics/disease.hpp +++ b/apps/openmw/mwmechanics/disease.hpp @@ -25,6 +25,8 @@ namespace MWMechanics MWBase::Environment::get().getWorld()->getStore().get().find( "fDiseaseXferChance")->getFloat(); + MagicEffects& actorEffects = actor.getClass().getCreatureStats(actor).getMagicEffects(); + Spells& spells = carrier.getClass().getCreatureStats(carrier).getSpells(); for (Spells::TIterator it = spells.begin(); it != spells.end(); ++it) { @@ -35,14 +37,14 @@ namespace MWMechanics float resist = 0.f; if (spells.hasCorprusEffect(spell)) - resist = 1.f - 0.01 * (actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::ResistCorprusDisease).getMagnitude() - - actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::WeaknessToCorprusDisease).getMagnitude()); + resist = 1.f - 0.01 * (actorEffects.get(ESM::MagicEffect::ResistCorprusDisease).getMagnitude() + - actorEffects.get(ESM::MagicEffect::WeaknessToCorprusDisease).getMagnitude()); else if (spell->mData.mType == ESM::Spell::ST_Disease) - resist = 1.f - 0.01 * (actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::ResistCommonDisease).getMagnitude() - - actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::WeaknessToCommonDisease).getMagnitude()); + resist = 1.f - 0.01 * (actorEffects.get(ESM::MagicEffect::ResistCommonDisease).getMagnitude() + - actorEffects.get(ESM::MagicEffect::WeaknessToCommonDisease).getMagnitude()); else if (spell->mData.mType == ESM::Spell::ST_Blight) - resist = 1.f - 0.01 * (actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::ResistBlightDisease).getMagnitude() - - actor.getClass().getCreatureStats(actor).getMagicEffects().get(ESM::MagicEffect::WeaknessToBlightDisease).getMagnitude()); + resist = 1.f - 0.01 * (actorEffects.get(ESM::MagicEffect::ResistBlightDisease).getMagnitude() + - actorEffects.get(ESM::MagicEffect::WeaknessToBlightDisease).getMagnitude()); else continue;