Allow fixed-destination teleport traps

Add a theme room with multiple visible teleportation traps
which will always teleport to specific locations in the same level.

Teleport trap change from xNetHack by copperwater <aosdict@gmail.com>.
This commit is contained in:
Pasi Kallinen
2024-06-14 19:47:29 +03:00
parent a8099edca6
commit 951401e52a
6 changed files with 76 additions and 3 deletions

View File

@@ -220,6 +220,19 @@ themeroom_fills = {
end;
locs:iterate(func);
end,
-- Teleportation hub
function(rm)
local locs = selection.room():filter_mapchar(".");
for i = 1, 2 + nh.rn2(3) do
local pos = locs:rndcoord(1);
if (pos.x > 0) then
pos.x = pos.x + rm.region.x1 - 1;
pos.y = pos.y + rm.region.y1;
table.insert(postprocess, { handler = make_a_trap, data = { type = "teleport", seen = true, coord = pos, teledest = 1 } });
end
end
end,
};
themerooms = {
@@ -871,6 +884,17 @@ function make_garden_walls(data)
des.replace_terrain({ selection = sel, fromterrain="w", toterrain = "T" });
end
-- postprocess callback: make a trap
function make_a_trap(data)
if (data.teledest == 1 and data.type == "teleport") then
local locs = selection.negate():filter_mapchar(".");
repeat
data.teledest = locs:rndcoord(1);
until (data.teledest.x ~= data.coord.x and data.teledest.y ~= data.coord.y);
end
des.trap(data);
end
-- called once after the whole level has been generated
function post_level_generate()
for i, v in ipairs(postprocess) do