Make m_move return defines instead of magic numbers

This commit is contained in:
Pasi Kallinen
2022-02-26 17:40:17 +02:00
parent 8c447e6ad5
commit 7523623d95
4 changed files with 94 additions and 76 deletions

View File

@@ -398,6 +398,12 @@ typedef struct sortloot_item Loot;
#define TEST_TRAV 2 /* test a future travel location */ #define TEST_TRAV 2 /* test a future travel location */
#define TEST_TRAP 3 /* check if a future travel loc is a trap */ #define TEST_TRAP 3 /* check if a future travel loc is a trap */
/* m_move return values */
#define MMOVE_NOTHING 0
#define MMOVE_MOVED 1 /* monster moved */
#define MMOVE_DIED 2 /* monster died */
#define MMOVE_DONE 3 /* monster used up all actions */
/*** some utility macros ***/ /*** some utility macros ***/
#define yn(query) yn_function(query, ynchars, 'n') #define yn(query) yn_function(query, ynchars, 'n')
#define ynq(query) yn_function(query, ynqchars, 'q') #define ynq(query) yn_function(query, ynqchars, 'q')

View File

@@ -901,19 +901,19 @@ dog_move(register struct monst *mtmp,
omx = mtmp->mx; omx = mtmp->mx;
omy = mtmp->my; omy = mtmp->my;
if (has_edog && dog_hunger(mtmp, edog)) if (has_edog && dog_hunger(mtmp, edog))
return 2; /* starved */ return MMOVE_DIED; /* starved */
udist = distu(omx, omy); udist = distu(omx, omy);
/* Let steeds eat and maybe throw rider during Conflict */ /* Let steeds eat and maybe throw rider during Conflict */
if (mtmp == u.usteed) { if (mtmp == u.usteed) {
if (Conflict && !resist_conflict(mtmp)) { if (Conflict && !resist_conflict(mtmp)) {
dismount_steed(DISMOUNT_THROWN); dismount_steed(DISMOUNT_THROWN);
return 1; return MMOVE_MOVED;
} }
udist = 1; udist = 1;
} else if (!udist) } else if (!udist)
/* maybe we tamed him while being swallowed --jgm */ /* maybe we tamed him while being swallowed --jgm */
return 0; return MMOVE_NOTHING;
nix = omx; /* set before newdogpos */ nix = omx; /* set before newdogpos */
niy = omy; niy = omy;
@@ -923,7 +923,7 @@ dog_move(register struct monst *mtmp,
if (has_edog) { if (has_edog) {
j = dog_invent(mtmp, edog, udist); j = dog_invent(mtmp, edog, udist);
if (j == 2) if (j == 2)
return 2; /* died */ return MMOVE_DIED; /* died */
else if (j == 1) else if (j == 1)
goto newdogpos; /* eating something */ goto newdogpos; /* eating something */
@@ -934,7 +934,7 @@ dog_move(register struct monst *mtmp,
appr = dog_goal(mtmp, has_edog ? edog : (struct edog *) 0, after, udist, appr = dog_goal(mtmp, has_edog ? edog : (struct edog *) 0, after, udist,
whappr); whappr);
if (appr == -2) if (appr == -2)
return 0; return MMOVE_NOTHING;
if (Conflict && !resist_conflict(mtmp)) { if (Conflict && !resist_conflict(mtmp)) {
if (!has_edog) { if (!has_edog) {
@@ -942,7 +942,7 @@ dog_move(register struct monst *mtmp,
* it disappears, angrily, and sends in some nasties * it disappears, angrily, and sends in some nasties
*/ */
lose_guardian_angel(mtmp); lose_guardian_angel(mtmp);
return 2; /* current monster is gone */ return MMOVE_DIED; /* current monster is gone */
} }
} }
#if 0 /* [this is now handled in dochug()] */ #if 0 /* [this is now handled in dochug()] */
@@ -1018,14 +1018,14 @@ dog_move(register struct monst *mtmp,
continue; continue;
if (after) if (after)
return 0; /* hit only once each move */ return MMOVE_NOTHING; /* hit only once each move */
g.notonhead = 0; g.notonhead = 0;
mstatus = mattackm(mtmp, mtmp2); mstatus = mattackm(mtmp, mtmp2);
/* aggressor (pet) died */ /* aggressor (pet) died */
if (mstatus & MM_AGR_DIED) if (mstatus & MM_AGR_DIED)
return 2; return MMOVE_DIED;
if ((mstatus & MM_HIT) && !(mstatus & MM_DEF_DIED) && rn2(4) if ((mstatus & MM_HIT) && !(mstatus & MM_DEF_DIED) && rn2(4)
&& mtmp2->mlstmv != g.moves && mtmp2->mlstmv != g.moves
@@ -1034,9 +1034,9 @@ dog_move(register struct monst *mtmp,
&& monnear(mtmp2, mtmp->mx, mtmp->my)) { && monnear(mtmp2, mtmp->mx, mtmp->my)) {
mstatus = mattackm(mtmp2, mtmp); /* return attack */ mstatus = mattackm(mtmp2, mtmp); /* return attack */
if (mstatus & MM_DEF_DIED) if (mstatus & MM_DEF_DIED)
return 2; return MMOVE_DIED;
} }
return 3; return MMOVE_DONE;
} }
if ((info[i] & ALLOW_MDISP) && MON_AT(nx, ny) if ((info[i] & ALLOW_MDISP) && MON_AT(nx, ny)
&& better_with_displacing && !undesirable_disp(mtmp, nx, ny)) { && better_with_displacing && !undesirable_disp(mtmp, nx, ny)) {
@@ -1045,8 +1045,8 @@ dog_move(register struct monst *mtmp,
mstatus = mdisplacem(mtmp, mtmp2, FALSE); /* displace monster */ mstatus = mdisplacem(mtmp, mtmp2, FALSE); /* displace monster */
if (mstatus & MM_DEF_DIED) if (mstatus & MM_DEF_DIED)
return 2; return MMOVE_DIED;
return 0; return MMOVE_NOTHING;
} }
{ {
@@ -1152,7 +1152,7 @@ dog_move(register struct monst *mtmp,
if (mtarg == &g.youmonst) { if (mtarg == &g.youmonst) {
if (mattacku(mtmp)) if (mattacku(mtmp))
return 2; return MMOVE_DIED;
/* Treat this as the pet having initiated an attack even if it /* 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, * didn't, so it will lose its move. This isn't entirely fair,
* but mattacku doesn't distinguish between "did not attack" * but mattacku doesn't distinguish between "did not attack"
@@ -1165,7 +1165,7 @@ dog_move(register struct monst *mtmp,
/* Shouldn't happen, really */ /* Shouldn't happen, really */
if (mstatus & MM_AGR_DIED) if (mstatus & MM_AGR_DIED)
return 2; return MMOVE_DIED;
/* Allow the targeted nasty to strike back - if /* Allow the targeted nasty to strike back - if
* the targeted beast doesn't have a ranged attack, * the targeted beast doesn't have a ranged attack,
@@ -1182,7 +1182,7 @@ dog_move(register struct monst *mtmp,
if (mtarg->mcansee && haseyes(mtarg->data)) { if (mtarg->mcansee && haseyes(mtarg->data)) {
mstatus = mattackm(mtarg, mtmp); mstatus = mattackm(mtarg, mtmp);
if (mstatus & MM_DEF_DIED) if (mstatus & MM_DEF_DIED)
return 2; return MMOVE_DIED;
} }
} }
} }
@@ -1197,7 +1197,7 @@ dog_move(register struct monst *mtmp,
* will return MM_MISS. * will return MM_MISS.
*/ */
if (mstatus != MM_MISS) if (mstatus != MM_MISS)
return 3; return MMOVE_DONE;
} }
} }
@@ -1212,12 +1212,12 @@ dog_move(register struct monst *mtmp,
m_unleash(mtmp, FALSE); m_unleash(mtmp, FALSE);
} }
(void) mattacku(mtmp); (void) mattacku(mtmp);
return 3; return MMOVE_DONE;
} }
if (!m_in_out_region(mtmp, nix, niy)) if (!m_in_out_region(mtmp, nix, niy))
return 1; return MMOVE_MOVED;
if (m_digweapon_check(mtmp, nix,niy)) if (m_digweapon_check(mtmp, nix,niy))
return 0; return MMOVE_NOTHING;
/* insert a worm_move() if worms ever begin to eat things */ /* insert a worm_move() if worms ever begin to eat things */
wasseen = canseemon(mtmp); wasseen = canseemon(mtmp);
@@ -1245,7 +1245,7 @@ dog_move(register struct monst *mtmp,
*/ */
if (do_eat) { if (do_eat) {
if (dog_eat(mtmp, obj, omx, omy, FALSE) == 2) if (dog_eat(mtmp, obj, omx, omy, FALSE) == 2)
return 2; return MMOVE_DIED;
} }
} else if (mtmp->mleashed && distu(omx, omy) > 4) { } else if (mtmp->mleashed && distu(omx, omy) > 4) {
/* an incredible kludge, but the only way to keep pooch near /* an incredible kludge, but the only way to keep pooch near
@@ -1275,13 +1275,13 @@ dog_move(register struct monst *mtmp,
cc.y = mtmp->my; cc.y = mtmp->my;
dognext: dognext:
if (!m_in_out_region(mtmp, nix, niy)) if (!m_in_out_region(mtmp, nix, niy))
return 1; return MMOVE_MOVED;
remove_monster(mtmp->mx, mtmp->my); remove_monster(mtmp->mx, mtmp->my);
place_monster(mtmp, cc.x, cc.y); place_monster(mtmp, cc.x, cc.y);
newsym(cc.x, cc.y); newsym(cc.x, cc.y);
set_apparxy(mtmp); set_apparxy(mtmp);
} }
return 1; return MMOVE_MOVED;
} }
/* check if a monster could pick up objects from a location */ /* check if a monster could pick up objects from a location */

View File

@@ -437,7 +437,7 @@ int
dochug(register struct monst* mtmp) dochug(register struct monst* mtmp)
{ {
register struct permonst *mdat; register struct permonst *mdat;
register int tmp = 0; register int tmp = MMOVE_NOTHING;
int inrange, nearby, scared, res; int inrange, nearby, scared, res;
struct obj *otmp; struct obj *otmp;
@@ -688,7 +688,7 @@ dochug(register struct monst* mtmp)
if (a->aatyp == AT_MAGC if (a->aatyp == AT_MAGC
&& (a->adtyp == AD_SPEL || a->adtyp == AD_CLRC)) { && (a->adtyp == AD_SPEL || a->adtyp == AD_CLRC)) {
if (castmu(mtmp, a, FALSE, FALSE)) { if (castmu(mtmp, a, FALSE, FALSE)) {
tmp = 3; /* bypass m_move() */ tmp = MMOVE_DONE; /* bypass m_move() */
break; break;
} }
} }
@@ -697,12 +697,12 @@ dochug(register struct monst* mtmp)
if (!tmp) if (!tmp)
tmp = m_move(mtmp, 0); tmp = m_move(mtmp, 0);
if (tmp != 2) if (tmp != MMOVE_DIED)
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 0: /* no movement, but it can still attack you */ case MMOVE_NOTHING: /* no movement, but it can still attack you */
case 3: /* absolutely no movement */ case MMOVE_DONE: /* absolutely no movement */
/* vault guard might have vanished */ /* vault guard might have vanished */
if (mtmp->isgd && (DEADMONSTER(mtmp) || mtmp->mx == 0)) if (mtmp->isgd && (DEADMONSTER(mtmp) || mtmp->mx == 0))
return 1; /* behave as if it died */ return 1; /* behave as if it died */
@@ -712,7 +712,7 @@ dochug(register struct monst* mtmp)
if (Hallucination) if (Hallucination)
newsym(mtmp->mx, mtmp->my); newsym(mtmp->mx, mtmp->my);
break; break;
case 1: /* monster moved */ case MMOVE_MOVED: /* monster moved */
/* Maybe it stepped on a trap and fell asleep... */ /* Maybe it stepped on a trap and fell asleep... */
if (mtmp->msleeping || !mtmp->mcanmove) if (mtmp->msleeping || !mtmp->mcanmove)
return 0; return 0;
@@ -732,7 +732,7 @@ dochug(register struct monst* mtmp)
unstuck(mtmp); unstuck(mtmp);
} }
return 0; return 0;
case 2: /* monster died */ case MMOVE_DIED: /* monster died */
return 1; return 1;
} }
} }
@@ -740,7 +740,7 @@ dochug(register struct monst* mtmp)
/* Now, attack the player if possible - one attack set per monst /* Now, attack the player if possible - one attack set per monst
*/ */
if (tmp != 3 && (!mtmp->mpeaceful if (tmp != MMOVE_DONE && (!mtmp->mpeaceful
|| (Conflict && !resist_conflict(mtmp)))) { || (Conflict && !resist_conflict(mtmp)))) {
if (inrange && !scared && !noattacks(mdat) if (inrange && !scared && !noattacks(mdat)
/* [is this hp check really needed?] */ /* [is this hp check really needed?] */
@@ -762,7 +762,7 @@ dochug(register struct monst* mtmp)
cuss(mtmp); cuss(mtmp);
/* note: can't get here when tmp==2 so this always returns 0 */ /* note: can't get here when tmp==2 so this always returns 0 */
return (tmp == 2); return (tmp == MMOVE_DIED);
} }
static NEARDATA const char practical[] = { WEAPON_CLASS, ARMOR_CLASS, static NEARDATA const char practical[] = { WEAPON_CLASS, ARMOR_CLASS,
@@ -1015,7 +1015,7 @@ m_move(register struct monst* mtmp, register int after)
boolean sawmon = canspotmon(mtmp); /* before it moved */ boolean sawmon = canspotmon(mtmp); /* before it moved */
struct permonst *ptr; struct permonst *ptr;
struct monst *mtoo; struct monst *mtoo;
schar mmoved = 0; /* not strictly nec.: chi >= 0 will do */ schar mmoved = MMOVE_NOTHING; /* not strictly nec.: chi >= 0 will do */
long info[9]; long info[9];
long flag; long flag;
int omx = mtmp->mx, omy = mtmp->my; int omx = mtmp->mx, omy = mtmp->my;
@@ -1025,10 +1025,10 @@ m_move(register struct monst* mtmp, register int after)
if (i == Trap_Killed_Mon) { if (i == Trap_Killed_Mon) {
newsym(mtmp->mx, mtmp->my); newsym(mtmp->mx, mtmp->my);
return 2; return MMOVE_DIED;
} /* it died */ } /* it died */
if (i == Trap_Caught_Mon) if (i == Trap_Caught_Mon)
return 0; /* still in trap, so didn't move */ return MMOVE_NOTHING; /* still in trap, so didn't move */
} }
ptr = mtmp->data; /* mintrap() can change mtmp->data -dlc */ ptr = mtmp->data; /* mintrap() can change mtmp->data -dlc */
@@ -1036,10 +1036,10 @@ m_move(register struct monst* mtmp, register int after)
mtmp->meating--; mtmp->meating--;
if (mtmp->meating <= 0) if (mtmp->meating <= 0)
finish_meating(mtmp); finish_meating(mtmp);
return 3; /* still eating */ return MMOVE_DONE; /* still eating */
} }
if (hides_under(ptr) && OBJ_AT(mtmp->mx, mtmp->my) && rn2(10)) if (hides_under(ptr) && OBJ_AT(mtmp->mx, mtmp->my) && rn2(10))
return 0; /* do not leave hiding place */ return MMOVE_NOTHING; /* do not leave hiding place */
/* Where does 'mtmp' think you are? Not necessary if m_move() called /* Where does 'mtmp' think you are? Not necessary if m_move() called
from this file, but needed for other calls of m_move(). */ from this file, but needed for other calls of m_move(). */
@@ -1061,22 +1061,30 @@ m_move(register struct monst* mtmp, register int after)
/* likewise for shopkeeper */ /* likewise for shopkeeper */
if (mtmp->isshk) { if (mtmp->isshk) {
mmoved = shk_move(mtmp); int xm = shk_move(mtmp);
if (mmoved == -2) switch (xm) {
return 2; case -2: return MMOVE_DIED;
if (mmoved >= 0) case -1: mmoved = MMOVE_NOTHING; break; /* follow hero outside shop */
case 0: mmoved = MMOVE_NOTHING; goto postmov;
case 1: mmoved = MMOVE_MOVED; goto postmov;
default: impossible("unknown shk_move return value (%i)", xm);
mmoved = MMOVE_NOTHING;
goto postmov; goto postmov;
mmoved = 0; /* follow player outside shop */ }
} }
/* and for the guard */ /* and for the guard */
if (mtmp->isgd) { if (mtmp->isgd) {
mmoved = gd_move(mtmp); int xm = gd_move(mtmp);
if (mmoved == -2) switch (xm) {
return 2; case -2: return MMOVE_DIED;
if (mmoved >= 0) case -1: mmoved = MMOVE_NOTHING; break;
case 0: mmoved = MMOVE_NOTHING; goto postmov;
case 1: mmoved = MMOVE_MOVED; goto postmov;
default: impossible("unknown gd_move return value (%i)", xm);
mmoved = MMOVE_NOTHING;
goto postmov; goto postmov;
mmoved = 0; }
} }
/* and the acquisitive monsters get special treatment */ /* and the acquisitive monsters get special treatment */
@@ -1092,21 +1100,25 @@ m_move(register struct monst* mtmp, register int after)
&& (intruder != mtmp)) { && (intruder != mtmp)) {
g.notonhead = (intruder->mx != tx || intruder->my != ty); g.notonhead = (intruder->mx != tx || intruder->my != ty);
if (mattackm(mtmp, intruder) == 2) if (mattackm(mtmp, intruder) == 2)
return 2; return MMOVE_DIED;
mmoved = 1; mmoved = MMOVE_MOVED;
} else } else
mmoved = 0; mmoved = MMOVE_NOTHING;
goto postmov; goto postmov;
} }
/* and for the priest */ /* and for the priest */
if (mtmp->ispriest) { if (mtmp->ispriest) {
mmoved = pri_move(mtmp); int xm = pri_move(mtmp);
if (mmoved == -2) switch (xm) {
return 2; case -2: return MMOVE_DIED;
if (mmoved >= 0) case -1: mmoved = MMOVE_NOTHING; break;
case 0: mmoved = MMOVE_NOTHING; goto postmov;
case 1: mmoved = MMOVE_MOVED; goto postmov;
default: impossible("unknown pri_move return value (%i)", xm);
mmoved = MMOVE_NOTHING;
goto postmov; goto postmov;
mmoved = 0; }
} }
#ifdef MAIL_STRUCTURES #ifdef MAIL_STRUCTURES
@@ -1114,7 +1126,7 @@ m_move(register struct monst* mtmp, register int after)
if (!Deaf && canseemon(mtmp)) if (!Deaf && canseemon(mtmp))
verbalize("I'm late!"); verbalize("I'm late!");
mongone(mtmp); mongone(mtmp);
return 2; return MMOVE_DIED;
} }
#endif #endif
@@ -1125,12 +1137,12 @@ m_move(register struct monst* mtmp, register int after)
(void) rloc(mtmp, RLOC_MSG); (void) rloc(mtmp, RLOC_MSG);
else else
mnexto(mtmp, RLOC_MSG); mnexto(mtmp, RLOC_MSG);
mmoved = 1; mmoved = MMOVE_MOVED;
goto postmov; goto postmov;
} }
not_special: not_special:
if (u.uswallow && !mtmp->mflee && u.ustuck != mtmp) if (u.uswallow && !mtmp->mflee && u.ustuck != mtmp)
return 1; return MMOVE_MOVED;
omx = mtmp->mx; omx = mtmp->mx;
omy = mtmp->my; omy = mtmp->my;
gx = mtmp->mux; gx = mtmp->mux;
@@ -1284,7 +1296,7 @@ m_move(register struct monst* mtmp, register int after)
gx = otmp->ox; gx = otmp->ox;
gy = otmp->oy; gy = otmp->oy;
if (gx == omx && gy == omy) { if (gx == omx && gy == omy) {
mmoved = 3; /* actually unnecessary */ mmoved = MMOVE_DONE; /* actually unnecessary */
goto postmov; goto postmov;
} }
} }
@@ -1365,7 +1377,7 @@ m_move(register struct monst* mtmp, register int after)
niy = ny; niy = ny;
nidist = ndist; nidist = ndist;
chi = i; chi = i;
mmoved = 1; mmoved = MMOVE_MOVED;
} }
nxti: nxti:
; ;
@@ -1375,11 +1387,11 @@ m_move(register struct monst* mtmp, register int after)
if (mmoved) { if (mmoved) {
register int j; register int j;
if (mmoved == 1 && (u.ux != nix || u.uy != niy) && itsstuck(mtmp)) if (mmoved == MMOVE_MOVED && (u.ux != nix || u.uy != niy) && itsstuck(mtmp))
return 3; return MMOVE_DONE;
if (mmoved == 1 && m_digweapon_check(mtmp, nix,niy)) if (mmoved == MMOVE_MOVED && m_digweapon_check(mtmp, nix,niy))
return 3; return MMOVE_DONE;
/* If ALLOW_U is set, either it's trying to attack you, or it /* If ALLOW_U is set, either it's trying to attack you, or it
* thinks it is. In either case, attack this spot in preference to * thinks it is. In either case, attack this spot in preference to
@@ -1400,7 +1412,7 @@ m_move(register struct monst* mtmp, register int after)
if (u_at(nix, niy)) { if (u_at(nix, niy)) {
mtmp->mux = u.ux; mtmp->mux = u.ux;
mtmp->muy = u.uy; mtmp->muy = u.uy;
return 0; return MMOVE_NOTHING;
} }
/* The monster may attack another based on 1 of 2 conditions: /* The monster may attack another based on 1 of 2 conditions:
* 1 - It may be confused. * 1 - It may be confused.
@@ -1418,14 +1430,14 @@ m_move(register struct monst* mtmp, register int after)
mtmp2 = m_at(nix, niy); mtmp2 = m_at(nix, niy);
mstatus = mdisplacem(mtmp, mtmp2, FALSE); mstatus = mdisplacem(mtmp, mtmp2, FALSE);
if ((mstatus & MM_AGR_DIED) || (mstatus & MM_DEF_DIED)) if ((mstatus & MM_AGR_DIED) || (mstatus & MM_DEF_DIED))
return 2; return MMOVE_DIED;
if (mstatus & MM_HIT) if (mstatus & MM_HIT)
return 1; return MMOVE_MOVED;
return 3; return MMOVE_DONE;
} }
if (!m_in_out_region(mtmp, nix, niy)) if (!m_in_out_region(mtmp, nix, niy))
return 3; return MMOVE_DONE;
/* move a normal monster; for a long worm, remove_monster() and /* move a normal monster; for a long worm, remove_monster() and
place_monster() only manipulate the head; they leave tail as-is */ place_monster() only manipulate the head; they leave tail as-is */
@@ -1444,7 +1456,7 @@ m_move(register struct monst* mtmp, register int after)
} else { } else {
if (is_unicorn(ptr) && rn2(2) && !tele_restrict(mtmp)) { if (is_unicorn(ptr) && rn2(2) && !tele_restrict(mtmp)) {
(void) rloc(mtmp, RLOC_MSG); (void) rloc(mtmp, RLOC_MSG);
return 1; return MMOVE_MOVED;
} }
/* for a long worm, shrink it (by discarding end of tail) when /* for a long worm, shrink it (by discarding end of tail) when
it has failed to move */ it has failed to move */
@@ -1452,11 +1464,11 @@ m_move(register struct monst* mtmp, register int after)
worm_nomove(mtmp); worm_nomove(mtmp);
} }
postmov: postmov:
if (mmoved == 1 || mmoved == 3) { if (mmoved == MMOVE_MOVED || mmoved == MMOVE_DONE) {
boolean canseeit = cansee(mtmp->mx, mtmp->my), boolean canseeit = cansee(mtmp->mx, mtmp->my),
didseeit = canseeit; didseeit = canseeit;
if (mmoved == 1) { if (mmoved == MMOVE_MOVED) {
/* normal monster move will already have <nix,niy>, /* normal monster move will already have <nix,niy>,
but pet dog_move() with 'goto postmov' won't */ but pet dog_move() with 'goto postmov' won't */
nix = mtmp->mx, niy = mtmp->my; nix = mtmp->mx, niy = mtmp->my;
@@ -1680,7 +1692,7 @@ m_move(register struct monst* mtmp, register int after)
if (uses_items) if (uses_items)
picked |= mpickstuff(mtmp, (char *) 0); picked |= mpickstuff(mtmp, (char *) 0);
if (picked) if (picked)
mmoved = 3; mmoved = MMOVE_DONE;
} }
if (mtmp->minvis) { if (mtmp->minvis) {
@@ -1731,7 +1743,7 @@ m_move_aggress(struct monst* mtmp, xchar x, xchar y)
mstatus = mattackm(mtmp, mtmp2); mstatus = mattackm(mtmp, mtmp2);
if (mstatus & MM_AGR_DIED) /* aggressor died */ if (mstatus & MM_AGR_DIED) /* aggressor died */
return 2; return MMOVE_DIED;
if ((mstatus & MM_HIT) && !(mstatus & MM_DEF_DIED) && rn2(4) if ((mstatus & MM_HIT) && !(mstatus & MM_DEF_DIED) && rn2(4)
&& mtmp2->movement >= NORMAL_SPEED) { && mtmp2->movement >= NORMAL_SPEED) {
@@ -1739,9 +1751,9 @@ m_move_aggress(struct monst* mtmp, xchar x, xchar y)
g.notonhead = 0; g.notonhead = 0;
mstatus = mattackm(mtmp2, mtmp); /* return attack */ mstatus = mattackm(mtmp2, mtmp); /* return attack */
if (mstatus & MM_DEF_DIED) if (mstatus & MM_DEF_DIED)
return 2; return MMOVE_DIED;
} }
return 3; return MMOVE_DONE;
} }
void void

View File

@@ -487,7 +487,7 @@ do_attack(struct monst *mtmp)
/* Is the "it died" check actually correct? */ /* Is the "it died" check actually correct? */
if (mdat->mlet == S_LEPRECHAUN && !mtmp->mfrozen && !mtmp->msleeping if (mdat->mlet == S_LEPRECHAUN && !mtmp->mfrozen && !mtmp->msleeping
&& !mtmp->mconf && mtmp->mcansee && !rn2(7) && !mtmp->mconf && mtmp->mcansee && !rn2(7)
&& (m_move(mtmp, 0) == 2 /* it died */ && (m_move(mtmp, 0) == MMOVE_DIED /* it died */
|| mtmp->mx != u.ux + u.dx || mtmp->mx != u.ux + u.dx
|| mtmp->my != u.uy + u.dy)) { /* it moved */ || mtmp->my != u.uy + u.dy)) { /* it moved */
You("miss wildly and stumble forwards."); You("miss wildly and stumble forwards.");