diff --git a/src/creatures/combat/combat.cpp b/src/creatures/combat/combat.cpp index f5ec13f3473..151e5458a85 100644 --- a/src/creatures/combat/combat.cpp +++ b/src/creatures/combat/combat.cpp @@ -2024,13 +2024,12 @@ void Combat::applyExtensions(std::shared_ptr caster, std::shared_ptrgetPlayer(); auto monster = caster->getMonster(); if (player) { chance = player->getSkillLevel(SKILL_CRITICAL_HIT_CHANCE); - multiplier = player->getSkillLevel(SKILL_CRITICAL_HIT_DAMAGE); - + bonus = player->getSkillLevel(SKILL_CRITICAL_HIT_DAMAGE); if (target) { uint16_t playerCharmRaceid = player->parseRacebyCharm(CHARM_LOW, false, 0); if (playerCharmRaceid != 0) { @@ -2048,8 +2047,8 @@ void Combat::applyExtensions(std::shared_ptr caster, std::shared_ptrcritChance(); } - multiplier += damage.criticalDamage; - multiplier = 1 + multiplier / 100; + bonus += damage.criticalDamage; + double multiplier = 1.0 + static_cast(bonus) / 100; chance += (uint16_t)damage.criticalChance; if (chance != 0 && uniform_random(1, 100) <= chance) { diff --git a/src/game/game.cpp b/src/game/game.cpp index b6733395831..e9cb108942e 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -6625,10 +6625,8 @@ bool Game::combatChangeHealth(std::shared_ptr attacker, std::shared_pt } } + std::string attackMsg = fmt::format("{} attack", damage.critical ? "critical " : " "); std::stringstream ss; - ss << (damage.critical ? "critical " : " ") << "attack"; - std::string attackMsg = ss.str(); - ss.str({}); if (target->hasCondition(CONDITION_MANASHIELD) && damage.primary.type != COMBAT_UNDEFINEDDAMAGE) { int32_t manaDamage = std::min(target->getMana(), healthChange); @@ -6915,17 +6913,19 @@ void Game::buildMessageAsSpectator( ) const { if (spectatorMessage.empty()) { ss.str({}); + auto attackMsg = damage.critical ? "critical " : ""; + auto article = damage.critical ? "a" : "an"; ss << ucfirst(target->getNameDescription()) << " loses " << damageString; if (attacker) { ss << " due to "; if (attacker == target) { if (targetPlayer) { - ss << targetPlayer->getPossessivePronoun() << " own attack"; + ss << targetPlayer->getPossessivePronoun() << " own " << attackMsg << "attack"; } else { - ss << "its own attack"; + ss << "its own " << attackMsg << "attack"; } } else { - ss << "an attack by " << attacker->getNameDescription(); + ss << article << " " << attackMsg << "attack by " << attacker->getNameDescription(); } } ss << '.'; @@ -6945,13 +6945,15 @@ void Game::buildMessageAsTarget( const std::string &damageString ) const { ss.str({}); + auto attackMsg = damage.critical ? "critical " : ""; + auto article = damage.critical ? "a" : "an"; ss << "You lose " << damageString; if (!attacker) { ss << '.'; } else if (targetPlayer == attackerPlayer) { - ss << " due to your own attack."; + ss << " due to your own " << attackMsg << "attack."; } else { - ss << " due to an attack by " << attacker->getNameDescription() << '.'; + ss << " due to " << article << " " << attackMsg << "attack by " << attacker->getNameDescription() << '.'; } if (damage.extension) { ss << " " << damage.exString; @@ -6965,7 +6967,7 @@ void Game::buildMessageAsAttacker( std::stringstream &ss, const std::string &damageString ) const { ss.str({}); - ss << ucfirst(target->getNameDescription()) << " loses " << damageString << " due to your attack."; + ss << ucfirst(target->getNameDescription()) << " loses " << damageString << " due to your " << (damage.critical ? "critical " : " ") << "attack."; if (damage.extension) { ss << " " << damage.exString; }