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 });
This commit is contained in:
Pasi Kallinen
2021-05-09 12:15:48 +03:00
parent 967c7e5b0b
commit d2b331abf7
3 changed files with 7 additions and 3 deletions

View 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

View 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;

View File

@@ -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;