]> granicus.if.org Git - nethack/commitdiff
Revisit the Valkyrie goal level hack
authorPasi Kallinen <paxed@alt.org>
Fri, 15 Apr 2022 15:52:46 +0000 (18:52 +0300)
committerPasi Kallinen <paxed@alt.org>
Fri, 15 Apr 2022 15:52:49 +0000 (18:52 +0300)
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.

dat/Val-goal.lua
include/extern.h
src/mklev.c
src/mkmaze.c
src/sp_lev.c

index 2753afaa37bd80e49799b6fb92abc2275315474f..f42b97ba9ef22a9ac3a6a338e810d6acce6cef2f 100644 (file)
@@ -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))
index 2bd636c2cca518f774f76e2110ceb3c3feae3e3f..46d5a326bc4fe30801b55b980c0047b2dff8abf9 100644 (file)
@@ -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);
 
index 5e78777e7eef41d4582f8104ac2a1be965fc0c4c..9965b802d3ded7a3fe13fa852d551f78c3dd96a6 100644 (file)
@@ -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 */
 }
index da5254cf5f253d8165e6e1cb5220e4baa22a25c8..05620488acee0bb1beb9abcef27791ca93de96ac 100644 (file)
@@ -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;
index 4b5d9b201945a4d99bc3ab6b57956af626a5f0a1..5ab2c279e7c956e7701852b9437084eb31ba1811 100644 (file)
@@ -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;
 }