/* ### dbridge.c ### */
+extern boolean is_waterwall(xchar, xchar);
extern boolean is_pool(int, int);
extern boolean is_lava(int, int);
extern boolean is_pool_or_lava(int, int);
#define IS_FURNITURE(typ) ((typ) >= STAIRS && (typ) <= ALTAR)
#define IS_AIR(typ) ((typ) == AIR || (typ) == CLOUD)
#define IS_SOFT(typ) ((typ) == AIR || (typ) == CLOUD || IS_POOL(typ))
+#define IS_WATERWALL(typ) ((typ) == WATER)
/*
* Note: secret doors (SDOOR) want to use both rm.doormask and
static boolean e_jumps(struct entity *);
static void do_entity(struct entity *);
+boolean
+is_waterwall(xchar x, xchar y)
+{
+ if (isok(x, y) && IS_WATERWALL(levl[x][y].typ))
+ return TRUE;
+ return FALSE;
+}
+
boolean
is_pool(int x, int y)
{
switch_terrain();
if (is_pool(x, y) && !u.uinwater) {
- if ((Is_waterlevel(&u.uz) && levl[x][y].typ == WATER)
+ if ((Is_waterlevel(&u.uz) && is_waterwall(x,y))
|| !(Levitation || Flying || Wwalking)) {
g.multi = 0; /* can move, so drown() allows crawling out of water */
(void) drown();
{
boolean u_in_air = (Levitation || Flying || !grounded(g.youmonst.data));
- if (levl[x][y].typ == WATER)
+ if (is_waterwall(x,y))
return WATER; /* wall of water, fly/lev does not matter */
if (!u_in_air) {
if (is_pool(x,y))
swim_move_danger(xchar x, xchar y)
{
schar newtyp = u_simple_floortyp(x, y);
- boolean liquid_wall = (newtyp == WATER);
+ boolean liquid_wall = IS_WATERWALL(newtyp);
if ((newtyp != u_simple_floortyp(u.ux, u.uy))
&& !Stunned && !Confusion && levl[x][y].seenv
{
struct rm *lev = &levl[u.ux][u.uy];
boolean blocklev = (IS_ROCK(lev->typ) || closed_door(u.ux, u.uy)
- || lev->typ == WATER),
+ || IS_WATERWALL(lev->typ)),
was_levitating = !!Levitation, was_flying = !!Flying;
if (blocklev) {
if (is_lava(u.ux, u.uy)) {
if (lava_effects())
return TRUE;
- } else if ((!Wwalking || levl[u.ux][u.uy].typ == WATER)
+ } else if ((!Wwalking || is_waterwall(u.ux,u.uy))
&& (newspot || !u.uinwater || !(Swimming || Amphibious))) {
if (drown())
return TRUE;
&& !is_undirected_spell(mattk->adtyp, spellnum)) {
pline("%s casts a spell at %s!",
canseemon(mtmp) ? Monnam(mtmp) : "Something",
- levl[mtmp->mux][mtmp->muy].typ == WATER ? "empty water"
- : "thin air");
+ is_waterwall(mtmp->mux,mtmp->muy) ? "empty water"
+ : "thin air");
return 0;
}
break;
case 2:
pline("%s strikes at %s!", Monst_name,
- (levl[mtmp->mux][mtmp->muy].typ == WATER)
+ is_waterwall(mtmp->mux,mtmp->muy)
? "empty water"
: "thin air");
break;
if (!ufound) {
pline("%s explodes at a spot in %s!",
canseemon(mtmp) ? Monnam(mtmp) : "It",
- levl[mtmp->mux][mtmp->muy].typ == WATER ? "empty water"
- : "thin air");
+ is_waterwall(mtmp->mux,mtmp->muy) ? "empty water"
+ : "thin air");
} else {
hitmsg(mtmp, mattk);
}
minliquid_core(struct monst* mtmp)
{
boolean inpool, inlava, infountain;
- boolean waterwall = (levl[mtmp->mx][mtmp->my].typ == WATER);
+ boolean waterwall = is_waterwall(mtmp->mx,mtmp->my);
/* [ceiling clingers are handled below] */
inpool = (is_pool(mtmp->mx, mtmp->my)
nodiag = NODIAG(mdat - mons);
wantpool = (mdat->mlet == S_EEL);
- poolok = ((!Is_waterlevel(&u.uz) && !(nowtyp != WATER)
+ poolok = ((!Is_waterlevel(&u.uz) && IS_WATERWALL(nowtyp)
&& !grounded(mdat))
|| (is_swimmer(mdat) && !wantpool));
/* note: floating eye is the only is_floater() so this could be
if (!isok(bx, by))
return FALSE;
if (IS_ROCK(levl[bx][by].typ) || closed_door(bx, by)
- || levl[bx][by].typ == WATER)
+ || is_waterwall(bx, by))
return FALSE;
if ((*fnc)(bx, by))
return TRUE;
/* <bx,by> is guaranteed to eventually converge with <ax,ay> */
bx += dx, by += dy;
if (IS_ROCK(levl[bx][by].typ) || closed_door(bx, by)
- || levl[bx][by].typ == WATER)
+ || is_waterwall(bx, by))
return FALSE;
if (sobj_at(BOULDER, bx, by))
++boulderspots;
} else {
return "moat";
}
- } else if (ltyp == WATER) {
+ } else if (IS_WATERWALL(ltyp)) {
if (Is_waterlevel(&u.uz))
return "limitless water"; /* even if hallucinating */
Snprintf(pooltype, sizeof pooltype, "wall of %s", hliquid("water"));
if (mtmp == &g.youmonst)
return (Swimming || Amphibious
|| (!Is_waterlevel(&u.uz)
- && !(levl[x][y].typ == WATER)
+ && !is_waterwall(x, y)
/* water on the Plane of Water has no surface
so there's no way to be on or above that */
&& (Levitation || Flying || Wwalking)));
else
return (is_swimmer(mdat)
|| (!Is_waterlevel(&u.uz)
- && !(levl[x][y].typ == WATER)
+ && !is_waterwall(x, y)
&& !grounded(mdat)));
} else if (mdat->mlet == S_EEL && rn2(13) && !ignorewater) {
return FALSE;
const char *pool_of_water;
boolean inpool_ok = FALSE, crawl_ok;
int i, x, y;
- boolean is_solid = (levl[u.ux][u.uy].typ == WATER);
+ boolean is_solid = is_waterwall(u.ux, u.uy);
feel_newsym(u.ux, u.uy); /* in case Blind, map the water here */
/* happily wading in the same contiguous pool */
} else if (u.ustuck == magr) {
if (is_pool(magr->mx, magr->my) && !Swimming && !Amphibious) {
boolean moat = (levl[magr->mx][magr->my].typ != POOL)
- && (levl[magr->mx][magr->my].typ != WATER)
+ && !is_waterwall(magr->mx, magr->my)
&& !Is_medusa_level(&u.uz)
&& !Is_waterlevel(&u.uz);
&& (lev->doormask & (D_CLOSED | D_LOCKED | D_TRAPPED))))
return 1;
- if (lev->typ == CLOUD || lev->typ == WATER
+ if (lev->typ == CLOUD || IS_WATERWALL(lev->typ)
|| (lev->typ == MOAT && Underwater))
return 1;
typ = levl[g.bhitpos.x][g.bhitpos.y].typ;
/* WATER aka "wall of water" stops items */
- if (typ == WATER) {
+ if (IS_WATERWALL(typ)) {
if (weapon == THROWN_WEAPON || weapon == KICKED_WEAPON)
break;
}
boolean lava = is_lava(x, y),
moat = is_moat(x, y);
- if (lev->typ == WATER) {
+ if (IS_WATERWALL(lev->typ)) {
/* For now, don't let WATER freeze. */
if (see_it)
pline_The("%s freezes for a moment.", hliquid("water"));