From 8ede1b841ac3ed50021858bbd830689e0d548e0f Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Fri, 21 Jun 2024 22:02:33 -0700 Subject: [PATCH] Use ActiveEntity.getFaceDirection to determine sprite drawing... ...index. Defaults to "down" when facing direction cannot be determined. Closes: https://github.com/arianne/stendhal/issues/721 --- src/js/stendhal/entity/RPEntity.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/js/stendhal/entity/RPEntity.ts b/src/js/stendhal/entity/RPEntity.ts index 6931663e54..3a81984ff8 100644 --- a/src/js/stendhal/entity/RPEntity.ts +++ b/src/js/stendhal/entity/RPEntity.ts @@ -553,13 +553,14 @@ export class RPEntity extends ActiveEntity { if (image.height) { // image.complete is true on missing image files var nFrames = 3; var nDirections = 4; - var yRow = this["dir"] - 1; + const facing = this.getFaceDirection().val; + var yRow = facing - 1; var frame = 1; // draw center column when idle // Ents are a hack in Java client too if (this["class"] == "ent") { nFrames = 1; nDirections = 2; - yRow = Math.floor((this["dir"] - 1) / 2); + yRow = Math.floor((facing - 1) / 2); frame = 0; } this["drawHeight"] = image.height as number / nDirections;