Skip to content

Commit

Permalink
Entity: Don't show combat text when damage reflect is 0
Browse files Browse the repository at this point in the history
This would occur when the entity that would be reflecting damage was hit
with a zero-damage power with `ignore_zero_damage=true`.
  • Loading branch information
dorkster committed Jan 4, 2025
1 parent 973418f commit 62bd985
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
33 changes: 17 additions & 16 deletions src/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ FLARE. If not, see http://www.gnu.org/licenses/

#include <SDL.h>

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);

Expand Down

0 comments on commit 62bd985

Please sign in to comment.