From: Pasi Kallinen Date: Fri, 18 Mar 2022 08:19:04 +0000 (+0200) Subject: Add helpless monster macro X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=39acd095b28560d9a73a32de0dab37b0f36a9df0;p=nethack Add helpless monster macro --- diff --git a/include/monst.h b/include/monst.h index 535b0ffbd..4dc0ccd1f 100644 --- a/include/monst.h +++ b/include/monst.h @@ -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. */ diff --git a/src/dbridge.c b/src/dbridge.c index 4f9a32d16..b75cd16c6 100644 --- a/src/dbridge.c +++ b/src/dbridge.c @@ -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; diff --git a/src/detect.c b/src/detect.c index 24f6572dd..50b2c4dc0 100644 --- a/src/detect.c +++ b/src/detect.c @@ -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; diff --git a/src/do_name.c b/src/do_name.c index cb6c7e49f..6409fe60c 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -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); diff --git a/src/dog.c b/src/dog.c index a032812e1..34f137818 100644 --- 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)) diff --git a/src/dogmove.c b/src/dogmove.c index 39da00b38..4a783c95e 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -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; diff --git a/src/dothrow.c b/src/dothrow.c index 1eb4c5cf3..b8c2d2cf6 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -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) { diff --git a/src/hack.c b/src/hack.c index 68650075e..1a875993c 100644 --- a/src/hack.c +++ b/src/hack.c @@ -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; } diff --git a/src/mhitm.c b/src/mhitm.c index 4d7c4957d..318aa75fa 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -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); diff --git a/src/monmove.c b/src/monmove.c index 4aa66a264..9ae4f15b3 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -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); } diff --git a/src/muse.c b/src/muse.c index 6b2dc09f7..ba70c5bac 100644 --- a/src/muse.c +++ b/src/muse.c @@ -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; diff --git a/src/polyself.c b/src/polyself.c index 4d10f4e1c..222613843 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -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; diff --git a/src/priest.c b/src/priest.c index 91675a57f..ce5d45405 100644 --- a/src/priest.c +++ b/src/priest.c @@ -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; diff --git a/src/quest.c b/src/quest.c index 23d7037ac..306b7a56b 100644 --- a/src/quest.c +++ b/src/quest.c @@ -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)); } diff --git a/src/shk.c b/src/shk.c index 883c71a0b..8aceca533 100644 --- 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)) { diff --git a/src/sounds.c b/src/sounds.c index 0011d72ed..786d36f29 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -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); diff --git a/src/steed.c b/src/steed.c index 00b8b614c..3f5f759a6 100644 --- a/src/steed.c +++ b/src/steed.c @@ -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 ." */ @@ -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; } diff --git a/src/trap.c b/src/trap.c index 2470dab9b..b6bb0df39 100644 --- a/src/trap.c +++ b/src/trap.c @@ -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; diff --git a/src/uhitm.c b/src/uhitm.c index 4116da820..b99db0cfa 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -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); } diff --git a/src/were.c b/src/were.c index 5f9e0cac6..6d66fef50 100644 --- a/src/were.c +++ b/src/were.c @@ -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 */ diff --git a/src/wizard.c b/src/wizard.c index c90cd4ff5..9f450acba 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -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,