Skip to content
Snippets Groups Projects
Commit 32c14f3d authored by dg's avatar dg
Browse files

Fix FOV error at the Mouth and others

git-svn-id: http://svn.net-core.org/repos/t-engine4@6233 51575b47-30f0-44d4-a5cc-537603b46e54
parent 9a633391
No related branches found
No related tags found
No related merge requests found
......@@ -156,7 +156,8 @@ function _M:aiSeeTargetPos(target)
local tx, ty = target.x, target.y
local spread = 0
if target == self.ai_target.actor and self.ai_state.target_last_seen and not self:hasLOS(self.ai_state.target_last_seen.x, self.ai_state.target_last_seen.y) then
-- Adding some type-safety checks, but this isn't fixing the source of the errors
if target == self.ai_target.actor and self.ai_state.target_last_seen and type(self.ai_state.target_last_seen) == "table" and self.ai_state.target_last_seen.x and not self:hasLOS(self.ai_state.target_last_seen.x, self.ai_state.target_last_seen.y) then
tx, ty = self.ai_state.target_last_seen.x, self.ai_state.target_last_seen.y
spread = spread + math.floor((game.turn - (self.ai_state.target_last_seen.turn or game.turn)) / (game.energy_to_act / game.energy_per_tick))
end
......
......@@ -168,9 +168,18 @@ function _M:seen_by(who)
if self.ai_target.actor then
-- Pass last seen coordinates
if self.ai_target.actor == who.ai_target.actor then
local last_seen = ((self.ai_state.target_last_seen and self.ai_state.target_last_seen.turn or game.turn) > (who.ai_state.target_last_seen and who.ai_state.target_last_seen.turn or game.turn)) and self.ai_state.target_last_seen or who.ai_state.target_last_seen
self.ai_state.target_last_seen = last_seen
who.ai_state.target_last_seen = last_seen
-- Adding some type-safety checks, but this isn't fixing the source of the errors
local last_seen = {turn=0}
if self.ai_state.target_last_seen and type(self.ai_state.target_last_seen) == "table" then
last_seen = self.ai_state.target_last_seen
end
if who.ai_state.target_last_seen and type(who.ai_state.target_last_seen) == "table" and who.ai_state.target_last_seen.turn > last_seen.turn then
last_seen = who.ai_state.target_last_seen
end
if last_seen.x and last_seen.y then
self.ai_state.target_last_seen = last_seen
who.ai_state.target_last_seen = last_seen
end
end
return
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment