Scared hostile monster which cannot move away will attack

This commit is contained in:
Pasi Kallinen
2022-07-21 20:21:10 +03:00
parent 8747d2ddce
commit 82f0b1e8ea
3 changed files with 12 additions and 3 deletions

View File

@@ -975,6 +975,7 @@ some large monsters can knock back smaller monsters with a hit
change Demonbane to a mace, make it the first sac gift for priests, change Demonbane to a mace, make it the first sac gift for priests,
and give it an invoke ability to banish demons and give it an invoke ability to banish demons
wielding Giantslayer prevents knockback from larger monsters wielding Giantslayer prevents knockback from larger monsters
scared hostile monster which cannot move away will attack
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository Fixes to 3.7.0-x Problems that Were Exposed Via git Repository

View File

@@ -440,6 +440,7 @@ typedef uint32_t mmflags_nht; /* makemon MM_ flags */
#define MMOVE_MOVED 1 /* monster moved */ #define MMOVE_MOVED 1 /* monster moved */
#define MMOVE_DIED 2 /* monster died */ #define MMOVE_DIED 2 /* monster died */
#define MMOVE_DONE 3 /* monster used up all actions */ #define MMOVE_DONE 3 /* monster used up all actions */
#define MMOVE_NOMOVES 4 /* monster has no valid locations to move to */
/*** some utility macros ***/ /*** some utility macros ***/
#define yn(query) yn_function(query, ynchars, 'n') #define yn(query) yn_function(query, ynchars, 'n')

View File

@@ -473,6 +473,7 @@ dochug(register struct monst* mtmp)
register int tmp = MMOVE_NOTHING; register int tmp = MMOVE_NOTHING;
int inrange, nearby, scared, res; int inrange, nearby, scared, res;
struct obj *otmp; struct obj *otmp;
boolean panicattk = FALSE;
/* Pre-movement adjustments /* Pre-movement adjustments
*/ */
@@ -734,6 +735,10 @@ dochug(register struct monst* mtmp)
distfleeck(mtmp, &inrange, &nearby, &scared); /* recalc */ distfleeck(mtmp, &inrange, &nearby, &scared); /* recalc */
switch (tmp) { /* for pets, cases 0 and 3 are equivalent */ switch (tmp) { /* for pets, cases 0 and 3 are equivalent */
case MMOVE_NOMOVES:
if (scared)
panicattk = TRUE;
/*FALLTHRU*/
case MMOVE_NOTHING: /* no movement, but it can still attack you */ case MMOVE_NOTHING: /* no movement, but it can still attack you */
case MMOVE_DONE: /* absolutely no movement */ case MMOVE_DONE: /* absolutely no movement */
/* vault guard might have vanished */ /* vault guard might have vanished */
@@ -775,7 +780,7 @@ dochug(register struct monst* mtmp)
if (tmp != MMOVE_DONE && (!mtmp->mpeaceful if (tmp != MMOVE_DONE && (!mtmp->mpeaceful
|| (Conflict && !resist_conflict(mtmp)))) { || (Conflict && !resist_conflict(mtmp)))) {
if (inrange && !scared && !noattacks(mdat) if (((inrange && !scared) || panicattk) && !noattacks(mdat)
/* [is this hp check really needed?] */ /* [is this hp check really needed?] */
&& (Upolyd ? u.mh : u.uhp) > 0) { && (Upolyd ? u.mh : u.uhp) > 0) {
if (mattacku(mtmp)) if (mattacku(mtmp))
@@ -1342,6 +1347,8 @@ m_move(register struct monst* mtmp, register int after)
coord poss[9]; coord poss[9];
cnt = mfndpos(mtmp, poss, info, flag); cnt = mfndpos(mtmp, poss, info, flag);
if (cnt == 0)
return MMOVE_NOMOVES;
chcnt = 0; chcnt = 0;
jcnt = min(MTSZ, cnt - 1); jcnt = min(MTSZ, cnt - 1);
chi = -1; chi = -1;
@@ -1378,7 +1385,7 @@ m_move(register struct monst* mtmp, register int after)
nearer = ((ndist = dist2(nx, ny, gx, gy)) < nidist); nearer = ((ndist = dist2(nx, ny, gx, gy)) < nidist);
if ((appr == 1 && nearer) || (appr == -1 && !nearer) if ((appr == 1 && nearer) || (appr == -1 && !nearer)
|| (!appr && !rn2(++chcnt)) || !mmoved) { || (!appr && !rn2(++chcnt)) || (mmoved == MMOVE_NOTHING)) {
nix = nx; nix = nx;
niy = ny; niy = ny;
nidist = ndist; nidist = ndist;
@@ -1390,7 +1397,7 @@ m_move(register struct monst* mtmp, register int after)
} }
} }
if (mmoved) { if (mmoved != MMOVE_NOTHING) {
if (mmoved == MMOVE_MOVED && (u.ux != nix || u.uy != niy) && itsstuck(mtmp)) if (mmoved == MMOVE_MOVED && (u.ux != nix || u.uy != niy) && itsstuck(mtmp))
return MMOVE_DONE; return MMOVE_DONE;