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

Resurrecting now happens on the spot of the last party member death

git-svn-id: http://svn.net-core.org/repos/t-engine4@2536 51575b47-30f0-44d4-a5cc-537603b46e54
parent 6931cc40
No related branches found
No related tags found
No related merge requests found
......@@ -99,6 +99,24 @@ function _M:findMember(filter)
end
end
function _M:setDeathTurn(actor, turn)
local def = self.members[actor]
if not def then return end
def.last_death_turn = turn
end
function _M:findLastDeath()
local max_turn = -9999
local last = nil
for i, actor in ipairs(self.m_list) do
local def = self.members[actor]
if def.last_death_turn and def.last_death_turn > max_turn then max_turn = def.last_death_turn; last = actor end
end
return last or self:findMember{main=true}
end
function _M:canControl(actor, vocal)
if not actor then return false end
if actor == game.player then return false end
......
......@@ -26,6 +26,9 @@ function _M:onPartyDeath(src)
-- Remove from the party if needed
if self.remove_from_party_on_death then
game.party:removeMember(self, true)
-- Overwise note the death turn
else
game.party:setDeathTurn(self, game.turn)
end
-- Die
......
......@@ -91,11 +91,15 @@ function _M:resurrectBasic(actor)
actor.dead = false
actor.died = (actor.died or 0) + 1
local x, y = util.findFreeGrid(actor.x, actor.y, 20, true, {[Map.ACTOR]=true})
if not x then x, y = actor.x, actor.y end
actor.x, actor.y = nil, nil
-- Find the position of the last dead
local last = game.party:findLastDeath()
local x, y = util.findFreeGrid(last.x, last.y, 20, true, {[Map.ACTOR]=true})
if not x then x, y = last.x, last.y end
actor.x, actor.y = nil, nil
actor:move(x, y, true)
game.level:addEntity(actor)
game:unregisterDialog(self)
game.level.map:redisplay()
......
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