Use is_pit macro to check for (spiked) pit

This commit is contained in:
Pasi Kallinen
2018-09-15 17:19:26 +03:00
parent bd23a56f29
commit adf070eb04
18 changed files with 52 additions and 55 deletions

View File

@@ -328,8 +328,7 @@ int x, y, typ;
if (u.utrap && x == u.ux && y == u.uy
&& ((u.utraptype == TT_BEARTRAP && typ != BEAR_TRAP)
|| (u.utraptype == TT_WEB && typ != WEB)
|| (u.utraptype == TT_PIT && typ != PIT
&& typ != SPIKED_PIT)))
|| (u.utraptype == TT_PIT && !is_pit(typ))))
u.utrap = 0;
/* old <tx,ty> remain valid */
} else if (IS_FURNITURE(lev->typ)
@@ -862,7 +861,7 @@ unsigned trflags;
nomul(0);
/* KMH -- You can't escape the Sokoban level traps */
if (Sokoban && (ttype == PIT || ttype == SPIKED_PIT
if (Sokoban && (is_pit(ttype)
|| ttype == HOLE || ttype == TRAPDOOR)) {
/* The "air currents" message is still appropriate -- even when
* the hero isn't flying or levitating -- because it conveys the
@@ -875,7 +874,7 @@ unsigned trflags;
/* then proceed to normal trap effect */
} else if (already_seen && !forcetrap) {
if ((Levitation || (Flying && !plunged))
&& (ttype == PIT || ttype == SPIKED_PIT || ttype == HOLE
&& (is_pit(ttype) || ttype == HOLE
|| ttype == BEAR_TRAP)) {
You("%s over %s %s.", Levitation ? "float" : "fly",
a_your[trap->madeby_u],
@@ -885,7 +884,7 @@ unsigned trflags;
if (!Fumbling && ttype != MAGIC_PORTAL && ttype != VIBRATING_SQUARE
&& ttype != ANTI_MAGIC && !forcebungle && !plunged
&& !conj_pit && !adj_pit
&& (!rn2(5) || ((ttype == PIT || ttype == SPIKED_PIT)
&& (!rn2(5) || (is_pit(ttype)
&& is_clinger(youmonst.data)))) {
You("escape %s %s.", (ttype == ARROW_TRAP && !trap->madeby_u)
? "an"
@@ -2075,8 +2074,8 @@ register struct monst *mtmp;
mtmp->mtrapped = 0; /* perhaps teleported? */
} else if (mtmp->mtrapped) { /* is currently in the trap */
if (!trap->tseen && cansee(mtmp->mx, mtmp->my) && canseemon(mtmp)
&& (trap->ttyp == SPIKED_PIT || trap->ttyp == BEAR_TRAP
|| trap->ttyp == HOLE || trap->ttyp == PIT
&& (is_pit(trap->ttyp) || trap->ttyp == BEAR_TRAP
|| trap->ttyp == HOLE
|| trap->ttyp == WEB)) {
/* If you come upon an obviously trapped monster, then
* you must be able to see the trap it's in too.
@@ -2086,7 +2085,7 @@ register struct monst *mtmp;
if (!rn2(40)) {
if (sobj_at(BOULDER, mtmp->mx, mtmp->my)
&& (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) {
&& is_pit(trap->ttyp)) {
if (!rn2(2)) {
mtmp->mtrapped = 0;
if (canseemon(mtmp))
@@ -2818,7 +2817,7 @@ int x, y;
struct obj *otmp;
struct trap *t;
if ((t = t_at(x, y)) && ((t->ttyp == PIT) || (t->ttyp == SPIKED_PIT))
if ((t = t_at(x, y)) && is_pit(t->ttyp)
&& (otmp = sobj_at(BOULDER, x, y))) {
obj_extract_self(otmp);
(void) flooreffects(otmp, x, y, "settle");
@@ -2865,7 +2864,7 @@ long hmask, emask; /* might cancel timeout */
if (Punished && !carried(uball)
&& (is_pool(uball->ox, uball->oy)
|| ((trap = t_at(uball->ox, uball->oy))
&& ((trap->ttyp == PIT) || (trap->ttyp == SPIKED_PIT)
&& (is_pit(trap->ttyp)
|| (trap->ttyp == TRAPDOOR) || (trap->ttyp == HOLE))))) {
u.ux0 = u.ux;
u.uy0 = u.uy;
@@ -4313,7 +4312,7 @@ boolean force;
if (ttmp) {
Strcpy(the_trap, the(trapdescr));
if (boxcnt) {
if (ttmp->ttyp == PIT || ttmp->ttyp == SPIKED_PIT) {
if (is_pit(ttmp->ttyp)) {
You_cant("do much about %s%s.", the_trap,
u.utrap ? " that you're stuck in"
: " while standing on the edge of it");
@@ -4615,8 +4614,7 @@ boolean *noticed; /* set to true iff hero notices the effect; */
/* if no trap here or it's not a falling trap, we're done
(note: falling rock traps have a trapdoor in the ceiling) */
if (!t || ((t->ttyp != TRAPDOOR && t->ttyp != ROCKTRAP)
&& (trapdoor_only || (t->ttyp != HOLE && t->ttyp != PIT
&& t->ttyp != SPIKED_PIT))))
&& (trapdoor_only || (t->ttyp != HOLE && !is_pit(t->ttyp)))))
return FALSE;
if (ishero) {
@@ -4875,8 +4873,8 @@ boolean u_entering_trap2;
if (!trap1 || !trap2)
return FALSE;
if (!isok(trap2->tx, trap2->ty) || !isok(trap1->tx, trap1->ty)
|| !(trap2->ttyp == PIT || trap2->ttyp == SPIKED_PIT)
|| !(trap1->ttyp == PIT || trap1->ttyp == SPIKED_PIT)
|| !is_pit(trap2->ttyp)
|| !is_pit(trap1->ttyp)
|| (u_entering_trap2 && !(u.utrap && u.utraptype == TT_PIT)))
return FALSE;
dx = sgn(trap2->tx - trap1->tx);
@@ -4901,14 +4899,14 @@ struct trap *trap;
int diridx, adjidx, x, y;
struct trap *t;
if (trap && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) {
if (trap && is_pit(trap->ttyp)) {
for (diridx = 0; diridx < 8; ++diridx) {
if (trap->conjoined & (1 << diridx)) {
x = trap->tx + xdir[diridx];
y = trap->ty + ydir[diridx];
if (isok(x, y)
&& (t = t_at(x, y)) != 0
&& (t->ttyp == PIT || t->ttyp == SPIKED_PIT)) {
&& is_pit(t->ttyp)) {
adjidx = (diridx + 4) % 8;
t->conjoined &= ~(1 << adjidx);
}
@@ -4925,8 +4923,8 @@ struct trap *adjtrap;
struct trap *trap_with_u = t_at(u.ux0, u.uy0);
if (trap_with_u && adjtrap && u.utrap && u.utraptype == TT_PIT &&
(trap_with_u->ttyp == PIT || trap_with_u->ttyp == SPIKED_PIT) &&
(adjtrap->ttyp == PIT || adjtrap->ttyp == SPIKED_PIT)) {
is_pit(trap_with_u->ttyp) &&
is_pit(adjtrap->ttyp)) {
int idx;
for (idx = 0; idx < 8; idx++) {
if (xdir[idx] == u.dx && ydir[idx] == u.dy)
@@ -4955,7 +4953,7 @@ struct trap *trap;
y = trap->ty + ydir[diridx];
if (isok(x, y)) {
if ((t = t_at(x, y)) != 0
&& (t->ttyp == PIT || t->ttyp == SPIKED_PIT)) {
&& is_pit(t->ttyp)) {
trap->conjoined |= (1 << diridx);
join_adjacent_pits(t);
} else
@@ -4973,7 +4971,7 @@ uteetering_at_seen_pit(trap)
struct trap *trap;
{
if (trap && trap->tseen && (!u.utrap || u.utraptype != TT_PIT)
&& (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT))
&& is_pit(trap->ttyp))
return TRUE;
else
return FALSE;
@@ -4987,7 +4985,7 @@ register struct trap *ttmp;
/* some of these are arbitrary -dlc */
if (ttmp && ((ttmp->ttyp == SQKY_BOARD) || (ttmp->ttyp == BEAR_TRAP)
|| (ttmp->ttyp == LANDMINE) || (ttmp->ttyp == FIRE_TRAP)
|| (ttmp->ttyp == PIT) || (ttmp->ttyp == SPIKED_PIT)
|| is_pit(ttmp->ttyp)
|| (ttmp->ttyp == HOLE) || (ttmp->ttyp == TRAPDOOR)
|| (ttmp->ttyp == TELEP_TRAP) || (ttmp->ttyp == LEVEL_TELEP)
|| (ttmp->ttyp == WEB) || (ttmp->ttyp == MAGIC_TRAP)