pull request #1174 - trapeffect code cleanup

Pull request from entrez:  some old trap code became obsolete or
at least less useful when the trap routine was split into separate
routines for each type of trap.  The type of trap currently being
handled is already known by each of those routines.

Closes #1174
This commit is contained in:
PatR
2024-01-22 17:04:02 -08:00
+7 -15
View File
@@ -1671,7 +1671,6 @@ trapeffect_pit(
boolean already_known = trap->tseen ? TRUE : FALSE; boolean already_known = trap->tseen ? TRUE : FALSE;
boolean deliberate = FALSE; boolean deliberate = FALSE;
int steed_article = ARTICLE_THE; int steed_article = ARTICLE_THE;
int oldumort;
/* suppress article in various steed messages when using its /* suppress article in various steed messages when using its
name (which won't occur when hallucinating) */ name (which won't occur when hallucinating) */
@@ -1749,7 +1748,8 @@ trapeffect_pit(
set_utrap((unsigned) rn1(6, 2), TT_PIT); set_utrap((unsigned) rn1(6, 2), TT_PIT);
if (!steedintrap(trap, (struct obj *) 0)) { if (!steedintrap(trap, (struct obj *) 0)) {
if (ttype == SPIKED_PIT) { if (ttype == SPIKED_PIT) {
oldumort = u.umortality; int oldumort = u.umortality;
losehp(Maybe_Half_Phys(rnd(conj_pit ? 4 : adj_pit ? 6 : 10)), losehp(Maybe_Half_Phys(rnd(conj_pit ? 4 : adj_pit ? 6 : 10)),
/* note: these don't need locomotion() handling; /* note: these don't need locomotion() handling;
if fatal while poly'd and Unchanging, the if fatal while poly'd and Unchanging, the
@@ -1792,13 +1792,10 @@ trapeffect_pit(
exercise(A_DEX, FALSE); exercise(A_DEX, FALSE);
} }
} else { } else {
int tt = trap->ttyp;
boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed); boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
boolean trapkilled = FALSE; boolean trapkilled = FALSE;
boolean forcetrap = ((trflags & FORCETRAP) != 0); boolean forcetrap = ((trflags & FORCETRAP) != 0);
boolean inescapable = (forcetrap boolean inescapable = (forcetrap || (Sokoban && !trap->madeby_u));
|| ((tt == HOLE || tt == PIT)
&& Sokoban && !trap->madeby_u));
struct permonst *mptr = mtmp->data; struct permonst *mptr = mtmp->data;
const char *fallverb; const char *fallverb;
@@ -1814,7 +1811,7 @@ trapeffect_pit(
return Trap_Effect_Finished; return Trap_Effect_Finished;
} }
if (!inescapable) if (!inescapable)
return Trap_Effect_Finished; /* avoids trap */ return Trap_Effect_Finished; /* avoids trap */
fallverb = "is dragged"; /* sokoban pit */ fallverb = "is dragged"; /* sokoban pit */
} }
if (!passes_walls(mptr)) if (!passes_walls(mptr))
@@ -1830,7 +1827,7 @@ trapeffect_pit(
} }
mselftouch(mtmp, "Falling, ", FALSE); mselftouch(mtmp, "Falling, ", FALSE);
if (DEADMONSTER(mtmp) || thitm(0, mtmp, (struct obj *) 0, if (DEADMONSTER(mtmp) || thitm(0, mtmp, (struct obj *) 0,
rnd((tt == PIT) ? 6 : 10), FALSE)) rnd((ttype == PIT) ? 6 : 10), FALSE))
trapkilled = TRUE; trapkilled = TRUE;
return trapkilled ? Trap_Killed_Mon : mtmp->mtrapped return trapkilled ? Trap_Killed_Mon : mtmp->mtrapped
@@ -1858,9 +1855,7 @@ trapeffect_hole(
struct permonst *mptr = mtmp->data; struct permonst *mptr = mtmp->data;
boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed); boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
boolean forcetrap = ((trflags & FORCETRAP) != 0); boolean forcetrap = ((trflags & FORCETRAP) != 0);
boolean inescapable = (forcetrap boolean inescapable = (forcetrap || (Sokoban && !trap->madeby_u));
|| ((tt == HOLE || tt == PIT)
&& Sokoban && !trap->madeby_u));
if (!Can_fall_thru(&u.uz)) { if (!Can_fall_thru(&u.uz)) {
impossible("mintrap: %ss cannot exist on this level.", impossible("mintrap: %ss cannot exist on this level.",
@@ -1931,11 +1926,8 @@ trapeffect_level_telep(
int tt = trap->ttyp; int tt = trap->ttyp;
boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed); boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
boolean forcetrap = ((trflags & FORCETRAP) != 0); boolean forcetrap = ((trflags & FORCETRAP) != 0);
boolean inescapable = (forcetrap
|| ((tt == HOLE || tt == PIT)
&& Sokoban && !trap->madeby_u));
return mlevel_tele_trap(mtmp, trap, inescapable, in_sight); return mlevel_tele_trap(mtmp, trap, forcetrap, in_sight);
} }
return Trap_Effect_Finished; return Trap_Effect_Finished;
} }