From 62bd98555965464f08e9eb124b0907cf80bad166 Mon Sep 17 00:00:00 2001 From: Justin Jacobs Date: Sat, 4 Jan 2025 10:56:57 -0500 Subject: [PATCH] Entity: Don't show combat text when damage reflect is 0 This would occur when the entity that would be reflecting damage was hit with a zero-damage power with `ignore_zero_damage=true`. --- RELEASE_NOTES.txt | 1 + src/Entity.cpp | 33 +++++++++++++++++---------------- src/Version.cpp | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index e2ef8c6ea..c1b7e8935 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -68,6 +68,7 @@ Engine fixes: * Prevent summons with zero base speed from teleporting with their summoner. * The text for dialog options now respects the 'font_dialog' property in menus/talker.txt. * Fixed books not closing properly when trying to load another book with an invalid filename. +* Fixed combat text being shown for zero damage reflect. * Android: Fix 'Flare' directory not being automatically created. * Android: Added a dialog to direct the player to the wiki page for installing if no game data is found. diff --git a/src/Entity.cpp b/src/Entity.cpp index f5545242f..430a5b080 100644 --- a/src/Entity.cpp +++ b/src/Entity.cpp @@ -587,22 +587,23 @@ bool Entity::takeHit(Hazard &h) { // deal return damage if (stats.get(Stats::RETURN_DAMAGE) > 0) { - if (Math::percentChanceF(h.src_stats->get(Stats::RESIST_DAMAGE_REFLECT))) { - comb->addString(msg->get("Resist"), stats.pos, CombatText::MSG_MISS); - } - else { - float dmg_return = (dmg * stats.get(Stats::RETURN_DAMAGE)) / 100.f; - dmg_return = eset->combat.resourceRound(dmg_return); - - // swap the source type when dealing return damage - int return_source_type = Power::SOURCE_TYPE_NEUTRAL; - if (h.source_type == Power::SOURCE_TYPE_HERO || h.source_type == Power::SOURCE_TYPE_ALLY) - return_source_type = Power::SOURCE_TYPE_ENEMY; - else if (h.source_type == Power::SOURCE_TYPE_ENEMY) - return_source_type = stats.hero ? Power::SOURCE_TYPE_HERO : Power::SOURCE_TYPE_ALLY; - - h.src_stats->takeDamage(dmg_return, !StatBlock::TAKE_DMG_CRIT, return_source_type); - comb->addFloat(dmg_return, h.src_stats->pos, CombatText::MSG_GIVEDMG); + float dmg_return = (dmg * stats.get(Stats::RETURN_DAMAGE)) / 100.f; + dmg_return = eset->combat.resourceRound(dmg_return); + if (dmg_return > 0) { + if (Math::percentChanceF(h.src_stats->get(Stats::RESIST_DAMAGE_REFLECT))) { + comb->addString(msg->get("Resist"), stats.pos, CombatText::MSG_MISS); + } + else { + // swap the source type when dealing return damage + int return_source_type = Power::SOURCE_TYPE_NEUTRAL; + if (h.source_type == Power::SOURCE_TYPE_HERO || h.source_type == Power::SOURCE_TYPE_ALLY) + return_source_type = Power::SOURCE_TYPE_ENEMY; + else if (h.source_type == Power::SOURCE_TYPE_ENEMY) + return_source_type = stats.hero ? Power::SOURCE_TYPE_HERO : Power::SOURCE_TYPE_ALLY; + + h.src_stats->takeDamage(dmg_return, !StatBlock::TAKE_DMG_CRIT, return_source_type); + comb->addFloat(dmg_return, h.src_stats->pos, CombatText::MSG_GIVEDMG); + } } } } diff --git a/src/Version.cpp b/src/Version.cpp index b0c9697b3..701ab1948 100644 --- a/src/Version.cpp +++ b/src/Version.cpp @@ -30,7 +30,7 @@ FLARE. If not, see http://www.gnu.org/licenses/ #include -Version VersionInfo::ENGINE(1, 14, 83); +Version VersionInfo::ENGINE(1, 14, 84); Version VersionInfo::MIN(0, 0, 0); Version VersionInfo::MAX(USHRT_MAX, USHRT_MAX, USHRT_MAX);