Commit 77b7890dee9d7a00067ce9f57df554a41ede6035

Authored by DarkGod
1 parent 009517d1

transfered psicave to main game assets

new mapscript lib to add a subvault easily
Showing 58 changed files with 277 additions and 16 deletions
... ... @@ -42,7 +42,15 @@ end
42 42 function _M:resolve(c, list, force)
43 43 if force then return Generator.resolve(self, c, list, force) end
44 44 if self.self_tiles[c] then
45   - return Generator.resolve(self, self.self_tiles[c].grid or '.', list, true)
  45 + if type(self.self_tiles[c].grid) == "table" and self.self_tiles[c].grid.__ATOMIC then
  46 + local res = self.self_tiles[c].grid
  47 + if res.force_clone then res = res:clone() end
  48 + res:resolve()
  49 + res:resolve(nil, true)
  50 + return res
  51 + else
  52 + return Generator.resolve(self, self.self_tiles[c].grid or '.', list, true)
  53 + end
46 54 else
47 55 return Generator.resolve(self, c, list, force)
48 56 end
... ...
... ... @@ -3123,11 +3123,15 @@ function _M:dynamicZoneEntry(g, id, zone_def, zone_lists, zone_alter)
3123 3123 def.__embed_lists_def = self.dynamic_zone.lists
3124 3124 if self.dynamic_zone.alter then
3125 3125 def.__alter_back_def = {short_name=game.zone.short_name, name=game.zone.name}
3126   - def.__alter_back_fct = function(backdef, name, base_terrain)
3127   - base_terrain.change_level_shift_back = true
3128   - base_terrain.change_zone_auto_stairs = true
3129   - base_terrain.name = name:format(backdef.name)
3130   - base_terrain.change_zone = backdef.short_name
  3126 + def.__alter_back_fct = function(zone, backdef, name, base_terrain)
  3127 + local terrain = base_terrain:cloneFull()
  3128 + terrain.change_level_shift_back = true
  3129 + terrain.change_zone_auto_stairs = true
  3130 + terrain.name = name:format(backdef.name)
  3131 + terrain.change_zone = backdef.short_name
  3132 + terrain.define_as = "DYNAMIC_ZONE_EXIT"
  3133 + terrain:altered()
  3134 + zone.grid_list.DYNAMIC_ZONE_EXIT = terrain
3131 3135 end
3132 3136 def.__alter_back_custom = self.dynamic_zone.alter
3133 3137 end
... ... @@ -3153,7 +3157,7 @@ function _M:dynamicZoneEntry(g, id, zone_def, zone_lists, zone_alter)
3153 3157
3154 3158 -- Alter whatever we need. Most likely the exit, so we provide an easy function for that
3155 3159 if zone.__alter_back_fct then
3156   - zone.__alter_back_custom(zone, function(name, base_terrain) zone.__alter_back_fct(zone.__alter_back_def, name, base_terrain) end)
  3160 + zone.__alter_back_custom(zone, function(name, base_terrain) zone:__alter_back_fct(zone.__alter_back_def, name, base_terrain) end)
3157 3161 end
3158 3162 end
3159 3163 return mod.class.Zone.new(self.dynamic_zone.id, def)
... ...
... ... @@ -1221,6 +1221,30 @@ grass_wm = { method="borders", type="grass", forbid={lava=true, rock=true},
1221 1221 default7i={add_mos={{image="terrain/grass_worldmap/grass_inner_7_%02d.png", display_x=-1, display_y=-1}}, min=1, max=2},
1222 1222 default9i={add_mos={{image="terrain/grass_worldmap/grass_inner_9_%02d.png", display_x=1, display_y=-1}}, min=1, max=2},
1223 1223 },
  1224 +psitechwall = { method="walls", type="psitechwall", forbid={}, use_type=true, extended=true, consider_diagonal_doors=true,
  1225 + default8={add_displays={{image="terrain/psicave/psitechwall_8_%d.png", display_y=-1, z=16}}, min=1, max=1},
  1226 + default8p={add_displays={{image="terrain/psicave/psitech_V3_pillar_top_0%d.png", display_y=-1, z=16}}, min=1, max=1},
  1227 + default7={add_displays={{image="terrain/psicave/psitech_V3_inner_7_01.png", display_y=-1, z=16}}, min=1, max=1},
  1228 + default9={add_displays={{image="terrain/psicave/psitech_V3_inner_9_01.png", display_y=-1, z=16}}, min=1, max=1},
  1229 + default7i={add_displays={{image="terrain/psicave/psitech_V3_3_01.png", display_y=-1, z=16}}, min=1, max=1},
  1230 + default8i={add_displays={{image="terrain/psicave/psitechwall_8h_1.png", display_y=-1, z=16}}, min=1, max=1},
  1231 + default9i={add_displays={{image="terrain/psicave/psitech_V3_1_01.png", display_y=-1, z=16}}, min=1, max=1},
  1232 + default73i={add_displays={{image="terrain/psicave/psitechwall_91d_1.png", display_y=-1, z=16}}, min=1, max=1},
  1233 + default91i={add_displays={{image="terrain/psicave/psitechwall_73d_1.png", display_y=-1, z=16}}, min=1, max=1},
  1234 +
  1235 + default2={image="terrain/psicave/psitech_floor_1_01.png", add_mos={{image="terrain/psicave/psitech_V3_8_0%d.png"}}, min=1, max=3},
  1236 + default2p={image="terrain/psicave/psitech_floor_1_01.png", add_mos={{image="terrain/psicave/psitech_V3_pillar_bottom_0%d.png"}}, min=1, max=3},
  1237 + default1={image="terrain/psicave/psitech_floor_1_01.png", add_mos={{image="terrain/psicave/psitech_V3_inner_1_01.png"}}, min=1, max=1},
  1238 + default3={image="terrain/psicave/psitech_floor_1_01.png", add_mos={{image="terrain/psicave/psitech_V3_inner_3_01.png"}}, min=1, max=1},
  1239 + default1i={image="terrain/psicave/psitech_floor_1_01.png", add_mos={{image="terrain/psicave/psitech_V3_7_01.png"}}, min=1, max=1},
  1240 + default2i={image="terrain/psicave/psitech_floor_1_01.png", add_mos={{image="terrain/psicave/psitechwall_2h_1.png"}}, min=1, max=1},
  1241 + default3i={image="terrain/psicave/psitech_floor_1_01.png", add_mos={{image="terrain/psicave/psitech_V3_9_01.png"}}, min=1, max=1},
  1242 + default19i={image="terrain/psicave/psitech_floor_1_01.png", add_mos={{image="terrain/psicave/psitechwall_19d_1.png"}}, min=1, max=1},
  1243 + default37i={image="terrain/psicave/psitech_floor_1_01.png", add_mos={{image="terrain/psicave/psitechwall_37d_1.png"}}, min=1, max=1},
  1244 +
  1245 + default4={add_displays={{image="terrain/psicave/psitech_ver_edge_left_01.png", display_x=-1}}, min=1, max=1},
  1246 + default6={add_displays={{image="terrain/psicave/psitech_ver_edge_right_01.png", display_x=1}}, min=1, max=1},
  1247 +},
1224 1248 }
1225 1249 _M.generic_borders_defs = defs
1226 1250
... ...
... ... @@ -47,7 +47,7 @@ local g = game.state:dynamicZoneEntry(game.level.map(x, y, engine.Map.TERRAIN):c
47 47 min_floor = 1200,
48 48 floor = "CAVEFLOOR",
49 49 wall = "CAVEWALL",
50   - up = "CAVE_LADDER_UP_WILDERNESS",
  50 + up = "DYNAMIC_ZONE_EXIT",
51 51 door = "CAVEFLOOR",
52 52 },
53 53 actor = {
... ...
  1 +-- ToME - Tales of Maj'Eyal
  2 +-- Copyright (C) 2009 - 2019 Nicolas Casalini
  3 +--
  4 +-- This program is free software: you can redistribute it and/or modify
  5 +-- it under the terms of the GNU General Public License as published by
  6 +-- the Free Software Foundation, either version 3 of the License, or
  7 +-- (at your option) any later version.
  8 +--
  9 +-- This program is distributed in the hope that it will be useful,
  10 +-- but WITHOUT ANY WARRANTY; without even the implied warranty of
  11 +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12 +-- GNU General Public License for more details.
  13 +--
  14 +-- You should have received a copy of the GNU General Public License
  15 +-- along with this program. If not, see <http://www.gnu.org/licenses/>.
  16 +--
  17 +-- Nicolas Casalini "DarkGod"
  18 +-- darkgod@te4.org
  19 +
  20 +local psitech_wall_editer = { method="sandWalls_def", def="psitechwall"}
  21 +
  22 +newEntity{
  23 + define_as = "PSYCAVEFLOOR",
  24 + type = "floor", subtype = "psitech",
  25 + name = "psitech floor", image = "terrain/psicave/psitech_floor_1_01.png",
  26 + display = '.', color=colors.SANDY_BROWN, back_color=colors.DARK_UMBER,
  27 + grow = "PSYCAVEWALL",
  28 + nice_tiler = { method="replace", base={"PSYCAVEFLOOR", 100, 1, 5}},
  29 +}
  30 +for i = 1, 5 do newEntity{ base = "PSYCAVEFLOOR", define_as = "PSYCAVEFLOOR"..i, image = "terrain/psicave/psitech_floor_"..i.."_01.png"} end
  31 +
  32 +newEntity{
  33 + define_as = "PSYCAVEWALL",
  34 + type = "wall", subtype = "psitech",
  35 + name = "psitech walls", image = "terrain/psicave/psitechwall_5_1.png",
  36 + display = '#', color={r=203,g=189,b=72}, back_color={r=93,g=79,b=22},
  37 + always_remember = true,
  38 + can_pass = {pass_wall=1},
  39 + does_block_move = true,
  40 + block_sight = true,
  41 + air_level = -10,
  42 + dig = "PSYCAVEFLOOR",
  43 + nice_editer = psitech_wall_editer,
  44 + nice_tiler = { method="replace", base={"PSYCAVEWALL", 100, 1, 9}},
  45 +}
  46 +for i = 1, 9 do newEntity{ base = "PSYCAVEWALL", define_as = "PSYCAVEWALL"..i, image = "terrain/psicave/psitechwall_5_"..i..".png"} end
  47 +
  48 +-----------------------------------------
  49 +-- Doors
  50 +-----------------------------------------
  51 +newEntity{
  52 + define_as = "PSYCAVE_DOOR",
  53 + type = "wall", subtype = "psitech",
  54 + name = "psitech door", image = "terrain/psicave/psitech_door1.png",
  55 + display = '+', color={r=203,g=189,b=72}, back_color={r=93,g=79,b=22},
  56 + nice_tiler = { method="door3d", north_south="PSYCAVE_DOOR_VERT", west_east="PSYCAVE_DOOR_HORIZ" },
  57 + door_sound = "ambient/door_creaks/icedoor-break",
  58 + notice = true,
  59 + always_remember = true,
  60 + block_sight = true,
  61 + is_door = true,
  62 + door_opened = "PSYCAVE_DOOR_OPEN",
  63 + dig = "FLOOR",
  64 +}
  65 +newEntity{
  66 + define_as = "PSYCAVE_DOOR_OPEN",
  67 + type = "wall", subtype = "psitech",
  68 + name = "psitech door (open)", image="terrain/psicave/psitech_door1_open.png",
  69 + display = "'", color_r=238, color_g=154, color_b=77, back_color=colors.DARK_GREY,
  70 + always_remember = true,
  71 + is_door = true,
  72 + door_closed = "PSYCAVE_DOOR",
  73 +}
  74 +newEntity{ base = "PSYCAVE_DOOR", define_as = "PSYCAVE_DOOR_HORIZ", z=3, image = "terrain/psicave/psitech_door1.png", add_displays = {class.new{image="terrain/psicave/psitechwall_8_1.png", z=18, display_y=-1}}, door_opened = "PSYCAVE_DOOR_HORIZ_OPEN"}
  75 +newEntity{ base = "PSYCAVE_DOOR_OPEN", define_as = "PSYCAVE_DOOR_HORIZ_OPEN", image = "terrain/psicave/psitech_floor_1_01.png", add_mos={{image="terrain/psicave/psitech_door1_open_backg.png"}}, add_displays = {class.new{image="terrain/psicave/psitech_door1_open.png", z=17}, class.new{image="terrain/psicave/psitechwall_8_1.png", z=18, display_y=-1}}, door_closed = "PSYCAVE_DOOR_HORIZ"}
  76 +newEntity{ base = "PSYCAVE_DOOR", define_as = "PSYCAVE_DOOR_VERT", image = "terrain/psicave/psitech_floor_1_01.png", add_displays = {class.new{image="terrain/psicave/psitech_door1_vert.png", z=17}, class.new{image="terrain/psicave/psitech_door1_vert_north.png", z=18, display_y=-1}}, door_opened = "PSYCAVE_DOOR_OPEN_VERT", dig = "PSYCAVE_DOOR_OPEN_VERT"}
  77 +newEntity{ base = "PSYCAVE_DOOR_OPEN", define_as = "PSYCAVE_DOOR_OPEN_VERT", z=3, image = "terrain/psicave/psitech_floor_1_01.png", add_mos={{image="terrain/psicave/psitech_door1_open_vert_backg.png"}}, add_displays = {class.new{image="terrain/psicave/psitech_door1_open_vert.png", z=17, add_mos={{image="terrain/psicave/psitech_door1_open_vert_north_backg.png", display_y=-1}}}, class.new{image="terrain/psicave/psitech_door1_open_vert_north.png", z=18, display_y=-1}}, door_closed = "PSYCAVE_DOOR_VERT"}
  78 +
  79 +-----------------------------------------
  80 +-- Cavy exits
  81 +-----------------------------------------
  82 +
  83 +newEntity{
  84 + define_as = "PSYCAVE_LADDER_DOWN",
  85 + type = "floor", subtype = "psitech",
  86 + name = "ladder to the next level", image = "terrain/psicave/psitech_floor_1_01.png", add_displays = {class.new{image="terrain/psicave/psitech_stairs_down_1_01.png"}},
  87 + display = '>', color_r=255, color_g=255, color_b=0,
  88 + notice = true,
  89 + always_remember = true,
  90 + change_level = 1,
  91 +}
  92 +newEntity{
  93 + define_as = "PSYCAVE_LADDER_UP",
  94 + type = "floor", subtype = "psitech",
  95 + name = "ladder to the previous level", image = "terrain/psicave/psitech_floor_1_01.png", add_displays = {class.new{image="terrain/psicave/psitech_stairs_up_1_01.png"}},
  96 + display = '<', color_r=255, color_g=255, color_b=0,
  97 + notice = true,
  98 + always_remember = true,
  99 + change_level = -1,
  100 +}
  101 +newEntity{
  102 + define_as = "PSYCAVE_LADDER_UP_WILDERNESS",
  103 + type = "floor", subtype = "psitech",
  104 + name = "ladder to worldmap", image = "terrain/psicave/psitech_floor_1_01.png", add_displays = {class.new{image="terrain/psicave/psitech_stairs_exit_1_01.png"}},
  105 + display = '<', color_r=255, color_g=255, color_b=0,
  106 + notice = true,
  107 + change_level = 1,
  108 + change_zone = "wilderness",
  109 +}
... ...
... ... @@ -75,7 +75,7 @@ defineTile('.', "FLOOR")
75 75 defineTile('#', "HARDWALL")
76 76 defineTile('+', "DOOR")
77 77 defineTile('!', "DOOR_VAULT")
78   -defineTile('>', "DOWN")
  78 +defineTile('>', "DYNAMIC_ZONE_EXIT")
79 79
80 80
81 81 defineTile('b', "FLOOR", {random_filter={add_levels=10, tome_mod="gvault"}}, {random_filter={add_levels=5, name="skeleton magus"}})
... ...
  1 +-- ToME - Tales of Maj'Eyal
  2 +-- Copyright (C) 2009 - 2019 Nicolas Casalini
  3 +--
  4 +-- This program is free software: you can redistribute it and/or modify
  5 +-- it under the terms of the GNU General Public License as published by
  6 +-- the Free Software Foundation, either version 3 of the License, or
  7 +-- (at your option) any later version.
  8 +--
  9 +-- This program is distributed in the hope that it will be useful,
  10 +-- but WITHOUT ANY WARRANTY; without even the implied warranty of
  11 +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12 +-- GNU General Public License for more details.
  13 +--
  14 +-- You should have received a copy of the GNU General Public License
  15 +-- along with this program. If not, see <http://www.gnu.org/licenses/>.
  16 +--
  17 +-- Nicolas Casalini "DarkGod"
  18 +-- darkgod@te4.org
  19 +
  20 +local map = args.map
  21 +local spot = args.spot
  22 +local char = args.char or '_HV_'..core.game.getTime()
  23 +
  24 +local walltype = args.walltype or "HARDWALL"
  25 +local greater_vaults_list = args.greater_vaults_list
  26 +
  27 +local basemap = table.clone(args.basemap or level.data.generator.map, true)
  28 +basemap.zoneclass = nil
  29 +basemap.rooms = nil
  30 +basemap.required_rooms = nil
  31 +
  32 +local terrains = mod.class.Grid:loadList("/data/general/grids/basic.lua")
  33 +local g = game.state:dynamicZoneEntry(terrains.DOWN, "sub-vault", {
  34 + name = ("Hidden Vault - %s"):format(zone.name),
  35 + level_range = {zone:level_adjust_level(level, zone, "actor"), zone:level_adjust_level(level, zone, "actor")},
  36 + level_scheme = "player",
  37 + max_level = 1,
  38 + __applied_difficulty = true, --Difficulty already applied to parent zone
  39 + actor_adjust_level = function(zone, level, e) return zone.base_level + e:getRankLevelAdjust() + level.level-1 + rng.range(-1,2) end,
  40 + width = 50, height = 50,
  41 + ambient_music = zone.ambient_music,
  42 + persistent = "zone",
  43 + min_material_level = util.getval(zone.min_material_level),
  44 + max_material_level = util.getval(zone.max_material_level),
  45 + no_worldport = zone.no_worldport,
  46 + generator = {
  47 + map = table.merge(basemap, {
  48 + class = "mod.class.generator.map.VaultLevel",
  49 + subvault_wall = walltype,
  50 + subvault_up = "DYNAMIC_ZONE_EXIT",
  51 + greater_vaults_list = greater_vaults_list or nil,
  52 + entry_path_length = 10, -- path from level entrance to vault (affects space to fight when opening the vault)
  53 + }),
  54 + actor = {
  55 + class = "mod.class.generator.actor.Random",
  56 + nb_npc = {0, 0},
  57 + },
  58 + object = {
  59 + class = "engine.generator.object.Random",
  60 + nb_object = {0, 0},
  61 + },
  62 + trap = {
  63 + class = "engine.generator.trap.Random",
  64 + nb_trap = {0, 0},
  65 + },
  66 + },
  67 + post_process = function(level)
  68 + for uid, e in pairs(level.entities) do e.faction = e.hard_faction or "enemies" end
  69 + end,
  70 +}, {
  71 + npc_list = args.npc_list or {"/data/general/npcs/all.lua"},
  72 + object_list = args.object_list or {"/data/general/objects/objects.lua"},
  73 + grid_list = args.grid_list or {"/data/general/grids/basic.lua", "/data/general/grids/water.lua", "/data/general/grids/lava.lua"},
  74 + trap_list = args.trap_list or {"/data/general/traps/complex.lua", "/data/general/traps/annoy.lua", "/data/general/traps/alarm.lua"},
  75 +},
  76 +function(zone, goback)
  77 + goback("stairs back to %s", zone.grid_list.UP)
  78 +end)
  79 +
  80 +g.name = "hidden vault"
  81 +g.always_remember = true
  82 +g.desc = [[Crumbling stairs lead down to something.]]
  83 +g.show_tooltip = true
  84 +g.color_r=0 g.color_g=0 g.color_b=255 g.notice = true
  85 +g.special_minimap = colors.VIOLET
  86 +g._use_count = rng.range(2, 4)
  87 +g:altered()
  88 +g:initGlow()
  89 +g.change_level_check = function(self) -- limit stair scumming
  90 + self._use_count = self._use_count - 1
  91 + self.name = "collapsing hidden vault"
  92 + if self._use_count < 1 then
  93 + self.change_level_check = nil
  94 + self.change_level = nil
  95 + self.name = "collapsed hidden vault"
  96 + self.desc = [[It is fully collapsed, no way down.]]
  97 + game.log("#VIOLET# The stairway is about to collapses completely, you may still go back but it will be the last time!")
  98 + elseif self._use_count < 2 then
  99 + self.name = "nearly collapsed hidden vault"
  100 + game.log("#VIOLET# The decrepit stairs crumble some more as you climb them.")
  101 + end
  102 + game:changeLevel(1, self:real_change(), {temporary_zone_shift=true, direct_switch=true})
  103 + return true
  104 +end
  105 +game.zone:addEntity(game.level, g, "terrain", x, y)
  106 +
  107 +self:defineTile(char, g)
  108 +if spot then map:put(spot, char) end
  109 +
  110 +return g
... ...
... ... @@ -23,15 +23,17 @@ local tm = Tilemap.new(self.mapsize, '#')
23 23
24 24 -- self.data.greater_vaults_list = {"32-chambers"}
25 25 local room_factory = Rooms.new(self, "random_room")
26   -local vault_factory = Rooms.new(self, "lesser_vault")
  26 +local vault_factory = Rooms.new(self, "greater_vault")
27 27
  28 +local nb_vault = 0
28 29 local rooms = {}
29 30 for i = 1, 20 do
30   - local proom = (rng.percent(20) and vault_factory or room_factory):generateRoom()
  31 + local proom = (nb_vault > 0 and vault_factory or room_factory):generateRoom()
31 32 local pos = proom and tm:findRandomArea(nil, tm.data_size, proom.data_w, proom.data_h, '#', 1)
32 33 if pos then
33 34 tm:merge(pos, proom:build())
34 35 rooms[#rooms+1] = proom
  36 + nb_vault = nb_vault - 1
35 37 end
36 38 end
37 39
... ... @@ -54,15 +56,19 @@ for i = 1, 20 do
54 56 end
55 57 end
56 58
57   -if not loadMapScript("lib/connect_rooms_multi", {map=tm, rooms=rooms, edges_surplus=0}) then return self:regenerate() end
  59 +if not loadMapScript("lib/connect_rooms_multi", {map=tm, rooms=rooms, door_chance=60, edges_surplus=0}) then return self:redo() end
58 60 -- loadMapScript("lib/connect_rooms_multi", {map=tm, rooms=rooms})
59 61
60 62
61 63 self:setEntrance(tm:locateTile('<'))
62 64 self:setExit(rooms[#rooms]:centerPoint()) tm:put(rooms[#rooms]:centerPoint(), '>')
63 65
  66 +
64 67 -- Elimitate the rest
65   --- if tm:eliminateByFloodfill{'#', 'T'} < 600 then return self:regenerate() end
  68 +-- if tm:eliminateByFloodfill{'#', 'T'} < 600 then return self:redo() end
  69 +
  70 +local spot = tm:point(1, 1)
  71 +loadMapScript("lib/subvault", {map=tm, spot=spot, char="V"})
66 72
67 73 tm:printResult()
68 74
... ...
... ... @@ -17,4 +17,4 @@
17 17 -- Nicolas Casalini "DarkGod"
18 18 -- darkgod@te4.org
19 19
20   ----load("/data/general/objects/objects-maj-eyal.lua")
  20 +load("/data/general/objects/objects-maj-eyal.lua")
... ...
... ... @@ -24,8 +24,8 @@ return {
24 24 max_level = 4,
25 25 decay = {300, 800},
26 26 actor_adjust_level = function(zone, level, e) return zone.base_level + e:getRankLevelAdjust() + level.level-1 + rng.range(-1,2) end,
27   - width = 80, height = 80,
28   - -- all_remembered = true,
  27 + width = 50, height = 50,
  28 + all_remembered = true,
29 29 all_lited = true,
30 30 no_level_connectivity = true,
31 31
... ...