diff --git a/game/engines/default/engine/Map.lua b/game/engines/default/engine/Map.lua index f4f4663e8b2e9d78f0d4e50ada3f8e71361e3896..337ae86683c868b37e17ffb583067cc1c4cd6fdf 100644 --- a/game/engines/default/engine/Map.lua +++ b/game/engines/default/engine/Map.lua @@ -599,6 +599,29 @@ function _M:checkAllEntitiesNoStop(x, y, what, ...) return ret end +--- Check all entities of the grid for a property, counting the results +-- This will iterate over all entities without stopping. +-- No guaranty is given about the iteration order +-- @param x position +-- @param y position +-- @param what property to check +-- @return the number of times the property returned a non false value +function _M:checkAllEntitiesCount(x, y, what, ...) + if not x or not y or x < 0 or x >= self.w or y < 0 or y >= self.h then return {} end + local ret = {} + local tile = self.map[x + y * self.w] + local nb = 0 + if tile then + -- Collect the keys so we can modify the table while iterating + local k, e = next(tile) + while k do + if e:check(what, x, y, ...) then nb = nb + 1 end + k, e = next(tile, k) + end + end + return nb +end + --- Check specified entity position of the grid for a property -- @param x position -- @param y position diff --git a/game/engines/default/engine/Target.lua b/game/engines/default/engine/Target.lua index 9e2690f8e1ad7b767eafb7085eb960cd2496c497..c3d4cf23a8e572d091a90887ac639be1159a3987 100644 --- a/game/engines/default/engine/Target.lua +++ b/game/engines/default/engine/Target.lua @@ -189,11 +189,14 @@ function _M:getType(t) if typ.requires_knowledge and not game.level.map.remembers(lx, ly) and not game.level.map.seens(lx, ly) then return true, false, false end - if not typ.pass_terrain and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") then + if not typ.pass_terrain and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") and not game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "pass_projectile") then return true, true, false -- If we explode due to something other than terrain, then we should explode ON the tile, not before it - elseif typ.stop_block and game.level.map:checkAllEntities(lx, ly, "block_move") then - return true, true, true + elseif typ.stop_block then + local nb = game.level.map:checkAllEntitiesCount(lx, ly, "block_move") + if nb > 1 or (game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") and not game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "pass_projectile")) then + return true, true, true + end end end -- If we don't block the path, then the explode point should be here diff --git a/game/modules/tome/data/general/grids/burntland.lua b/game/modules/tome/data/general/grids/burntland.lua new file mode 100644 index 0000000000000000000000000000000000000000..52bf320c5c4896f5ed56bb8251ab3578e8bd7041 --- /dev/null +++ b/game/modules/tome/data/general/grids/burntland.lua @@ -0,0 +1,74 @@ +-- ToME - Tales of Maj'Eyal +-- Copyright (C) 2009, 2010, 2011 Nicolas Casalini +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. +-- +-- Nicolas Casalini "DarkGod" +-- darkgod@te4.org + +for i = 1, 20 do +newEntity{ + define_as = "BURNT_TREE"..i, + name = "burnt tree", + image = "terrain/grass_burnt1.png", + add_displays = class:makeTrees("terrain/burnttree_alpha"), + display = '#', color=colors.LIGHT_GREEN, back_color={r=44,g=95,b=43}, + always_remember = true, + can_pass = {pass_tree=1}, + does_block_move = true, + block_sight = true, + dig = "BURNT_GROUND1", +} +end + +for i = 1, 4 do +newEntity{ define_as = "BURNT_GROUND"..i, + name='burnt ground', + display='.', color=colors.UMBER, back_color=colors.DARK_GREY, image="terrain/grass_burnt"..i..".png", +} +end + +newEntity{ + define_as = "ALTAR", + name = "corrupted altar", image = "terrain/grass_burnt1.png", add_displays = {class.new{image = "terrain/floor_pentagram.png"}}, + display = ';', color=colors.RED, back_color=colors.DARK_UMBER, + notice = true, + always_remember = true, +} + +newEntity{ + define_as = "BURNT_UP_WILDERNESS", + name = "exit to the worldmap", image = "terrain/grass_burnt1.png", add_displays = {class.new{image="terrain/worldmap.png"}}, + display = '<', color_r=255, color_g=0, color_b=255, + always_remember = true, + notice = true, + change_level = 1, + change_zone = "wilderness", +} +newEntity{ + define_as = "BURNT_UP4", + name = "way to the previous level", image = "terrain/grass_burnt1.png", add_displays = {class.new{image="terrain/way_next_4.png"}}, + display = '<', color_r=255, color_g=255, color_b=0, + notice = true, + always_remember = true, + change_level = -1, +} +newEntity{ + define_as = "BURNT_DOWN6", + name = "way to the next level", image = "terrain/grass_burnt1.png", add_displays = {class.new{image="terrain/way_next_6.png"}}, + display = '>', color_r=255, color_g=255, color_b=0, + notice = true, + always_remember = true, + change_level = 1, +} diff --git a/game/modules/tome/data/general/grids/void.lua b/game/modules/tome/data/general/grids/void.lua index 1407a6f45924ca608b13c2cefa27be160e61d744..878c0213957b2ed1860fa943d4e882c48b060251 100644 --- a/game/modules/tome/data/general/grids/void.lua +++ b/game/modules/tome/data/general/grids/void.lua @@ -28,6 +28,17 @@ newEntity{ _noalpha = false, } +newEntity{ + define_as = "VOID_WALL", + name = "void", + display = ' ', + _noalpha = false, + always_remember = true, + does_block_move = true, + pass_projectile = true, + air_level = -40, +} + newEntity{ define_as = "SPACE_TURBULENCE1", name = "space turbulence", diff --git a/game/modules/tome/data/zones/mark-spellblaze/grids.lua b/game/modules/tome/data/zones/mark-spellblaze/grids.lua index e0f175864ed0d62140df96c274fafc7ea49f3be4..84cd053aa1f9214f2c9645b47e9400684647d6c0 100644 --- a/game/modules/tome/data/zones/mark-spellblaze/grids.lua +++ b/game/modules/tome/data/zones/mark-spellblaze/grids.lua @@ -21,59 +21,4 @@ load("/data/general/grids/basic.lua") load("/data/general/grids/forest.lua") load("/data/general/grids/water.lua") load("/data/general/grids/lava.lua") - -for i = 1, 20 do -newEntity{ - define_as = "BURNT_TREE"..i, - name = "burnt tree", - image = "terrain/grass_burnt1.png", - add_displays = class:makeTrees("terrain/burnttree_alpha"), - display = '#', color=colors.LIGHT_GREEN, back_color={r=44,g=95,b=43}, - always_remember = true, - can_pass = {pass_tree=1}, - does_block_move = true, - block_sight = true, - dig = "BURNT_GROUND1", -} -end - -for i = 1, 4 do -newEntity{ define_as = "BURNT_GROUND"..i, - name='burnt ground', - display='.', color=colors.UMBER, back_color=colors.DARK_GREY, image="terrain/grass_burnt"..i..".png", -} -end - -newEntity{ - define_as = "ALTAR", - name = "corrupted altar", image = "terrain/grass_burnt1.png", add_displays = {class.new{image = "terrain/floor_pentagram.png"}}, - display = ';', color=colors.RED, back_color=colors.DARK_UMBER, - notice = true, - always_remember = true, -} - -newEntity{ - define_as = "BURNT_UP_WILDERNESS", - name = "exit to the worldmap", image = "terrain/grass_burnt1.png", add_displays = {class.new{image="terrain/worldmap.png"}}, - display = '<', color_r=255, color_g=0, color_b=255, - always_remember = true, - notice = true, - change_level = 1, - change_zone = "wilderness", -} -newEntity{ - define_as = "BURNT_UP4", - name = "way to the previous level", image = "terrain/grass_burnt1.png", add_displays = {class.new{image="terrain/way_next_4.png"}}, - display = '<', color_r=255, color_g=255, color_b=0, - notice = true, - always_remember = true, - change_level = -1, -} -newEntity{ - define_as = "BURNT_DOWN6", - name = "way to the next level", image = "terrain/grass_burnt1.png", add_displays = {class.new{image="terrain/way_next_6.png"}}, - display = '>', color_r=255, color_g=255, color_b=0, - notice = true, - always_remember = true, - change_level = 1, -} +load("/data/general/grids/burntland.lua")