]> granicus.if.org Git - nethack/commitdiff
Add helpless monster macro
authorPasi Kallinen <paxed@alt.org>
Fri, 18 Mar 2022 08:19:04 +0000 (10:19 +0200)
committerPasi Kallinen <paxed@alt.org>
Fri, 18 Mar 2022 08:19:04 +0000 (10:19 +0200)
21 files changed:
include/monst.h
src/dbridge.c
src/detect.c
src/do_name.c
src/dog.c
src/dogmove.c
src/dothrow.c
src/hack.c
src/mhitm.c
src/monmove.c
src/muse.c
src/polyself.c
src/priest.c
src/quest.c
src/shk.c
src/sounds.c
src/steed.c
src/trap.c
src/uhitm.c
src/were.c
src/wizard.c

index 535b0ffbd3da4e80b78e2b8bcfd72aafb0ea2fff..4dc0ccd1fa7c84fa10a19c20f2aaee4652422a54 100644 (file)
@@ -234,6 +234,7 @@ struct monst {
     ((m)->data->mlet == S_TROLL && (o) && (o)->oartifact == ART_TROLLSBANE)
 
 #define engulfing_u(mon) (u.uswallow && (u.ustuck == (mon)))
+#define helpless(mon) ((mon)->msleeping || !(mon)->mcanmove)
 
 /* Get the maximum difficulty monsters that can currently be generated,
    given the current level difficulty and the hero's level. */
index 4f9a32d16bdcb37b52a774c4e5634b81e2fdcad1..b75cd16c656e3a2fba840e4885f49905f3dd0c28 100644 (file)
@@ -477,7 +477,7 @@ e_missed(struct entity *etmp, boolean chunks)
 
     if (is_flyer(etmp->edata)
         && (is_u(etmp) ? !Unaware
-                       : (etmp->emon->mcanmove && !etmp->emon->msleeping)))
+                       : !helpless(etmp->emon)))
         /* flying requires mobility */
         misses = 5; /* out of 8 */
     else if (is_floater(etmp->edata)
@@ -505,7 +505,7 @@ e_jumps(struct entity *etmp)
     int tmp = 4; /* out of 10 */
 
     if (is_u(etmp) ? (Unaware || Fumbling)
-                   : (!etmp->emon->mcanmove || etmp->emon->msleeping
+                   : (helpless(etmp->emon)
                       || !etmp->edata->mmove || etmp->emon->wormno))
         return FALSE;
 
index 24f6572ddfe6233a128dd62625e73ef9be313b2c..50b2c4dc0218b37cb96e915c7becbc932b5ef66f 100644 (file)
@@ -800,8 +800,7 @@ monster_detect(struct obj *otmp, /* detecting object (if any) */
                     && mclass == S_WORM_TAIL))
                 map_monst(mtmp, TRUE);
 
-            if (otmp && otmp->cursed
-                && (mtmp->msleeping || !mtmp->mcanmove)) {
+            if (otmp && otmp->cursed && helpless(mtmp)) {
                 mtmp->msleeping = mtmp->mfrozen = 0;
                 mtmp->mcanmove = 1;
                 woken = TRUE;
index cb6c7e49f549b686a1fe1d358f1f60b2dd9246f1..6409fe60cdda2dd32c960531d3bc4fe65121c8fb 100644 (file)
@@ -1213,7 +1213,7 @@ do_mgivenname(void)
         if (!alreadynamed(mtmp, monnambuf, buf))
             pline("%s doesn't like being called names!", upstart(monnambuf));
     } else if (mtmp->isshk
-               && !(Deaf || mtmp->msleeping || !mtmp->mcanmove
+               && !(Deaf || helpless(mtmp)
                     || mtmp->data->msound <= MS_ANIMAL)) {
         if (!alreadynamed(mtmp, monnambuf, buf))
             verbalize("I'm %s, not %s.", shkname(mtmp), buf);
index a032812e1fbad6def3ddf64bd89b2645fb5ac3c5..34f137818d6a8f8b55acc98158e12c41185709ce 100644 (file)
--- a/src/dog.c
+++ b/src/dog.c
@@ -608,7 +608,7 @@ keepdogs(boolean pets_only) /* true for ascension or final escape */
                 the amulet; if you don't have it, will chase you
                 only if in range. -3. */
              || (u.uhave.amulet && mtmp->iswiz))
-            && ((!mtmp->msleeping && mtmp->mcanmove)
+            && (!helpless(mtmp)
                 /* eg if level teleport or new trap, steed has no control
                    to avoid following */
                 || (mtmp == u.usteed))
index 39da00b38b58333c1324349e27e53627501a076d..4a783c95e8a668b9a9b8a721d50c3436e57f1796 100644 (file)
@@ -426,7 +426,7 @@ dog_invent(struct monst *mtmp, struct edog *edog, int udist)
     int omx, omy, carryamt = 0;
     struct obj *obj, *otmp;
 
-    if (mtmp->msleeping || !mtmp->mcanmove)
+    if (helpless(mtmp))
         return 0;
 
     omx = mtmp->mx;
index 1eb4c5cf3ab366b83f6475bd2620f102b5f11698..b8c2d2cf662644ede8a655020418199d56e8fa34 100644 (file)
@@ -1848,7 +1848,7 @@ thitmonst(
        and also treat gems or glass shot via sling as attacks */
     if (obj->oclass == GEM_CLASS && is_unicorn(mon->data)
         && objects[obj->otyp].oc_material != MINERAL && !uslinging()) {
-        if (mon->msleeping || !mon->mcanmove) {
+        if (helpless(mon)) {
             tmiss(obj, mon, FALSE);
             return 0;
         } else if (mon->mtame) {
index 68650075e1853b1927ce213047a4aab4948fbc4f..1a875993c7096cedb4377d6a7eba884928414296 100644 (file)
@@ -1655,7 +1655,7 @@ domove_attackmon_at(struct monst *mtmp, xchar x, xchar y, boolean *displaceu)
         /* target monster might decide to switch places with you... */
         *displaceu = (mtmp->data == &mons[PM_DISPLACER_BEAST] && !rn2(2)
                       && mtmp->mux == u.ux0 && mtmp->muy == u.uy0
-                      && mtmp->mcanmove && !mtmp->msleeping
+                      && !helpless(mtmp)
                       && !mtmp->meating && !mtmp->mtrapped
                       && !u.utrap && !u.ustuck && !u.usteed
                       && !(u.dx && u.dy
@@ -3410,7 +3410,7 @@ monster_nearby(void)
                 && (Hallucination
                     || (!mtmp->mpeaceful && !noattacks(mtmp->data)))
                 && (!is_hider(mtmp->data) || !mtmp->mundetected)
-                && mtmp->mcanmove && !mtmp->msleeping
+                && !helpless(mtmp)
                 && !onscary(u.ux, u.uy, mtmp) && canspotmon(mtmp))
                 return 1;
         }
index 4d7c4957d72c616be79fc85ad2d4d2d1636654b0..318aa75faba945bb05b2345f4a6515dcb3ac3d57 100644 (file)
@@ -301,7 +301,7 @@ mattackm(register struct monst *magr, register struct monst *mdef)
 
     if (!magr || !mdef)
         return MM_MISS; /* mike@genat */
-    if (!magr->mcanmove || magr->msleeping)
+    if (helpless(magr))
         return MM_MISS;
     pa = magr->data;
     pd = mdef->data;
@@ -313,7 +313,7 @@ mattackm(register struct monst *magr, register struct monst *mdef)
 
     /* Calculate the armour class differential. */
     tmp = find_mac(mdef) + magr->m_lev;
-    if (mdef->mconf || !mdef->mcanmove || mdef->msleeping) {
+    if (mdef->mconf || helpless(mdef)) {
         tmp += 4;
         mdef->msleeping = 0;
     }
@@ -540,7 +540,7 @@ mattackm(register struct monst *magr, register struct monst *mdef)
         if (res[i] & MM_AGR_DIED)
             return res[i];
         /* return if aggressor can no longer attack */
-        if (!magr->mcanmove || magr->msleeping)
+        if (helpless(magr))
             return res[i];
         if (res[i] & MM_HIT)
             struck = 1; /* at least one hit */
@@ -1091,7 +1091,7 @@ sleep_monst(struct monst *mon, int amt, int how)
 void
 slept_monst(struct monst *mon)
 {
-    if ((mon->msleeping || !mon->mcanmove) && mon == u.ustuck
+    if (helpless(mon) && mon == u.ustuck
         && !sticks(g.youmonst.data) && !u.uswallow) {
         pline("%s grip relaxes.", s_suffix(Monnam(mon)));
         unstuck(mon);
index 4aa66a264c740199079367aad41807a9293d8a93..9ae4f15b3a162ebabdbace646bcbdd47bce55ad1 100644 (file)
@@ -714,7 +714,7 @@ dochug(register struct monst* mtmp)
             break;
         case MMOVE_MOVED: /* monster moved */
             /* Maybe it stepped on a trap and fell asleep... */
-            if (mtmp->msleeping || !mtmp->mcanmove)
+            if (helpless(mtmp))
                 return 0;
             /* Monsters can move and then shoot on same turn;
                our hero can't.  Is that fair? */
@@ -754,7 +754,7 @@ dochug(register struct monst* mtmp)
         }
     }
     /* special speeches for quest monsters */
-    if (!mtmp->msleeping && mtmp->mcanmove && nearby)
+    if (!helpless(mtmp) && nearby)
         quest_talk(mtmp);
     /* extra emotional attack for vile monsters */
     if (inrange && mtmp->data->msound == MS_CUSS && !mtmp->mpeaceful
@@ -970,7 +970,7 @@ static void
 maybe_spin_web(struct monst *mtmp)
 {
     if (webmaker(mtmp->data)
-        && mtmp->mcanmove && !mtmp->msleeping && !mtmp->mspec_used
+        && !helpless(mtmp) && !mtmp->mspec_used
         && !t_at(mtmp->mx, mtmp->my) && soko_allow_web(mtmp)) {
         struct trap *trap;
         int prob = ((((mtmp->data == &mons[PM_GIANT_SPIDER]) ? 15 : 5)
@@ -1226,7 +1226,7 @@ m_move(register struct monst* mtmp, register int after)
                        underneath an immobile or hidden monster;
                        paralysis victims excluded */
                     if ((mtoo = m_at(xx, yy)) != 0
-                        && (mtoo->msleeping || mtoo->mundetected
+                        && (helpless(mtoo) || mtoo->mundetected
                             || (mtoo->mappearance && !mtoo->iswiz)
                             || !mtoo->data->mmove))
                         continue;
@@ -1686,7 +1686,7 @@ m_move(register struct monst* mtmp, register int after)
                (just in case the object it was hiding under went away);
                usually set mundetected unless monster can't move.  */
             if (mtmp->mundetected
-                || (mtmp->mcanmove && !mtmp->msleeping && rn2(5)))
+                || (!helpless(mtmp) && rn2(5)))
                 (void) hideunder(mtmp);
             newsym(mtmp->mx, mtmp->my);
         }
index 6b2dc09f73ae8e10335473c5c46ccc359b044c9b..ba70c5bac1cbf633b277e7d9e20c03355707b094 100644 (file)
@@ -527,7 +527,7 @@ find_defensive(struct monst* mtmp)
                     continue;
                 if ((mon = m_at(xx, yy)) != 0 && is_mercenary(mon->data)
                     && mon->data != &mons[PM_GUARD]
-                    && (mon->msleeping || !mon->mcanmove)) {
+                    && helpless(mon)) {
                     g.m.defensive = obj;
                     g.m.has_defense = MUSE_BUGLE;
                     goto toot; /* double break */
@@ -2521,7 +2521,7 @@ munstone(struct monst* mon, boolean by_you)
 
     if (resists_ston(mon))
         return FALSE;
-    if (mon->meating || !mon->mcanmove || mon->msleeping)
+    if (mon->meating || helpless(mon))
         return FALSE;
     mon->mstrategy &= ~STRAT_WAITFORU;
 
@@ -2675,7 +2675,7 @@ munslime(struct monst* mon, boolean by_you)
 
     if (slimeproof(mptr))
         return FALSE;
-    if (mon->meating || !mon->mcanmove || mon->msleeping)
+    if (mon->meating || helpless(mon))
         return FALSE;
     mon->mstrategy &= ~STRAT_WAITFORU;
 
index 4d10f4e1c81441921955ed5ff629473929ac79cb..222613843f21be477c52f91b2379ce22586d60d7 100644 (file)
@@ -1490,7 +1490,7 @@ dogaze(void)
                         continue;
                 }
                 setmangry(mtmp, TRUE);
-                if (!mtmp->mcanmove || mtmp->mstun || mtmp->msleeping
+                if (helpless(mtmp) || mtmp->mstun
                     || !mtmp->mcansee || !haseyes(mtmp->data)) {
                     looked--;
                     continue;
index 91675a57f80aa59a19b5324b545f3ce797716a12..ce5d45405af74b711c97659b1c1bf4626038a1d7 100644 (file)
@@ -428,7 +428,7 @@ intemple(int roomno)
         shrined = has_shrine(priest);
         sanctum = (priest->data == &mons[PM_HIGH_CLERIC]
                    && (Is_sanctum(&u.uz) || In_endgame(&u.uz)));
-        can_speak = (priest->mcanmove && !priest->msleeping);
+        can_speak = !helpless(priest);
         if (can_speak && !Deaf && g.moves >= epri_p->intone_time) {
             unsigned save_priest = priest->ispriest;
 
@@ -572,15 +572,14 @@ priest_talk(struct monst *priest)
     }
 
     /* priests don't chat unless peaceful and in their own temple */
-    if (!inhistemple(priest) || !priest->mpeaceful
-        || !priest->mcanmove || priest->msleeping) {
+    if (!inhistemple(priest) || !priest->mpeaceful || helpless(priest)) {
         static const char *const cranky_msg[3] = {
             "Thou wouldst have words, eh?  I'll give thee a word or two!",
             "Talk?  Here is what I have to say!",
             "Pilgrim, I would speak no longer with thee."
         };
 
-        if (!priest->mcanmove || priest->msleeping) {
+        if (helpless(priest)) {
             pline("%s breaks out of %s reverie!", Monnam(priest),
                   mhis(priest));
             priest->mfrozen = priest->msleeping = 0;
index 23d7037acdb2dea0bc1994a5ff3849f0513822a0..306b7a56b2dd99fef286f582602d19e7fb93d11b 100644 (file)
@@ -453,7 +453,7 @@ void
 quest_stat_check(struct monst *mtmp)
 {
     if (mtmp->data->msound == MS_NEMESIS)
-        Qstat(in_battle) = (mtmp->mcanmove && !mtmp->msleeping
+        Qstat(in_battle) = (!helpless(mtmp)
                             && monnear(mtmp, u.ux, u.uy));
 }
 
index 883c71a0b8ee9433747312a3ff422c692c8acc6e..8aceca533976d373f385cd1893123c0318647571 100644 (file)
--- a/src/shk.c
+++ b/src/shk.c
@@ -20,7 +20,7 @@ static void kops_gone(boolean);
 #define IS_SHOP(x) (g.rooms[x].rtype >= SHOPBASE)
 
 #define muteshk(shkp)                       \
-    ((shkp)->msleeping || !(shkp)->mcanmove \
+    (helpless(shkp) \
      || (shkp)->data->msound <= MS_ANIMAL)
 
 extern const struct shclass shtypes[]; /* defined in shknam.c */
@@ -1108,7 +1108,7 @@ rile_shk(register struct monst* shkp)
 static void
 rouse_shk(struct monst* shkp, boolean verbosely)
 {
-    if (!shkp->mcanmove || shkp->msleeping) {
+    if (helpless(shkp)) {
         /* greed induced recovery... */
         if (verbosely && canspotmon(shkp))
             pline("%s %s.", Shknam(shkp),
@@ -1340,7 +1340,7 @@ dopay(void)
     if (ltmp || eshkp->billct || eshkp->debit)
         rouse_shk(shkp, TRUE);
 
-    if (!shkp->mcanmove || shkp->msleeping) { /* still asleep/paralyzed */
+    if (helpless(shkp)) { /* still asleep/paralyzed */
         pline("%s %s.", Shknam(shkp),
               rn2(2) ? "seems to be napping" : "doesn't respond");
         return ECMD_OK;
@@ -1800,7 +1800,7 @@ inherits(struct monst* shkp, int numsk, int croaked, boolean silently)
                 Sprintf(takes, ", shakes %s %s,", noit_mhis(shkp),
                         mbodypart(shkp, HEAD));
             pline("%s %slooks at your corpse%s and %s.", Shknam(shkp),
-                  (!shkp->mcanmove || shkp->msleeping) ? "wakes up, " : "",
+                  helpless(shkp) ? "wakes up, " : "",
                   takes, !inhishop(shkp) ? "disappears" : "sighs");
         }
         rouse_shk(shkp, FALSE); /* wake shk for bones */
@@ -1834,7 +1834,7 @@ inherits(struct monst* shkp, int numsk, int croaked, boolean silently)
             goto skip;
         umoney = money_cnt(g.invent);
         takes[0] = '\0';
-        if (!shkp->mcanmove || shkp->msleeping)
+        if (helpless(shkp))
             Strcat(takes, "wakes up and ");
         if (!next2u(shkp->mx, shkp->my))
             Strcat(takes, "comes and ");
@@ -3449,7 +3449,7 @@ shkcatch(register struct obj* obj, register xchar x, register xchar y)
     if (!(shkp = shop_keeper(inside_shop(x, y))) || !inhishop(shkp))
         return 0;
 
-    if (shkp->mcanmove && !shkp->msleeping
+    if (!helpless(shkp)
         && (*u.ushops != ESHK(shkp)->shoproom || !inside_shop(u.ux, u.uy))
         && dist2(shkp->mx, shkp->my, x, y) < 3
         /* if it is the shk's pos, you hit and anger him */
@@ -3520,7 +3520,7 @@ shk_impaired(struct monst *shkp)
 {
     if (!shkp || !shkp->isshk || !inhishop(shkp))
         return TRUE;
-    if (shkp->msleeping || !shkp->mcanmove || ESHK(shkp)->following)
+    if (helpless(shkp) || ESHK(shkp)->following)
         return TRUE;
     return FALSE;
 }
@@ -4021,7 +4021,7 @@ shopdig(register int fall)
 
     /* 0 == can't speak, 1 == makes animal noises, 2 == speaks */
     lang = 0;
-    if (shkp->msleeping || !shkp->mcanmove || is_silent(shkp->data))
+    if (helpless(shkp) || is_silent(shkp->data))
         ; /* lang stays 0 */
     else if (shkp->data->msound <= MS_ANIMAL)
         lang = 1;
@@ -4053,7 +4053,7 @@ shopdig(register int fall)
             adjalign(-sgn(u.ualign.type));
         }
     } else if (!um_dist(shkp->mx, shkp->my, 5)
-               && !shkp->msleeping && shkp->mcanmove
+               && !helpless(shkp)
                && (ESHK(shkp)->billct || ESHK(shkp)->debit)) {
         register struct obj *obj, *obj2;
 
@@ -4252,7 +4252,7 @@ pay_for_damage(const char* dmgstr, boolean cant_mollify)
         || !rn2(50)) {
  getcad:
         if (muteshk(shkp)) {
-            if (animal && shkp->mcanmove && !shkp->msleeping)
+            if (animal && !helpless(shkp))
                 yelp(shkp);
         } else if (pursue || uinshp || !um_dist(x, y, 1)) {
             if (!Deaf)
@@ -4340,7 +4340,7 @@ shop_object(register xchar x, register xchar y)
             break;
     /* note: otmp might have ->no_charge set, but that's ok */
     return (otmp && costly_spot(x, y)
-            && NOTANGRY(shkp) && shkp->mcanmove && !shkp->msleeping)
+            && NOTANGRY(shkp) && !helpless(shkp))
                ? otmp
                : (struct obj *) 0;
 }
@@ -4729,7 +4729,7 @@ block_door(register xchar x, register xchar y)
          */
         && ESHK(shkp)->shd.x == x
         && ESHK(shkp)->shd.y == y
-        && shkp->mcanmove && !shkp->msleeping
+        && !helpless(shkp)
         && (ESHK(shkp)->debit || ESHK(shkp)->billct || ESHK(shkp)->robbed)) {
         pline("%s%s blocks your way!", Shknam(shkp),
               Invis ? " senses your motion and" : "");
@@ -4763,7 +4763,7 @@ block_entry(register xchar x, register xchar y)
     sx = ESHK(shkp)->shk.x;
     sy = ESHK(shkp)->shk.y;
 
-    if (shkp->mx == sx && shkp->my == sy && shkp->mcanmove && !shkp->msleeping
+    if (shkp->mx == sx && shkp->my == sy && !helpless(shkp)
         && (x == sx - 1 || x == sx + 1 || y == sy - 1 || y == sy + 1)
         && (Invis || carrying(PICK_AXE) || carrying(DWARVISH_MATTOCK)
             || u.usteed)) {
index 0011d72ed2da7750abc4eaf78e84ea44c57f75a6..786d36f29971efeb659442f4ed1f8fd05785c233 100644 (file)
@@ -222,7 +222,7 @@ dosounds(void)
                 continue;
             if (mtmp->ispriest && inhistemple(mtmp)
                 /* priest must be active */
-                && mtmp->mcanmove && !mtmp->msleeping
+                && !helpless(mtmp)
                 /* hero must be outside this temple */
                 && temple_occupied(u.urooms) != EPRI(mtmp)->shroom)
                 break;
@@ -351,7 +351,7 @@ growl(register struct monst* mtmp)
 {
     register const char *growl_verb = 0;
 
-    if (mtmp->msleeping || !mtmp->mcanmove || mtmp->data->msound == MS_SILENT)
+    if (helpless(mtmp) || mtmp->data->msound == MS_SILENT)
         return;
 
     /* presumably nearness and soundok checks have already been made */
@@ -376,7 +376,7 @@ yelp(register struct monst* mtmp)
 {
     register const char *yelp_verb = 0;
 
-    if (mtmp->msleeping || !mtmp->mcanmove || !mtmp->data->msound)
+    if (helpless(mtmp) || !mtmp->data->msound)
         return;
 
     /* presumably nearness and soundok checks have already been made */
@@ -418,7 +418,7 @@ whimper(register struct monst* mtmp)
 {
     register const char *whimper_verb = 0;
 
-    if (mtmp->msleeping || !mtmp->mcanmove || !mtmp->data->msound)
+    if (helpless(mtmp) || !mtmp->data->msound)
         return;
 
     /* presumably nearness and soundok checks have already been made */
@@ -449,7 +449,7 @@ whimper(register struct monst* mtmp)
 void
 beg(register struct monst* mtmp)
 {
-    if (mtmp->msleeping || !mtmp->mcanmove
+    if (helpless(mtmp)
         || !(carnivorous(mtmp->data) || herbivorous(mtmp->data)))
         return;
 
@@ -1117,7 +1117,7 @@ dochat(void)
     }
 
     if (u.usteed && u.dz > 0) {
-        if (!u.usteed->mcanmove || u.usteed->msleeping) {
+        if (helpless(u.usteed)) {
             pline("%s seems not to notice you.", Monnam(u.usteed));
             return ECMD_TIME;
         } else
@@ -1198,7 +1198,7 @@ dochat(void)
         return ECMD_OK;
 
     /* sleeping monsters won't talk, except priests (who wake up) */
-    if ((!mtmp->mcanmove || mtmp->msleeping) && !mtmp->ispriest) {
+    if (helpless(mtmp) && !mtmp->ispriest) {
         /* If it is unseen, the player can't tell the difference between
            not noticing him and just not existing, so skip the message. */
         if (canspotmon(mtmp))
@@ -1235,7 +1235,7 @@ responsive_mon_at(int x, int y)
 {
     struct monst *mtmp = isok(x, y) ? m_at(x, y) : 0;
 
-    if (mtmp && (!mtmp->mcanmove || mtmp->msleeping /* immobilized monst */
+    if (mtmp && (helpless(mtmp) /* immobilized monst */
                  || !mtmp->mcansee || !haseyes(mtmp->data) /* blind monst */
                  || (Invis && !perceives(mtmp->data)) /* unseen hero */
                  || (x != mtmp->mx || y != mtmp->my))) /* worm tail */
@@ -1271,7 +1271,7 @@ tiphat(void)
 
     if (!u.dx && !u.dy) {
         if (u.usteed && u.dz > 0) {
-            if (!u.usteed->mcanmove || u.usteed->msleeping)
+            if (helpless(u.usteed))
                 pline("%s doesn't notice.", Monnam(u.usteed));
             else
                 (void) domonnoise(u.usteed);
index 00b8b614c31b14776f5da378c3defef6bb4e3c28..3f5f759a61f9e095847c49547f0f84dc9ac551e7 100644 (file)
@@ -383,7 +383,7 @@ kick_steed(void)
         return;
 
     /* [ALI] Various effects of kicking sleeping/paralyzed steeds */
-    if (u.usteed->msleeping || !u.usteed->mcanmove) {
+    if (helpless(u.usteed)) {
         /* We assume a message has just been output of the form
          * "You kick <steed>."
          */
@@ -398,7 +398,7 @@ kick_steed(void)
                 u.usteed->mfrozen = 0;
                 u.usteed->mcanmove = 1;
             }
-            if (u.usteed->msleeping || !u.usteed->mcanmove)
+            if (helpless(u.usteed))
                 pline("%s stirs.", He);
             else
                 /* if hallucinating, might yield "He rouses herself" or
@@ -707,7 +707,7 @@ static void
 maybewakesteed(struct monst* steed)
 {
     int frozen = (int) steed->mfrozen;
-    boolean wasimmobile = steed->msleeping || !steed->mcanmove;
+    boolean wasimmobile = helpless(steed);
 
     steed->msleeping = 0;
     if (frozen) {
@@ -721,7 +721,7 @@ maybewakesteed(struct monst* steed)
             steed->mfrozen = frozen;
         }
     }
-    if (wasimmobile && !steed->msleeping && steed->mcanmove)
+    if (wasimmobile && !helpless(steed))
         pline("%s wakes up.", Monnam(steed));
     /* regardless of waking, terminate any meal in progress */
     finish_meating(steed);
@@ -736,7 +736,7 @@ stucksteed(boolean checkfeeding)
 
     if (steed) {
         /* check whether steed can move */
-        if (steed->msleeping || !steed->mcanmove) {
+        if (helpless(steed)) {
             pline("%s won't move!", upstart(y_monnam(steed)));
             return TRUE;
         }
index 2470dab9bf6f81db1ed9a3be96bb3e8c4bb6c88a..b6bb0df39a88f5825e2cb3f34e9c9068e6c85629 100644 (file)
@@ -1325,7 +1325,7 @@ trapeffect_slp_gas_trap(
         boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
 
         if (!resists_sleep(mtmp) && !breathless(mtmp->data)
-            && !mtmp->msleeping && mtmp->mcanmove) {
+            && !helpless(mtmp)) {
             if (sleep_monst(mtmp, rnd(25), -1) && in_sight) {
                 pline("%s suddenly falls asleep!", Monnam(mtmp));
                 seetrap(trap);
@@ -2581,7 +2581,7 @@ steedintrap(struct trap* trap, struct obj* otmp)
         break;
     case SLP_GAS_TRAP:
         if (!resists_sleep(steed) && !breathless(steed->data)
-            && !steed->msleeping && steed->mcanmove) {
+            && !helpless(steed)) {
             if (sleep_monst(steed, rnd(25), -1))
                 /* no in_sight check here; you can feel it even if blind */
                 pline("%s suddenly falls asleep!", Monnam(steed));
@@ -4687,7 +4687,7 @@ static void
 reward_untrap(struct trap* ttmp, struct monst* mtmp)
 {
     if (!ttmp->madeby_u) {
-        if (rnl(10) < 8 && !mtmp->mpeaceful && !mtmp->msleeping
+        if (rnl(10) < 8 && !mtmp->mpeaceful && !helpless(mtmp)
             && !mtmp->mfrozen && !mindless(mtmp->data)
             && mtmp->data->mlet != S_HUMAN) {
             mtmp->mpeaceful = 1;
@@ -4868,7 +4868,7 @@ help_monster_out(
         return 1;
 
     /* Will our hero succeed? */
-    if ((uprob = untrap_prob(ttmp)) && !mtmp->msleeping && mtmp->mcanmove) {
+    if ((uprob = untrap_prob(ttmp)) && !helpless(mtmp)) {
         You("try to reach out your %s, but %s backs away skeptically.",
             makeplural(body_part(ARM)), mon_nam(mtmp));
         return 1;
index 4116da820a0797a0067ce9788cba4df6633ed1e5..b99db0cfaa8f724260198b3a21bd91111fb9b08a 100644 (file)
@@ -269,7 +269,7 @@ check_caitiff(struct monst *mtmp)
 
     if (Role_if(PM_KNIGHT) && u.ualign.type == A_LAWFUL
         && !is_undead(mtmp->data)
-        && (!mtmp->mcanmove || mtmp->msleeping
+        && (helpless(mtmp)
             || (mtmp->mflee && !mtmp->mavenge))) {
         You("caitiff!");
         adjalign(-1);
@@ -432,7 +432,7 @@ do_attack(struct monst *mtmp)
                 You("stop.  %s is in the way!", buf);
                 end_running(TRUE);
                 return TRUE;
-            } else if (mtmp->mfrozen || mtmp->msleeping || !mtmp->mcanmove
+            } else if (mtmp->mfrozen || helpless(mtmp)
                        || (mtmp->data->mmove == 0 && rn2(6))) {
                 pline("%s doesn't seem to move!", Monnam(mtmp));
                 end_running(TRUE);
@@ -485,7 +485,7 @@ do_attack(struct monst *mtmp)
     u_wipe_engr(3);
 
     /* Is the "it died" check actually correct? */
-    if (mdat->mlet == S_LEPRECHAUN && !mtmp->mfrozen && !mtmp->msleeping
+    if (mdat->mlet == S_LEPRECHAUN && !mtmp->mfrozen && !helpless(mtmp)
         && !mtmp->mconf && mtmp->mcansee && !rn2(7)
         && (m_move(mtmp, 0) == MMOVE_DIED /* it died */
             || mtmp->mx != u.ux + u.dx
@@ -1473,8 +1473,7 @@ hmon_hitmon(
         nohandglow(mon);
         if (!mon->mconf && !resist(mon, SPBOOK_CLASS, 0, NOTELL)) {
             mon->mconf = 1;
-            if (!mon->mstun && mon->mcanmove && !mon->msleeping
-                && canseemon(mon))
+            if (!mon->mstun && !helpless(mon) && canseemon(mon))
                 pline("%s appears confused.", Monnam(mon));
         }
     }
@@ -4603,7 +4602,7 @@ missum(struct monst *mdef, struct attack *mattk, boolean wouldhavehit)
         You("miss %s.", mon_nam(mdef));
     else
         You("miss it.");
-    if (!mdef->msleeping && mdef->mcanmove)
+    if (!helpless(mdef))
         wakeup(mdef, TRUE);
 }
 
index 5f9e0cac6e1382a15b78d1933d17f1e4cd4b7008..6d66fef50fb6d8ef57ea899538ef6c9f66de9623 100644 (file)
@@ -106,7 +106,7 @@ new_were(struct monst *mon)
                                   : pmname(&mons[pm], Mgender(mon)) + 4);
 
     set_mon_data(mon, &mons[pm]);
-    if (mon->msleeping || !mon->mcanmove) {
+    if (helpless(mon)) {
         /* transformation wakens and/or revitalizes */
         mon->msleeping = 0;
         mon->mfrozen = 0; /* not asleep or paralyzed */
index c90cd4ff50e8f921407906f95b0709ec770f6f4e..9f450acbad719717530f93a13be5c7ddbaf4bdd8 100644 (file)
@@ -456,7 +456,7 @@ has_aggravatables(struct monst *mon)
         if (in_w_tower != In_W_tower(mtmp->mx, mtmp->my, &u.uz))
             continue;
         if ((mtmp->mstrategy & STRAT_WAITFORU) != 0
-            || mtmp->msleeping || !mtmp->mcanmove)
+            || helpless(mtmp))
             return TRUE;
     }
     return FALSE;
@@ -706,7 +706,7 @@ resurrect(void)
                     mtmp->msleeping = 0;
                 if (mtmp->mfrozen == 1) /* would unfreeze on next move */
                     mtmp->mfrozen = 0, mtmp->mcanmove = 1;
-                if (mtmp->mcanmove && !mtmp->msleeping) {
+                if (!helpless(mtmp)) {
                     *mmtmp = mtmp->nmon;
                     mon_arrive(mtmp, TRUE);
                     /* note: there might be a second Wizard; if so,