From 827069de71732523e62a903970030d24312ac1fb Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Wed, 10 Nov 2010 15:40:46 +0000 Subject: [PATCH] Right-click during birth correctly works Implemented "no teleport" objects. They do not prevent you from teleporting, but they do not follow. git-svn-id: http://svn.net-core.org/repos/t-engine4@1849 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engines/default/engine/Birther.lua | 2 +- game/modules/tome/class/Actor.lua | 23 ++++++++++++++++++- game/modules/tome/class/Player.lua | 2 +- .../tome/data/maps/vaults/mold-path-dark.lua | 4 ++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/game/engines/default/engine/Birther.lua b/game/engines/default/engine/Birther.lua index 8de65c39ba..49afc8a3f9 100644 --- a/game/engines/default/engine/Birther.lua +++ b/game/engines/default/engine/Birther.lua @@ -90,7 +90,7 @@ Mouse: #00FF00#Left click#FFFFFF# to accept; #00FF00#right click#FFFFFF# to go b {name="", width=92, display_prop="display_name"}, }, list={}, fct=function(item, sel, button, event) self.sel = sel - if event == "button" and button == "left" then self:next() + if (event == "key" or event == "button") and button == "left" then self:next() elseif event == "button" and button == "right" then self:prev() end end, select=function(item, sel) self.sel = sel self:select(item) end} diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index 9bbc353684..e8923a5cb7 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -314,6 +314,19 @@ function _M:getPathString() return ps end +--- Drop no-teleport items +function _M:dropNoTeleportObjects() + for inven_id, inven in pairs(self.inven) do + for item = #inven, 1, -1 do + local o = inven[item] + if o.no_teleport then + self:dropFloor(inven, item, false, true) + game.logPlayer(self, "#LIGHT_RED#Your %s is immunte to the teleportation and drops to the floor!", o:getName{do_color=true}) + end + end + end +end + --- Blink through walls function _M:probabilityTravel(x, y, dist) if game.zone.wilderness then return true end @@ -327,6 +340,7 @@ function _M:probabilityTravel(x, y, dist) dist = dist - 1 end if game.level.map:isBound(tx, ty) and not game.level.map:checkAllEntities(tx, ty, "block_move", self) and not game.level.map.attrs(tx, ty, "no_teleport") then + self:dropNoTeleportObjects() return engine.Actor.move(self, tx, ty, false) end return true @@ -343,7 +357,14 @@ function _M:teleportRandom(x, y, dist, min_dist) if game.level.data.no_teleport_south and y + dist > self.y then y = self.y - dist end - return engine.Actor.teleportRandom(self, x, y, dist, min_dist) + local ox, oy = self.x, self.y + local ret = engine.Actor.teleportRandom(self, x, y, dist, min_dist) + if self.x ~= ox or self.y ~= oy then + self.x, self.y, ox, oy = ox, oy, self.x, self.y + self:dropNoTeleportObjects() + self.x, self.y, ox, oy = ox, oy, self.x, self.y + end + return ret end --- Quake a zone diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index 66ae7f490a..4815cd216b 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -552,7 +552,7 @@ function _M:doDrop(inven, item) return end self:dropFloor(inven, item, true, true) - self:sortInven() + self:sortInven(inven) self:useEnergy() self.changed = true end diff --git a/game/modules/tome/data/maps/vaults/mold-path-dark.lua b/game/modules/tome/data/maps/vaults/mold-path-dark.lua index 38e57d30d6..842fd6e954 100644 --- a/game/modules/tome/data/maps/vaults/mold-path-dark.lua +++ b/game/modules/tome/data/maps/vaults/mold-path-dark.lua @@ -22,8 +22,8 @@ setStatusAll{no_teleport=true} rotates = {"default", "90", "180", "270", "flipx", "flipy"} defineTile('.', "GRASS_DARK1") -defineTile('#', "TREE_DARK") -defineTile('X', "HARDTREE_DARK") +defineTile('#', {"TREE_DARK1","TREE_DARK2","TREE_DARK3","TREE_DARK4","TREE_DARK5","TREE_DARK6","TREE_DARK7","TREE_DARK8","TREE_DARK9","TREE_DARK10","TREE_DARK11","TREE_DARK12","TREE_DARK13","TREE_DARK14","TREE_DARK15","TREE_DARK16","TREE_DARK17","TREE_DARK18","TREE_DARK19","TREE_DARK20"}) +defineTile('X', {"HARDTREE_DARK1","HARDTREE_DARK2","HARDTREE_DARK3","HARDTREE_DARK4","HARDTREE_DARK5","HARDTREE_DARK6","HARDTREE_DARK7","HARDTREE_DARK8","HARDTREE_DARK9","HARDTREE_DARK10","HARDTREE_DARK11","HARDTREE_DARK12","HARDTREE_DARK13","HARDTREE_DARK14","HARDTREE_DARK15","HARDTREE_DARK16","HARDTREE_DARK17","HARDTREE_DARK18","HARDTREE_DARK19","HARDTREE_DARK20"}) defineTile('~', "POISON_SHALLOW_WATER") defineTile('!', "ROCK_VAULT") -- GitLab