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

Leaving the level while an escort quest is going on will doom the escort

git-svn-id: http://svn.net-core.org/repos/t-engine4@1614 51575b47-30f0-44d4-a5cc-537603b46e54
parent a7dc91c3
No related branches found
No related tags found
No related merge requests found
......@@ -352,6 +352,8 @@ function _M:changeLevel(lev, zone, keep_old_lev, force_down)
if nz then zone = nz end
end
if self.zone and self.level then self.player:onLeaveLevel(self.zone, self.level) end
local old_lev = (self.level and not zone) and self.level.level or -1000
if keep_old_lev then old_lev = self.level.level end
if zone then
......
......@@ -110,6 +110,16 @@ function _M:onEnterLevel(zone, level)
end
end
function _M:onLeaveLevel(zone, level)
-- Fail past escort quests
local eid = "escort-duty-"..zone.short_name.."-"..level.level
if self.quests and self.quests[eid] then
local q = self.quests[eid]
q.abandoned = true
self:setQuestStatus(eid, q.FAILED)
end
end
function _M:move(x, y, force)
local moved = mod.class.Actor.move(self, x, y, force)
if moved then
......
......@@ -258,6 +258,17 @@ desc = function(self, who)
return table.concat(desc, "\n")
end
on_status_change = function(self, who, status, sub)
if status == self.FAILED then
for uid, e in pairs(game.level.entities) do
if e.quest_id and e.quest_id == self.id then
e:disappear()
e:removed()
end
end
end
end
local function getPortalSpot(npc, dist, min_dist)
local astar = Astar.new(game.level.map, npc)
local poss = {}
......
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