diff --git a/src/monmove.c b/src/monmove.c index b72353629..324eaeb05 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 monmove.c $NHDT-Date: 1575245074 2019/12/02 00:04:34 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.116 $ */ +/* NetHack 3.6 monmove.c $NHDT-Date: 1579616424 2020/01/21 14:20:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.128 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1286,20 +1286,27 @@ register int after; if (!m_in_out_region(mtmp, nix, niy)) return 3; + /* move a normal monster; for a long worm, remove_monster() and + place_monster() only manipulate the head; they leave tail as-is */ remove_monster(omx, omy); place_monster(mtmp, nix, niy); + /* for a long worm, insert a new segment to reconnect the head + with the tail; worm_move() keeps the end of the tail if worm + is scheduled to grow, removes that for move-without-growing */ + if (mtmp->wormno) + worm_move(mtmp); + for (j = MTSZ - 1; j > 0; j--) mtmp->mtrack[j] = mtmp->mtrack[j - 1]; mtmp->mtrack[0].x = omx; mtmp->mtrack[0].y = omy; - /* Place a segment at the old position. */ - if (mtmp->wormno) - worm_move(mtmp); } else { if (is_unicorn(ptr) && rn2(2) && !tele_restrict(mtmp)) { (void) rloc(mtmp, TRUE); return 1; } + /* for a long worm, shrink it (by discarding end of tail) when + it has failed to move */ if (mtmp->wormno) worm_nomove(mtmp); } diff --git a/src/worm.c b/src/worm.c index 3d7fb3f93..c5395cbe9 100644 --- a/src/worm.c +++ b/src/worm.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 worm.c $NHDT-Date: 1561340880 2019/06/24 01:48:00 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.30 $ */ +/* NetHack 3.6 worm.c $NHDT-Date: 1579616437 2020/01/21 14:20:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.40 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2009. */ /* NetHack may be freely redistributed. See license for details. */ @@ -218,6 +218,13 @@ struct monst *worm; seg->nseg = new_seg; /* attach it to the end of the list */ wheads[wnum] = new_seg; /* move the end pointer */ + /* + * [maybe] FIXME? + * scheduling wgrowtime[] seems to be based on normal movement + * speed (12) but long worms move at 1/4 of that (3), so they'll + * reach the scheduled 'moves' more quickly (in terms of their + * actual movement) and grow faster than was probably intended. + */ if (wgrowtime[wnum] <= g.moves) { if (!wgrowtime[wnum]) wgrowtime[wnum] = g.moves + rnd(5);