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.
This commit is contained in:
mimus-assa 2026-08-05 08:28:00 -06:00 committed by GitHub
parent 46ec6f13de
commit d978b8e14e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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