From 58945c557a4ca65e71e2c773181d41cc6614ff79 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 30 Aug 2014 02:45:35 +0200 Subject: [PATCH] Add sound for casting enchanted item with insufficent charge (Fixes #1857) --- apps/openmw/mwmechanics/spellcasting.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 6563d0e62..a1f0d994a 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -684,9 +684,23 @@ namespace MWMechanics if (item.getCellRef().getEnchantmentCharge() < castCost) { - // TODO: Should there be a sound here? if (mCaster.getRefData().getHandle() == "player") MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicInsufficientCharge}"); + + // Failure sound + int school = 0; + for (std::vector::const_iterator effectIt (enchantment->mEffects.mList.begin()); + effectIt!=enchantment->mEffects.mList.end(); ++effectIt) + { + const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get().find(effectIt->mEffectID); + school = magicEffect->mData.mSchool; + break; + } + 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