Add m_next2u, analogous to m_next2m and next2u
This commit is contained in:
@@ -540,6 +540,8 @@ struct _hitmon_data {
|
||||
|
||||
/* point px,py is adjacent to (or same location as) hero */
|
||||
#define next2u(px,py) (distu((px),(py)) <= 2)
|
||||
/* is monster on top of or next to hero? */
|
||||
#define m_next2u(m) (distu((m)->mx,(m)->my) <= 2)
|
||||
/* hero at (x,y)? */
|
||||
#define u_at(x,y) ((x) == u.ux && (y) == u.uy)
|
||||
|
||||
|
||||
@@ -870,9 +870,9 @@ static boolean
|
||||
mleashed_next2u(struct monst *mtmp)
|
||||
{
|
||||
if (mtmp->mleashed) {
|
||||
if (!next2u(mtmp->mx, mtmp->my))
|
||||
if (!m_next2u(mtmp))
|
||||
mnexto(mtmp, RLOC_NOMSG);
|
||||
if (!next2u(mtmp->mx, mtmp->my)) {
|
||||
if (!m_next2u(mtmp)) {
|
||||
struct obj *otmp = get_mleash(mtmp);
|
||||
|
||||
if (!otmp) {
|
||||
|
||||
@@ -2267,7 +2267,7 @@ distant_monnam(
|
||||
unless you're adjacent (overridden for hallucination which does
|
||||
its own obfuscation) */
|
||||
if (mon->data == &mons[PM_HIGH_CLERIC] && !Hallucination
|
||||
&& Is_astralevel(&u.uz) && !next2u(mon->mx, mon->my)) {
|
||||
&& Is_astralevel(&u.uz) && !m_next2u(mon)) {
|
||||
Strcpy(outbuf, article == ARTICLE_THE ? "the " : "");
|
||||
Strcat(outbuf, mon->female ? "high priestess" : "high priest");
|
||||
} else {
|
||||
|
||||
@@ -2435,7 +2435,7 @@ escape_from_sticky_mon(coordxy x, coordxy y)
|
||||
if (u.ustuck && (x != u.ustuck->mx || y != u.ustuck->my)) {
|
||||
struct monst *mtmp;
|
||||
|
||||
if (!next2u(u.ustuck->mx, u.ustuck->my)) {
|
||||
if (!m_next2u(u.ustuck)) {
|
||||
/* perhaps it fled (or was teleported or ... ) */
|
||||
set_ustuck((struct monst *) 0);
|
||||
} else if (sticks(gy.youmonst.data)) {
|
||||
|
||||
@@ -416,7 +416,7 @@ newmail(struct mail_info *info)
|
||||
if (info->response_cmd)
|
||||
new_omailcmd(obj, info->response_cmd);
|
||||
|
||||
if (!next2u(md->mx, md->my)) {
|
||||
if (!m_next2u(md)) {
|
||||
SetVoice(md, 0, 80, 0);
|
||||
verbalize("Catch!");
|
||||
}
|
||||
|
||||
14
src/mhitu.c
14
src/mhitu.c
@@ -475,7 +475,7 @@ mattacku(register struct monst *mtmp)
|
||||
/* Your steed won't attack you */
|
||||
return 0;
|
||||
/* Orcs like to steal and eat horses and the like */
|
||||
if (!rn2(is_orc(mtmp->data) ? 2 : 4) && next2u(mtmp->mx, mtmp->my)) {
|
||||
if (!rn2(is_orc(mtmp->data) ? 2 : 4) && m_next2u(mtmp)) {
|
||||
/* attack your steed instead; 'bhitpos' and 'notonhead' are
|
||||
already set from tagetting hero */
|
||||
i = mattackm(mtmp, u.usteed);
|
||||
@@ -483,7 +483,7 @@ mattacku(register struct monst *mtmp)
|
||||
return 1;
|
||||
/* make sure steed is still alive and within range */
|
||||
if ((i & M_ATTK_DEF_DIED) != 0 || !u.usteed
|
||||
|| !next2u(mtmp->mx, mtmp->my))
|
||||
|| !m_next2u(mtmp))
|
||||
return 0;
|
||||
/* Let your steed retaliate */
|
||||
gb.bhitpos.x = mtmp->mx, gb.bhitpos.y = mtmp->my;
|
||||
@@ -828,7 +828,7 @@ mattacku(register struct monst *mtmp)
|
||||
mon_currwep = MON_WEP(mtmp);
|
||||
if (mon_currwep) {
|
||||
boolean bash = (is_pole(mon_currwep)
|
||||
&& next2u(mtmp->mx, mtmp->my));
|
||||
&& m_next2u(mtmp));
|
||||
|
||||
hittmp = hitval(mon_currwep, &gy.youmonst);
|
||||
tmp += hittmp;
|
||||
@@ -1989,7 +1989,7 @@ doseduce(struct monst *mon)
|
||||
Ring_gone(uright);
|
||||
/* ring removal might cause loss of levitation which could
|
||||
drop hero onto trap that transports hero somewhere else */
|
||||
if (u.utotype || !next2u(mon->mx, mon->my))
|
||||
if (u.utotype || !m_next2u(mon))
|
||||
return 1;
|
||||
setworn(ring, RIGHT_RING);
|
||||
} else if (uleft && uleft->otyp != RIN_ADORNMENT) {
|
||||
@@ -1997,7 +1997,7 @@ doseduce(struct monst *mon)
|
||||
pline("%s replaces %s with %s.",
|
||||
Who, yname(uleft), yname(ring));
|
||||
Ring_gone(uleft);
|
||||
if (u.utotype || !next2u(mon->mx, mon->my))
|
||||
if (u.utotype || !m_next2u(mon))
|
||||
return 1;
|
||||
setworn(ring, LEFT_RING);
|
||||
} else
|
||||
@@ -2030,7 +2030,7 @@ doseduce(struct monst *mon)
|
||||
and changing location, so hero might not be adjacent to seducer
|
||||
any more (mayberem() has its own adjacency test so we don't need
|
||||
to check after each potential removal) */
|
||||
if (u.utotype || !next2u(mon->mx, mon->my))
|
||||
if (u.utotype || !m_next2u(mon))
|
||||
return 1;
|
||||
|
||||
if (uarm || uarmc) {
|
||||
@@ -2208,7 +2208,7 @@ mayberem(struct monst *mon,
|
||||
return;
|
||||
/* removal of a previous item might have sent the hero elsewhere
|
||||
(loss of levitation that leads to landing on a transport trap) */
|
||||
if (u.utotype || !next2u(mon->mx, mon->my))
|
||||
if (u.utotype || !m_next2u(mon))
|
||||
return;
|
||||
|
||||
/* being deaf overrides confirmation prompt for high charisma */
|
||||
|
||||
@@ -1068,7 +1068,7 @@ movemon_singlemon(struct monst *mtmp)
|
||||
if (mtmp->mundetected)
|
||||
return FALSE;
|
||||
} else if (mtmp->data->mlet == S_EEL && !mtmp->mundetected
|
||||
&& (mtmp->mflee || !next2u(mtmp->mx, mtmp->my))
|
||||
&& (mtmp->mflee || !m_next2u(mtmp))
|
||||
&& !canseemon(mtmp) && !rn2(4)) {
|
||||
/* some eels end up stuck in isolated pools, where they
|
||||
can't--or at least won't--move, so they never reach
|
||||
@@ -3124,7 +3124,7 @@ void
|
||||
set_ustuck(struct monst *mtmp)
|
||||
{
|
||||
if (iflags.sanity_check || iflags.debug_fuzzer) {
|
||||
if (mtmp && !next2u(mtmp->mx, mtmp->my))
|
||||
if (mtmp && !m_next2u(mtmp))
|
||||
impossible("Sticking to %s at distu %d?",
|
||||
mon_nam(mtmp), mdistu(mtmp));
|
||||
}
|
||||
@@ -4257,7 +4257,7 @@ restrap(struct monst *mtmp)
|
||||
/* can't hide on ceiling if there isn't one */
|
||||
|| (ceiling_hider(mtmp->data) && !has_ceiling(&u.uz))
|
||||
/* won't hide when adjacent to hero */
|
||||
|| (sensemon(mtmp) && next2u(mtmp->mx, mtmp->my)))
|
||||
|| (sensemon(mtmp) && m_next2u(mtmp)))
|
||||
return FALSE;
|
||||
|
||||
if (mtmp->data->mlet == S_MIMIC) {
|
||||
@@ -5268,7 +5268,7 @@ angry_guards(boolean silent)
|
||||
if (is_watch(mtmp->data) && mtmp->mpeaceful) {
|
||||
ct++;
|
||||
if (canspotmon(mtmp) && mtmp->mcanmove) {
|
||||
if (next2u(mtmp->mx, mtmp->my))
|
||||
if (m_next2u(mtmp))
|
||||
nct++;
|
||||
else
|
||||
sct++;
|
||||
|
||||
@@ -827,7 +827,7 @@ dochug(register struct monst* mtmp)
|
||||
break;
|
||||
case MMOVE_MOVED: /* monster moved */
|
||||
/* if confused grabber has wandered off, let go */
|
||||
if (mtmp == u.ustuck && !next2u(mtmp->mx, mtmp->my))
|
||||
if (mtmp == u.ustuck && !m_next2u(mtmp))
|
||||
unstuck(mtmp);
|
||||
if (grounded(mdat))
|
||||
disturb_buried_zombies(mtmp->mx, mtmp->my);
|
||||
|
||||
@@ -443,7 +443,7 @@ find_defensive(struct monst *mtmp, boolean tryescape)
|
||||
if (!tryescape && dist2(x, y, mtmp->mux, mtmp->muy) > 25)
|
||||
return FALSE;
|
||||
if (tryescape && Is_knox(&u.uz)
|
||||
&& !next2u(mtmp->mx, mtmp->my) && m_next2m(mtmp))
|
||||
&& !m_next2u(mtmp) && m_next2m(mtmp))
|
||||
return FALSE;
|
||||
if (u.uswallow && stuck)
|
||||
return FALSE;
|
||||
@@ -2084,7 +2084,7 @@ find_misc(struct monst *mtmp)
|
||||
&& uwep && !rn2(5) && obj == MON_WEP(mtmp)
|
||||
/* hero's location must be known and adjacent */
|
||||
&& u_at(mtmp->mux, mtmp->muy)
|
||||
&& next2u(mtmp->mx, mtmp->my)
|
||||
&& m_next2u(mtmp)
|
||||
/* don't bother if it can't work (this doesn't
|
||||
prevent cursed weapons from being targeted) */
|
||||
&& !u.uswallow
|
||||
|
||||
@@ -364,7 +364,7 @@ priestname(
|
||||
/* same as distant_monnam(), more or less... */
|
||||
if (do_hallu || !high_priest || reveal_high_priest
|
||||
|| !Is_astralevel(&u.uz)
|
||||
|| next2u(mon->mx, mon->my) || gp.program_state.gameover) {
|
||||
|| m_next2u(mon) || gp.program_state.gameover) {
|
||||
Strcat(pname, " of ");
|
||||
Strcat(pname, halu_gname(mon_aligntyp(mon)));
|
||||
}
|
||||
|
||||
12
src/shk.c
12
src/shk.c
@@ -1454,7 +1454,7 @@ dopay(void)
|
||||
for (shkp = next_shkp(fmon, FALSE); shkp;
|
||||
shkp = next_shkp(shkp->nmon, FALSE)) {
|
||||
sk++;
|
||||
if (next2u(shkp->mx, shkp->my)) {
|
||||
if (m_next2u(shkp)) {
|
||||
/* next to an irate shopkeeper? prioritize that */
|
||||
if (nxtm && ANGRY(nxtm))
|
||||
continue;
|
||||
@@ -1495,7 +1495,7 @@ dopay(void)
|
||||
shkp = next_shkp(shkp->nmon, FALSE))
|
||||
if (canspotmon(shkp))
|
||||
break;
|
||||
if (shkp != resident && !next2u(shkp->mx, shkp->my)) {
|
||||
if (shkp != resident && !m_next2u(shkp)) {
|
||||
pline("%s is not near enough to receive your payment.",
|
||||
Shknam(shkp));
|
||||
return ECMD_OK;
|
||||
@@ -1533,7 +1533,7 @@ dopay(void)
|
||||
pline("%s is not interested in your payment.", Monnam(mtmp));
|
||||
return ECMD_OK;
|
||||
}
|
||||
if (mtmp != resident && !next2u(mtmp->mx, mtmp->my)) {
|
||||
if (mtmp != resident && !m_next2u(mtmp)) {
|
||||
pline("%s is too far to receive your payment.", Shknam(mtmp));
|
||||
return ECMD_OK;
|
||||
}
|
||||
@@ -2088,7 +2088,7 @@ inherits(
|
||||
takes[0] = '\0';
|
||||
if (helpless(shkp))
|
||||
Strcat(takes, "wakes up and ");
|
||||
if (!next2u(shkp->mx, shkp->my))
|
||||
if (!m_next2u(shkp))
|
||||
Strcat(takes, "comes and ");
|
||||
Strcat(takes, "takes");
|
||||
|
||||
@@ -4505,10 +4505,10 @@ shopdig(int fall)
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
if (!next2u(shkp->mx, shkp->my)) {
|
||||
if (!m_next2u(shkp)) {
|
||||
mnexto(shkp, RLOC_MSG);
|
||||
/* for some reason the shopkeeper can't come next to you */
|
||||
if (!next2u(shkp->mx, shkp->my)) {
|
||||
if (!m_next2u(shkp)) {
|
||||
if (lang == 2)
|
||||
pline("%s curses you in anger and frustration!",
|
||||
Shknam(shkp));
|
||||
|
||||
@@ -1603,7 +1603,7 @@ rloc_to_core(
|
||||
if (u.uswallow) {
|
||||
u_on_newpos(mtmp->mx, mtmp->my);
|
||||
docrt();
|
||||
} else if (!next2u(mtmp->mx, mtmp->my)) {
|
||||
} else if (!m_next2u(mtmp)) {
|
||||
unstuck(mtmp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5829,7 +5829,7 @@ openholdingtrap(
|
||||
pline("%s%s opens.", upstart(strcpy(buf, which)), trapdescr);
|
||||
}
|
||||
/* might pacify monster if adjacent */
|
||||
if (rn2(2) && next2u(mon->mx, mon->my))
|
||||
if (rn2(2) && m_next2u(mon))
|
||||
reward_untrap(t, mon);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
10
src/uhitm.c
10
src/uhitm.c
@@ -234,7 +234,7 @@ attack_checks(
|
||||
if (M_AP_TYPE(mtmp) && !Protection_from_shape_changers) {
|
||||
if (!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data, AD_STCK)
|
||||
/* applied pole-arm attack is too far to get stuck */
|
||||
&& next2u(mtmp->mx, mtmp->my))
|
||||
&& m_next2u(mtmp))
|
||||
set_ustuck(mtmp);
|
||||
}
|
||||
/* #H7329 - if hero is on engraved "Elbereth", this will end up
|
||||
@@ -1940,7 +1940,7 @@ shade_miss(
|
||||
|
||||
if (verbose
|
||||
&& ((youdef || cansee(mdef->mx, mdef->my) || sensemon(mdef))
|
||||
|| (magr == &gy.youmonst && next2u(mdef->mx, mdef->my)))) {
|
||||
|| (magr == &gy.youmonst && m_next2u(mdef)))) {
|
||||
static const char harmlessly_thru[] = " harmlessly through ";
|
||||
|
||||
what = (!obj || shade_aware(obj)) ? "attack" : cxname(obj);
|
||||
@@ -3215,7 +3215,7 @@ mhitm_ad_stck(
|
||||
|
||||
if (magr == &gy.youmonst) {
|
||||
/* uhitm */
|
||||
if (!negated && !sticks(pd) && next2u(mdef->mx, mdef->my)) {
|
||||
if (!negated && !sticks(pd) && m_next2u(mdef)) {
|
||||
set_ustuck(mdef); /* it's now stuck to you */
|
||||
if (barbs)
|
||||
Your("barbs stick to %s!", y_monnam(mdef));
|
||||
@@ -5266,7 +5266,7 @@ hmonas(struct monst *mon)
|
||||
boolean monster_survived;
|
||||
|
||||
/* not used here but umpteen mhitm_ad_xxxx() need this */
|
||||
gv.vis = (canseemon(mon) || next2u(mon->mx, mon->my));
|
||||
gv.vis = (canseemon(mon) || m_next2u(mon));
|
||||
|
||||
/* with just one touch/claw/weapon attack, both rings matter;
|
||||
with more than one, alternate right and left when checking
|
||||
@@ -6024,7 +6024,7 @@ stumble_onto_mimic(struct monst *mtmp)
|
||||
|
||||
if (!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data, AD_STCK)
|
||||
/* must be adjacent; attack via polearm could be from farther away */
|
||||
&& next2u(mtmp->mx, mtmp->my))
|
||||
&& m_next2u(mtmp))
|
||||
set_ustuck(mtmp);
|
||||
|
||||
if (Blind) {
|
||||
|
||||
@@ -94,7 +94,7 @@ amulet(void)
|
||||
continue;
|
||||
if (mtmp->iswiz && mtmp->msleeping && !rn2(40)) {
|
||||
mtmp->msleeping = 0;
|
||||
if (!next2u(mtmp->mx, mtmp->my))
|
||||
if (!m_next2u(mtmp))
|
||||
You(
|
||||
"get the creepy feeling that somebody noticed your taking the Amulet.");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user