BlueGit

timfa questward

Clear deferred combat hits on despawn/respawn so empty HP bars do not stick.

Projectile killing blows queue health=0 until impact; if that runs after the target already respawned, the bar stayed empty despite full HP.

timfa Tim Falken · pushed by timfa

Authored 2026-08-31 · 2 months ago

Hash
7e99a71c30bfb174ee150757b9c36e95338be498
Parent
4a779bdf
2 files changed +23 −0
client/src/play/main.js +2 −0
@@ -2027,6 +2027,8 @@ async function main ()
2027 2027 break;
2028 2028 case MessageType.playerRespawned:
2029 2029 death?.hide();
2030 // Drop deferred killing-blow health=0 that may still be queued on a projectile.
2031 view?.cancelDeferredCombatHits?.(message.entityId);
2030 2032 view?.updateEntityHealth(message.entityId, message.health, message.maxHealth);
2031 2033 if (message.entityId === view?.localEntityId)
2032 2034 {
@@ -2027,6 +2027,8 @@ async function main ()
2027 break;
2027 break;
2028 case MessageType.playerRespawned:
2028 case MessageType.playerRespawned:
2029 death?.hide();
2029 death?.hide();
2030 // Drop deferred killing-blow health=0 that may still be queued on a projectile.
2031 view?.cancelDeferredCombatHits?.(message.entityId);
2030 view?.updateEntityHealth(message.entityId, message.health, message.maxHealth);
2032 view?.updateEntityHealth(message.entityId, message.health, message.maxHealth);
2031 if (message.entityId === view?.localEntityId)
2033 if (message.entityId === view?.localEntityId)
2032 {
2034 {
client/src/render/worldView.js +21 −0
@@ -694,6 +694,8 @@ export class WorldView
694 694
695 695 spawnEntity (payload)
696 696 {
697 // Fresh spawn is authoritative; do not let an older deferred hit overwrite HP.
698 this.cancelDeferredCombatHits(payload?.entityId);
697 699 this.#upsertEntity(payload);
698 700 }
699 701
@@ -735,6 +737,7 @@ export class WorldView
735 737
736 738 despawnEntity (entityId)
737 739 {
740 this.cancelDeferredCombatHits(entityId);
738 741 const existing = this.entities.get(entityId);
739 742 if (!existing)
740 743 { return; }
@@ -748,6 +751,24 @@ export class WorldView
748 751 this.entities.delete(entityId);
749 752 }
750 753
754 /**
755 * Drop queued combat-hit/block presentation for a target.
756 * Killing blows often defer health=0 until a projectile lands; if the
757 * target already despawned or respawned, that stale apply must not run.
758 */
759 cancelDeferredCombatHits (targetId)
760 {
761 if (targetId == null)
762 { return; }
763 for (const swipe of this.swipes)
764 {
765 if (swipe.targetId !== targetId)
766 { continue; }
767 swipe.onImpact = null;
768 swipe.trackTarget = false;
769 }
770 }
771
751 772 updateEntitySkull (entityId, skullValue)
752 773 {
753 774 const entity = this.entities.get(entityId);
@@ -694,6 +694,8 @@ export class WorldView
694
694
695 spawnEntity (payload)
695 spawnEntity (payload)
696 {
696 {
697 // Fresh spawn is authoritative; do not let an older deferred hit overwrite HP.
698 this.cancelDeferredCombatHits(payload?.entityId);
697 this.#upsertEntity(payload);
699 this.#upsertEntity(payload);
698 }
700 }
699
701
@@ -735,6 +737,7 @@ export class WorldView
735
737
736 despawnEntity (entityId)
738 despawnEntity (entityId)
737 {
739 {
740 this.cancelDeferredCombatHits(entityId);
738 const existing = this.entities.get(entityId);
741 const existing = this.entities.get(entityId);
739 if (!existing)
742 if (!existing)
740 { return; }
743 { return; }
@@ -748,6 +751,24 @@ export class WorldView
748 this.entities.delete(entityId);
751 this.entities.delete(entityId);
749 }
752 }
750
753
754 /**
755 * Drop queued combat-hit/block presentation for a target.
756 * Killing blows often defer health=0 until a projectile lands; if the
757 * target already despawned or respawned, that stale apply must not run.
758 */
759 cancelDeferredCombatHits (targetId)
760 {
761 if (targetId == null)
762 { return; }
763 for (const swipe of this.swipes)
764 {
765 if (swipe.targetId !== targetId)
766 { continue; }
767 swipe.onImpact = null;
768 swipe.trackTarget = false;
769 }
770 }
771
751 updateEntitySkull (entityId, skullValue)
772 updateEntitySkull (entityId, skullValue)
752 {
773 {
753 const entity = this.entities.get(entityId);
774 const entity = this.entities.get(entityId);