fix #K4331 - sticking from distance

Stop attacking if target isn't there anymore.  Already handled for
two-weapon in normal form, not for multi-attacks in poly'd form and
for multi-attack monster vs hero or monster vs other monster.

I didn't attempt to reproduce the reported problem.  This fix is
based on code inspection.

Also prevent monsters that have hug or engulf attacks from knocking
target back with other attacks since that prohibits the grab/engulf
from being able to hit.
This commit is contained in:
PatR
2025-06-03 22:13:22 -07:00
parent 28af1d6410
commit 45f751989a
3 changed files with 35 additions and 10 deletions

View File

@@ -284,6 +284,9 @@ mdisplacem(
* Each successive attack has a lower probability of hitting. Some rely on
* success of previous attacks. ** this doesn't seem to be implemented -dl **
*
* Attacker has targeted <bhitpos.x,bhitpos.y> rather than
* <mdef->mx,mdef->my>; matters for long worms.
*
* In the case of exploding monsters, the monster dies as well.
*/
int
@@ -353,7 +356,7 @@ mattackm(
/* Set up the visibility of action */
gv.vis = ((cansee(magr->mx, magr->my) && canspotmon(magr))
|| (cansee(mdef->mx, mdef->my) && canspotmon(mdef)));
|| (cansee(mdef->mx, mdef->my) && canspotmon(mdef)));
/* Set flag indicating monster has moved this turn. Necessary since a
* monster might get an attack out of sequence (i.e. before its move) in
@@ -371,6 +374,12 @@ mattackm(
/* Now perform all attacks for the monster. */
for (i = 0; i < NATTK; i++) {
res[i] = M_ATTK_MISS;
/* target might no longer be there */
if (i > 0 && (m_at(gb.bhitpos.x, gb.bhitpos.y) != mdef
|| DEADMONSTER(magr) || DEADMONSTER(mdef)))
continue;
mattk = getmattk(magr, mdef, i, res, &alt_attk);
/* reduce verbosity for mind flayer attacking creature without a
head (or worm's tail); this is similar to monster with multiple