Skip to content

Commit

Permalink
Fixed npc disappear when they can not see player while speaking
Browse files Browse the repository at this point in the history
  • Loading branch information
xomachine committed Mar 5, 2018
1 parent 0faec4c commit 6b511f6
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions translations/others/scripts/quest/text_generation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,22 @@ function QuestTextGenerator:generateExtraTags()
local mindist = 100000
local pl = nil
for idx, pid in pairs(world.players()) do
if entity.entityInSight(pid) then
local dstv = entity.distanceToEntity(pid)
local dst = dstv[1] * dstv[1] + dstv[2] * dstv[2]
if dst < mindist then
mindist = dst
pl = pid
end
local dstv = entity.distanceToEntity(pid)
local dst = dstv[1] * dstv[1] + dstv[2] * dstv[2]
if dst < mindist then
mindist = dst
pl = pid
end
end
self.parameters["player"] = {
gender = world.entityGender(pl),
species = world.entitySpecies(pl),
name = world.entityName(pl),
type = "entity",
id = function() return pl end
}
if pl then
self.parameters["player"] = {
gender = world.entityGender(pl),
species = world.entitySpecies(pl),
name = world.entityName(pl),
type = "entity",
id = function() return pl end
}
end
end
end

Expand Down

0 comments on commit 6b511f6

Please sign in to comment.