From d617651307cfa90503d641f2ca9c2c8b58606e25 Mon Sep 17 00:00:00 2001 From: Allofich Date: Sat, 13 Aug 2016 09:57:03 +0900 Subject: [PATCH] Don't allow re-casting of bound equipment spells --- apps/openmw/mwmechanics/spellcasting.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index c55ae67f2..61365be97 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -356,6 +356,14 @@ namespace MWMechanics bool castByPlayer = (!caster.isEmpty() && caster == getPlayer()); + ActiveSpells targetSpells; + if (target.getClass().isActor()) + targetSpells = target.getClass().getCreatureStats(target).getActiveSpells(); + + bool canCastAnEffect = false; // For bound equipment.If this remains false + // throughout the iteration of this spell's + // effects, we display a "can't re-cast" message + for (std::vector::const_iterator effectIt (effects.mList.begin()); effectIt!=effects.mList.end(); ++effectIt) { @@ -366,6 +374,16 @@ namespace MWMechanics MWBase::Environment::get().getWorld()->getStore().get().find ( effectIt->mEffectID); + // Re-casting a bound equipment effect has no effect if the spell is still active + if (magicEffect->mData.mFlags & ESM::MagicEffect::NonRecastable && targetSpells.isSpellActive(mId)) + { + if (effectIt == (effects.mList.end() - 1) && !canCastAnEffect && castByPlayer) + MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicCannotRecast}"); + continue; + } + else + canCastAnEffect = true; + if (!checkEffectTarget(effectIt->mEffectID, target, castByPlayer)) continue;