/* 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);
}
}
}
- 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;
}
}
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))