Skip to content
Snippets Groups Projects
Commit 12e6aa72 authored by dg's avatar dg
Browse files

Escort quest AI will now try to not get stuck deciding between two possible ways

git-svn-id: http://svn.net-core.org/repos/t-engine4@1175 51575b47-30f0-44d4-a5cc-537603b46e54
parent f3cd48b4
No related branches found
No related tags found
No related merge requests found
......@@ -35,13 +35,17 @@ function _M:add(x, y, duration, xvel, yvel, str, color, bigfont)
color = color or {255,255,255}
local s = core.display.drawStringBlendedNewSurface(bigfont and self.bigfont or self.font, str, color[1], color[2], color[3])
if not s then return end
local w, h = s:getSize()
local t, tw, th = s:glTexture()
local f = {
x=x,
y=y,
w=w, h=h,
tw=tw, th=th,
duration=duration or 10,
xvel = xvel or 0,
yvel = yvel or 0,
s = s
t = t,
}
self.flyers[f] = true
return f
......@@ -57,7 +61,7 @@ function _M:display()
local dels = {}
for fl, _ in pairs(self.flyers) do
fl.s:toScreen(fl.x, fl.y)
fl.t:toScreenFull(fl.x, fl.y, fl.w, fl.h, fl.tw, fl.th)
fl.x = fl.x + fl.xvel
fl.y = fl.y + fl.yvel
fl.duration = fl.duration - 1
......
......@@ -45,10 +45,15 @@ newAI("move_escort", function(self)
local tx, ty = self.escort_target.x, self.escort_target.y
local a = Astar.new(game.level.map, self)
local path = a:calc(self.x, self.y, tx, ty)
local path = self.escort_path
if not path or #path == 0 then path = a:calc(self.x, self.y, tx, ty) end
if not path then
return self:runAI("move_simple")
else
self.escort_path = {}
for i = 1, 3 do
if path[i+1] then self.escort_path[i] = path[i+1] end
end
return self:move(path[1].x, path[1].y)
end
end
......
......@@ -435,13 +435,14 @@ function _M:display()
if not self.zone_name_s then
local s = core.display.drawStringBlendedNewSurface(self.player_display.font, ("%s (%d)"):format(self.zone.name, self.level.level), 0, 255, 255)
self.zone_name_s = s:glTexture()
self.zone_name_w, self.zone_name_h = s:getSize()
self.zone_name_s, self.zone_name_tw, self.zone_name_th = s:glTexture()
end
self.zone_name_s:toScreen(
self.zone_name_s:toScreenFull(
self.level.map.display_x + self.level.map.viewport.width - self.zone_name_w,
self.level.map.display_y + self.level.map.viewport.height - self.zone_name_h,
self.zone_name_w, self.zone_name_h
self.zone_name_w, self.zone_name_h,
self.zone_name_tw, self.zone_name_th
)
-- Minimap display
......
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