Unify rocktrap

This commit is contained in:
Pasi Kallinen
2020-12-10 19:04:29 +02:00
parent 485985968e
commit a1227cefb3
+32 -21
View File
@@ -14,7 +14,7 @@ static boolean FDECL(mu_maybe_destroy_web, (struct monst *, BOOLEAN_P,
static struct obj *FDECL(t_missile, (int, struct trap *)); static struct obj *FDECL(t_missile, (int, struct trap *));
static int FDECL(trapeffect_arrow_trap, (struct monst *, struct trap *, unsigned)); static int FDECL(trapeffect_arrow_trap, (struct monst *, struct trap *, unsigned));
static int FDECL(trapeffect_dart_trap, (struct monst *, struct trap *, unsigned)); static int FDECL(trapeffect_dart_trap, (struct monst *, struct trap *, unsigned));
static void FDECL(trapeffect_rocktrap, (struct trap *, unsigned)); static int FDECL(trapeffect_rocktrap, (struct monst *, struct trap *, unsigned));
static void FDECL(trapeffect_sqky_board, (struct trap *, unsigned)); static void FDECL(trapeffect_sqky_board, (struct trap *, unsigned));
static void FDECL(trapeffect_bear_trap, (struct trap *, unsigned)); static void FDECL(trapeffect_bear_trap, (struct trap *, unsigned));
static void FDECL(trapeffect_slp_gas_trap, (struct trap *, unsigned)); static void FDECL(trapeffect_slp_gas_trap, (struct trap *, unsigned));
@@ -1046,11 +1046,15 @@ unsigned trflags;
return 0; return 0;
} }
static void static int
trapeffect_rocktrap(trap, trflags) trapeffect_rocktrap(mtmp, trap, trflags)
struct monst *mtmp;
struct trap *trap; struct trap *trap;
unsigned trflags; unsigned trflags;
{ {
struct obj *otmp;
if (mtmp == &g.youmonst) {
if (trap->once && trap->tseen && !rn2(15)) { if (trap->once && trap->tseen && !rn2(15)) {
pline("A trap door in %s opens, but nothing falls out!", pline("A trap door in %s opens, but nothing falls out!",
the(ceiling(u.ux, u.uy))); the(ceiling(u.ux, u.uy)));
@@ -1058,7 +1062,6 @@ unsigned trflags;
newsym(u.ux, u.uy); newsym(u.ux, u.uy);
} else { } else {
int dmg = d(2, 6); /* should be std ROCK dmg? */ int dmg = d(2, 6); /* should be std ROCK dmg? */
struct obj *otmp;
trap->once = 1; trap->once = 1;
feeltrap(trap); feeltrap(trap);
@@ -1083,6 +1086,29 @@ unsigned trflags;
losehp(Maybe_Half_Phys(dmg), "falling rock", KILLED_BY_AN); losehp(Maybe_Half_Phys(dmg), "falling rock", KILLED_BY_AN);
exercise(A_STR, FALSE); exercise(A_STR, FALSE);
} }
} else {
boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
boolean see_it = cansee(mtmp->mx, mtmp->my);
boolean trapkilled = FALSE;
if (trap->once && trap->tseen && !rn2(15)) {
if (in_sight && see_it)
pline("A trap door above %s opens, but nothing falls out!",
mon_nam(mtmp));
deltrap(trap);
newsym(mtmp->mx, mtmp->my);
return 0;
}
trap->once = 1;
otmp = t_missile(ROCK, trap);
if (in_sight)
seetrap(trap);
if (thitm(0, mtmp, otmp, d(2, 6), FALSE))
trapkilled = TRUE;
return trapkilled ? 2 : mtmp->mtrapped;
}
return 0;
} }
static void static void
@@ -1752,7 +1778,7 @@ unsigned trflags;
break; break;
case ROCKTRAP: case ROCKTRAP:
trapeffect_rocktrap(trap, trflags); (void) trapeffect_rocktrap(&g.youmonst, trap, trflags);
break; break;
case SQKY_BOARD: /* stepped on a squeaky board */ case SQKY_BOARD: /* stepped on a squeaky board */
@@ -2477,23 +2503,8 @@ register struct monst *mtmp;
return trapeffect_arrow_trap(mtmp, trap, 0); return trapeffect_arrow_trap(mtmp, trap, 0);
case DART_TRAP: case DART_TRAP:
return trapeffect_dart_trap(mtmp, trap, 0); return trapeffect_dart_trap(mtmp, trap, 0);
break;
case ROCKTRAP: case ROCKTRAP:
if (trap->once && trap->tseen && !rn2(15)) { return trapeffect_rocktrap(mtmp, trap, 0);
if (in_sight && see_it)
pline("A trap door above %s opens, but nothing falls out!",
mon_nam(mtmp));
deltrap(trap);
newsym(mtmp->mx, mtmp->my);
break;
}
trap->once = 1;
otmp = t_missile(ROCK, trap);
if (in_sight)
seetrap(trap);
if (thitm(0, mtmp, otmp, d(2, 6), FALSE))
trapkilled = TRUE;
break;
case SQKY_BOARD: case SQKY_BOARD:
if (is_flyer(mptr)) if (is_flyer(mptr))
break; break;