diff options
-rw-r--r-- | src/being.cpp | 33 | ||||
-rw-r--r-- | src/localplayer.cpp | 11 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 6 | ||||
-rw-r--r-- | src/resources/itemdb.cpp | 6 | ||||
-rw-r--r-- | src/resources/iteminfo.h | 6 |
5 files changed, 32 insertions, 30 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) diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 40849379..43c54731 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -837,17 +837,6 @@ void LocalPlayer::attack(Being *target, bool keep) setAction(ATTACK); - if (mEquippedWeapon) - { - std::string soundFile = mEquippedWeapon->getSound(EQUIP_EVENT_STRIKE); - if (!soundFile.empty()) - sound.playSfx(soundFile); - } - else - { - sound.playSfx(paths.getValue("attackSfxFile", "fist-swish.ogg")); - } - Net::getPlayerHandler()->attack(target->getId()); } diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 33adb93b..159352cc 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -360,23 +360,19 @@ void BeingHandler::handleMessage(MessageIn &msg) case Being::FLEE: // Lucky Dodge if (dstBeing) dstBeing->takeDamage(srcBeing, param1, - (Being::AttackType)type); + static_cast<Being::AttackType>(type)); if (srcBeing) srcBeing->handleAttack(dstBeing, param1); break; case 0x02: // Sit if (srcBeing) - { srcBeing->setAction(Being::SIT); - } break; case 0x03: // Stand up if (srcBeing) - { srcBeing->setAction(Being::STAND); - } break; } break; diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index bb5b5abd..28830e67 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -137,11 +137,11 @@ void ItemDB::loadSoundRef(ItemInfo &itemInfo, xmlNodePtr node) if (event == "hit") { - itemInfo.addSound(EQUIP_EVENT_HIT, filename); + itemInfo.addSound(EquipmentSoundEvent::HIT, filename); } - else if (event == "strike") + else if (event == "strike" || event == "miss") { - itemInfo.addSound(EQUIP_EVENT_STRIKE, filename); + itemInfo.addSound(EquipmentSoundEvent::STRIKE, filename); } else { diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index a5b62fdc..78c808da 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -30,10 +30,10 @@ #include <string> #include <vector> -enum EquipmentSoundEvent +enum class EquipmentSoundEvent { - EQUIP_EVENT_STRIKE, - EQUIP_EVENT_HIT + STRIKE, + HIT }; /** |