From d2b331abf7a21824d4187924e437aa89eebfeb42 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sun, 9 May 2021 12:15:48 +0300 Subject: [PATCH] Accept "waiting" on special level des.monster() specifications 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 | 2 +- include/sp_lev.h | 2 +- src/sp_lev.c | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dat/themerms.lua b/dat/themerms.lua index 0004ff36a..e8f35352e 100644 --- a/dat/themerms.lua +++ b/dat/themerms.lua @@ -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 diff --git a/include/sp_lev.h b/include/sp_lev.h index b27adb874..b989b709e 100644 --- a/include/sp_lev.h +++ b/include/sp_lev.h @@ -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; diff --git a/src/sp_lev.c b/src/sp_lev.c index 8812b2ae3..2105ba80e 100755 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -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;