Unify rocktrap

This commit is contained in:
Pasi Kallinen
2020-12-10 19:04:29 +02:00
parent 485985968e
commit a1227cefb3
+58 -47
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,43 +1046,69 @@ 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;
{ {
if (trap->once && trap->tseen && !rn2(15)) { struct obj *otmp;
pline("A trap door in %s opens, but nothing falls out!",
the(ceiling(u.ux, u.uy)));
deltrap(trap);
newsym(u.ux, u.uy);
} else {
int dmg = d(2, 6); /* should be std ROCK dmg? */
struct obj *otmp;
trap->once = 1; if (mtmp == &g.youmonst) {
feeltrap(trap); if (trap->once && trap->tseen && !rn2(15)) {
otmp = t_missile(ROCK, trap); pline("A trap door in %s opens, but nothing falls out!",
place_object(otmp, u.ux, u.uy); the(ceiling(u.ux, u.uy)));
deltrap(trap);
newsym(u.ux, u.uy);
} else {
int dmg = d(2, 6); /* should be std ROCK dmg? */
pline("A trap door in %s opens and %s falls on your %s!", trap->once = 1;
the(ceiling(u.ux, u.uy)), an(xname(otmp)), body_part(HEAD)); feeltrap(trap);
if (uarmh) { otmp = t_missile(ROCK, trap);
if (is_metallic(uarmh)) { place_object(otmp, u.ux, u.uy);
pline("Fortunately, you are wearing a hard helmet.");
dmg = 2; pline("A trap door in %s opens and %s falls on your %s!",
} else if (flags.verbose) { the(ceiling(u.ux, u.uy)), an(xname(otmp)), body_part(HEAD));
pline("%s does not protect you.", Yname2(uarmh)); if (uarmh) {
if (is_metallic(uarmh)) {
pline("Fortunately, you are wearing a hard helmet.");
dmg = 2;
} else if (flags.verbose) {
pline("%s does not protect you.", Yname2(uarmh));
}
} }
} if (!Blind)
if (!Blind) otmp->dknown = 1;
otmp->dknown = 1; stackobj(otmp);
stackobj(otmp); newsym(u.ux, u.uy); /* map the rock */
newsym(u.ux, u.uy); /* map the rock */
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;