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

Duplicate entities protection

git-svn-id: http://svn.net-core.org/repos/t-engine4@5230 51575b47-30f0-44d4-a5cc-537603b46e54
parent 3dfc7e34
No related branches found
No related tags found
No related merge requests found
......@@ -75,7 +75,10 @@ function _M:addEntity(e, after, no_error)
end
if self.entities[e.uid] and self.entities[e.uid] == e then return end
if self.entities[e.uid] then if no_error then return else error("Entity "..e.uid.."("..(e.name or "???")..") already present on the level") end end
if self.entities[e.uid] then
if self.remove_old_entity_on_duplicate then self:removeEntity(self.entities[e.uid], true) end
if no_error then return else error("Entity "..e.uid.."("..(e.name or "???")..") already present on the level") end
end
self.entities[e.uid] = e
if e.addEntityOrder then after = e:addEntityOrder(level) end
if not after or not self:hasEntity(after) then
......
......@@ -162,6 +162,8 @@ function _M:onWorldEncounter(target, x, y)
end
function _M:describeFloor(x, y)
if self.old_x == x and self.old_y == y then return end
-- Autopickup money
if self:getInven(self.INVEN_INVEN) and not self.no_inventory_access then
local i, nb = 1, 0
......@@ -233,6 +235,8 @@ function _M:move(x, y, force)
-- Update zone name
if game.zone.variable_zone_name then game:updateZoneName() end
self.old_x, self.old_y = self.x, self.y
return moved
end
......
......@@ -87,6 +87,7 @@ for i = 1, 3 do
ov.image = "terrain/pedestal_orb_0"..rng.range(1, 5)..".png"
game.level.map:updateMap(self.pedestal_x, self.pedestal_y)
game.level.pedestal_events = (game.level.pedestal_events or 0) + 1
game.logSeen(self, "%s soul is absorbed by the pedestal. A glowing orb appears.", self.name:capitalize())
if game.level.pedestal_events >= 3 then
game.level.pedestal_events = 0
......
......@@ -29,6 +29,7 @@ local KeyBind = require "engine.KeyBind"
local DamageType = require "engine.DamageType"
local Faction = require "engine.Faction"
local Map = require "engine.Map"
local Level = require "engine.Level"
local Tiles = require "engine.Tiles"
local InventoryUI = require "engine.ui.Inventory"
local ActorStats = require "engine.interface.ActorStats"
......@@ -81,6 +82,7 @@ Map.smooth_scroll = config.settings.tome.smooth_move
Map.faction_danger2 = "tactical_danger.png"
Map.faction_danger1 = "tactical_enemy_strong.png"
Map.faction_danger_check = function(self, e, max) return (not max and e.rank > 3) or (max and e.rank >= 3.5) end
Level.remove_old_entity_on_duplicate = true
-- Dialog UI
UIBase.ui = config.settings.tome.ui_theme2
......
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