omx = mtmp->mx;
omy = mtmp->my;
if (has_edog && dog_hunger(mtmp, edog))
- return 2; /* starved */
+ return MMOVE_DIED; /* starved */
udist = distu(omx, omy);
/* Let steeds eat and maybe throw rider during Conflict */
if (mtmp == u.usteed) {
if (Conflict && !resist_conflict(mtmp)) {
dismount_steed(DISMOUNT_THROWN);
- return 1;
+ return MMOVE_MOVED;
}
udist = 1;
} else if (!udist)
/* maybe we tamed him while being swallowed --jgm */
- return 0;
+ return MMOVE_NOTHING;
nix = omx; /* set before newdogpos */
niy = omy;
if (has_edog) {
j = dog_invent(mtmp, edog, udist);
if (j == 2)
- return 2; /* died */
+ return MMOVE_DIED; /* died */
else if (j == 1)
goto newdogpos; /* eating something */
appr = dog_goal(mtmp, has_edog ? edog : (struct edog *) 0, after, udist,
whappr);
if (appr == -2)
- return 0;
+ return MMOVE_NOTHING;
if (Conflict && !resist_conflict(mtmp)) {
if (!has_edog) {
* it disappears, angrily, and sends in some nasties
*/
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()] */
continue;
if (after)
- return 0; /* hit only once each move */
+ return MMOVE_NOTHING; /* hit only once each move */
g.notonhead = 0;
mstatus = mattackm(mtmp, mtmp2);
/* aggressor (pet) died */
if (mstatus & MM_AGR_DIED)
- return 2;
+ return MMOVE_DIED;
if ((mstatus & MM_HIT) && !(mstatus & MM_DEF_DIED) && rn2(4)
&& mtmp2->mlstmv != g.moves
&& monnear(mtmp2, mtmp->mx, mtmp->my)) {
mstatus = mattackm(mtmp2, mtmp); /* return attack */
if (mstatus & MM_DEF_DIED)
- return 2;
+ return MMOVE_DIED;
}
- return 3;
+ return MMOVE_DONE;
}
if ((info[i] & ALLOW_MDISP) && MON_AT(nx, ny)
&& better_with_displacing && !undesirable_disp(mtmp, nx, ny)) {
mstatus = mdisplacem(mtmp, mtmp2, FALSE); /* displace monster */
if (mstatus & MM_DEF_DIED)
- return 2;
- return 0;
+ return MMOVE_DIED;
+ return MMOVE_NOTHING;
}
{
if (mtarg == &g.youmonst) {
if (mattacku(mtmp))
- return 2;
+ return MMOVE_DIED;
/* 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,
* but mattacku doesn't distinguish between "did not attack"
/* Shouldn't happen, really */
if (mstatus & MM_AGR_DIED)
- return 2;
+ return MMOVE_DIED;
/* Allow the targeted nasty to strike back - if
* the targeted beast doesn't have a ranged attack,
if (mtarg->mcansee && haseyes(mtarg->data)) {
mstatus = mattackm(mtarg, mtmp);
if (mstatus & MM_DEF_DIED)
- return 2;
+ return MMOVE_DIED;
}
}
}
* will return MM_MISS.
*/
if (mstatus != MM_MISS)
- return 3;
+ return MMOVE_DONE;
}
}
m_unleash(mtmp, FALSE);
}
(void) mattacku(mtmp);
- return 3;
+ return MMOVE_DONE;
}
if (!m_in_out_region(mtmp, nix, niy))
- return 1;
+ return MMOVE_MOVED;
if (m_digweapon_check(mtmp, nix,niy))
- return 0;
+ return MMOVE_NOTHING;
/* insert a worm_move() if worms ever begin to eat things */
wasseen = canseemon(mtmp);
*/
if (do_eat) {
if (dog_eat(mtmp, obj, omx, omy, FALSE) == 2)
- return 2;
+ return MMOVE_DIED;
}
} else if (mtmp->mleashed && distu(omx, omy) > 4) {
/* an incredible kludge, but the only way to keep pooch near
cc.y = mtmp->my;
dognext:
if (!m_in_out_region(mtmp, nix, niy))
- return 1;
+ return MMOVE_MOVED;
remove_monster(mtmp->mx, mtmp->my);
place_monster(mtmp, cc.x, cc.y);
newsym(cc.x, cc.y);
set_apparxy(mtmp);
}
- return 1;
+ return MMOVE_MOVED;
}
/* check if a monster could pick up objects from a location */
dochug(register struct monst* mtmp)
{
register struct permonst *mdat;
- register int tmp = 0;
+ register int tmp = MMOVE_NOTHING;
int inrange, nearby, scared, res;
struct obj *otmp;
if (a->aatyp == AT_MAGC
&& (a->adtyp == AD_SPEL || a->adtyp == AD_CLRC)) {
if (castmu(mtmp, a, FALSE, FALSE)) {
- tmp = 3; /* bypass m_move() */
+ tmp = MMOVE_DONE; /* bypass m_move() */
break;
}
}
if (!tmp)
tmp = m_move(mtmp, 0);
- if (tmp != 2)
+ if (tmp != MMOVE_DIED)
distfleeck(mtmp, &inrange, &nearby, &scared); /* recalc */
switch (tmp) { /* for pets, cases 0 and 3 are equivalent */
- case 0: /* no movement, but it can still attack you */
- case 3: /* absolutely no movement */
+ case MMOVE_NOTHING: /* no movement, but it can still attack you */
+ case MMOVE_DONE: /* absolutely no movement */
/* vault guard might have vanished */
if (mtmp->isgd && (DEADMONSTER(mtmp) || mtmp->mx == 0))
return 1; /* behave as if it died */
if (Hallucination)
newsym(mtmp->mx, mtmp->my);
break;
- case 1: /* monster moved */
+ case MMOVE_MOVED: /* monster moved */
/* Maybe it stepped on a trap and fell asleep... */
if (mtmp->msleeping || !mtmp->mcanmove)
return 0;
unstuck(mtmp);
}
return 0;
- case 2: /* monster died */
+ case MMOVE_DIED: /* monster died */
return 1;
}
}
/* 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)))) {
if (inrange && !scared && !noattacks(mdat)
/* [is this hp check really needed?] */
cuss(mtmp);
/* 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,
boolean sawmon = canspotmon(mtmp); /* before it moved */
struct permonst *ptr;
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 flag;
int omx = mtmp->mx, omy = mtmp->my;
if (i == Trap_Killed_Mon) {
newsym(mtmp->mx, mtmp->my);
- return 2;
+ return MMOVE_DIED;
} /* it died */
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 */
mtmp->meating--;
if (mtmp->meating <= 0)
finish_meating(mtmp);
- return 3; /* still eating */
+ return MMOVE_DONE; /* still eating */
}
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
from this file, but needed for other calls of m_move(). */
/* likewise for shopkeeper */
if (mtmp->isshk) {
- mmoved = shk_move(mtmp);
- if (mmoved == -2)
- return 2;
- if (mmoved >= 0)
+ int xm = shk_move(mtmp);
+ switch (xm) {
+ case -2: return MMOVE_DIED;
+ 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;
- mmoved = 0; /* follow player outside shop */
+ }
}
/* and for the guard */
if (mtmp->isgd) {
- mmoved = gd_move(mtmp);
- if (mmoved == -2)
- return 2;
- if (mmoved >= 0)
+ int xm = gd_move(mtmp);
+ switch (xm) {
+ case -2: return MMOVE_DIED;
+ 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;
- mmoved = 0;
+ }
}
/* and the acquisitive monsters get special treatment */
&& (intruder != mtmp)) {
g.notonhead = (intruder->mx != tx || intruder->my != ty);
if (mattackm(mtmp, intruder) == 2)
- return 2;
- mmoved = 1;
+ return MMOVE_DIED;
+ mmoved = MMOVE_MOVED;
} else
- mmoved = 0;
+ mmoved = MMOVE_NOTHING;
goto postmov;
}
/* and for the priest */
if (mtmp->ispriest) {
- mmoved = pri_move(mtmp);
- if (mmoved == -2)
- return 2;
- if (mmoved >= 0)
+ int xm = pri_move(mtmp);
+ switch (xm) {
+ case -2: return MMOVE_DIED;
+ 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;
- mmoved = 0;
+ }
}
#ifdef MAIL_STRUCTURES
if (!Deaf && canseemon(mtmp))
verbalize("I'm late!");
mongone(mtmp);
- return 2;
+ return MMOVE_DIED;
}
#endif
(void) rloc(mtmp, RLOC_MSG);
else
mnexto(mtmp, RLOC_MSG);
- mmoved = 1;
+ mmoved = MMOVE_MOVED;
goto postmov;
}
not_special:
if (u.uswallow && !mtmp->mflee && u.ustuck != mtmp)
- return 1;
+ return MMOVE_MOVED;
omx = mtmp->mx;
omy = mtmp->my;
gx = mtmp->mux;
gx = otmp->ox;
gy = otmp->oy;
if (gx == omx && gy == omy) {
- mmoved = 3; /* actually unnecessary */
+ mmoved = MMOVE_DONE; /* actually unnecessary */
goto postmov;
}
}
niy = ny;
nidist = ndist;
chi = i;
- mmoved = 1;
+ mmoved = MMOVE_MOVED;
}
nxti:
;
if (mmoved) {
register int j;
- if (mmoved == 1 && (u.ux != nix || u.uy != niy) && itsstuck(mtmp))
- return 3;
+ if (mmoved == MMOVE_MOVED && (u.ux != nix || u.uy != niy) && itsstuck(mtmp))
+ return MMOVE_DONE;
- if (mmoved == 1 && m_digweapon_check(mtmp, nix,niy))
- return 3;
+ if (mmoved == MMOVE_MOVED && m_digweapon_check(mtmp, nix,niy))
+ return MMOVE_DONE;
/* 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
if (u_at(nix, niy)) {
mtmp->mux = u.ux;
mtmp->muy = u.uy;
- return 0;
+ return MMOVE_NOTHING;
}
/* The monster may attack another based on 1 of 2 conditions:
* 1 - It may be confused.
mtmp2 = m_at(nix, niy);
mstatus = mdisplacem(mtmp, mtmp2, FALSE);
if ((mstatus & MM_AGR_DIED) || (mstatus & MM_DEF_DIED))
- return 2;
+ return MMOVE_DIED;
if (mstatus & MM_HIT)
- return 1;
- return 3;
+ return MMOVE_MOVED;
+ return MMOVE_DONE;
}
if (!m_in_out_region(mtmp, nix, niy))
- return 3;
+ return MMOVE_DONE;
/* move a normal monster; for a long worm, remove_monster() and
place_monster() only manipulate the head; they leave tail as-is */
} else {
if (is_unicorn(ptr) && rn2(2) && !tele_restrict(mtmp)) {
(void) rloc(mtmp, RLOC_MSG);
- return 1;
+ return MMOVE_MOVED;
}
/* for a long worm, shrink it (by discarding end of tail) when
it has failed to move */
worm_nomove(mtmp);
}
postmov:
- if (mmoved == 1 || mmoved == 3) {
+ if (mmoved == MMOVE_MOVED || mmoved == MMOVE_DONE) {
boolean canseeit = cansee(mtmp->mx, mtmp->my),
didseeit = canseeit;
- if (mmoved == 1) {
+ if (mmoved == MMOVE_MOVED) {
/* normal monster move will already have <nix,niy>,
but pet dog_move() with 'goto postmov' won't */
nix = mtmp->mx, niy = mtmp->my;
if (uses_items)
picked |= mpickstuff(mtmp, (char *) 0);
if (picked)
- mmoved = 3;
+ mmoved = MMOVE_DONE;
}
if (mtmp->minvis) {
mstatus = mattackm(mtmp, mtmp2);
if (mstatus & MM_AGR_DIED) /* aggressor died */
- return 2;
+ return MMOVE_DIED;
if ((mstatus & MM_HIT) && !(mstatus & MM_DEF_DIED) && rn2(4)
&& mtmp2->movement >= NORMAL_SPEED) {
g.notonhead = 0;
mstatus = mattackm(mtmp2, mtmp); /* return attack */
if (mstatus & MM_DEF_DIED)
- return 2;
+ return MMOVE_DIED;
}
- return 3;
+ return MMOVE_DONE;
}
void