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

Grids can be made passable by projectiles but not actors using pass_projectile

git-svn-id: http://svn.net-core.org/repos/t-engine4@3423 51575b47-30f0-44d4-a5cc-537603b46e54
parent de981d5c
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
-- 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,
}
......@@ -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",
......
......@@ -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")
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