Fix: Critical hits by monsters#3606
Conversation
|
|
Couldn't reproduce here with 2 players and attack giant spider with SD |
dudantas
left a comment
There was a problem hiding this comment.
The change just converts
} else if (monster) { ... }into
return; // early-return for players
...
if (monster) { ... }Because a Creature can’t be both player and monster at the same time, the old else if already guaranteed that the monster block ran only when the caster was not a player.
I tested the scenario described in #3600 but couldn’t reproduce any double-critical or inflated damage; numbers are identical before and after the patch.
So the change has no practical effect, it’s only a stylistic refactor (early-return vs. else if). If you’re seeing different damage, please share exact repro steps or a minimal test case.
As mentioned in #3545 How to Reproduce |
|
Reproduced here too! My bad, I was hitting the giant spider not the player 19:43 You lose 113 hitpoints due to an attack by a giant spider.
19:43 You lose 555 hitpoints due to an attack by Player Two.
19:43 You lose 19 hitpoints due to an attack by a giant spider.
19:43 You lose 1111 hitpoints due to an attack by a giant spider.
19:44 You lose 139 hitpoints due to an attack by a giant spider.
19:44 You lose 546 hitpoints due to an attack by Player Two.
19:44 You lose 141 hitpoints due to an attack by a giant spider.
19:44 You lose 1093 hitpoints due to an attack by a giant spider.
19:44 You lose 88 hitpoints due to an attack by a giant spider. |
I think that the problems is not the monster.attacks = {
{ name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -300, condition = { type = CONDITION_POISON, totalDamage = 160, interval = 4000 } },
{ name = "poisonfield", interval = 2000, chance = 10, range = 7, radius = 1, shootEffect = CONST_ANI_POISON, target = true },
{ name = "combat", interval = 2000, chance = 10, type = COMBAT_EARTHDAMAGE, minDamage = -40, maxDamage = -70, range = 7, radius = 1, shootEffect = CONST_ANI_POISON, target = true },
}Maybe it's getting some "garbage" or "ref" from last player damage, as we can see the giant spider hit the player with death damage |
|
Most important was missing "return;" previously in player logic. Without it, the player-specific critical and fatal hit bonuses are applied first, but then the monster logic also executes afterward. As a result, you may encounter: |
|
This PR is stale because it has been open 45 days with no activity. |
|
Still the same, I don't think it's the creature's critical hit, I disabled mine before running the test again and a giant spider attacks the same damage as the player, only bigger, in this case the sd 03:29 Test Dois loses 22688 hitpoints due to an attack by a giant spider. 2025-08-27.03-29-28.mp4 |
|
It is also happening on NO-PVP servers.
|
I have the same problem, it reproduces, with a knight or any vocation you stay blocking a creature and with another character you start hitting the one who blocked the creature with sd, or spells and you will notice that the creature replicates and increases the damage caused by the other character |
According to ChatGPT Creatures should use their own Combat Damage when attacking. Key Technical Issue Consequence In the CombatFunc function, when applying damage (func), tmpDamage is used if creature->getCombatDamage() is empty. |
|
This PR is stale because it has been open 45 days with no activity. |
|
https://github.com/opentibiabr/canary/blob/main/src/creatures/combat/combat.cpp#L2410 https://github.com/opentibiabr/canary/blob/main/src/creatures/combat/combat.cpp#L1325 |
|
Resolved here: #3800 |




Description
Simple fix, adding missing return to prevent monster logic from executing
based on fix suggestion:
#3545 (comment)
Behaviour
Actual
"When a player casts a spell/attack, the damage calculation incorrectly continues execution into the monster logic section, causing monster critical damage modifiers to be applied on top of player damage calculations. This results in significantly higher damage than intended."
Expected
Proper monster critical damage calculation
Fixes #issuenumber
#3600
Type of change
Test Configuration:
Checklist