Dmap and stealth/invis/etc?
Posted: Fri Apr 29, 2011 7:39 pm
I was looking into tiger_eye's bug report about fleeing and stealth (link) and tracked it down to how the dmap features are not obfuscated with the aiSeeTargetPos method. How should this work? Should we assume that anything with dmap has a supernatural sense for the player and leave it as is? In that case we should introduce a flee_simple AI routine that uses aiSeeTargetPos, something like this:
An alternative would be to add some random values to the move/flee_dmap that takes into account the canSee chance. Thoughts?
Code: Select all
newAI("flee_simple", function(self)
if self.ai_target.actor then
local tx, ty = self:aiSeeTargetPos(self.ai_target.actor)
local dir = 5
local bestdist = 0
for i = 1, 9 do
local sx, sy = util.coordAddDir(self.x, self.y, i)
local sqdist = math.pow(self.x - sx, 2) + math.pow(self.y - sy, 2)
if self:canMove(sx, sy) and sqdist < bestdist then
bestdist = sqdist
dir = i
end
end
return self:moveDirection(util.coordAddDir(tx, ty, dir))
end
end)