/* point px,py is adjacent to (or same location as) hero */
#define next2u(px,py) (distu((px),(py)) <= 2)
+/* hero at (x,y)? */
+#define u_at(x,y) ((x) == u.ux && (y) == u.uy)
#endif /* YOU_H */
return TRUE;
} else if (corpse) {
- boolean here = (rx == u.ux && ry == u.uy),
+ boolean here = u_at(rx, ry),
one = (corpse->quan == 1L && !more_corpses), reviver = FALSE;
int visglyph, corpseglyph;
mptr = &mons[statue->corpsenm];
if (Blind) { /* ignore statue->dknown; it'll always be set */
Sprintf(buf, "%s %s",
- (rx == u.ux && ry == u.uy) ? "This" : "That",
+ u_at(rx, ry) ? "This" : "That",
humanoid(mptr) ? "person" : "creature");
what = buf;
} else {
if (!get_adjacent_loc((char *) 0, (char *) 0, u.ux, u.uy, &cc))
return ECMD_OK;
- if (cc.x == u.ux && cc.y == u.uy) {
+ if (u_at(cc.x, cc.y)) {
if (u.usteed && u.dz > 0) {
mtmp = u.usteed;
spotmon = 1;
return;
}
ttyp = (otmp->otyp == LAND_MINE) ? LANDMINE : BEAR_TRAP;
- if (otmp == g.trapinfo.tobj && u.ux == g.trapinfo.tx
- && u.uy == g.trapinfo.ty) {
+ if (otmp == g.trapinfo.tobj && u_at(g.trapinfo.tx, g.trapinfo.ty)) {
You("resume setting %s%s.", shk_your(buf, otmp),
trapname(ttyp, FALSE));
set_occupation(set_trap, occutext, 0);
pline("Too far!");
return res;
} else if (distu(cc.x, cc.y) < min_range) {
- if (autohit && cc.x == u.ux && cc.y == u.uy)
+ if (autohit && u_at(cc.x, cc.y))
pline("Don't know what to hit.");
else
pline("Too close!");
for (yy = y - 1; yy <= y + 1; ++yy) {
if (!isok(xx, yy))
continue;
- if (xx == u.ux && yy == u.uy)
+ if (u_at(xx, yy))
continue;
if (!(mtmp = m_at(xx, yy)))
continue;
for (y = 0; y < ROWNO; y++) {
for (x = startx, curx = 0; x < stopx; x++, curx += 2) {
- if (x == u.ux && y == u.uy) {
+ if (u_at(x, y)) {
row[curx] = row[curx + 1] = '@';
} else {
v = levl[x][y].seenv & 0xff;
putstr(win, 0, "");
for (y = 0; y < ROWNO; y++) {
for (x = 1; x < COLNO; x++) {
- if (x == u.ux && y == u.uy) {
+ if (u_at(x, y)) {
row[x] = '@';
} else {
v = g.viz_array[y][x]; /* data access should be hidden */
for (y = 0; y < ROWNO; y++) {
for (x = 0; x < COLNO; x++) {
lev = &levl[x][y];
- if (x == u.ux && y == u.uy)
+ if (u_at(x, y))
row[x] = '@';
else if (IS_WALL(lev->typ) || lev->typ == SDOOR)
row[x] = '0' + (lev->wall_info & WM_MASK);
static void
set_entity(int x, int y, struct entity *etmp)
{
- if ((x == u.ux) && (y == u.uy))
+ if (u_at(x, y))
u_to_e(etmp);
else if (MON_AT(x, y))
m_to_e(m_at(x, y), x, y, etmp);
if (sobj_at(CHEST, x, y) || sobj_at(LARGE_BOX, x, y))
return TRUE;
/* in inventory, we need to find one which is actually trapped */
- if (x == u.ux && y == u.uy) {
+ if (u_at(x, y)) {
for (otmp = g.invent; otmp; otmp = otmp->nobj)
if (Is_box(otmp) && otmp->otrapped)
return TRUE;
}
map_object(temp, 1);
}
- if (temp && temp->ox == u.ux && temp->oy == u.uy)
+ if (temp && u_at(temp->ox, temp->oy))
ugold = TRUE;
}
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
break;
}
}
- if (temp && temp->ox == u.ux && temp->oy == u.uy)
+ if (temp && u_at(temp->ox, temp->oy))
ugold = TRUE;
}
if (!ugold) {
for (obj = fobj; obj; obj = obj->nobj)
if (o_in(obj, oclass)) {
- if (obj->ox == u.ux && obj->oy == u.uy)
+ if (u_at(obj->ox, obj->oy))
ctu++;
else
ct++;
continue;
for (obj = mtmp->minvent; obj; obj = obj->nobj)
if (o_in(obj, oclass)) {
- if (mtmp->mx == u.ux && mtmp->my == u.uy)
+ if (u_at(mtmp->mx, mtmp->my))
ctu++; /* steed or an engulfer with inventory */
else
ct++;
for (obj = fobj; obj; obj = obj->nobj) {
if ((!class && !boulder) || o_in(obj, class) || o_in(obj, boulder)) {
- if (obj->ox == u.ux && obj->oy == u.uy)
+ if (u_at(obj->ox, obj->oy))
ctu++;
else
ct++;
for (obj = g.level.buriedobjlist; obj; obj = obj->nobj) {
if (!class || o_in(obj, class)) {
- if (obj->ox == u.ux && obj->oy == u.uy)
+ if (u_at(obj->ox, obj->oy))
ctu++;
else
ct++;
for (otmp = objlist; otmp; otmp = otmp->nobj) {
if (Is_box(otmp) && otmp->otrapped
&& get_obj_location(otmp, &x, &y, BURIED_TOO | CONTAINED_TOO)) {
- result |= (x == u.ux && y == u.uy) ? OTRAP_HERE : OTRAP_THERE;
+ result |= u_at(x, y) ? OTRAP_HERE : OTRAP_THERE;
if (show_them)
sense_trap((struct trap *) 0, x, y, how);
}
see_monsters() to update visible ones and warned-of ones */
for (zx = lo_x; zx <= hi_x; zx++)
for (zy = lo_y; zy <= hi_y; zy++) {
- if (zx == u.ux && zy == u.uy)
+ if (u_at(zx, zy))
continue;
newglyph = glyph_at(zx, zy);
if (glyph_is_monster(newglyph)
newsym(zx, zy);
(*num_p)++;
}
- mon = (zx == u.ux && zy == u.uy) ? &g.youmonst : m_at(zx, zy);
+ mon = u_at(zx, zy) ? &g.youmonst : m_at(zx, zy);
if (openholdingtrap(mon, &dummy)
|| openfallingtrap(mon, TRUE, &dummy))
(*num_p)++;
for (y = u.uy - 1; y < u.uy + 2; y++) {
if (!isok(x, y))
continue;
- if (x == u.ux && y == u.uy)
+ if (u_at(x, y))
continue;
if (Blind && !aflag)
for (x = u.ux - 1; x <= u.ux + 1; x++)
for (y = u.uy - 1; y <= u.uy + 1; y++) {
- if (!isok(x, y) || (x == u.ux && y == u.uy))
+ if (!isok(x, y) || u_at(x, y))
continue;
if ((mtmp = m_at(x, y)) != 0
&& warning_of(mtmp) && mtmp->mundetected)
the invisible monster glyph, which is handled like
an object, replacing any object or trap at its spot) */
glyph = !swallowed ? glyph_at(x, y) : levl_glyph;
- if (keep_mons && x == u.ux && y == u.uy && swallowed)
+ if (keep_mons && u_at(x, y) && swallowed)
glyph = mon_to_glyph(u.ustuck, rn2_on_display_rng);
else if (((glyph_is_monster(glyph)
|| glyph_is_warning(glyph)) && !keep_mons)
struct monst *mtmp = m_at(x, y); /* may be madeby */
boolean madeby_u = (madeby == BY_YOU);
boolean madeby_obj = (madeby == BY_OBJECT);
- boolean at_u = (x == u.ux) && (y == u.uy);
+ boolean at_u = u_at(x, y);
boolean wont_fall = Levitation || Flying;
if (at_u && u.utrap) {
{
struct obj *objchain;
struct monst *mon;
- boolean u_spot = (x == u.ux && y == u.uy);
+ boolean u_spot = u_at(x, y);
if (ttmp)
(void) delfloortrap(ttmp);
|| g.context.digging.down) {
if (flags.autodig && dig_target == DIGTYP_ROCK
&& !g.context.digging.down
- && g.context.digging.pos.x == u.ux
- && g.context.digging.pos.y == u.uy
+ && u_at(g.context.digging.pos.x, g.context.digging.pos.y)
&& (g.moves <= g.context.digging.lastdigtime + 2
&& g.moves >= g.context.digging.lastdigtime)) {
/* avoid messages if repeated autodigging */
t = *trap;
levl[t.tx][t.ty].typ = filltyp, levl[t.tx][t.ty].flags = 0;
liquid_flow(t.tx, t.ty, filltyp, trap,
- (t.tx == u.ux && t.ty == u.uy)
+ u_at(t.tx, t.ty)
? "Suddenly %s flows in from the adjacent pit!"
: (char *) 0);
for (idx = 0; idx < N_DIRS; ++idx) {
if (mtmp && !OBJ_AT(x, y) && mtmp->mundetected
&& hides_under(mtmp->data)) {
mtmp->mundetected = 0;
- } else if (x == u.ux && y == u.uy
+ } else if (u_at(x, y)
&& u.uundetected && hides_under(g.youmonst.data))
(void) hideunder(&g.youmonst);
newsym(x, y);
/* only permit updating the hero when swallowed */
if (u.uswallow) {
- if (x == u.ux && y == u.uy)
+ if (u_at(x, y))
display_self();
return;
}
return;
}
- if (x == u.ux && y == u.uy) {
+ if (u_at(x, y)) {
int see_self = canspotself();
/* update map information for <u.ux,u.uy> (remembered topology
/* Can't see the location. */
} else {
- if (x == u.ux && y == u.uy) {
+ if (u_at(x, y)) {
feel_location(u.ux, u.uy); /* forces an update */
if (canspotself())
for (x = u.ux - 1; x <= u.ux + 1; x++)
for (y = u.uy - 1; y <= u.uy + 1; y++)
if (isok(x, y) && (is_pool_or_lava(x, y) || is_ice(x, y))) {
- if (Blind && !(x == u.ux && y == u.uy))
+ if (Blind && !u_at(x, y))
show_glyph(x, y, GLYPH_UNEXPLORED);
else
newsym(x, y);
glyph_info *glyphinfo)
{
int offset;
- boolean is_you = (x == u.ux && y == u.uy
+ boolean is_you = (u_at(x, y)
/* verify hero or steed (not something underneath
when hero is invisible without see invisible,
or a temporary display effect like an explosion);
ttyp = t->ttyp;
tseen = t->tseen ? TRUE : FALSE;
if (((mtmp = m_at(x, y)) && mtmp->mtrapped)
- || (u.utrap && u.ux == x && u.uy == y)) {
+ || (u.utrap && u_at(x,y))) {
if (*verb && (cansee(x, y) || distu(x, y) == 0))
pline("%s boulder %s into the pit%s.",
Blind ? "A" : "The",
}
}
if (*verb) {
- if (Blind && (x == u.ux) && (y == u.uy)) {
+ if (Blind && u_at(x, y)) {
You_hear("a CRASH! beneath you.");
} else if (!Blind && cansee(x, y)) {
pline_The("boulder %s%s.",
/* Reasonably bulky objects (arbitrary) splash when dropped.
* If you're floating above the water even small things make
* noise. Stuff dropped near fountains always misses */
- if ((Blind || (Levitation || Flying)) && !Deaf
- && ((x == u.ux) && (y == u.uy))) {
+ if ((Blind || (Levitation || Flying)) && !Deaf && u_at(x, y)) {
if (!Underwater) {
if (weight(obj) > 9) {
pline("Splash!");
newsym(x, y);
}
res = water_damage(obj, NULL, FALSE) == ER_DESTROYED;
- } else if (u.ux == x && u.uy == y && (t = t_at(x, y)) != 0
+ } else if (u_at(x, y) && (t = t_at(x, y)) != 0
&& (uteetering_at_seen_pit(t) || uescaped_shaft(t))) {
if (is_pit(t->ttyp)) {
if (Blind && !Deaf)
for (pass = 0; pass < 2; pass++) {
for (x = 1; x < COLNO; x++)
for (y = 0; y < ROWNO; y++) {
- if ((x == u.ux && y == u.uy)
- || gather_locs_interesting(x, y, gloc)) {
+ if (u_at(x, y) || gather_locs_interesting(x, y, gloc)) {
if (!pass) {
++*cnt_p;
} else {
return;
cx = cc.x, cy = cc.y;
- if (cx == u.ux && cy == u.uy) {
+ if (u_at(cx, cy)) {
if (u.usteed && canspotmon(u.usteed)) {
mtmp = u.usteed;
} else {
? "over" : "under");
if (getpos(&cc, FALSE, buf) < 0 || cc.x <= 0)
return;
- if (cc.x == u.ux && cc.y == u.uy) {
+ if (u_at(cc.x, cc.y)) {
obj = vobj_at(u.ux, u.uy);
} else {
glyph = glyph_at(cc.x, cc.y);
if (!obj) {
/* "under you" is safe here since there's no object to hide under */
pline("There doesn't seem to be any object %s.",
- (cc.x == u.ux && cc.y == u.uy) ? "under you" : "there");
+ u_at(cc.x, cc.y) ? "under you" : "there");
return;
}
/* note well: 'obj' might be an instance of STRANGE_OBJECT if target
&& g.moves < edog->hungrytime)) {
g.gx = u.ux;
g.gy = u.uy;
- if (after && udist <= 4 && g.gx == u.ux && g.gy == u.uy)
+ if (after && udist <= 4 && u_at(g.gx, g.gy))
return -2;
appr = (udist >= 9) ? 1 : (mtmp->mflee) ? -1 : 0;
if (udist > 1) {
appr = 0;
#define FARAWAY (COLNO + 2) /* position outside screen */
- if (g.gx == u.ux && g.gy == u.uy && !in_masters_sight) {
+ if (u_at(g.gx, g.gy) && !in_masters_sight) {
register coord *cp;
cp = gettrack(omx, omy);
*/
for (x = 1; x < COLNO; x++) {
for (y = 0; y < ROWNO; y++) {
- if (cansee(x, y) || (x == u.ux && y == u.uy && !Levitation)) {
+ if (cansee(x, y) || (u_at(x, y) && !Levitation)) {
ltyp = levl[x][y].typ;
if (ltyp == DRAWBRIDGE_UP)
ltyp = db_under_typ(levl[x][y].drawbridgemask);
{
struct rm *lev = &levl[x][y];
- if (x == u.ux && y == u.uy && u.uswallow && is_animal(u.ustuck->data))
+ if (u_at(x, y) && u.uswallow && is_animal(u.ustuck->data))
return "maw";
else if (IS_AIR(lev->typ) && Is_airlevel(&u.uz))
return "air";
} else
explmask[i][j] = 0;
- if (i + x - 1 == u.ux && j + y - 1 == u.uy) {
+ if (u_at(i + x - 1, j + y - 1)) {
switch (adtyp) {
case AD_PHYS:
explmask[i][j] = 0;
}
/* can be both you and mtmp if you're swallowed or riding */
mtmp = m_at(i + x - 1, j + y - 1);
- if (!mtmp && i + x - 1 == u.ux && j + y - 1 == u.uy)
+ if (!mtmp && u_at(i + x - 1, j + y - 1))
mtmp = u.usteed;
if (mtmp) {
if (DEADMONSTER(mtmp))
for (j = 0; j < 3; j++) {
if (explmask[i][j] == 2)
continue;
- if (i + x - 1 == u.ux && j + y - 1 == u.uy) {
+ if (u_at(i + x - 1, j + y - 1)) {
uhurt = (explmask[i][j] == 1) ? 1 : 2;
/* If the player is attacking via polyself into something
* with an explosion attack, leave them (and their gear)
&shopdamage, exploding_wand_typ);
mtmp = m_at(i + x - 1, j + y - 1);
- if (!mtmp && i + x - 1 == u.ux && j + y - 1 == u.uy)
+ if (!mtmp && u_at(i + x - 1, j + y - 1))
mtmp = u.usteed;
if (!mtmp)
continue;
stmp->stopped = TRUE;
}
}
- } else if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) {
+ } else if (u_at(g.bhitpos.x, g.bhitpos.y)) {
if (scflags & MAY_HITYOU) {
int hitvalu, hitu;
newsym(x, y);
}
newsym(sx, sy);
- if (sx == u.ux && sy == u.uy && u.uundetected
- && hides_under(g.youmonst.data))
+ if (u_at(sx, sy) && u.uundetected && hides_under(g.youmonst.data))
(void) hideunder(&g.youmonst);
if (lostgoods) /* implies shop_origin and therefore shkp valid */
credit_report(shkp, 1, FALSE);
register struct monst *mtmp;
register struct trap *ttmp;
- if (((x + y) % 2) || (x == u.ux && y == u.uy)
+ if (((x + y) % 2) || u_at(x, y)
|| (rn2(1 + distmin(u.ux, u.uy, x, y))) || (levl[x][y].typ != ROOM)
|| (sobj_at(BOULDER, x, y)) || nexttodoor(x, y))
return;
void
breaksink(int x, int y)
{
- if (cansee(x, y) || (x == u.ux && y == u.uy))
+ if (cansee(x, y) || u_at(x, y))
pline_The("pipes break! Water spurts out!");
g.level.flags.nsinks--;
levl[x][y].typ = FOUNTAIN, levl[x][y].looted = 0;
updates hunger state and requests status update if changed */
morehungry(-nut);
}
- digtxt = (x == u.ux && y == u.uy)
+ digtxt = u_at(x, y)
? "devour the iron bars."
: "eat through the bars.";
dissolve_bars(x, y);
}
}
- if (px == u.ux && py == u.uy) {
+ if (u_at(px, py)) {
/* no guesses, just go in the general direction */
u.dx = sgn(u.tx - u.ux);
u.dy = sgn(u.ty - u.uy);
boolean ret;
int glyph = glyph_at(x,y);
- if (x == u.ux && y == u.uy)
+ if (u_at(x, y))
return TRUE;
if (isok(x,y) && glyph_is_cmap(glyph) && S_stone == glyph_to_cmap(glyph)
&& !levl[x][y].seenv)
/* prevent recursion from affecting the hero all over again
[hero poly'd to iron golem enters water here, drown() inflicts
damage that triggers rehumanize() which calls spoteffects()...] */
- if (inspoteffects && u.ux == spotloc.x && u.uy == spotloc.y
+ if (inspoteffects && u_at(spotloc.x, spotloc.y)
/* except when reason is transformed terrain (ice -> water) */
&& spotterrain == levl[u.ux][u.uy].typ
/* or transformed trap (land mine -> pit) */
for (x = u.ux - 1; x <= u.ux + 1; x++)
for (y = u.uy - 1; y <= u.uy + 1; y++) {
/* ignore out of bounds, and our own location */
- if (!isok(x, y) || (x == u.ux && y == u.uy))
+ if (!isok(x, y) || u_at(x, y))
continue;
/* (grid bugs) ignore diagonals */
if (NODIAG(u.umonnum) && x != u.ux && y != u.uy)
/* Also see the similar check in dochugw() in monmove.c */
for (x = u.ux - 1; x <= u.ux + 1; x++)
for (y = u.uy - 1; y <= u.uy + 1; y++) {
- if (!isok(x, y) || (x == u.ux && y == u.uy))
+ if (!isok(x, y) || u_at(x, y))
continue;
if ((mtmp = m_at(x, y)) != 0
&& M_AP_TYPE(mtmp) != M_AP_FURNITURE
useupf(struct obj *obj, long numused)
{
struct obj *otmp;
- boolean at_u = (obj->ox == u.ux && obj->oy == u.uy);
+ boolean at_u = u_at(obj->ox, obj->oy);
/* burn_floor_objects() keeps an object pointer that it tries to
* useupf() multiple times, so obj must survive if plural */
/* minor optimization: don't bother with duplicate light sources
at hero */
- if (ls->x == u.ux && ls->y == u.uy) {
+ if (u_at(ls->x, ls->y)) {
if (at_hero_range >= ls->range)
ls->flags &= ~LSF_SHOW;
else
if ((max_x = (ls->x + offset)) >= COLNO)
max_x = COLNO - 1;
- if (ls->x == u.ux && ls->y == u.uy) {
+ if (u_at(ls->x, ls->y)) {
/*
* If the light source is located at the hero, then
* we can use the COULD_SEE bits already calculated
return PICKLOCK_DID_NOTHING;
}
- if (cc.x == u.ux && cc.y == u.uy) { /* pick lock on a container */
+ if (u_at(cc.x, cc.y)) { /* pick lock on a container */
const char *verb;
char qsfx[QBUFSZ];
boolean it;
return ECMD_OK;
/* open at yourself/up/down */
- if ((cc.x == u.ux) && (cc.y == u.uy))
+ if (u_at(cc.x, cc.y))
return doloot();
if (stumble_on_door_mimic(cc.x, cc.y))
x = u.ux + u.dx;
y = u.uy + u.dy;
- if ((x == u.ux) && (y == u.uy)) {
+ if (u_at(x, y)) {
You("are in the way!");
return ECMD_TIME;
}
for (x = u.ux - 1; x <= u.ux + 1; x++)
for (y = u.uy - 1; y <= u.uy + 1; y++) {
- if (!isok(x, y) || (x == u.ux && y == u.uy))
+ if (!isok(x, y) || u_at(x, y))
continue;
if (accessible(x, y) && !MON_AT(x, y)) {
if ((mon = m_at(fx, fy)) != 0) /* save monster at this position */
verbalize1(md_exclamations());
- else if (fx == u.ux && fy == u.uy)
+ else if (u_at(fx, fy))
verbalize("Excuse me.");
if (mon)
coord cc;
int mndx, mcham, ct, mitem;
boolean anymon = !ptr,
- byyou = (x == u.ux && y == u.uy),
+ byyou = u_at(x, y),
allow_minvent = ((mmflags & NO_MINVENT) == 0),
countbirth = ((mmflags & MM_NOCOUNTBIRTH) == 0),
allowtail = ((mmflags & MM_NOTAIL) == 0);
*/
boolean ranged = (distu(mtmp->mx, mtmp->my) > 3),
range2 = !monnear(mtmp, mtmp->mux, mtmp->muy),
- foundyou = (mtmp->mux == u.ux && mtmp->muy == u.uy),
+ foundyou = u_at(mtmp->mux, mtmp->muy),
youseeit = canseemon(mtmp),
skipnonmagc = FALSE;
mon->mx = mon->my = 0;
mon->mstate |= MON_BUBBLEMOVE;
}
- if (!u.uswallow && x == u.ux && y == u.uy) {
+ if (!u.uswallow && u_at(x, y)) {
cons = (struct container *) alloc(sizeof *cons);
cons->x = x;
cons->y = y;
continue;
info[cnt] |= ALLOW_SSM;
}
- if ((nx == u.ux && ny == u.uy)
+ if (u_at(nx, ny)
|| (nx == mon->mux && ny == mon->muy)) {
- if (nx == u.ux && ny == u.uy) {
+ if (u_at(nx, ny)) {
/* If it's right next to you, it found you,
* displaced or no. We must set mux and muy
* right now, so when we return we can tell
* Astral Plane; the influence of the Valar only reaches so far.
*/
return (sengr_at("Elbereth", x, y, TRUE)
- && ((u.ux == x && u.uy == y)
- || (Displaced && mtmp->mux == x && mtmp->muy == y))
+ && (u_at(x, y) || (Displaced && mtmp->mux == x && mtmp->muy == y))
&& !(mtmp->isshk || mtmp->isgd || !mtmp->mcansee
|| mtmp->mpeaceful || mtmp->data->mlet == S_HUMAN
|| mtmp->data == &mons[PM_MINOTAUR]
nix = mtmp->mux;
niy = mtmp->muy;
}
- if (nix == u.ux && niy == u.uy) {
+ if (u_at(nix, niy)) {
mtmp->mux = u.ux;
mtmp->muy = u.uy;
return 0;
levl[x][y].typ = (Is_special(&u.uz) || *in_rooms(x, y, 0)) ? ROOM : CORR;
levl[x][y].flags = 0;
newsym(x, y);
- if (x == u.ux && y == u.uy)
+ if (u_at(x, y))
switch_terrain();
}
/* monsters which know where you are don't suddenly forget,
if you haven't moved away */
- if (mx == u.ux && my == u.uy)
+ if (u_at(mx, my))
goto found_you;
notseen = (!mtmp->mcansee || (Invis && !perceives(mtmp->data)));
if (!objgone) {
if (!flooreffects(obj, x, y, "fall")) {
place_object(obj, x, y);
- if (!mtmp && x == u.ux && y == u.uy)
+ if (!mtmp && u_at(x, y))
mtmp = &g.youmonst;
if (mtmp && ohit)
passive_obj(mtmp, obj, (struct attack *) 0);
} else if (mtmp) {
if (ohitmon(mtmp, singleobj, range, TRUE))
break;
- } else if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) {
+ } else if (u_at(g.bhitpos.x, g.bhitpos.y)) {
if (g.multi)
nomul(0);
/* straight line, orthogonal to the map or diagonal */
if ((!g.tbx || !g.tby || abs(g.tbx) == abs(g.tby))
&& distmin(g.tbx, g.tby, 0, 0) < BOLT_LIM) {
- if ((ax == u.ux && ay == u.uy) ? (boolean) couldsee(bx, by)
- : clear_path(ax, ay, bx, by))
+ if (u_at(ax, ay) ? (boolean) couldsee(bx, by)
+ : clear_path(ax, ay, bx, by))
return TRUE;
/* don't have line of sight, but might still be lined up
if that lack of sight is due solely to boulders */
/* skip if it's hero's location
or a diagonal spot and monster can't move diagonally
or some other monster is there */
- if ((xx == u.ux && yy == u.uy)
+ if (u_at(xx, yy)
|| (xx != x && yy != y && !diag_ok)
|| (g.level.monsters[xx][yy] && !(xx == x && yy == y)))
continue;
case WAN_STRIKING:
destroy_drawbridge(x, y);
}
- if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) {
+ if (u_at(g.bhitpos.x, g.bhitpos.y)) {
(*fhitm)(&g.youmonst, obj);
range -= 3;
} else if ((mtmp = m_at(g.bhitpos.x, g.bhitpos.y)) != 0) {
monster from attempting disarm every turn */
&& uwep && !rn2(5) && obj == MON_WEP(mtmp)
/* hero's location must be known and adjacent */
- && mtmp->mux == u.ux && mtmp->muy == u.uy
+ && u_at(mtmp->mux, mtmp->muy)
&& next2u(mtmp->mx, mtmp->my)
/* don't bother if it can't work (this doesn't
prevent cursed weapons from being targetted) */
if ((otmp = sobj_at(BOULDER, x, y)) != 0) {
if (cansee(x, y))
pline("KADOOM! The boulder falls into a chasm%s!",
- (x == u.ux && y == u.uy) ? " below you" : "");
+ u_at(x, y) ? " below you" : "");
if (mtmp)
mtmp->mtrapped = 0;
obj_extract_self(otmp);
}
}
}
- } else if (x == u.ux && y == u.uy) {
+ } else if (u_at(x, y)) {
if (u.utrap && u.utraptype == TT_BURIEDBALL) {
/* Note: the chain should break if a pit gets
created at the buried ball's location, which
buf[0] = monbuf[0] = '\0';
glyph = glyph_at(x, y);
- if (u.ux == x && u.uy == y && canspotself()
+ if (u_at(x, y) && canspotself()
&& !(iflags.save_uswallow
&& glyph == mon_to_glyph(u.ustuck, rn2_on_display_rng))
&& (!iflags.terrainmode || (iflags.terrainmode & TER_MON) != 0)) {
playing a character which isn't normally displayed by that
symbol; firstmatch is assumed to already be set for '@' */
if ((looked ? (sym == g.showsyms[S_HUMAN + SYM_OFF_M]
- && cc.x == u.ux && cc.y == u.uy)
+ && u_at(cc.x, cc.y))
: (sym == def_monsyms[S_HUMAN].sym && !flags.showrace))
&& !(Race_if(PM_HUMAN) || Race_if(PM_ELF)) && !Upolyd)
found += append_str(out_str, "you"); /* tack on "or you" */
g.bhitpos.x = x; /* [is this actually necessary?] */
g.bhitpos.y = y;
- if (x == u.ux && y == u.uy && canspotself()) {
+ if (u_at(x, y) && canspotself()) {
(void) self_lookat(lookbuf);
++count;
} else if ((mtmp = m_at(x, y)) != 0) {
if (!get_adjacent_loc("Loot in what direction?",
"Invalid loot location", u.ux, u.uy, &cc))
return ECMD_OK;
- if (cc.x == u.ux && cc.y == u.uy) {
+ if (u_at(cc.x, cc.y)) {
underfoot = TRUE;
if (container_at(cc.x, cc.y, FALSE))
goto lootcont;
ay = y = EPRI(priest)->shrpos.y;
troom = &g.rooms[roomno - ROOMOFFSET];
- if ((u.ux == x && u.uy == y) || !linedup(u.ux, u.uy, x, y, 1)) {
+ if (u_at(x, y) || !linedup(u.ux, u.uy, x, y, 1)) {
if (IS_DOOR(levl[u.ux][u.uy].typ)) {
if (u.ux == troom->lx - 1) {
x = troom->hx;
cc.y = u.uy;
}
}
- if (cc.x == u.ux && cc.y == u.uy) {
+ if (u_at(cc.x, cc.y)) {
pline_The("scroll erupts in a tower of flame!");
iflags.last_msg = PLNMSG_TOWER_OF_FLAME; /* for explode() */
burn_away_slime();
if (inside_region(reg, x, y)) {
if (!does_block(x, y, &levl[x][y]))
unblock_point(x, y);
- if (x == u.ux && y == u.uy)
+ if (u_at(x, y))
g.gas_cloud_diss_within = TRUE;
if (cansee(x, y))
g.gas_cloud_diss_seen++;
for (x = r->lx; x <= r->hx; ++x)
for (y = r->ly; y <= r->hy; ++y) {
- if (x == u.ux && y == u.uy)
+ if (u_at(x, y))
continue;
if ((mtmp = m_at(x, y)) != 0) {
++n;
pline("Try again...");
return ECMD_OK;
}
- if (u.ux == cx && u.uy == cy) {
+ if (u_at(cx, cy)) {
You("are generous to yourself.");
return ECMD_OK;
}
/* if you're not in this shk's shop room, or if you're in its doorway
or entry spot, then your gear gets dumped all the way inside */
if (*u.ushops != eshkp->shoproom || IS_DOOR(levl[u.ux][u.uy].typ)
- || (u.ux == eshkp->shk.x && u.uy == eshkp->shk.y)) {
+ || u_at(eshkp->shk.x, eshkp->shk.y)) {
/* shk.x,shk.y is the position immediately in
* front of the door -- move in one more space
*/
return FALSE;
/* is it a wall? don't fix if anyone is in the way */
if (!IS_ROOM(dam->typ)) {
- if ((x == u.ux && y == u.uy && !Passes_walls)
+ if ((u_at(x, y) && !Passes_walls)
|| (x == shkp->mx && y == shkp->my)
|| ((mtmp = m_at(x, y)) != 0 && !passes_walls(mtmp->data)))
return FALSE;
/* is it a trap? don't fix if hero or monster is in it */
ttmp = t_at(x, y);
if (ttmp) {
- if (x == u.ux && y == u.uy)
+ if (u_at(x, y))
return FALSE;
if ((mtmp = m_at(x,y)) != 0 && mtmp->mtrapped)
return FALSE;
if (Invis || u.usteed) {
avoid = FALSE;
} else {
- uondoor = (u.ux == eshkp->shd.x && u.uy == eshkp->shd.y);
+ uondoor = u_at(eshkp->shd.x, eshkp->shd.y);
if (uondoor) {
badinv =
(carrying(PICK_AXE) || carrying(DWARVISH_MATTOCK)
for (; !found && i < 2; ++i) {
for (x = u.ux - 1; x <= u.ux + 1; x++)
for (y = u.uy - 1; y <= u.uy + 1; y++) {
- if (!isok(x, y) || (x == u.ux && y == u.uy))
+ if (!isok(x, y) || u_at(x, y))
continue;
if (accessible(x, y) && !MON_AT(x, y)
* oh well.
*/
if (!allow_u) {
- if (x == u.ux && y == u.uy && mtmp != &g.youmonst
+ if (u_at(x, y) && mtmp != &g.youmonst
&& (mtmp != u.ustuck || !u.uswallow)
&& (!u.usteed || mtmp != u.usteed))
return FALSE;
if (teleok(cc.x, cc.y, FALSE)) {
/* for scroll, discover it regardless of destination */
teleds(cc.x, cc.y, TELEDS_TELEPORT);
- if (iflags.travelcc.x == u.ux && iflags.travelcc.y == u.uy)
+ if (u_at(iflags.travelcc.x, iflags.travelcc.y))
iflags.travelcc.x = iflags.travelcc.y = 0;
return;
}
if (undestroyable_trap(ttmp->ttyp))
return (struct trap *) 0;
oldplace = TRUE;
- if (u.utrap && x == u.ux && y == u.uy
+ if (u.utrap && u_at(x, y)
&& ((u.utraptype == TT_BEARTRAP && typ != BEAR_TRAP)
|| (u.utraptype == TT_WEB && typ != WEB)
|| (u.utraptype == TT_PIT && !is_pit(typ))
: golem_xform ? "turns into flesh"
: (nonliving(mon->data) || is_vampshifter(mon)) ? "moves"
: "comes to life";
- if ((x == u.ux && y == u.uy) || cause == ANIMATE_SPELL) {
+ if (u_at(x, y) || cause == ANIMATE_SPELL) {
/* "the|your|Manlobbi's statue [of a wombat]" */
shkp = shop_keeper(*in_rooms(mon->mx, mon->my, SHOPBASE));
Sprintf(statuename, "%s%s", shk_your(tmpbuf, statue),
delobj(statue);
/* avoid hiding under nothing */
- if (x == u.ux && y == u.uy && Upolyd && hides_under(g.youmonst.data)
+ if (u_at(x, y) && Upolyd && hides_under(g.youmonst.data)
&& !OBJ_AT(x, y))
u.uundetected = 0;
launch_drop_spot((struct obj *) 0, 0, 0);
break;
}
- } else if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) {
+ } else if (u_at(g.bhitpos.x, g.bhitpos.y)) {
if (g.multi)
nomul(0);
if (thitu(9 + singleobj->spe, dmgval(singleobj, &g.youmonst),
stackobj(otmp);
}
newsym(ttmp->tx, ttmp->ty);
- if (u.utrap && ttmp->tx == u.ux && ttmp->ty == u.uy)
+ if (u.utrap && u_at(ttmp->tx, ttmp->ty))
reset_utrap(TRUE);
deltrap(ttmp);
}
if (ttmp && !ttmp->tseen)
ttmp = 0;
trapdescr = ttmp ? trapname(ttmp->ttyp, FALSE) : 0;
- here = (x == u.ux && y == u.uy); /* !u.dx && !u.dy */
+ here = u_at(x, y); /* !u.dx && !u.dy */
if (here) /* are there are one or more containers here? */
for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere)
if (deal_with_floor_trap) {
if (u.utrap) {
You("cannot deal with %s while trapped%s!", the_trap,
- (x == u.ux && y == u.uy) ? " in it" : "");
+ u_at(x, y) ? " in it" : "");
return 1;
}
if ((mtmp = m_at(x, y)) != 0
delete_contents(obj);
/* unpunish() in advance if either ball or chain (or both)
is going to be destroyed */
- if (Punished && ((uchain->ox == u.ux && uchain->oy == u.uy)
+ if (Punished && (u_at(uchain->ox, uchain->oy)
|| (uball->where == OBJ_FLOOR
- && uball->ox == u.ux && uball->oy == u.uy)))
+ && u_at(uball->ox, uball->oy))))
unpunish();
for (otmp = g.level.objects[u.ux][u.uy]; otmp; otmp = otmp2) {
uteetering_at_seen_pit(struct trap* trap)
{
return (trap && is_pit(trap->ttyp) && trap->tseen
- && trap->tx == u.ux && trap->ty == u.uy
+ && u_at(trap->tx, trap->ty)
&& !(u.utrap && u.utraptype == TT_PIT));
}
uescaped_shaft(struct trap* trap)
{
return (trap && is_hole(trap->ttyp) && trap->tseen
- && trap->tx == u.ux && trap->ty == u.uy);
+ && u_at(trap->tx, trap->ty));
}
/* Destroy a trap that emanates from the floor. */
|| (ttmp->ttyp == ANTI_MAGIC))) {
register struct monst *mtmp;
- if (ttmp->tx == u.ux && ttmp->ty == u.uy) {
+ if (u_at(ttmp->tx, ttmp->ty)) {
if (u.utraptype != TT_BURIEDBALL)
reset_utrap(TRUE);
} else if ((mtmp = m_at(ttmp->tx, ttmp->ty)) != 0) {
if ((DEADMONSTER(grd) || !in_fcorridor(grd, u.ux, u.uy))
&& egrd->gddone)
forceshow = TRUE;
- if ((u.ux == fcx && u.uy == fcy && !DEADMONSTER(grd))
+ if ((u_at(fcx, fcy) && !DEADMONSTER(grd))
|| (!forceshow && couldsee(fcx, fcy))
|| (Punished && !carried(uball) && uball->ox == fcx
&& uball->oy == fcy))
else
y += dy;
}
- if (x == u.ux && y == u.uy) {
+ if (u_at(x, y)) {
if (levl[x + 1][y].typ == HWALL || levl[x + 1][y].typ == DOOR)
x = x + 1;
else if (levl[x - 1][y].typ == HWALL
coord newcc, bestcc;
int gdelta, newdelta, bestdelta, tryct,
guardx = grd->mx, guardy = grd->my;
- boolean under_u = (goldx == u.ux && goldy == u.uy),
+ boolean under_u = u_at(goldx, goldy),
see_it = cansee(goldx, goldy);
if (under_u) {
if (!targ) { /* simply wants you to close */
return 0;
}
- if ((u.ux == tx && u.uy == ty) || where == STRAT_PLAYER) {
+ if (u_at(tx, ty) || where == STRAT_PLAYER) {
/* player is standing on it (or has it) */
mnexto(mtmp, RLOC_MSG);
return 0;
g.bhitpos.y -= dy;
break;
}
- if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) { /* ct == 9 */
+ if (u_at(g.bhitpos.x, g.bhitpos.y)) { /* ct == 9 */
if (Fumbling || rn2(20) >= ACURR(A_DEX)) {
/* we hit ourselves */
(void) thitu(10 + obj->spe, dmgval(obj, &g.youmonst), &obj,
/* save name before potential delobj() */
if (give_feedback) {
obj->quan = 1L;
- Strcpy(buf1, (x == u.ux && y == u.uy)
+ Strcpy(buf1, u_at(x, y)
? xname(obj)
: distant_name(obj, xname));
obj->quan = 2L;
- Strcpy(buf2, (x == u.ux && y == u.uy)
+ Strcpy(buf2, u_at(x, y)
? xname(obj)
: distant_name(obj, xname));
obj->quan = scrquan;
if (say || canseemon(mon))
miss(flash_str(fltyp, FALSE), mon);
}
- } else if (sx == u.ux && sy == u.uy && range >= 0) {
+ } else if (u_at(sx, sy) && range >= 0) {
nomul(0);
if (u.usteed && !rn2(3) && !mon_reflects(u.usteed, (char *) 0)) {
mon = u.usteed;
if (Underwater)
vision_recalc(1);
newsym(x, y);
- if (cansee(x, y) || (x == u.ux && y == u.uy))
+ if (cansee(x, y) || u_at(x, y))
Norep("%s", msg);
if ((otmp = sobj_at(BOULDER, x, y)) != 0) {
if (cansee(x, y))
} while (is_pool(x, y) && (otmp = sobj_at(BOULDER, x, y)) != 0);
newsym(x, y);
}
- if (x == u.ux && y == u.uy)
+ if (u_at(x, y))
spoteffects(TRUE); /* possibly drown, notice objects */
else if (is_pool(x, y) && (mtmp = m_at(x, y)) != 0)
(void) minliquid(mtmp);
} else if (!lava)
You_hear("a crackling sound.");
- if (x == u.ux && y == u.uy) {
+ if (u_at(x, y)) {
if (u.uinwater) { /* not just `if (Underwater)' */
/* leave the no longer existent water */
set_uinwater(0); /* u.uinwater = 0 */