Skip to content
Snippets Groups Projects
Commit 669a0942 authored by dg's avatar dg
Browse files

Added two new generic terrains: GENERIC_LEVER and GENERIC_LEVER_DOOR

git-svn-id: http://svn.net-core.org/repos/t-engine4@3695 51575b47-30f0-44d4-a5cc-537603b46e54
parent e34752a3
No related branches found
No related tags found
No related merge requests found
......@@ -308,3 +308,81 @@ newEntity{ base = "OLD_WALL", define_as = "OLD_WALL_SMALL_PILLAR", image = "terr
newEntity{ base = "OLD_WALL", define_as = "OLD_WALL_PILLAR_6", image = "terrain/oldstone_floor.png", z=1, add_displays = {class.new{image="terrain/granite_wall_pillar_3.png", z=3}, class.new{image="terrain/granite_wall_pillar_9.png", z=18, display_y=-1}}}
newEntity{ base = "OLD_WALL", define_as = "OLD_WALL_PILLAR_4", image = "terrain/oldstone_floor.png", z=1, add_displays = {class.new{image="terrain/granite_wall_pillar_1.png", z=3}, class.new{image="terrain/granite_wall_pillar_7.png", z=18, display_y=-1}}}
newEntity{ base = "OLD_WALL", define_as = "OLD_WALL_PILLAR_2", image = "terrain/oldstone_floor.png", z=1, add_displays = {class.new{image="terrain/granite_wall_pillar_2.png", z=3}}}
-----------------------------------------
-- Levers & such tricky tings
-----------------------------------------
newEntity{
define_as = "GENERIC_LEVER_DOOR",
type = "wall", subtype = "floor",
name = "sealed door", image = "terrain/granite_door1.png",
display = '+', color_r=238, color_g=154, color_b=77, back_color=colors.DARK_UMBER,
nice_tiler = { method="door3d", north_south="GENERIC_LEVER_DOOR_VERT", west_east="GENERIC_LEVER_DOOR_HORIZ" },
notice = true,
always_remember = true,
block_sight = true,
block_sense = true,
block_esp = true,
force_clone = true,
door_player_stop = "This door seems to have been sealed off, you need to find a way to open it.",
door_opened = "DOOR_OPEN",
on_lever_change = function(self, x, y, who, val, oldval)
local trigger = game.level.map.attrs(x, y, "lever_action")
if val > oldval and val >= trigger then
game.level.map(x, y, engine.Map.TERRAIN, game.zone.grid_list[self.door_opened])
game.log("#VIOLET#You hear a door openning.")
return true
end
end,
}
newEntity{ base = "GENERIC_LEVER_DOOR", define_as = "GENERIC_LEVER_DOOR_HORIZ", image = "terrain/granite_door1.png", add_displays = {class.new{image="terrain/granite_wall3.png", z=18, display_y=-1}}, door_opened = "DOOR_HORIZ_OPEN"}
newEntity{ base = "GENERIC_LEVER_DOOR", define_as = "GENERIC_LEVER_DOOR_VERT", image = "terrain/marble_floor.png", add_displays = {class.new{image="terrain/granite_door1_vert.png", z=17}, class.new{image="terrain/granite_door1_vert_north.png", z=18, display_y=-1}}, door_opened = "DOOR_OPEN_VERT"}
newEntity{
define_as = "GENERIC_LEVER",
type = "lever", subtype = "floor",
name = "huge lever", image = "terrain/marble_floor.png", add_mos = {{image="terrain/lever1_state1.png"}},
display = '&', color=colors.UMBER, back_color=colors.DARK_UMBER,
notice = true,
always_remember = true,
lever = false,
force_clone = true,
block_move = function(self, x, y, e, act)
if act and e.player then
local block = game.level.map.attrs(x, y, "lever_block") or nil
local radius = game.level.map.attrs(x, y, "lever_radius") or 10
local val = game.level.map.attrs(x, y, "lever")
local kind = game.level.map.attrs(x, y, "lever_kind")
if self.lever then
self.color_r = colors.UMBER.r self.color_g = colors.UMBER.g self.color_b = colors.UMBER.b
self.add_mos[1].image = "terrain/lever1_state1.png"
else
self.color_r = 255 self.color_g = 255 self.color_b = 255
self.add_mos[1].image = "terrain/lever1_state2.png"
end
self:removeAllMOs()
game.level.map:updateMap(x, y)
self.lever = not self.lever
game.log("#VIOLET#You hear a mechanism clicking.")
core.fov.calc_circle(x, y, game.level.map.w, game.level.map.h, radius, function(_, i, j)
if block and game.level.map.attrs(i, j, block) then return true end
end, function(_, i, j)
if game.level.map.attrs(i, j, "lever_action_kind") == kind then
local old = game.level.map.attrs(i, j, "lever_action_value")
local newval = old + (self.lever and val or -val)
game.level.map.attrs(i, j, "lever_action_value", newval)
if game.level.map:checkEntity(i, j, engine.Map.TERRAIN, "on_lever_change", e, newval, old) then
if game.level.map.attrs(i, j, "lever_action_only_once") then game.level.map.attrs(i, j, "lever_action_kind", false) end
end
local fct = game.level.map.attrs(i, j, "lever_action_custom")
if fct and fct(i, j, e, newval, old) then
if game.level.map.attrs(i, j, "lever_action_only_once") then game.level.map.attrs(i, j, "lever_action_kind", false) end
end
end
end, nil)
end
return true
end,
}
-- 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
-- This is simply and example of how to use levers, not a real ingame vault
setStatusAll{no_teleport=true}
defineTile('.', "FLOOR")
defineTile('=', "FLOOR", nil, nil, nil, {foobar=true})
defineTile('&', "GENERIC_LEVER", nil, nil, nil, {lever=1, lever_kind="foo", lever_radius=10, lever_block="foobar"})
defineTile('+', "GENERIC_LEVER_DOOR", nil, nil, nil, {lever_action=3, lever_action_only_once=true, lever_action_value=0, lever_action_kind="foo"})
defineTile('"', "FLOOR", nil, nil, nil, {lever_action_value=0, lever_action_only_once=true, lever_action_kind="foo", lever_action_custom=function(i, j, who, val, old)
if val == 3 then
game.level.map:particleEmitter(i, j, 5, "ball_fire", {radius=5})
return true
end
end})
rotates = {"default", "90", "180", "270", "flipx", "flipy"}
startx = 5
starty = 0
return {
[[...........]],
[[...+.......]],
[[..=====....]],
[[........"..]],
[[..&.&.&....]],
[[...........]],
[[....+......]],
[[...........]],
}
......@@ -31,6 +31,17 @@ return {
no_level_connectivity = true,
generator = {
map = {
class = "engine.generator.map.Roomer",
nb_rooms = 10,
rooms = {"random_room", "lesser_vault"},
lesser_vaults_list = {"test"},
lite_room_chance = 100,
['.'] = "FLOOR",
['#'] = "WALL",
up = "UP",
down = "DOWN",
door = "DOOR",
--[[
class = "engine.generator.map.Building",
max_block_w = 15, max_block_h = 15,
max_building_w = 5, max_building_h = 5,
......@@ -40,6 +51,7 @@ return {
up = "FLAT_UP6",
down = "FLAT_DOWN4",
door = "DOOR",
]]
},
actor = {
class = "engine.generator.actor.Random",
......
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