diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-12-30 20:24:32 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-12-30 20:24:32 +0300 |
commit | 1a152bbcfc63445287cc96bbbff325cce3092789 (patch) | |
tree | d9a3baa2191b597563009bbaa5e539a69d1ff9a8 /src/being.cpp | |
parent | db4e377024c8116b6095892469bfad1c1e5482e9 (diff) | |
download | manaplus-1a152bbcfc63445287cc96bbbff325cce3092789.tar.gz manaplus-1a152bbcfc63445287cc96bbbff325cce3092789.tar.bz2 manaplus-1a152bbcfc63445287cc96bbbff325cce3092789.tar.xz manaplus-1a152bbcfc63445287cc96bbbff325cce3092789.zip |
Add support for different sounds from different weapons.
Also fixed sounds from non local player.
Diffstat (limited to 'src/being.cpp')
-rw-r--r-- | src/being.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
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, |