From: Pasi Kallinen Date: Fri, 15 Apr 2022 15:52:46 +0000 (+0300) Subject: Revisit the Valkyrie goal level hack X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cb02ce88c55d5a6713f86cbbd6493c0c590495aa;p=nethack Revisit the Valkyrie goal level hack Instead of hardcoding the lava terrain change in core, if the stairs are created in a fixed location, force the terrain to room floor first. Move the surrounding lava changing to room floor to the Val-goal lua file. --- diff --git a/dat/Val-goal.lua b/dat/Val-goal.lua index 2753afaa3..f42b97ba9 100644 --- a/dat/Val-goal.lua +++ b/dat/Val-goal.lua @@ -32,6 +32,8 @@ xxxxxxxxx..................xxxxxxxx des.region(selection.area(00,00,34,16), "lit") -- Stairs -- Note: The up stairs are *intentionally* off of the map. +-- if the stairs are surrounded by lava, maybe give some room +des.replace_terrain({ region = {44,09, 46,11}, fromterrain='L', toterrain='.', chance=50 }); des.stair("up", 45,10) -- Non diggable walls des.non_diggable(selection.area(00,00,34,16)) diff --git a/include/extern.h b/include/extern.h index 2bd636c2c..46d5a326b 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1348,7 +1348,7 @@ extern boolean occupied(xchar, xchar); extern int okdoor(xchar, xchar); extern void dodoor(int, int, struct mkroom *); extern void mktrap(int, int, struct mkroom *, coord *); -extern void mkstairs(xchar, xchar, char, struct mkroom *); +extern void mkstairs(xchar, xchar, char, struct mkroom *, boolean); extern void mkinvokearea(void); extern void mineralize(int, int, int, int, boolean); diff --git a/src/mklev.c b/src/mklev.c index 5e78777e7..9965b802d 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -1619,11 +1619,14 @@ mktrap( } } +/* Create stairs up or down at x,y. + If force is TRUE, change the terrain to ROOM first */ void mkstairs( xchar x, xchar y, char up, /* [why 'char' when usage is boolean?] */ - struct mkroom *croom UNUSED) + struct mkroom *croom UNUSED, + boolean force) { int ltyp; d_level dest; @@ -1632,6 +1635,8 @@ mkstairs( impossible("mkstairs: bogus stair attempt at <%d,%d>", x, y); return; } + if (force) + levl[x][y].typ = ROOM; ltyp = levl[x][y].typ; /* somexyspace() allows ice */ if (ltyp != ROOM && ltyp != CORR && ltyp != ICE) { int glyph = back_to_glyph(x, y), @@ -1718,7 +1723,7 @@ generate_stairs(void) pos.x = somex(croom); pos.y = somey(croom); } - mkstairs(pos.x, pos.y, 0, croom); /* down */ + mkstairs(pos.x, pos.y, 0, croom, FALSE); /* down */ } if (g.nroom > 1) @@ -1729,7 +1734,7 @@ generate_stairs(void) pos.x = somex(croom); pos.y = somey(croom); } - mkstairs(pos.x, pos.y, 1, croom); /* up */ + mkstairs(pos.x, pos.y, 1, croom, FALSE); /* up */ } } @@ -1920,7 +1925,7 @@ mkinvokearea(void) } You("are standing at the top of a stairwell leading down!"); - mkstairs(u.ux, u.uy, 0, (struct mkroom *) 0); /* down */ + mkstairs(u.ux, u.uy, 0, (struct mkroom *) 0, FALSE); /* down */ newsym(u.ux, u.uy); g.vision_full_recalc = 1; /* everything changed */ } diff --git a/src/mkmaze.c b/src/mkmaze.c index da5254cf5..05620488a 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -392,7 +392,7 @@ put_lregion_here( break; case LR_DOWNSTAIR: case LR_UPSTAIR: - mkstairs(x, y, (char) rtype, (struct mkroom *) 0); + mkstairs(x, y, (char) rtype, (struct mkroom *) 0, FALSE); break; case LR_BRANCH: place_branch(Is_branchlev(&u.uz), x, y); @@ -1043,10 +1043,10 @@ makemaz(const char *s) wallification(2, 2, g.x_maze_max, g.y_maze_max); mazexy(&mm); - mkstairs(mm.x, mm.y, 1, (struct mkroom *) 0); /* up */ + mkstairs(mm.x, mm.y, 1, (struct mkroom *) 0, FALSE); /* up */ if (!Invocation_lev(&u.uz)) { mazexy(&mm); - mkstairs(mm.x, mm.y, 0, (struct mkroom *) 0); /* down */ + mkstairs(mm.x, mm.y, 0, (struct mkroom *) 0, FALSE); /* down */ } else { /* choose "vibrating square" location */ stairway *stway; int trycnt = 0; diff --git a/src/sp_lev.c b/src/sp_lev.c index 4b5d9b201..5ab2c279e 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -3905,22 +3905,8 @@ l_create_stairway(lua_State *L, boolean using_ladder) levl[x][y].ladder = LA_DOWN; } } else { - /* hack for Valkyrie goal level where upstairs are at a fixed - location outside the mapped area; make sure they don't get - placed on a lava spot */ - if (levl[x][y].typ == LAVAPOOL) { - int tx, ty; - - for (tx = x - 1; tx <= x + 1; ++tx) - for (ty = y - 1; ty <= y + 1; ++ty) - if (isok(tx, ty) && levl[tx][ty].typ == LAVAPOOL - && ((tx == x && ty == y) || !rn2(2))) { - levl[tx][ty].typ = ROOM; - SpLev_Map[tx][ty] = 1; - } - } - - mkstairs(x, y, (char) up, g.coder->croom); + mkstairs(x, y, (char) up, g.coder->croom, + !(scoord & SP_COORD_IS_RANDOM)); } return 0; }