Skip to content

Commit

Permalink
Merge pull request #10 from jprzimba/fix-damage
Browse files Browse the repository at this point in the history
* Fixed sending damage higher then monster health
  • Loading branch information
jprzimba authored Dec 30, 2024
2 parents f602f6c + e06a056 commit 2e3c23a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7496,6 +7496,13 @@ bool Game::combatChangeHealth(const std::shared_ptr<Creature> &attacker, const s

addCreatureHealth(spectators.data(), target);

int32_t adjustedDamage = realDamage;
if (target) {
if (realDamage > targetHealth) {
adjustedDamage = targetHealth > 0 ? targetHealth : realDamage;
}
}

sendDamageMessageAndEffects(
attacker,
target,
Expand All @@ -7505,7 +7512,7 @@ bool Game::combatChangeHealth(const std::shared_ptr<Creature> &attacker, const s
targetPlayer,
message,
spectators.data(),
realDamage
adjustedDamage // realDamage
);

if (attackerPlayer) {
Expand Down

0 comments on commit 2e3c23a

Please sign in to comment.