winid toptenwin;
/* trap.c */
- int force_mintrap; /* mintrap() should take a flags argument, but for time
- being we use this */
/* context for water_damage(), managed by water_damage_chain();
when more than one stack of potions of acid explode while processing
a chain of objects, use alternate phrasing after the first message */
extern void dotrap(struct trap *, unsigned);
extern void seetrap(struct trap *);
extern void feeltrap(struct trap *);
-extern int mintrap(struct monst *);
+extern int mintrap(struct monst *, long);
extern void instapetrify(const char *);
extern void minstapetrify(struct monst *, boolean);
extern void selftouch(const char *);
#define PICK_RANDOM 0
#define PICK_RIGID 1
-/* Flags to control dotrap() in trap.c */
-#define FORCETRAP 0x01 /* triggering not left to chance */
-#define NOWEBMSG 0x02 /* suppress stumble into web message */
-#define FORCEBUNGLE 0x04 /* adjustments appropriate for bungling */
+/* Flags to control dotrap() and mintrap() in trap.c */
+#define NO_TRAP_FLAGS 0
+#define FORCETRAP 0x01 /* triggering not left to chance */
+#define NOWEBMSG 0x02 /* suppress stumble into web message */
+#define FORCEBUNGLE 0x04 /* adjustments appropriate for bungling */
#define RECURSIVETRAP 0x08 /* trap changed into another type this same turn */
-#define TOOKPLUNGE 0x10 /* used '>' to enter pit below you */
-#define VIASITTING 0x20 /* #sit while at trap location (affects message) */
-#define FAILEDUNTRAP 0x40 /* trap activated by failed untrap attempt */
+#define TOOKPLUNGE 0x10 /* used '>' to enter pit below you */
+#define VIASITTING 0x20 /* #sit while at trap location (affects message) */
+#define FAILEDUNTRAP 0x40 /* trap activated by failed untrap attempt */
/* Flags to control test_move in hack.c */
#define DO_MOVE 0 /* really doing the move */
mtmp->mundetected = 0; /* reveal non-mimic hider */
if (canspotmon(mtmp))
++pet_cnt;
- if (mintrap(mtmp) == Trap_Killed_Mon)
+ if (mintrap(mtmp, NO_TRAP_FLAGS) == Trap_Killed_Mon)
change_luck(-1);
}
}
WIN_ERR, /* toptenwin */
/* trap.c */
- 0, /* force_mintrap */
{ 0, 0, FALSE },
UNDEFINED_VALUES,
pline("%s %s over the pit.", Monnam(mtmp),
(is_flyer(mtmp->data)) ? "flies" : "floats");
} else if (mtmp != madeby)
- (void) mintrap(mtmp);
+ (void) mintrap(mtmp, NO_TRAP_FLAGS);
}
} else { /* was TRAPDOOR now a HOLE*/
&& !(mtmp->mstrategy & STRAT_WAITFORU)) {
stay_behind = FALSE;
if (mtmp->mtrapped)
- (void) mintrap(mtmp); /* try to escape */
+ (void) mintrap(mtmp, NO_TRAP_FLAGS); /* try to escape */
if (mtmp == u.usteed) {
/* make sure steed is eligible to accompany hero */
mtmp->mtrapped = 0; /* escape trap */
/* see if the monster has a place to move into */
mdx = mon->mx + u.dx;
mdy = mon->my + u.dy;
+ /* TODO: replace with mhurtle? */
if (goodpos(mdx, mdy, mon, 0)) {
pline("%s reels from the blow.", Monnam(mon));
if (m_in_out_region(mon, mdx, mdy)) {
place_monster(mon, mdx, mdy);
newsym(mon->mx, mon->my);
set_apparxy(mon);
- if (mintrap(mon) == Trap_Killed_Mon)
+ if (mintrap(mon, NO_TRAP_FLAGS) == Trap_Killed_Mon)
trapkilled = TRUE;
}
}
set_apparxy(mon);
if (is_waterwall(x, y))
return FALSE;
- res = mintrap(mon);
+ res = mintrap(mon, NO_TRAP_FLAGS); /* TODO: TEMPFLIGHT? */
if (res == Trap_Killed_Mon
|| res == Trap_Caught_Mon
|| res == Trap_Moved_Mon)
if ((mtmp = makemon(&mons[PM_WATER_MOCCASIN], u.ux, u.uy,
MM_NOMSG)) != 0
&& t_at(mtmp->mx, mtmp->my))
- (void) mintrap(mtmp);
+ (void) mintrap(mtmp, NO_TRAP_FLAGS);
} else
pline_The("fountain bubbles furiously for a moment, then calms.");
}
/* give a wish and discard the monster (mtmp set to null) */
mongrantswish(&mtmp);
} else if (t_at(mtmp->mx, mtmp->my))
- (void) mintrap(mtmp);
+ (void) mintrap(mtmp, NO_TRAP_FLAGS);
}
} else
pline_The("fountain bubbles furiously for a moment, then calms.");
You_hear("a seductive voice.");
mtmp->msleeping = 0;
if (t_at(mtmp->mx, mtmp->my))
- (void) mintrap(mtmp);
+ (void) mintrap(mtmp, NO_TRAP_FLAGS);
} else if (!Blind)
pline("A large bubble rises to the surface and pops.");
else
or blame if something bad happens to it */
g.context.mon_moving = 1;
if (!minliquid(mtmp))
- (void) mintrap(mtmp);
+ (void) mintrap(mtmp, NO_TRAP_FLAGS);
g.context.mon_moving = 0;
/*
has_mgivenname(mtmp) ? SUPPRESS_SADDLE : 0, FALSE));
/* check for displacing it into pools and traps */
- switch (minliquid(mtmp) ? Trap_Killed_Mon : mintrap(mtmp)) {
+ switch (minliquid(mtmp) ? Trap_Killed_Mon
+ : mintrap(mtmp, NO_TRAP_FLAGS)) {
case Trap_Effect_Finished:
break;
case Trap_Caught_Mon: /* trapped */
pline("%s divides as %s hits it!", buf,
mon_nam(magr));
}
- (void) mintrap(mclone);
+ (void) mintrap(mclone, NO_TRAP_FLAGS);
}
}
} else
place_monster(magr, dx, dy);
newsym(dx, dy);
/* aggressor moves to <dx,dy> and might encounter trouble there */
- if (minliquid(magr) || (t_at(dx, dy) && mintrap(magr) == Trap_Killed_Mon))
+ if (minliquid(magr)
+ || (t_at(dx, dy)
+ && mintrap(magr, NO_TRAP_FLAGS) == Trap_Killed_Mon))
status |= MM_AGR_DIED;
} else if (status & MM_AGR_DIED) { /* aggressor died */
place_monster(mdef, dx, dy);
seemimic(mon);
if ((ttmp = t_at(x, y)) != 0)
- (void) mintrap(mon);
+ (void) mintrap(mon, NO_TRAP_FLAGS);
else
(void) minliquid(mon);
}
int omx = mtmp->mx, omy = mtmp->my;
if (mtmp->mtrapped) {
- int i = mintrap(mtmp);
+ int i = mintrap(mtmp, NO_TRAP_FLAGS);
if (i == Trap_Killed_Mon) {
newsym(mtmp->mx, mtmp->my);
}
newsym(omx, omy); /* update the old position */
- if (mintrap(mtmp) == Trap_Killed_Mon) {
+ if (mintrap(mtmp, NO_TRAP_FLAGS) == Trap_Killed_Mon) {
if (mtmp->mx)
newsym(mtmp->mx, mtmp->my);
return 2; /* it died */
is_floater(mon->data) ? "over" : "onto",
trap->tseen ? "the" : "a");
}
- /* hack to avoid mintrap()'s chance of avoiding known trap */
- mon->mtrapseen &= ~(1 << (FIRE_TRAP - 1));
- (void) mintrap(mon);
+ (void) mintrap(mon, FORCETRAP);
} else if (otyp == STRANGE_OBJECT) {
/* monster is using fire breath on self */
if (vis)
/* Put your steed in your trap */
if (save_utrap)
- (void) mintrap(mtmp);
+ (void) mintrap(mtmp, NO_TRAP_FLAGS);
}
/* Couldn't move hero... try moving the steed. */
/* trapped monster teleported away */
if (mtmp->mtrapped && !mtmp->wormno)
- (void) mintrap(mtmp);
+ (void) mintrap(mtmp, NO_TRAP_FLAGS);
}
void
|| mptr == &mons[PM_BUGBEAR])
You_hear("the roaring of an angry bear!");
}
- } else if (g.force_mintrap) {
+ } else if (forcetrap) {
if (in_sight) {
pline("%s evades %s bear trap!", Monnam(mtmp),
a_your[trap->madeby_u]);
int tt = trap->ttyp;
boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
boolean trapkilled = FALSE;
- boolean inescapable = (g.force_mintrap
+ boolean forcetrap = ((trflags & FORCETRAP) != 0);
+ boolean inescapable = (forcetrap
|| ((tt == HOLE || tt == PIT)
&& Sokoban && !trap->madeby_u));
struct permonst *mptr = mtmp->data;
fallverb = "falls";
if (!grounded(mptr) || (mtmp->wormno && count_wsegs(mtmp) > 5)) {
- if (g.force_mintrap && !Sokoban) {
+ if (forcetrap && !Sokoban) {
/* openfallingtrap; not inescapable here */
if (in_sight) {
seetrap(trap);
int tt = trap->ttyp;
struct permonst *mptr = mtmp->data;
boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
- boolean inescapable = (g.force_mintrap
+ boolean forcetrap = ((trflags & FORCETRAP) != 0);
+ boolean inescapable = (forcetrap
|| ((tt == HOLE || tt == PIT)
&& Sokoban && !trap->madeby_u));
}
if (!grounded(mptr) || (mtmp->wormno && count_wsegs(mtmp) > 5)
|| mptr->msize >= MZ_HUGE) {
- if (g.force_mintrap && !Sokoban) {
+ if (forcetrap && !Sokoban) {
/* openfallingtrap; not inescapable here */
if (in_sight) {
seetrap(trap);
} else {
int tt = trap->ttyp;
boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
- boolean inescapable = (g.force_mintrap
+ boolean forcetrap = ((trflags & FORCETRAP) != 0);
+ boolean inescapable = (forcetrap
|| ((tt == HOLE || tt == PIT)
&& Sokoban && !trap->madeby_u));
/* mintrap currently does not return Trap_Killed_Mon
(mon died) for webs */
- if (mintrap(u.usteed)) {
+ if (mintrap(u.usteed, trflags) != Trap_Effect_Finished) {
u.usteed->mtrapped = 0;
if (strongmonst(u.usteed->data))
str = 17;
/* Monster in a web. */
boolean tear_web;
boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
+ boolean forcetrap = ((trflags & FORCETRAP) != 0);
struct permonst *mptr = mtmp->data;
if (webmaker(mptr))
a_your[trap->madeby_u]);
deltrap(trap);
newsym(mtmp->mx, mtmp->my);
- } else if (g.force_mintrap && !mtmp->mtrapped) {
+ } else if (forcetrap && !mtmp->mtrapped) {
if (in_sight) {
pline("%s avoids %s spider web!", Monnam(mtmp),
a_your[trap->madeby_u]);
trapkilled = TRUE;
} else {
/* monsters recursively fall into new pit */
- if (mintrap(mtmp) == Trap_Killed_Mon)
+ if (mintrap(mtmp, trflags|FORCETRAP) == Trap_Killed_Mon)
trapkilled = TRUE;
}
/* a boulder may fill the new pit, crushing monster */
}
int
-mintrap(register struct monst *mtmp)
+mintrap(register struct monst *mtmp, long mintrapflags)
{
register struct trap *trap = t_at(mtmp->mx, mtmp->my);
struct permonst *mptr = mtmp->data;
trap_result = mtmp->mtrapped ? Trap_Caught_Mon : Trap_Effect_Finished;
} else {
register int tt = trap->ttyp;
- boolean inescapable = (g.force_mintrap
+ boolean forcetrap = ((mintrapflags & FORCETRAP) != 0);
+ boolean inescapable = (forcetrap
|| ((tt == HOLE || tt == PIT)
&& Sokoban && !trap->madeby_u));
if (trap->madeby_u && rnl(5))
setmangry(mtmp, FALSE);
- trap_result = trapeffect_selector(mtmp, trap, 0);
+ trap_result = trapeffect_selector(mtmp, trap, mintrapflags);
}
return trap_result;
}
/* dotrap calls mintrap when mounted hero encounters a web */
if (u.usteed)
dotrapflags |= NOWEBMSG;
- ++g.force_mintrap;
- dotrap(t, dotrapflags);
- --g.force_mintrap;
+ dotrap(t, dotrapflags|FORCETRAP);
result = (u.utrap != 0);
} else {
if (mon->mtrapped)
/* you notice it if you see the trap close/tremble/whatever
or if you sense the monster who becomes trapped */
*noticed = cansee(t->tx, t->ty) || canspotmon(mon);
- ++g.force_mintrap;
- result = (mintrap(mon) != Trap_Effect_Finished);
- --g.force_mintrap;
+ result = (mintrap(mon, FORCETRAP) != Trap_Effect_Finished);
}
return result;
}
*noticed = cansee(t->tx, t->ty) || canspotmon(mon);
/* monster will be angered; mintrap doesn't handle that */
wakeup(mon, TRUE);
- ++g.force_mintrap;
- result = (mintrap(mon) != 0);
- --g.force_mintrap;
+ result = (mintrap(mon, FORCETRAP) != Trap_Effect_Finished);
/* mon might now be on the migrating monsters list */
}
return result;
Sprintf(withwhat, " with %s", yname(obj));
pline("%s divides as you hit it%s!", Monnam(mon), withwhat);
hittxt = TRUE;
- (void) mintrap(mclone);
+ (void) mintrap(mclone, NO_TRAP_FLAGS);
}
}