ranged attack in repertoire might not be used

Commit 22884522, ported (from Sporkhack, Evilhack), added the ability
for monsters to maintain awareness of player resistances that they
observed.

Since they will refrain from using a ranged attack that they deem
futile, take the specific monster's seen_resistance field into consideration
when choosing code paths based on the availability of ranged attacks.

Resolves #1307
This commit is contained in:
nhmall
2024-11-03 09:03:04 -05:00
parent 70a5b06c45
commit 9a42d70901
3 changed files with 64 additions and 2 deletions

View File

@@ -910,7 +910,8 @@ dochug(struct monst *mtmp)
return 0;
/* Monsters can move and then shoot on same turn;
our hero can't. Is that fair? */
if (!nearby && (ranged_attk(mdat)
if (!nearby
&& (ranged_attk_available(mtmp)
|| attacktype(mdat, AT_WEAP)
|| find_offensive(mtmp)))
break;
@@ -1159,7 +1160,7 @@ m_balks_at_approaching(struct monst *mtmp)
return TRUE;
/* can attack from distance, and hp loss or attack not used */
if (ranged_attk(mtmp->data)
if (ranged_attk_available(mtmp)
&& ((mtmp->mhp < (mtmp->mhpmax+1) / 3)
|| !mtmp->mspec_used))
return TRUE;