]> granicus.if.org Git - nethack/commitdiff
More Gehennom filler level variance
authorPasi Kallinen <paxed@alt.org>
Thu, 12 Jan 2023 10:36:29 +0000 (12:36 +0200)
committerPasi Kallinen <paxed@alt.org>
Thu, 12 Jan 2023 10:37:08 +0000 (12:37 +0200)
dat/hellfill.lua
doc/lua.adoc
src/sp_lev.c

index e1325d8e32ce489016779435903c8630cc56ff64..0c87550dea60f1f87fc4dcd112a056bbe93f5519 100644 (file)
@@ -82,16 +82,90 @@ end
 
 --
 
+function rnd_halign()
+   local aligns = { "half-left", "center", "half-right" };
+   return aligns[math.random(1, #aligns)];
+end
+
+function rnd_valign()
+   local aligns = { "top", "center", "bottom" };
+   return aligns[math.random(1, #aligns)];
+end
+
+-- the prefab maps must have contents-function, or populatemaze()
+-- puts the stuff only inside the prefab map.
+local hell_prefabs = {
+   function ()
+      des.map({ halign = rnd_halign(), valign = "center", map = [[
+......
+......
+......
+......
+......
+......
+......
+......
+......
+......
+......
+......
+......
+......
+......
+......]], contents = function() end });
+   end,
+   function ()
+      des.map({ halign = rnd_halign(), valign = "center", map = [[
+xxxxxx.....xxxxxx
+xxxx.........xxxx
+xx.............xx
+xx.............xx
+x...............x
+x...............x
+.................
+.................
+.................
+.................
+.................
+x...............x
+x...............x
+xx.............xx
+xx.............xx
+xxxx.........xxxx
+xxxxxx.....xxxxxx
+]], contents = function() end });
+   end,
+   function ()
+      des.map({ halign = "center", valign = "center", map = [[
+..............................................................
+..............................................................
+..............................................................
+..............................................................
+..............................................................]], contents = function() end });
+   end,
+   function ()
+      des.map({ halign = rnd_halign(), valign = rnd_valign(), lit = true, map = [[
+x.....x
+.......
+.......
+.......
+.......
+.......
+x.....x]], contents = function() end  });
+   end,
+};
+
+function rnd_hell_prefab()
+   local pf = math.random(1, #hell_prefabs);
+   hell_prefabs[pf]();
+end
+
 -- TODO: cold hells? (ice & water instead of lava. sometimes floor = ice)
--- TODO: more hell_tweaks:
---    - replacing walls with iron bars
---    - random prefab areas
---    - replace all walls (in a full level width/height) in a small area
 
 hells = {
    -- 1: "mines" style with lava
    function ()
-      des.level_init({ style = "solidfill", fg = " " });
+      des.level_init({ style = "solidfill", fg = " ", lit = 0 });
       des.level_flags("mazelevel", "noflip");
       des.level_init({ style="mines", fg=".", smoothed=true ,joined=true, lit=0, walled=true });
       des.replace_terrain({ fromterrain = " ", toterrain = "L" });
@@ -102,37 +176,50 @@ hells = {
 
    -- 2: mazes like original, with some hell_tweaks
    function ()
+      des.level_init({ style = "solidfill", fg = " ", lit = 0 });
       des.level_flags("mazelevel", "noflip");
       des.level_init({ style = "mazegrid", bg = "-" });
-      des.mazewalk(01,10,"east");
+      des.mazewalk({ coord = {01,10}, dir = "east", stocked = false});
       local tmpbounds = selection.match("-");
       local bnds = tmpbounds:bounds();
       local protected_area = selection.fillrect(bnds.lx, bnds.ly + 1, bnds.hx - 2, bnds.hy - 1);
       hell_tweaks(protected_area:negate());
+      if (percent(25)) then
+         rnd_hell_prefab();
+      end
    end,
 
    -- 3: mazes, style 1: wall thick = 1, random wid corr
    function ()
-      des.level_init({ style = "solidfill", fg = " " });
+      des.level_init({ style = "solidfill", fg = " ", lit = 0 });
       des.level_flags("mazelevel", "noflip");
       des.level_init({ style = "maze", wallthick = 1 });
    end,
 
-   -- 4: mazes, style 2: replace wall with iron bars of lava
+   -- 4: mazes, style 2: replace wall with iron bars or lava
    function ()
-      des.level_init({ style = "solidfill", fg = " " });
+      local cwid = math.random(4);
+      des.level_init({ style = "solidfill", fg = " ", lit = 0 });
       des.level_flags("mazelevel", "noflip");
-      des.level_init({ style = "maze", wallthick = 1 });
+      des.level_init({ style = "maze", wallthick = 1, corrwid = cwid });
       local outside_walls = selection.match(" ");
       local wallterrain = { "F", "L" };
       shuffle(wallterrain);
       des.replace_terrain({ mapfragment = "w", toterrain = wallterrain[1] });
+      if (cwid == 1) then
+         if (wallterrain[1] == "F" and percent(80)) then
+            -- replace some horizontal iron bars walls with floor
+            des.replace_terrain({ mapfragment = ".\nF\n.", toterrain = ".", chance = 25 * math.random(4) });
+         elseif (percent(25)) then
+            rnd_hell_prefab();
+         end
+      end
       des.terrain(outside_walls, " ");  -- return the outside back to solid wall
    end,
 
    -- 5: mazes, thick walls, occasionally lava instead of walls
    function ()
-      des.level_init({ style = "solidfill", fg = " " });
+      des.level_init({ style = "solidfill", fg = " ", lit = 0 });
       des.level_flags("mazelevel", "noflip");
       des.level_init({ style = "maze", wallthick = 1 + math.random(2), corrwid = math.random(2) });
       if (percent(50)) then
@@ -151,5 +238,4 @@ hells[hellno]();
 des.stair("up")
 des.stair("down")
 
-des.region(selection.area(00,00,77,21),"unlit");
 populatemaze();
index 632ccd949a4f8893e30e48f112dfb312d211a1f5..705991b8e1c599f97807ee7fc0eb388611616bfb 100644 (file)
@@ -556,6 +556,7 @@ the map are not relative to it.
 | halign    | Horizontal alignment on a rough 3x3 grid.
 | valign    | Vertical alignment on a rough 3x3 grid.
 | map       | Multi-line string describing the map. See <<_map_characters>>
+| lit       | Boolean. Are the map grids lit? Default is false.
 | contents  | A function called with one parameter, a table with "width" and "height", the map width and height. All coordinates in the function will be relative to the map.
 |===
 
index 042eb152337626c602f8722d5ef758c54234c236..2a79b2ee74469eb6e4f3a0a784b8684167dade66 100644 (file)
@@ -6494,6 +6494,7 @@ TODO: gc.coder->croom needs to be updated
     boolean has_contents = FALSE;
     int tryct = 0;
     int ox, oy;
+    boolean lit = FALSE;
     struct selectionvar *sel;
 
     create_des_coder();
@@ -6512,6 +6513,7 @@ TODO: gc.coder->croom needs to be updated
         tb = t_or_b2i[get_table_option(L, "valign", "none", top_or_bot)];
         get_table_xy_or_coord(L, &x, &y);
         tmpstr = get_table_str(L, "map");
+        lit = (boolean) get_table_boolean_opt(L, "lit", FALSE);
         lua_getfield(L, 1, "contents");
         if (lua_type(L, -1) == LUA_TFUNCTION) {
             lua_remove(L, -2);
@@ -6677,7 +6679,7 @@ TODO: gc.coder->croom needs to be updated
                     continue;
                 selection_setpoint(x, y, sel, 1);
                 levl[x][y].typ = mptyp;
-                levl[x][y].lit = FALSE;
+                levl[x][y].lit = lit;
                 /* clear out levl: load_common_data may set them */
                 levl[x][y].flags = 0;
                 levl[x][y].horizontal = 0;