Repository navigation
fix(view): never show a living creature at 0 health - #4
Open
sorcerer-merlin wants to merge 1 commit into
Open
sorcerer-merlin wants to merge 1 commit into
sorcerer-merlin wants to merge 1 commit into
Conversation
GetViewPool scales health to the viewer's effective level and rounds down, so a creature at 1 HP (142 real, 84 shown) was sent as 0. The client treats health 0 as death (OnDeath), so it played the death animation while the server kept the creature alive and fighting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With the Z-14 per-viewer view enabled, a creature shown at a lower effective level than its real one can have
its health bar sent to the viewer as 0 while it is still alive.
ZoneScalingMgr::GetViewPool(src/ZoneScalingCombat.cpp) scales current health to the viewer's max andtruncates:
out.Health = uint32(uint64(creature->GetHealth()) * out.MaxHealth / realMax);The 3.3.5a client treats
UNIT_FIELD_HEALTHreaching 0 as the unit's death: it plays the death animation,writes " dies." to the combat log and keeps showing the unit as a corpse. The server still has the
creature alive, so the client then shows a "corpse" that keeps attacking, talks, or slides along the ground
when it moves.
It hits whenever
realHealth < realMax / shownMax, so only for viewers below the creature's real level, andonly at very low health. It's easiest to reproduce with any creature that a script holds at a low health floor
(e.g. SmartAI
SET_INVINCIBILITY_HP_LEVELfor "beat them down" quest NPCs): a creature with 142 real max healthheld at 1 HP, viewed at a level where its max shows as 84, is sent
1 × 84 / 142 = 0. Ordinary mobs show itbriefly as a "death" one hit early.
Fix
If the creature has any health left, the viewer sees at least 1:
The real health and every server-side calculation are unchanged; only the value sent to the viewer is affected.
Mana is left as is (0 mana doesn't mean anything to the client).
Testing
On a 3.3.5a server with Z-14 active: a level 1 character fought level 3 quest NPCs held at 1 HP by a SmartAI
invincibility floor. Before: the client showed them dead (
UnitHealth0,UnitIsDeadtrue) while they keptfighting. After: they show 1 HP, alive, and their scripted surrender plays normally. Regular kills are
unaffected (health really reaches 0 on death).