Prevent monster generation in the sokoban trap hallway

Makes Sokoban far less tedious when you don't have to worry about
monsters randomly popping up in the trap hallway while you're pushing
the boulder.

Adds a new exclusion zone for monster generation, and the goodpos
routine avoids the zones when GP_AVOID_MONPOS is used.
This commit is contained in:
Pasi Kallinen
2024-10-18 13:26:43 +03:00
parent 9e4b2c121b
commit f12635ccd9
16 changed files with 45 additions and 9 deletions

View File

@@ -129,7 +129,7 @@ m_initgrp(
* are peaceful and some are not, the result will just be a
* smaller group.
*/
if (enexto(&mm, mm.x, mm.y, mtmp->data)) {
if (enexto_gpflags(&mm, mm.x, mm.y, mtmp->data, mmflags)) {
mon = makemon(mtmp->data, mm.x, mm.y, (mmflags | MM_NOGRP));
if (mon) {
mon->mpeaceful = FALSE;

View File

@@ -26,7 +26,6 @@ staticfn void stolen_booty(void);
staticfn boolean maze_inbounds(coordxy, coordxy);
staticfn void maze_remove_deadends(xint16);
staticfn void populate_maze(void);
staticfn boolean is_exclusion_zone(xint16, coordxy, coordxy);
/* adjust a coordinate one step in the specified direction */
#define mz_move(X, Y, dir) \
@@ -302,7 +301,7 @@ maze0xy(coord *cc)
return;
}
staticfn boolean
boolean
is_exclusion_zone(xint16 type, coordxy x, coordxy y)
{
struct exclusion_zone *ez = sve.exclusion_zones;

View File

@@ -5446,10 +5446,10 @@ int
lspo_exclusion(lua_State *L)
{
static const char *const ez_types[] = {
"teleport", "teleport-up", "teleport-down", NULL
"teleport", "teleport-up", "teleport-down", "monster-generation", NULL
};
static const int ez_types2i[] = {
LR_TELE, LR_UPTELE, LR_DOWNTELE, 0
LR_TELE, LR_UPTELE, LR_DOWNTELE, LR_MONGEN, 0
};
struct exclusion_zone *ez = (struct exclusion_zone *) alloc(sizeof *ez);
lua_Integer x1,y1,x2,y2;

View File

@@ -172,6 +172,9 @@ goodpos(
/* skip boulder locations for most creatures */
if (sobj_at(BOULDER, x, y) && (!mdat || !throws_rocks(mdat)))
return FALSE;
/* pretend GP_AVOID_MONPOS == monster creation */
if (avoid_monpos && is_exclusion_zone(LR_MONGEN, x, y))
return FALSE;
return TRUE;
}
@@ -194,6 +197,17 @@ enexto(
|| enexto_core(cc, xx, yy, mdat, NO_MM_FLAGS));
}
boolean
enexto_gpflags(
coord *cc,
coordxy xx, coordxy yy,
struct permonst *mdat,
mmflags_nht entflags)
{
return (enexto_core(cc, xx, yy, mdat, GP_CHECKSCARY | entflags)
|| enexto_core(cc, xx, yy, mdat, entflags));
}
#ifdef NEW_ENEXTO
boolean