Add a new wand, the wand of stasis

A wand of stasis prevents teleportation (even in some cases where
it would normally not be prevented, e.g. the hero teleporting a
monster, or covetous monsters teleporting). This is intended to
provide an alternative tactic against covetous monsters (and their
AI has been adjusted to handle being under a stasis effect), but
might also be useful in other situations. It does not prevent
teleportation of objects, only the hero / monsters, and does not
at present prevent level teleportation (although I'm not sure about
this and it might well change in the future).

This breaks save compatibility, but is being pushed together with
other save-breaking changes to avoid the need for multiple bumps to
EDITLEVEL.
This commit is contained in:
Alex Smith
2026-03-19 01:16:30 +00:00
parent 6886b199be
commit 07fc4904c6
13 changed files with 75 additions and 17 deletions

View File

@@ -526,6 +526,10 @@ magic_whistled(struct obj *obj)
already_discovered = objects[obj->otyp].oc_name_known != 0;
int omx, omy, shift = 0, appear = 0, disappear = 0, trapped = 0;
/* stasis prevents magic-whistling */
if (svl.level.flags.stasis_until >= svm.moves)
return;
/* need to copy (up to 3) names as they're collected rather than just
save pointers to them, otherwise churning through every mbuf[] might
clobber the ones we care about */
@@ -3984,6 +3988,7 @@ do_break_wand(struct obj *obj)
case WAN_PROBING:
case WAN_ENLIGHTENMENT:
case WAN_SECRET_DOOR_DETECTION:
case WAN_STASIS:
pline(nothing_else_happens);
discard_broken_wand();
return ECMD_TIME;

View File

@@ -2248,7 +2248,8 @@ revive_mon(anything *arg, long timeout UNUSED)
/* corpse will revive somewhere else if there is a monster in the way;
Riders get a chance to try to bump the obstacle out of their way */
if (is_displacer(mptr) && body->where == OBJ_FLOOR
&& get_obj_location(body, &x, &y, 0) && (mtmp = m_at(x, y)) != 0) {
&& get_obj_location(body, &x, &y, 0) && (mtmp = m_at(x, y)) != 0 &&
svl.level.flags.stasis_until < svm.moves) {
boolean notice_it = canseemon(mtmp); /* before rloc() */
char *monname = Monnam(mtmp);

View File

@@ -589,6 +589,7 @@ doengrave_sfx_item_WAN(struct _doengrave_ctx *de)
/* NODIR wands */
case WAN_LIGHT:
case WAN_SECRET_DOOR_DETECTION:
case WAN_STASIS:
case WAN_CREATE_MONSTER:
case WAN_WISHING:
case WAN_ENLIGHTENMENT:

View File

@@ -891,6 +891,7 @@ clear_level_structures(void)
svl.level.flags.noautosearch = 0;
svl.level.flags.fumaroles = 0;
svl.level.flags.stormy = 0;
svl.level.flags.stasis_until = 0L;
svn.nroom = 0;
svr.rooms[0].hx = -1;

View File

@@ -1115,6 +1115,10 @@ mksobj_init(struct obj **obj, boolean artif)
case WAND_CLASS:
if (otmp->otyp == WAN_WISHING)
otmp->spe = 1;
else if (otmp->otyp == WAN_STASIS)
/* just as easy to recharge as other NODIR wands, but starts with
fewer charges */
otmp->spe = rn1(4, 3);
else
otmp->spe = rn1(5,
(objects[otmp->otyp].oc_dir == NODIR) ? 11 : 4);

View File

@@ -1794,11 +1794,10 @@ m_move(struct monst *mtmp, int after)
if (covetousattack & M_ATTK_AGR_DIED)
return MMOVE_DIED;
mmoved = MMOVE_MOVED;
} else {
mmoved = MMOVE_NOTHING;
return postmov(mtmp, ptr, omx, omy, mmoved,
seenflgs, can_tunnel, can_unlock, can_open);
}
return postmov(mtmp, ptr, omx, omy, mmoved,
seenflgs, can_tunnel, can_unlock, can_open);
/* otherwise continue with normal AI routine */
}
/* likewise for shopkeeper, guard, or priest */

View File

@@ -34,8 +34,13 @@ noteleport_level(struct monst *mon)
if (get_iter_mons(m_blocks_teleporting))
return TRUE;
/* natural no-teleport level */
if (svl.level.flags.noteleport)
/* natural no-teleport level; covetous monsters can bypass these */
if (svl.level.flags.noteleport && !is_covetous(mon->data))
return TRUE;
/* wand of stasis prevents teleportation while the effect is active
(even for covetous monsters) */
if (svl.level.flags.stasis_until >= svm.moves)
return TRUE;
return FALSE;
@@ -1958,8 +1963,11 @@ mtele_trap(struct monst *mtmp, struct trap *trap, int in_sight)
{
char *monname;
if (tele_restrict(mtmp))
/* don't print feedback here: a monster stepping on a trap and not
teleporting from it isn't visible */
if (noteleport_level(mtmp))
return;
if (teleport_pet(mtmp, FALSE)) {
/* save name with pre-movement visibility */
monname = Monnam(mtmp);
@@ -2257,7 +2265,12 @@ u_teleport_mon(
{
coord cc;
if (mtmp->ispriest && *in_rooms(mtmp->mx, mtmp->my, TEMPLE)) {
if (svl.level.flags.stasis_until >= svm.moves) {
if (give_feedback)
pline("A mysterious force prevents you teleporting %s!",
mon_nam(mtmp));
return FALSE;
} else if (mtmp->ispriest && *in_rooms(mtmp->mx, mtmp->my, TEMPLE)) {
if (give_feedback)
pline("%s resists your magic!", Monnam(mtmp));
return FALSE;

View File

@@ -386,10 +386,12 @@ tactics(struct monst *mtmp)
mtmp->mavenge = 1; /* covetous monsters attack while fleeing */
if (In_W_tower(mx, my, &u.uz)
|| (mtmp->iswiz && !sx && !mon_has_amulet(mtmp))) {
if (!rn2(3 + mtmp->mhp / 10))
if (!noteleport_level(mtmp) &&
!rn2(3 + mtmp->mhp / 10))
(void) rloc(mtmp, RLOC_MSG);
} else if (sx && (mx != sx || my != sy)) {
if (!mnearto(mtmp, sx, sy, TRUE, RLOC_MSG)) {
if (!noteleport_level(mtmp) &&
!mnearto(mtmp, sx, sy, TRUE, RLOC_MSG)) {
/* couldn't move to the target spot for some reason,
so stay where we are (don't actually need rloc_to()
because mtmp is still on the map at <mx,my>... */
@@ -408,7 +410,7 @@ tactics(struct monst *mtmp)
/*FALLTHRU*/
case STRAT_NONE: /* harass */
if (!rn2(!mtmp->mflee ? 5 : 33))
if (!noteleport_level(mtmp) && !rn2(!mtmp->mflee ? 5 : 33))
mnexto(mtmp, RLOC_MSG);
return 0;
@@ -419,13 +421,16 @@ tactics(struct monst *mtmp)
int targ = (int) (strat & STRAT_GOAL);
struct obj *otmp;
if (!targ) { /* simply wants you to close */
if (!targ || !isok(tx, ty)) { /* simply wants you to close */
return 0;
}
if (noteleport_level(mtmp) && !monnear(mtmp, tx, ty))
return 0;
if (u_at(tx, ty) || where == STRAT_PLAYER) {
/* player is standing on it (or has it) */
mx = mtmp->mx, my = mtmp->my;
if (!mnearto(mtmp, tx, ty, FALSE, RLOC_MSG))
if (noteleport_level(mtmp) ||
!mnearto(mtmp, tx, ty, FALSE, RLOC_MSG))
rloc_to(mtmp, mx, my); /* no room? stay put */
return 0;
}
@@ -445,13 +450,14 @@ tactics(struct monst *mtmp)
return 0;
} else {
/* a monster is standing on it - cause some trouble */
if (!rn2(5))
if (!rn2(5) && !noteleport_level(mtmp))
mnexto(mtmp, RLOC_MSG);
return 0;
}
} else { /* a monster has it - 'port beside it. */
mx = mtmp->mx, my = mtmp->my;
if (!mnearto(mtmp, tx, ty, FALSE, RLOC_MSG))
if (!noteleport_level(mtmp) &&
!mnearto(mtmp, tx, ty, FALSE, RLOC_MSG))
rloc_to(mtmp, mx, my); /* no room? stay put */
return 0;
}

View File

@@ -2555,6 +2555,11 @@ zapnodir(struct obj *obj)
known = !!obj->dknown;
(void) findit();
break;
case WAN_STASIS:
/* no immediately obvious effect, and no message so that it isn't
distinguishable from other NODIR wands that produce no message */
svl.level.flags.stasis_until = svm.moves + rn1(21, 10);
break;
case WAN_CREATE_MONSTER:
/* create_critters() returns True iff hero sees a new monster appear */
if (create_critters(rn2(23) ? 1 : rn1(7, 2),