Minor ranged attack tweak

Make monsters with magic and gaze attacks avoid hero,
just like spitters and breathers already did.
Some small code cleanup related to the ranged attacks.
This commit is contained in:
Pasi Kallinen
2022-08-07 22:31:41 +03:00
parent 2b51a22c6c
commit b635160297
3 changed files with 15 additions and 20 deletions

View File

@@ -28,6 +28,11 @@
#define AT_WEAP 254 /* uses weapon */
#define AT_MAGC 255 /* uses magic spell(s) */
#define DISTANCE_ATTK_TYPE(atyp) ((atyp) == AT_SPIT \
|| (atyp) == AT_BREA \
|| (atyp) == AT_MAGC \
|| (atyp) == AT_GAZE)
/* Add new damage types below.
*
* Note that 1-10 correspond to the types of attack used in buzz().

View File

@@ -306,22 +306,11 @@ can_blnd(
boolean
ranged_attk(struct permonst* ptr)
{
register int i, atyp;
long atk_mask = (1L << AT_BREA) | (1L << AT_SPIT) | (1L << AT_GAZE);
int i;
/* was: (attacktype(ptr, AT_BREA) || attacktype(ptr, AT_WEAP)
* || attacktype(ptr, AT_SPIT) || attacktype(ptr, AT_GAZE)
* || attacktype(ptr, AT_MAGC));
* but that's too slow -dlc
*/
for (i = 0; i < NATTK; i++) {
atyp = ptr->mattk[i].aatyp;
if (atyp >= AT_WEAP)
for (i = 0; i < NATTK; i++)
if (DISTANCE_ATTK_TYPE(ptr->mattk[i].aatyp))
return TRUE;
/* assert(atyp < 32); */
if ((atk_mask & (1L << atyp)) != 0L)
return TRUE;
}
return FALSE;
}

View File

@@ -756,7 +756,9 @@ dochug(register 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) || find_offensive(mtmp)))
if (!nearby && (ranged_attk(mdat)
|| attacktype(mdat, AT_WEAP)
|| find_offensive(mtmp)))
break;
/* engulfer/grabber checks */
if (mtmp == u.ustuck) {
@@ -945,9 +947,8 @@ m_balks_at_approaching(struct monst* mtmp)
|| !m_canseeu(mtmp))
return FALSE;
/* has ammo+launcher or can spit */
if (m_has_launcher_and_ammo(mtmp)
|| attacktype(mtmp->data, AT_SPIT))
/* has ammo+launcher */
if (m_has_launcher_and_ammo(mtmp))
return TRUE;
/* is using a polearm and in range */
@@ -955,8 +956,8 @@ m_balks_at_approaching(struct monst* mtmp)
&& dist2(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy) <= MON_POLE_DIST)
return TRUE;
/* breath attack, and hp loss or breath not used */
if (attacktype(mtmp->data, AT_BREA)
/* can attack from distance, and hp loss or attack not used */
if (ranged_attk(mtmp->data)
&& ((mtmp->mhp < (mtmp->mhpmax+1) / 3)
|| !mtmp->mspec_used))
return TRUE;