]> granicus.if.org Git - nethack/commitdiff
Dehardcode the monk minetown food shop conversion
authorPasi Kallinen <paxed@alt.org>
Thu, 16 Apr 2020 18:01:24 +0000 (21:01 +0300)
committerPasi Kallinen <paxed@alt.org>
Thu, 16 Apr 2020 18:01:37 +0000 (21:01 +0300)
Instead of trying to figure out in core whether to change a minetown
food shop to health food shop for monks, just figure it out in the
minetown level creation script.

dat/minetn-2.lua
dat/minetn-3.lua
dat/minetn-4.lua
dat/minetn-5.lua
dat/minetn-6.lua
dat/minetn-7.lua
dat/nhlib.lua
src/nhlua.c
src/shknam.c

index 87e58a34845e12cb32c7382cb659e8351ce240b4..7081021e6fb703a6d542494517a2f52d53bd13e7 100644 (file)
@@ -106,7 +106,7 @@ des.room({ type = "ordinary", lit=1, x=3, y=3,
                          end
               });
 
-              des.room({ type = "food shop", chance=90, lit=1, x=24,y=5, w=3,h=4,
+              des.room({ type = monkfoodshop(), chance=90, lit=1, x=24,y=5, w=3,h=4,
                          contents = function()
                             des.door({ state="closed", wall="north" })
                          end
index 6217d174ee8cf74faa48db8fda76289cf3938be5..b4ff7fb0672b5d962d1ffdc3406ffaeb819f4616 100644 (file)
@@ -84,7 +84,7 @@ des.room({ type = "ordinary",lit=1,x=3,y=3,
              end
   })
 
-  des.room({ type = "food shop", chance=90,lit=1,x=26,y=8,w=3,h=2,
+  des.room({ type = monkfoodshop(), chance=90,lit=1,x=26,y=8,w=3,h=2,
              contents = function()
                 des.door({ state="closed", wall="west" })
              end
index 717185d67f9790a2e01d6f7c2e917806175835e9..cc4dc7611332da059e98288ff36e9c3a0624a66a 100644 (file)
@@ -69,7 +69,7 @@ des.room({ type = "ordinary", lit=1, x=3,y=3,
                          end
               })
 
-              des.room({ type = "food shop", chance=90, lit=1, x=11, y=11, w=3, h=2,
+              des.room({ type = monkfoodshop(), chance=90, lit=1, x=11, y=11, w=3, h=2,
                          contents = function()
                             des.door({ state = "closed", wall="east" })
                          end
index 241c5b70dc93d48d345b765d1091d2e74119a362..baade6a41cb2fc72cbe8a0a531a6d5eb36057406 100644 (file)
@@ -101,7 +101,7 @@ des.region({ region={59, 9, 67,10}, lit=1, type="shop", prefilled=0 })
 des.door("closed",66,08)
 des.region({ region={57,13, 60,15}, lit=1, type="tool shop", prefilled=0 })
 des.door("closed",56,14)
-des.region({ region={05,09, 08,10}, lit=1, type="food shop", prefilled=0 })
+des.region({ region={05,09, 08,10}, lit=1, type=monkfoodshop(), prefilled=0 })
 des.door("closed",07,11)
 -- Gnome homes
 des.door("closed",04,14)
index 758ce320b90a29c433aad9a11c3fe225f6283940..6de06d11a1bee5a5ba07c237ca070924330bb90c 100644 (file)
@@ -39,7 +39,7 @@ des.region(selection.area(13,5,14,6),"unlit")
 des.region({ region={09,07, 11,09}, lit=1, type="candle shop", prefilled=0 })
 des.region({ region={16,04, 18,06}, lit=1, type="tool shop", prefilled=0 })
 des.region({ region={23,01, 25,03}, lit=1, type="shop", prefilled=0 })
-des.region({ region={22,12, 24,13}, lit=1, type="food shop", prefilled=0 })
+des.region({ region={22,12, 24,13}, lit=1, type=monkfoodshop(), prefilled=0 })
 des.region({ region={31,12, 36,14}, lit=1, type="temple", prefilled=0 })
 des.altar({ x=35,y=13,align=align[1],type="shrine"})
 
index eb4a7f56d3f515aeb6ac54b75316b492ca1fcaa0..16bca3ae1859e26f4752ca9b3c634e4fae779bb0 100644 (file)
@@ -73,7 +73,7 @@ des.room({ type="ordinary", lit=1, x=3,y=3,
                  })
               end
 
-              des.room({ type="food shop", chance=50, lit=1, x=19,y=5, w=2,h=3,
+              des.room({ type=monkfoodshop(), chance=50, lit=1, x=19,y=5, w=2,h=3,
                          contents = function()
                             des.door({ state = "closed", wall="south" })
                          end
@@ -131,7 +131,7 @@ des.room({ type="ordinary", lit=1, x=3,y=3,
                  })
               end
 
-              des.room({ type="food shop", chance=50, lit=1, x=25,y=11, w=3,h=2,
+              des.room({ type=monkfoodshop(), chance=50, lit=1, x=25,y=11, w=3,h=2,
                          contents = function()
                             des.door({ state = "closed", wall="east" })
                          end
index a07ff4a41077b8fcadce7fc8d0519d31c74a1606..a8888cabdf6dc0937d09c0bdab4c0e6f56364344 100644 (file)
@@ -41,3 +41,10 @@ end
 function percent(threshold)
    return math.random(0, 99) < threshold
 end
+
+function monkfoodshop()
+   if (u.role == "Monk") then
+      return "health food shop";
+   end
+   return "food shop";
+end
index 23713deb696b232f895684f8030e661f1bb02519..24bcc5d59854e7bf0e365a83007336056a76e2d2 100644 (file)
@@ -929,6 +929,9 @@ lua_State *L;
     if (!strcmp(tkey, "inventory")) {
         nhl_push_obj(L, g.invent);
         return 1;
+    } else if (!strcmp(tkey, "role")) {
+        lua_pushstring(L, g.urole.name.m);
+        return 1;
     }
 
     nhl_error(L, "Unknown u table index");
index e08cdef506070a80844c1442362325bc5d75be44..823570d462781e93a8c6891d0888f41726a95f18 100644 (file)
@@ -498,13 +498,6 @@ const char *const *nlp;
     int name_wanted;
     s_level *sptr;
 
-    if (nlp == shkfoods && In_mines(&u.uz) && Role_if(PM_MONK)
-        && (sptr = Is_special(&u.uz)) != 0 && sptr->flags.town) {
-        /* special-case override for minetown food store for monks */
-        nlp = shkhealthfoods;
-        ESHK(shk)->shoptype = FODDERSHOP;
-    }
-
     if (nlp == shklight && In_mines(&u.uz)
         && (sptr = Is_special(&u.uz)) != 0 && sptr->flags.town) {
         /* special-case minetown lighting shk */
@@ -676,8 +669,6 @@ struct mkroom *sroom;
     if (shp->shknms == shkrings)
         (void) mongets(shk, TOUCHSTONE);
     nameshk(shk, shp->shknms);
-    /* might have changed delicatessen to health food store */
-    sroom->rtype = eshkp->shoptype;
 
     return sh;
 }