]> granicus.if.org Git - nethack/commitdiff
Add new level init type, swamp
authorPasi Kallinen <paxed@alt.org>
Tue, 25 Feb 2020 16:53:06 +0000 (18:53 +0200)
committerPasi Kallinen <paxed@alt.org>
Tue, 25 Feb 2020 17:24:58 +0000 (19:24 +0200)
Creates a "relaxed blockwise maze".
Make Juiblex's swamp use it.

dat/juiblex.lua
doc/fixes37.0
include/sp_lev.h
src/sp_lev.c

index 19c95e88471761767392d5ff162739eee3d7e849..68b50f327136db1df1bab2e73071f128d172d3ce 100644 (file)
@@ -3,11 +3,10 @@
 --     Copyright (c) 1992 by M. Stephenson and Izchak Miller
 -- NetHack may be freely redistributed.  See license for details.
 --
-des.level_init({ style = "solidfill", fg = " " });
 
-des.level_flags("mazelevel", "noteleport", "shortsighted")
+des.level_flags("mazelevel", "noteleport", "shortsighted", "noflip")
 -- des.level_init(mines,'.','}',true,true,unlit,false)
-des.level_init({ style = "mines", fg = ".", bg = "}", smoothed=1, joined=1, lit=0 });
+des.level_init({ style = "swamp", lit = 0 });
 -- guarantee at least one open spot to ensure successful stair placement
 des.map({ halign = "left", valign = "bottom", map = [[
 xxxxxxxx
@@ -27,24 +26,24 @@ xxxxxxxx
 des.object("boulder")
 -- lair
 des.map([[
-xx}}}}}x}}}}}x}}}}}x}}}}}x}}}}}x}}}}}x}}}}}x}}}}}xx
-x}}}.}}}}}..}}}..}}}}}..}}}..}}}}}..}}}..}}}}}.}}}x
-}}}...}}..}}.}.}}.}}.}}}...}}}.}}}..}}}..}}}}...}}}
-x}}}.}}.}}}.}}.}}.}}...}}.}}.....}}.....}....}.}}}x
-xx}}}..}}}.}}.}}.}}..}}.....}}.}}}.}}.}}}}}}}}}}}xx
-x}}}..}}}}}.}}.}}.}}...}}}}}.....}}.}}}}}}.....}}}x
-}}}..}}...}}..}}.}}}.}}}...}}}.}}}.}.}}}}..P.P..}}}
-}}.}}}}...}}}}}.}...}}}..P..}}}.}.}}}.}}}}.....}}}}
-}.}}}}.}}.}..}.}}}}}}}..P.P..}}}.}}}.}}..}}...}}}}x
-x}}}}.}}}}....}}}}}.}}}..P..}}}.}}}}.}}..}}...}}}.}
-}}}}..}}.}}..}}}}...}}}}...}}}.}}}}}.}}}}.}}}}}}.}}
-}}}...}}...}}}..}}}}}}}}}}}}.....}}}}.}}...}..}.}}}
-x}}}..}}.}}}}....}}..}}}..}}.....}}}}.}}}.}....}}}x
-xx}}}.}}}}..}}..}}..}}..}}..}}.}}}..}.}..}}}..}}}xx
-x}}}.}}}}....}}}}..}}....}}}}}}}...}}}....}}}}.}}}x
-}}}...}}}....}}}..}}}....}}}..}}...}}}....}}}...}}}
-x}}}.}}}}}..}}}..}}}}}..}}}..}}}}}..}}}..}}}}}.}}}x
-xx}}}}}x}}}}}x}}}}}x}}}}}x}}}}}x}}}}}x}}}}}x}}}}}xx
+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+xxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxx
+xxx...xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...xxx
+xxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxx
+xxxxxxxxxxxxxxxxxxxxxxxx}}}xxxxxxxxxxxxxxx}}}}}xxxx
+xxxxxxxxxxxxxxxxxxxxxxx}}}}}xxxxxxxxxxxxx}.....}xxx
+xxxxxxxxxxxxxxxxxxxxxx}}...}}xxxxxxxxxxx}..P.P..}xx
+xxxxxxxxxxxxxxxxxxxxx}}..P..}}xxxxxxxxxxx}.....}xxx
+xxxxxxxxxxxxxxxxxxxxx}}.P.P.}}xxxxxxxxxxxx}...}xxxx
+xxxxxxxxxxxxxxxxxxxxx}}..P..}}xxxxxxxxxxxx}...}xxxx
+xxxxxxxxxxxxxxxxxxxxxx}}...}}xxxxxxxxxxxxxx}}}xxxxx
+xxxxxxxxxxxxxxxxxxxxxxx}}}}}xxxxxxxxxxxxxxxxxxxxxxx
+xxxxxxxxxxxxxxxxxxxxxxxx}}}xxxxxxxxxxxxxxxxxxxxxxxx
+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+xxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxx
+xxx...xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...xxx
+xxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxx
+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 ]]);
 -- Random registers
 local monster = { "j","b","P","F" }
@@ -58,8 +57,6 @@ place:set(46,15);
 
 -- Dungeon description
 des.region({ region={00,00,50,17}, lit=0, type="swamp" })
-des.mazewalk(00,09,"west")
-des.mazewalk(50,08,"east")
 des.levregion({ region = {01,00,11,20}, region_islev=1, exclude={0,0,50,17}, type="stair-down" });
 des.levregion({ region = {69,00,79,20}, region_islev=1, exclude={0,0,50,17}, type="stair-up" });
 des.levregion({ region = {01,00,11,20}, region_islev=1, exclude={0,0,50,17}, type="branch" });
index 57d8d40d58ccc3282ccf68763f73d0da5b4ef65b..9e42f5ee2eeda1b9b58eaa390e9c9c1ecda74d67 100644 (file)
@@ -164,6 +164,7 @@ added several new status conditions all of which are opt-in except
        the new cond_grab and cond_lava which are opt-out
 tipping your cap might get a response
 special levels can be flipped horizontally and/or vertically
+new special level initialization routine, "swamp"
 
 
 Platform- and/or Interface-Specific New Features
index 783edf441411dc06e962e947eb03200dcc09ee25..13530c7d1feecd1a312c87650458ddeab4734b2c 100644 (file)
@@ -39,7 +39,8 @@ enum lvlinit_types {
     LVLINIT_SOLIDFILL,
     LVLINIT_MAZEGRID,
     LVLINIT_MINES,
-    LVLINIT_ROGUE
+    LVLINIT_ROGUE,
+    LVLINIT_SWAMP
 };
 
 /* max. nested depth of subrooms */
index 828fa02afaf16685d039759d64a358cca2cb1419..3d638e035f8399e410b17e4e281053f31fe230fc 100644 (file)
@@ -27,6 +27,7 @@ static void NDECL(create_des_coder);
 static void NDECL(solidify_map);
 static void FDECL(lvlfill_maze_grid, (int, int, int, int, SCHAR_P));
 static void FDECL(lvlfill_solid, (SCHAR_P, SCHAR_P));
+static void FDECL(lvlfill_swamp, (SCHAR_P, SCHAR_P, SCHAR_P));
 static void FDECL(flip_drawbridge_horizontal, (struct rm *));
 static void FDECL(flip_drawbridge_vertical, (struct rm *));
 static int FDECL(flip_encoded_direction_bits, (int, int));
@@ -215,6 +216,33 @@ schar lit;
         }
 }
 
+static void
+lvlfill_swamp(fg, bg, lit)
+schar fg, bg, lit;
+{
+    int x,y;
+
+    lvlfill_solid(bg, lit);
+
+    /* "relaxed blockwise maze" algorithm, Jamis Buck */
+    for (x = 2; x <= g.x_maze_max; x+=2)
+        for (y = 0; y <= g.y_maze_max; y+=2) {
+            int c = 0;
+            SET_TYPLIT(x, y, fg, lit);
+            if (levl[x+1][y].typ == bg) c++;
+            if (levl[x][y+1].typ == bg) c++;
+            if (levl[x+1][y+1].typ == bg) c++;
+            if (c == 3) {
+                switch (rn2(3)) {
+                case 0: SET_TYPLIT((x+1),y, fg, lit); break;
+                case 1: SET_TYPLIT(x, (y+1), fg, lit); break;
+                case 2: SET_TYPLIT((x+1),(y+1), fg, lit); break;
+                default: break;
+                }
+            }
+        }
+}
+
 static void
 flip_drawbridge_horizontal(lev)
 struct rm *lev;
@@ -2666,6 +2694,11 @@ lev_init *linit;
         linit->icedpools = icedpools;
         mkmap(linit);
         break;
+    case LVLINIT_SWAMP:
+        if (linit->lit == -1)
+            linit->lit = rn2(2);
+        lvlfill_swamp(linit->fg, linit->bg, linit->lit);
+        break;
     }
 }
 
@@ -3302,10 +3335,11 @@ lspo_level_init(L)
 lua_State *L;
 {
     static const char *const initstyles[] = {
-        "solidfill", "mazegrid", "rogue", "mines", NULL
+        "solidfill", "mazegrid", "rogue", "mines", "swamp", NULL
     };
     static const int initstyles2i[] = {
-        LVLINIT_SOLIDFILL, LVLINIT_MAZEGRID, LVLINIT_ROGUE, LVLINIT_MINES
+        LVLINIT_SOLIDFILL, LVLINIT_MAZEGRID, LVLINIT_ROGUE,
+        LVLINIT_MINES, LVLINIT_SWAMP, 0
     };
     lev_init init_lev;
 
@@ -3318,7 +3352,7 @@ lua_State *L;
     init_lev.init_style
         = initstyles2i[get_table_option(L, "style", "solidfill", initstyles)];
     init_lev.fg = get_table_mapchr_opt(L, "fg", ROOM);
-    init_lev.bg = get_table_mapchr_opt(L, "bg", STONE);
+    init_lev.bg = get_table_mapchr_opt(L, "bg", INVALID_TYPE);
     init_lev.smoothed = get_table_boolean_opt(L, "smoothed", 0);
     init_lev.joined = get_table_boolean_opt(L, "joined", 0);
     init_lev.lit = get_table_int_or_random(L, "lit", -1); /* TODO: allow lit=BOOL */
@@ -3327,6 +3361,9 @@ lua_State *L;
 
     g.coder->lvl_is_joined = init_lev.joined;
 
+    if (init_lev.bg == INVALID_TYPE)
+        init_lev.bg = (init_lev.init_style == LVLINIT_SWAMP) ? MOAT : STONE;
+
     splev_initlev(&init_lev);
 
     return 0;