From: Pasi Kallinen Date: Thu, 16 Apr 2020 18:01:24 +0000 (+0300) Subject: Dehardcode the monk minetown food shop conversion X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c44e06ab115faf3cb70fe763e0a498f65c6a508;p=nethack Dehardcode the monk minetown food shop conversion 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. --- diff --git a/dat/minetn-2.lua b/dat/minetn-2.lua index 87e58a348..7081021e6 100644 --- a/dat/minetn-2.lua +++ b/dat/minetn-2.lua @@ -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 diff --git a/dat/minetn-3.lua b/dat/minetn-3.lua index 6217d174e..b4ff7fb06 100644 --- a/dat/minetn-3.lua +++ b/dat/minetn-3.lua @@ -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 diff --git a/dat/minetn-4.lua b/dat/minetn-4.lua index 717185d67..cc4dc7611 100644 --- a/dat/minetn-4.lua +++ b/dat/minetn-4.lua @@ -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 diff --git a/dat/minetn-5.lua b/dat/minetn-5.lua index 241c5b70d..baade6a41 100644 --- a/dat/minetn-5.lua +++ b/dat/minetn-5.lua @@ -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) diff --git a/dat/minetn-6.lua b/dat/minetn-6.lua index 758ce320b..6de06d11a 100644 --- a/dat/minetn-6.lua +++ b/dat/minetn-6.lua @@ -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"}) diff --git a/dat/minetn-7.lua b/dat/minetn-7.lua index eb4a7f56d..16bca3ae1 100644 --- a/dat/minetn-7.lua +++ b/dat/minetn-7.lua @@ -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 diff --git a/dat/nhlib.lua b/dat/nhlib.lua index a07ff4a41..a8888cabd 100644 --- a/dat/nhlib.lua +++ b/dat/nhlib.lua @@ -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 diff --git a/src/nhlua.c b/src/nhlua.c index 23713deb6..24bcc5d59 100644 --- a/src/nhlua.c +++ b/src/nhlua.c @@ -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"); diff --git a/src/shknam.c b/src/shknam.c index e08cdef50..823570d46 100644 --- a/src/shknam.c +++ b/src/shknam.c @@ -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; }