diff options
Diffstat (limited to 'src/being.cpp')
-rw-r--r-- | src/being.cpp | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/being.cpp b/src/being.cpp index 5e869662..7c77f19f 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -416,17 +416,34 @@ void Being::handleAttack(Being *victim, int damage, int attackId) setAction(Being::ATTACK, attackId); if (victim) + { lookAt(victim->getPosition()); - if (getType() == PLAYER && victim && mEquippedWeapon) - fireMissile(victim, mEquippedWeapon->missileParticleFile); - else - fireMissile(victim, - mInfo->getAttack(attackId).missileParticleFilename); + if (getType() == PLAYER && mEquippedWeapon) + fireMissile(victim, mEquippedWeapon->missileParticleFile); + else + fireMissile(victim, mInfo->getAttack(attackId).missileParticleFilename); + } + + if (getType() == PLAYER) + { + auto itemInfo = mEquippedWeapon; + + // Fall back to racesprite item + if (!itemInfo) + itemInfo = &itemDb->get(-100 - mSubType); - sound.playSfx(mInfo->getSound((damage > 0) ? - SoundEvent::HIT : SoundEvent::MISS), - getPixelX(), getPixelY()); + const auto event = damage > 0 ? EquipmentSoundEvent::HIT + : EquipmentSoundEvent::STRIKE; + const auto &soundFile = itemInfo->getSound(event); + sound.playSfx(soundFile, getPixelX(), getPixelY()); + } + else + { + const auto event = damage > 0 ? SoundEvent::HIT : SoundEvent::MISS; + const auto &soundFile = mInfo->getSound(event); + sound.playSfx(soundFile, getPixelX(), getPixelY()); + } } void Being::setName(const std::string &name) |