From 5dc827c770fbe2da1b0f4f25cceef15081a96bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Wed, 15 Jan 2025 19:27:35 -0300 Subject: [PATCH 1/2] * Fix mana drain not displayed in Input Analyzer --- src/game/game.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index 1b2333d..0ce341d 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -7466,7 +7466,7 @@ bool Game::combatChangeHealth(const std::shared_ptr &attacker, const s } auto targetHealth = target->getHealth(); - realDamage = damage.primary.value + damage.secondary.value; + realDamage = std::min(targetHealth, damage.primary.value + damage.secondary.value); if (realDamage == 0) { return true; } else if (realDamage >= targetHealth) { @@ -7500,14 +7500,7 @@ bool Game::combatChangeHealth(const std::shared_ptr &attacker, const s spectators.find(targetPos, true); } - addCreatureHealth(spectators.data(), target); - - int32_t adjustedDamage = realDamage; - if (target) { - if (realDamage > targetHealth) { - adjustedDamage = targetHealth > 0 ? targetHealth : realDamage; - } - } + addCreatureHealth(spectators.data(), target); sendDamageMessageAndEffects( attacker, @@ -7518,7 +7511,7 @@ bool Game::combatChangeHealth(const std::shared_ptr &attacker, const s targetPlayer, message, spectators.data(), - adjustedDamage // realDamage + realDamage ); if (attackerPlayer) { @@ -7933,6 +7926,14 @@ bool Game::combatChangeMana(const std::shared_ptr &attacker, const std } target->drainMana(attacker, manaLoss); + std::string cause = "(other)"; + if (attacker) { + cause = attacker->getName(); + } + + if (targetPlayer) { + targetPlayer->updateInputAnalyzer(damage.primary.type, manaLoss, cause); + } std::stringstream ss; @@ -7964,7 +7965,7 @@ bool Game::combatChangeMana(const std::shared_ptr &attacker, const std } else if (targetPlayer == attackerPlayer) { ss << " due to your own attack."; } else { - ss << " mana due to an attack by " << attacker->getNameDescription() << '.'; + ss << " due to an attack by " << attacker->getNameDescription() << '.'; } message.type = MESSAGE_DAMAGE_RECEIVED; message.text = ss.str(); From f273d2aebde7d1535a6fe28901e4ee91822ccb07 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 15 Jan 2025 22:28:06 +0000 Subject: [PATCH 2/2] Code format - (Clang-format) --- src/game/game.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index 0ce341d..6f3d430 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -7500,7 +7500,7 @@ bool Game::combatChangeHealth(const std::shared_ptr &attacker, const s spectators.find(targetPos, true); } - addCreatureHealth(spectators.data(), target); + addCreatureHealth(spectators.data(), target); sendDamageMessageAndEffects( attacker, @@ -7930,7 +7930,7 @@ bool Game::combatChangeMana(const std::shared_ptr &attacker, const std if (attacker) { cause = attacker->getName(); } - + if (targetPlayer) { targetPlayer->updateInputAnalyzer(damage.primary.type, manaLoss, cause); }