From 65ee420ab93422e0b3ee4ce87279cf51b770cce9 Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Sun, 14 Jul 2019 23:42:42 +0300 Subject: [PATCH] Only play on-strike failure sound on the player (bug #5092) --- apps/openmw/mwmechanics/spellcasting.cpp | 27 +++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 2de6f75fa0..2c178a40e1 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -838,21 +838,24 @@ namespace MWMechanics if (item.getCellRef().getEnchantmentCharge() < castCost) { if (mCaster == getPlayer()) + { MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicInsufficientCharge}"); - // Failure sound - int school = 0; - if (!enchantment->mEffects.mList.empty()) - { - short effectId = enchantment->mEffects.mList.front().mEffectID; - const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get().find(effectId); - school = magicEffect->mData.mSchool; + // Failure sound + int school = 0; + if (!enchantment->mEffects.mList.empty()) + { + short effectId = enchantment->mEffects.mList.front().mEffectID; + const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get().find(effectId); + school = magicEffect->mData.mSchool; + } + + static const std::string schools[] = { + "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" + }; + MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); + sndMgr->playSound3D(mCaster, "Spell Failure " + schools[school], 1.0f, 1.0f); } - static const std::string schools[] = { - "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" - }; - MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); - sndMgr->playSound3D(mCaster, "Spell Failure " + schools[school], 1.0f, 1.0f); return false; } // Reduce charge