From: Pasi Kallinen Date: Tue, 25 Feb 2020 16:53:06 +0000 (+0200) Subject: Add new level init type, swamp X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ccb00f59bc8510f46491543dc5fc3640a9debff3;p=nethack Add new level init type, swamp Creates a "relaxed blockwise maze". Make Juiblex's swamp use it. --- diff --git a/dat/juiblex.lua b/dat/juiblex.lua index 19c95e884..68b50f327 100644 --- a/dat/juiblex.lua +++ b/dat/juiblex.lua @@ -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" }); diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 57d8d40d5..9e42f5ee2 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -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 diff --git a/include/sp_lev.h b/include/sp_lev.h index 783edf441..13530c7d1 100644 --- a/include/sp_lev.h +++ b/include/sp_lev.h @@ -39,7 +39,8 @@ enum lvlinit_types { LVLINIT_SOLIDFILL, LVLINIT_MAZEGRID, LVLINIT_MINES, - LVLINIT_ROGUE + LVLINIT_ROGUE, + LVLINIT_SWAMP }; /* max. nested depth of subrooms */ diff --git a/src/sp_lev.c b/src/sp_lev.c index 828fa02af..3d638e035 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -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;