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

If the Eidolon is removed by any means from the Eidolon Plane it will instantly come back

git-svn-id: http://svn.net-core.org/repos/t-engine4@3430 51575b47-30f0-44d4-a5cc-537603b46e54
parent 03a261b8
No related branches found
No related tags found
No related merge requests found
......@@ -98,7 +98,7 @@ function _M:addEntity(e, after)
end
--- Removes an entity from the level
function _M:removeEntity(e)
function _M:removeEntity(e, force)
if e._fake_level_entity then
-- Tells it to delete itself if needed
if e.deleteFromMap then e:deleteFromMap(self.map) end
......@@ -107,7 +107,7 @@ function _M:removeEntity(e)
return
end
if not self.entities[e.uid] then error("Entity "..e.uid.."("..e.name..") not present on the level") end
if not self.entities[e.uid] and not force then error("Entity "..e.uid.."("..e.name..") not present on the level") end
self.entities[e.uid] = nil
for i = 1, #self.e_array do
if self.e_array[i] == e then
......
......@@ -75,6 +75,24 @@ return {
who:addObject(who.INVEN_INVEN, o)
end,
on_turn = function()
local eidolon = nil
for uid, e in pairs(game.level.entities) do
if e.define_as == "EIDOLON" then eidolon = e end
end
if not eidolon then
eidolon = game.zone:makeEntityByName(game.level, "actor", "EIDOLON")
local x, y = util.findFreeGrid(game.player.x, game.player.y, 10, true, {[engine.Map.ACTOR] = true})
if x and y then game.zone:addEntity(game.level, eidolon, "actor", x, y) end
elseif not eidolon.x or game.level.map(eidolon.x, eidolon.y, engine.Map.ACTOR) ~= eidolon then
eidolon.deleteFromMap = false
game.level:removeEntity(eidolon, true)
local x, y = util.findFreeGrid(game.player.x, game.player.y, 10, true, {[engine.Map.ACTOR] = true})
if x and y then game.zone:addEntity(game.level, eidolon, "actor", x, y) end
eidolon.deleteFromMap = nil
end
end,
eidolon_exit = function(to_worldmap)
game:onTickEnd(function()
local oldzone = game.zone
......
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