BlueGit

timfa questward

Fix mob hover labels missing level.

Include creature level in entity spawn payloads and format mob tooltips
with mobLevelDisplayName so Lv.n Name always shows.

timfa Tim Falken · pushed by timfa

Authored 2026-09-01 · 2 months ago

Hash
f1eee5199d9159f933c12cb71163f2af5bb95116
Parent
bf5e0a0d
2 files changed +14 −5
client/src/play/main.js +13 −5
@@ -22,6 +22,7 @@ import { initContextMenu } from "./contextMenu.js";
22 22 import { initDeath } from "./death.js";
23 23 import { initToasts } from "./toasts.js";
24 24 import { skillLevelUpToastText, skillUnlockMessages } from "/shared/skills/levelUpUnlocks.js";
25 import { mobDefinition, mobLevelDisplayName } from "/shared/definitions/mobs.js";
25 26 import { initQuests } from "./quests.js";
26 27 import { initDialogue } from "./dialogue.js";
27 28 import { initShop } from "./shop.js";
@@ -1395,13 +1396,20 @@ function handleRightClick (event, mouseX, mouseY)
1395 1396
1396 1397 function entityLabel (entity)
1397 1398 {
1399 if (entity?.mobTypeId)
1400 {
1401 const def = mobDefinition(entity.mobTypeId);
1402 const first = (entity?.firstName ?? "").trim();
1403 const last = (entity?.lastName ?? "").trim();
1404 const name = first && last
1405 ? `${first} ${last}`
1406 : (first || def?.displayName || "Creature");
1407 const level = entity?.level ?? def?.attackSkill ?? 1;
1408 return mobLevelDisplayName(level, name);
1409 }
1398 1410 const first = (entity?.firstName ?? "").trim();
1399 1411 const last = (entity?.lastName ?? "").trim();
1400 const name = first && last ? `${first} ${last}` : (first || "target");
1401 const level = entity?.level | 0;
1402 if (entity?.mobTypeId && level > 0)
1403 { return `Lv.${level} ${name}`; }
1404 return name;
1412 return first && last ? `${first} ${last}` : (first || "target");
1405 1413 }
1406 1414
1407 1415 function groundLabel (ground)
@@ -22,6 +22,7 @@ import { initContextMenu } from "./contextMenu.js";
22import { initDeath } from "./death.js";
22import { initDeath } from "./death.js";
23import { initToasts } from "./toasts.js";
23import { initToasts } from "./toasts.js";
24import { skillLevelUpToastText, skillUnlockMessages } from "/shared/skills/levelUpUnlocks.js";
24import { skillLevelUpToastText, skillUnlockMessages } from "/shared/skills/levelUpUnlocks.js";
25import { mobDefinition, mobLevelDisplayName } from "/shared/definitions/mobs.js";
25import { initQuests } from "./quests.js";
26import { initQuests } from "./quests.js";
26import { initDialogue } from "./dialogue.js";
27import { initDialogue } from "./dialogue.js";
27import { initShop } from "./shop.js";
28import { initShop } from "./shop.js";
@@ -1395,13 +1396,20 @@ function handleRightClick (event, mouseX, mouseY)
1395
1396
1396function entityLabel (entity)
1397function entityLabel (entity)
1397{
1398{
1399 if (entity?.mobTypeId)
1400 {
1401 const def = mobDefinition(entity.mobTypeId);
1402 const first = (entity?.firstName ?? "").trim();
1403 const last = (entity?.lastName ?? "").trim();
1404 const name = first && last
1405 ? `${first} ${last}`
1406 : (first || def?.displayName || "Creature");
1407 const level = entity?.level ?? def?.attackSkill ?? 1;
1408 return mobLevelDisplayName(level, name);
1409 }
1398 const first = (entity?.firstName ?? "").trim();
1410 const first = (entity?.firstName ?? "").trim();
1399 const last = (entity?.lastName ?? "").trim();
1411 const last = (entity?.lastName ?? "").trim();
1400 const name = first && last ? `${first} ${last}` : (first || "target");
1412 return first && last ? `${first} ${last}` : (first || "target");
1401 const level = entity?.level | 0;
1402 if (entity?.mobTypeId && level > 0)
1403 { return `Lv.${level} ${name}`; }
1404 return name;
1405}
1413}
1406
1414
1407function groundLabel (ground)
1415function groundLabel (ground)
server/src/gateway/websocket.js +1 −0
@@ -2290,6 +2290,7 @@ export function attachGateway ({ httpServer, auth, stateDb, characters, friends,
2290 2290 hasShop: !!(record.hasShop ?? event.hasShop),
2291 2291 untargetable: !!(record.untargetable ?? event.untargetable),
2292 2292 freeFlight: !!(record.freeFlight ?? event.freeFlight),
2293 level: record.level ?? event.level ?? null,
2293 2294 health: record.health ?? event.health,
2294 2295 maxHealth: record.maxHealth ?? event.maxHealth,
2295 2296 lightRadiusTiles: record.lightRadiusTiles ?? event.lightRadiusTiles ?? 0,
@@ -2290,6 +2290,7 @@ export function attachGateway ({ httpServer, auth, stateDb, characters, friends,
2290 hasShop: !!(record.hasShop ?? event.hasShop),
2290 hasShop: !!(record.hasShop ?? event.hasShop),
2291 untargetable: !!(record.untargetable ?? event.untargetable),
2291 untargetable: !!(record.untargetable ?? event.untargetable),
2292 freeFlight: !!(record.freeFlight ?? event.freeFlight),
2292 freeFlight: !!(record.freeFlight ?? event.freeFlight),
2293 level: record.level ?? event.level ?? null,
2293 health: record.health ?? event.health,
2294 health: record.health ?? event.health,
2294 maxHealth: record.maxHealth ?? event.maxHealth,
2295 maxHealth: record.maxHealth ?? event.maxHealth,
2295 lightRadiusTiles: record.lightRadiusTiles ?? event.lightRadiusTiles ?? 0,
2296 lightRadiusTiles: record.lightRadiusTiles ?? event.lightRadiusTiles ?? 0,