diff --git a/src/dogmove.c b/src/dogmove.c index 5a385b6aa..200779ea3 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -1086,11 +1086,18 @@ int after; /* this is extra fast monster movement */ continue; /* lessen the chance of backtracking to previous position(s) */ - k = has_edog ? uncursedcnt : cnt; - for (j = 0; j < MTSZ && j < k - 1; j++) - if (nx == mtmp->mtrack[j].x && ny == mtmp->mtrack[j].y) - if (rn2(MTSZ * (k - j))) - goto nxti; + /* This causes unintended issues for pets trying to follow + the hero. Thus, only run it if not leashed and >5 tiles + away. */ + if (!mtmp->mleashed && + distmin(mtmp->mx, mtmp->my, u.ux, u.uy) > 5) { + k = has_edog ? uncursedcnt : cnt; + for (j = 0; j < MTSZ && j < k - 1; j++) + if (nx == mtmp->mtrack[j].x && + ny == mtmp->mtrack[j].y) + if (rn2(MTSZ * (k - j))) + goto nxti; + } j = ((ndist = GDIST(nx, ny)) - nidist) * appr; if ((j == 0 && !rn2(++chcnt)) || j < 0 diff --git a/src/mon.c b/src/mon.c index d01a79c95..a872b93a9 100644 --- a/src/mon.c +++ b/src/mon.c @@ -2787,8 +2787,13 @@ wake_nearby() mtmp->msleeping = 0; if (!unique_corpstat(mtmp->data)) mtmp->mstrategy &= ~STRAT_WAITMASK; - if (mtmp->mtame && !mtmp->isminion) - EDOG(mtmp)->whistletime = moves; + if (mtmp->mtame) { + if (!mtmp->isminion) + EDOG(mtmp)->whistletime = moves; + /* Clear mtrack. This is to fix up a pet who is + stuck "fleeing" its master. */ + memset(mtmp->mtrack, 0, sizeof(mtmp->mtrack)); + } } } }