From 1a152bbcfc63445287cc96bbbff325cce3092789 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 30 Dec 2012 20:24:32 +0300 Subject: Add support for different sounds from different weapons. Also fixed sounds from non local player. --- src/being.cpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'src/being.cpp') diff --git a/src/being.cpp b/src/being.cpp index 1f92030ab..d5ac23f4a 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -758,8 +758,41 @@ void Being::handleAttack(Being *const victim, const int damage, if (damage && victim->mType == PLAYER && victim->mAction == SIT) victim->setAction(STAND); - sound.playSfx(mInfo->getSound((damage > 0) ? - SOUND_EVENT_HIT : SOUND_EVENT_MISS), mX, mY); + if (mType == PLAYER) + { + if (mSpriteIDs.size() >= 10) + { + // here 10 is weapon slot + const int weaponId = mSpriteIDs[10]; + std::string soundFile; + if (weaponId > 0) + { + const ItemInfo &info = ItemDB::get(weaponId); + soundFile = info.getSound((damage > 0) ? + EQUIP_EVENT_HIT : EQUIP_EVENT_STRIKE); + } + else + { + soundFile = mInfo->getSound((damage > 0) ? + SOUND_EVENT_HIT : SOUND_EVENT_MISS); + } + if (!soundFile.empty()) + { + sound.playSfx(soundFile, mX, mY); + } + else + { + sound.playSfx(paths.getValue((damage > 0) + ? "attackSfxFile" : "missSfxFile", + "fist-swish.ogg"), mX, mY); + } + } + } + else + { + sound.playSfx(mInfo->getSound((damage > 0) ? + SOUND_EVENT_HIT : SOUND_EVENT_MISS), mX, mY); + } } void Being::handleSkill(Being *const victim, const int damage, -- cgit v1.2.3-60-g2f50