diff --git a/src/dogmove.c b/src/dogmove.c index ad24f9674..30a2f8725 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -1156,11 +1156,17 @@ int after; /* this is extra fast monster movement */ /* Hungry pets are unlikely to use breath/spit attacks */ if (mtarg && (!hungry || !rn2(5))) { - int mstatus; + int mstatus = MM_MISS; if (mtarg == &g.youmonst) { if (mattacku(mtmp)) return 2; + /* Treat this as the pet having initiated an attack even if it + * didn't, so it will lose its move. This isn't entirely fair, + * but mattacku doesn't distinguish between "did not attack" and + * "attacked but didn't die" cases, and this is preferable to + * letting the pet attack the player and continuing to move */ + mstatus = MM_HIT; } else { mstatus = mattackm(mtmp, mtarg); @@ -1187,7 +1193,18 @@ int after; /* this is extra fast monster movement */ } } } - return 3; + /* Only return 3 if the pet actually made a ranged attack, and thus + * should lose the rest of its move. + * There's a chain of assumptions here: + * 1. score_targ and best_target will never select a monster that + * can be attacked in melee, so the mattackm call can only ever + * try ranged options + * 2. if the only attacks available to mattackm are ranged options, + * and the monster cannot make a ranged attack, it will return + * MM_MISS. + */ + if (mstatus != MM_MISS) + return 3; } } diff --git a/src/mhitm.c b/src/mhitm.c index 37cf537eb..e848c1d99 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -368,6 +368,9 @@ register struct monst *magr, *mdef; if (distmin(magr->mx, magr->my, mdef->mx, mdef->my) > 1) { /* D: Do a ranged attack here! */ strike = thrwmm(magr, mdef); + if (strike) + /* We don't really know if we hit or not; pretend we did. */ + res[i] |= MM_HIT; if (DEADMONSTER(mdef)) res[i] = MM_DEF_DIED; if (DEADMONSTER(magr))