From f0699b76d9a6fde10ca1fc19870a7a4949c67559 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Mon, 27 Apr 2015 21:09:26 +0300 Subject: [PATCH] Add is_watch define for watchmen --- include/mondata.h | 2 ++ src/dig.c | 3 +-- src/dokick.c | 6 ++---- src/fountain.c | 3 +-- src/mon.c | 9 +++------ src/monmove.c | 2 +- src/uhitm.c | 3 +-- 7 files changed, 11 insertions(+), 17 deletions(-) diff --git a/include/mondata.h b/include/mondata.h index 1a4d8eb9c..5043f8aaa 100644 --- a/include/mondata.h +++ b/include/mondata.h @@ -134,6 +134,8 @@ #define is_displacer(ptr) (((ptr)->mflags3 & M3_DISPLACES) != 0L) #define is_mplayer(ptr) (((ptr) >= &mons[PM_ARCHEOLOGIST]) && \ ((ptr) <= &mons[PM_WIZARD])) +#define is_watch(ptr) ((ptr) == &mons[PM_WATCHMAN] || \ + (ptr) == &mons[PM_WATCH_CAPTAIN]) #define is_rider(ptr) ((ptr) == &mons[PM_DEATH] || \ (ptr) == &mons[PM_FAMINE] || \ (ptr) == &mons[PM_PESTILENCE]) diff --git a/src/dig.c b/src/dig.c index 1d7d5dd7a..9f031f1c5 100644 --- a/src/dig.c +++ b/src/dig.c @@ -1171,8 +1171,7 @@ watch_dig(mtmp, x, y, zap) if (!mtmp) { for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; - if ((mtmp->data == &mons[PM_WATCHMAN] || - mtmp->data == &mons[PM_WATCH_CAPTAIN]) && + if (is_watch(mtmp->data) && mtmp->mcansee && m_canseeu(mtmp) && couldsee(mtmp->mx, mtmp->my) && mtmp->mpeaceful) break; diff --git a/src/dokick.c b/src/dokick.c index d558bdd38..6626c601c 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -1198,8 +1198,7 @@ dumb: if (in_town(x, y)) for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; - if((mtmp->data == &mons[PM_WATCHMAN] || - mtmp->data == &mons[PM_WATCH_CAPTAIN]) && + if (is_watch(mtmp->data) && couldsee(mtmp->mx, mtmp->my) && mtmp->mpeaceful) { if (canspotmon(mtmp)) @@ -1218,8 +1217,7 @@ dumb: if (in_town(x, y)) for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; - if ((mtmp->data == &mons[PM_WATCHMAN] || - mtmp->data == &mons[PM_WATCH_CAPTAIN]) && + if (is_watch(mtmp->data) && mtmp->mpeaceful && couldsee(mtmp->mx, mtmp->my)) { if (canspotmon(mtmp)) pline("%s yells:", Amonnam(mtmp)); diff --git a/src/fountain.c b/src/fountain.c index 405fac4a3..03a373843 100644 --- a/src/fountain.c +++ b/src/fountain.c @@ -169,8 +169,7 @@ boolean isyou; /* Warn about future fountain use. */ for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; - if ((mtmp->data == &mons[PM_WATCHMAN] || - mtmp->data == &mons[PM_WATCH_CAPTAIN]) && + if (is_watch(mtmp->data) && couldsee(mtmp->mx, mtmp->my) && mtmp->mpeaceful) { pline("%s yells:", Amonnam(mtmp)); diff --git a/src/mon.c b/src/mon.c index 3a2fc402b..665ca989b 100644 --- a/src/mon.c +++ b/src/mon.c @@ -3117,9 +3117,7 @@ register boolean silent; for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; - if((mtmp->data == &mons[PM_WATCHMAN] || - mtmp->data == &mons[PM_WATCH_CAPTAIN]) - && mtmp->mpeaceful) { + if (is_watch(mtmp->data) && mtmp->mpeaceful) { ct++; if(cansee(mtmp->mx, mtmp->my) && mtmp->mcanmove) { if (distu(mtmp->mx, mtmp->my) == 2) nct++; @@ -3157,9 +3155,8 @@ pacify_guards() for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; - if (mtmp->data == &mons[PM_WATCHMAN] || - mtmp->data == &mons[PM_WATCH_CAPTAIN]) - mtmp->mpeaceful = 1; + if (is_watch(mtmp->data)) + mtmp->mpeaceful = 1; } } diff --git a/src/monmove.c b/src/monmove.c index a7a3ca46f..990955861 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -400,7 +400,7 @@ register struct monst *mtmp; } /* the watch will look around and see if you are up to no good :-) */ - if (mdat == &mons[PM_WATCHMAN] || mdat == &mons[PM_WATCH_CAPTAIN]) + if (is_watch(mdat)) watch_on_duty(mtmp); else if (is_mind_flayer(mdat) && !rn2(20)) { diff --git a/src/uhitm.c b/src/uhitm.c index 19361c261..a7ecbed9b 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -516,8 +516,7 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */ anger_guards = (mon->mpeaceful && (mon->ispriest || mon->isshk || - mon->data == &mons[PM_WATCHMAN] || - mon->data == &mons[PM_WATCH_CAPTAIN])); + is_watch(mon->data))); result = hmon_hitmon(mon, obj, thrown); if (mon->ispriest && !rn2(2)) ghod_hitsu(mon); if (anger_guards) (void)angry_guards(!!Deaf);