Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Astar = require "engine.Astar"
- newAI("creep_move_simple", function(self)
- if self.ai_target.grid then
- local tx, ty = self:aiSeeTargetPos(self.ai_target.grid)
- return self:moveDirection(tx, ty)
- end
- end)
- newAI("creep_move_astar", function(self)
- if self.ai_target.grid then
- local tx, ty = self:aiSeeTargetPos(self.ai_target.grid)
- if tx==self.x and ty==self.y then
- self:spawnSinkReached()
- end
- local a = Astar.new(game.level.map, self)
- local path = a:calc(self.x, self.y, tx, ty)
- if not path then
- return self:runAI("creep_move_simple")
- else
- return self:move(path[1].x, path[1].y)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement