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 | |
parent | db4e377024c8116b6095892469bfad1c1e5482e9 (diff) | |
download | plus-1a152bbcfc63445287cc96bbbff325cce3092789.tar.gz plus-1a152bbcfc63445287cc96bbbff325cce3092789.tar.bz2 plus-1a152bbcfc63445287cc96bbbff325cce3092789.tar.xz plus-1a152bbcfc63445287cc96bbbff325cce3092789.zip |
Add support for different sounds from different weapons.
Also fixed sounds from non local player.
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 37 | ||||
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/localplayer.cpp | 3 | ||||
-rw-r--r-- | src/resources/iteminfo.h | 2 |
4 files changed, 40 insertions, 3 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, diff --git a/src/defaults.cpp b/src/defaults.cpp index 42d6f1fd9..9ff313ae3 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -359,6 +359,7 @@ DefaultsData* getPathsDefaults() AddDEF("sfx", "sfx/"); AddDEF("attackSfxFile", "fist-swish.ogg"); + AddDEF("missSfxFile", "fist-swish.ogg"); AddDEF("music", "music/"); AddDEF("wallpapers", "graphics/images/"); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 890191bcc..a23811bd3 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -1350,6 +1350,7 @@ void LocalPlayer::attack(Being *const target, const bool keep, { setAction(ATTACK); +/* if (mEquippedWeapon) { std::string soundFile = mEquippedWeapon->getSound( @@ -1361,7 +1362,7 @@ void LocalPlayer::attack(Being *const target, const bool keep, { sound.playSfx(paths.getValue("attackSfxFile", "fist-swish.ogg")); } - +*/ if (!Client::limitPackets(PACKET_ATTACK)) return; diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index e8a11c2a5..8e6cc2ee0 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -32,7 +32,9 @@ enum EquipmentSoundEvent { + // miss EQUIP_EVENT_STRIKE = 0, + // hit EQUIP_EVENT_HIT }; |