Unify pits

This commit is contained in:
Pasi Kallinen
2020-12-10 19:04:30 +02:00
parent 5773f49dfe
commit afa1fef1ff
+54 -36
View File
@@ -20,7 +20,7 @@ static int FDECL(trapeffect_bear_trap, (struct monst *, struct trap *, unsigned)
static int FDECL(trapeffect_slp_gas_trap, (struct monst *, struct trap *, unsigned)); static int FDECL(trapeffect_slp_gas_trap, (struct monst *, struct trap *, unsigned));
static int FDECL(trapeffect_rust_trap, (struct monst *, struct trap *, unsigned)); static int FDECL(trapeffect_rust_trap, (struct monst *, struct trap *, unsigned));
static int FDECL(trapeffect_fire_trap, (struct monst *, struct trap *, unsigned)); static int FDECL(trapeffect_fire_trap, (struct monst *, struct trap *, unsigned));
static void FDECL(trapeffect_pit, (struct trap *, unsigned)); static int FDECL(trapeffect_pit, (struct monst *, struct trap *, unsigned));
static void FDECL(trapeffect_hole, (struct trap *, unsigned)); static void FDECL(trapeffect_hole, (struct trap *, unsigned));
static void FDECL(trapeffect_telep_trap, (struct trap *, unsigned)); static void FDECL(trapeffect_telep_trap, (struct trap *, unsigned));
static void FDECL(trapeffect_level_telep, (struct trap *, unsigned)); static void FDECL(trapeffect_level_telep, (struct trap *, unsigned));
@@ -1479,12 +1479,15 @@ unsigned trflags;
return 0; return 0;
} }
static void static int
trapeffect_pit(trap, trflags) trapeffect_pit(mtmp, trap, trflags)
struct monst *mtmp;
struct trap *trap; struct trap *trap;
unsigned trflags; unsigned trflags;
{ {
int ttype = trap->ttyp; int ttype = trap->ttyp;
if (mtmp == &g.youmonst) {
boolean plunged = (trflags & TOOKPLUNGE) != 0; boolean plunged = (trflags & TOOKPLUNGE) != 0;
boolean conj_pit = conjoined_pits(trap, t_at(u.ux0, u.uy0), TRUE); boolean conj_pit = conjoined_pits(trap, t_at(u.ux0, u.uy0), TRUE);
boolean adj_pit = adj_nonconjoined_pit(trap); boolean adj_pit = adj_nonconjoined_pit(trap);
@@ -1493,7 +1496,7 @@ unsigned trflags;
/* KMH -- You can't escape the Sokoban level traps */ /* KMH -- You can't escape the Sokoban level traps */
if (!Sokoban && (Levitation || (Flying && !plunged))) if (!Sokoban && (Levitation || (Flying && !plunged)))
return; return 0;
feeltrap(trap); feeltrap(trap);
if (!Sokoban && is_clinger(g.youmonst.data) && !plunged) { if (!Sokoban && is_clinger(g.youmonst.data) && !plunged) {
if (trap->tseen) { if (trap->tseen) {
@@ -1504,7 +1507,7 @@ unsigned trflags;
ttype == SPIKED_PIT ? "full of spikes " : ""); ttype == SPIKED_PIT ? "full of spikes " : "");
You("don't fall in!"); You("don't fall in!");
} }
return; return 0;
} }
if (!Sokoban) { if (!Sokoban) {
char verbbuf[BUFSZ]; char verbbuf[BUFSZ];
@@ -1600,6 +1603,50 @@ unsigned trflags;
exercise(A_STR, FALSE); exercise(A_STR, FALSE);
exercise(A_DEX, FALSE); exercise(A_DEX, FALSE);
} }
} else {
int tt = trap->ttyp;
boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
boolean trapkilled = FALSE;
boolean inescapable = (g.force_mintrap
|| ((tt == HOLE || tt == PIT)
&& Sokoban && !trap->madeby_u));
struct permonst *mptr = mtmp->data;
const char *fallverb;
fallverb = "falls";
if (is_flyer(mptr) || is_floater(mptr)
|| (mtmp->wormno && count_wsegs(mtmp) > 5)
|| is_clinger(mptr)) {
if (g.force_mintrap && !Sokoban) {
/* openfallingtrap; not inescapable here */
if (in_sight) {
seetrap(trap);
pline("%s doesn't fall into the pit.", Monnam(mtmp));
}
return 0;
}
if (!inescapable)
return 0; /* avoids trap */
fallverb = "is dragged"; /* sokoban pit */
}
if (!passes_walls(mptr))
mtmp->mtrapped = 1;
if (in_sight) {
pline("%s %s into %s pit!", Monnam(mtmp), fallverb,
a_your[trap->madeby_u]);
if (mptr == &mons[PM_PIT_VIPER]
|| mptr == &mons[PM_PIT_FIEND])
pline("How pitiful. Isn't that the pits?");
seetrap(trap);
}
mselftouch(mtmp, "Falling, ", FALSE);
if (DEADMONSTER(mtmp) || thitm(0, mtmp, (struct obj *) 0,
rnd((tt == PIT) ? 6 : 10), FALSE))
trapkilled = TRUE;
return trapkilled ? 2 : mtmp->mtrapped;
}
return 0;
} }
static void static void
@@ -2022,7 +2069,7 @@ unsigned trflags;
case PIT: case PIT:
case SPIKED_PIT: case SPIKED_PIT:
trapeffect_pit(trap, trflags); (void) trapeffect_pit(&g.youmonst, trap, trflags);
break; break;
case HOLE: case HOLE:
@@ -2742,36 +2789,7 @@ register struct monst *mtmp;
break; break;
case PIT: case PIT:
case SPIKED_PIT: case SPIKED_PIT:
fallverb = "falls"; return trapeffect_pit(mtmp, trap, 0);
if (is_flyer(mptr) || is_floater(mptr)
|| (mtmp->wormno && count_wsegs(mtmp) > 5)
|| is_clinger(mptr)) {
if (g.force_mintrap && !Sokoban) {
/* openfallingtrap; not inescapable here */
if (in_sight) {
seetrap(trap);
pline("%s doesn't fall into the pit.", Monnam(mtmp));
}
break; /* inescapable = FALSE; */
}
if (!inescapable)
break; /* avoids trap */
fallverb = "is dragged"; /* sokoban pit */
}
if (!passes_walls(mptr))
mtmp->mtrapped = 1;
if (in_sight) {
pline("%s %s into %s pit!", Monnam(mtmp), fallverb,
a_your[trap->madeby_u]);
if (mptr == &mons[PM_PIT_VIPER]
|| mptr == &mons[PM_PIT_FIEND])
pline("How pitiful. Isn't that the pits?");
seetrap(trap);
}
mselftouch(mtmp, "Falling, ", FALSE);
if (DEADMONSTER(mtmp) || thitm(0, mtmp, (struct obj *) 0,
rnd((tt == PIT) ? 6 : 10), FALSE))
trapkilled = TRUE;
break; break;
case HOLE: case HOLE:
case TRAPDOOR: case TRAPDOOR: