diff --git a/game/engines/default/engine/interface/ActorAI.lua b/game/engines/default/engine/interface/ActorAI.lua index e1a45b1b288d1f5fdd79d693de72fd93e8bc20b5..ba9ade5b4da83564c47f8d000184dccc21ebc808 100644 --- a/game/engines/default/engine/interface/ActorAI.lua +++ b/game/engines/default/engine/interface/ActorAI.lua @@ -190,7 +190,7 @@ function _M:aiSeeTargetPos(target) if LSeen.GCache_x then -- update guess with new random position. Could use util.findFreeGrid here at cost of speed tx = math.floor(LSeen.GCache_x + (tx-LSeen.GCache_x)/2) ty = math.floor(LSeen.GCache_y + (ty-LSeen.GCache_y)/2) - if not target:canMove(tx, ty, true) or (tx == self.x and ty == self.y) then -- find a reasonable spot if target can't be at that position + if (target.canMove and not target:canMove(tx, ty, true)) or (tx == self.x and ty == self.y) then -- find a reasonable spot if target can't be at that position local nx, ny = util.findFreeGrid(tx, ty, math.max(1, spread), false) if nx then tx, ty = nx, ny end end