From d978b8e14e6ea9dd7e00b0cf5d2607bab0d6ec1b Mon Sep 17 00:00:00 2001 From: mimus-assa <73607556+mimus-assa@users.noreply.github.com> Date: Wed, 5 Aug 2026 08:28:00 -0600 Subject: [PATCH] fix: NPC dialog window shows the wrong NPC when several are in talk range (#1795) Bug Fixes: - NPC conversations now open with the currently active NPC instead of the oldest listed NPC. --- modules/game_npctrade/controllers/npc_dialog.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/game_npctrade/controllers/npc_dialog.lua b/modules/game_npctrade/controllers/npc_dialog.lua index 3b3a45d5e..7d01922cb 100644 --- a/modules/game_npctrade/controllers/npc_dialog.lua +++ b/modules/game_npctrade/controllers/npc_dialog.lua @@ -169,7 +169,10 @@ function onNpcChatWindow(data) if type(data) ~= "table" or type(data.npcIds) ~= "table" or #data.npcIds == 0 then return end - local creature = g_map.getCreatureById(data.npcIds[1]) + -- The server appends every greeting NPC to the list and builds the buttons from the + -- LAST id (the active conversation); npcIds[1] is the oldest, e.g. a bystander that + -- happened to be in talk range. Showing npcIds[1] paints the wrong name and outfit. + local creature = g_map.getCreatureById(data.npcIds[#data.npcIds]) if creature then controllerNpcTrader:initNpcWindow(creature, data.buttons) end