]> granicus.if.org Git - nethack/commitdiff
Accept "waiting" on special level des.monster() specifications
authorPasi Kallinen <paxed@alt.org>
Sun, 9 May 2021 09:15:48 +0000 (12:15 +0300)
committerPasi Kallinen <paxed@alt.org>
Sun, 9 May 2021 09:24:27 +0000 (12:24 +0300)
Allow specifying "waiting" for monsters created via lua level scripts.
This sets the monster strategy to make it wait for the hero
to be in visual range before allowing the monster to move.

Also makes the monster inside the Mausoleum themed room use this feature,
to prevent out of depth liches bothering the player unprovoked.

For example:

des.monster({ class = "D", waiting = 1 });

dat/themerms.lua
include/sp_lev.h
src/sp_lev.c

index 0004ff36a3fdde8223425ab39f68ad170111b959..e8f35352eb2c1898342ebe208947d598a164bb9f 100644 (file)
@@ -234,7 +234,7 @@ themerooms = {
                                   if (percent(50)) then
                                      local mons = { "M", "V", "L", "Z" };
                                      shuffle(mons);
-                                     des.monster(mons[1], 0,0);
+                                     des.monster({ class = mons[1], x=0,y=0, waiting = 1 });
                                   else
                                      des.object({ id = "corpse", montype = "@", coord = {0,0} });
                                   end
index b27adb874bc0390430a29b76ec76f60496eef653..b989b709e4ff7b2c3efa87c65d5fda4dea6bf021 100644 (file)
@@ -137,7 +137,7 @@ typedef struct {
     xchar x, y, class, appear;
     schar peaceful, asleep;
     short female, invis, cancelled, revived, avenge, fleeing, blinded,
-        paralyzed, stunned, confused;
+        paralyzed, stunned, confused, waiting;
     long seentraps;
     short has_invent;
 } monster;
index 8812b2ae3376d438dc0c552cd8b4f30c3a8f95fa..2105ba80e805c6fa1b54e920787550667f1a1288 100755 (executable)
@@ -2028,7 +2028,9 @@ create_monster(monster* m, struct mkroom* croom)
             mtmp->mflee = 1;
             mtmp->mfleetim = (m->fleeing % 127);
         }
-
+        if (m->waiting) {
+            mtmp->mstrategy |= STRAT_WAITFORU;
+        }
         if (m->has_invent) {
             discard_minvent(mtmp, TRUE);
             invent_carrying_monster = mtmp;
@@ -3026,6 +3028,7 @@ lspo_monster(lua_State* L)
     tmpmons.confused = 0;
     tmpmons.seentraps = 0;
     tmpmons.has_invent = 0;
+    tmpmons.waiting = 0;
 
     if (argc == 1 && lua_type(L, 1) == LUA_TSTRING) {
         const char *paramstr = luaL_checkstring(L, 1);
@@ -3089,6 +3092,7 @@ lspo_monster(lua_State* L)
         tmpmons.paralyzed = get_table_int_opt(L, "paralyzed", 0);
         tmpmons.stunned = get_table_int_opt(L, "stunned", 0);
         tmpmons.confused = get_table_int_opt(L, "confused", 0);
+        tmpmons.waiting = get_table_int_opt(L, "waiting", 0);
         tmpmons.seentraps = 0; /* TODO: list of trap names to bitfield */
         tmpmons.has_invent = 0;