Get rid of force_mintrap, allow passing flags to mintrap
It uses the same flags as dotrap, so simulate force_mintrap by passing FORCETRAP flag.
This commit is contained in:
@@ -509,7 +509,7 @@ use_magic_whistle(struct obj *obj)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -654,7 +654,6 @@ const struct instance_globals g_init = {
|
||||
WIN_ERR, /* toptenwin */
|
||||
|
||||
/* trap.c */
|
||||
0, /* force_mintrap */
|
||||
{ 0, 0, FALSE },
|
||||
UNDEFINED_VALUES,
|
||||
|
||||
|
||||
@@ -634,7 +634,7 @@ digactualhole(int x, int y, struct monst *madeby, int ttyp)
|
||||
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*/
|
||||
|
||||
|
||||
@@ -616,7 +616,7 @@ keepdogs(boolean pets_only) /* true for ascension or final escape */
|
||||
&& !(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 */
|
||||
|
||||
@@ -91,6 +91,7 @@ kickdmg(struct monst *mon, boolean clumsy)
|
||||
/* 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)) {
|
||||
@@ -99,7 +100,7 @@ kickdmg(struct monst *mon, boolean clumsy)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -921,7 +921,7 @@ mhurtle_step(genericptr_t arg, int x, int y)
|
||||
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)
|
||||
|
||||
@@ -49,7 +49,7 @@ dowatersnakes(void)
|
||||
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.");
|
||||
}
|
||||
@@ -76,7 +76,7 @@ dowaterdemon(void)
|
||||
/* 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.");
|
||||
@@ -97,7 +97,7 @@ dowaternymph(void)
|
||||
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
|
||||
|
||||
@@ -2058,7 +2058,7 @@ domove_core(void)
|
||||
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;
|
||||
|
||||
/*
|
||||
@@ -2138,7 +2138,8 @@ domove_core(void)
|
||||
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 */
|
||||
|
||||
@@ -438,7 +438,7 @@ mattackm(register struct monst *magr, register struct monst *mdef)
|
||||
pline("%s divides as %s hits it!", buf,
|
||||
mon_nam(magr));
|
||||
}
|
||||
(void) mintrap(mclone);
|
||||
(void) mintrap(mclone, NO_TRAP_FLAGS);
|
||||
}
|
||||
}
|
||||
} else
|
||||
@@ -810,7 +810,9 @@ gulpmm(register struct monst *magr, register struct monst *mdef,
|
||||
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);
|
||||
|
||||
@@ -1981,7 +1981,7 @@ mkinvpos(xchar x, xchar y, int dist)
|
||||
seemimic(mon);
|
||||
|
||||
if ((ttmp = t_at(x, y)) != 0)
|
||||
(void) mintrap(mon);
|
||||
(void) mintrap(mon, NO_TRAP_FLAGS);
|
||||
else
|
||||
(void) minliquid(mon);
|
||||
}
|
||||
|
||||
@@ -1021,7 +1021,7 @@ m_move(register struct monst* mtmp, register int after)
|
||||
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);
|
||||
@@ -1491,7 +1491,7 @@ m_move(register struct monst* mtmp, register int after)
|
||||
}
|
||||
|
||||
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 */
|
||||
|
||||
@@ -2775,9 +2775,7 @@ muse_unslime(
|
||||
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)
|
||||
|
||||
@@ -662,7 +662,7 @@ dismount_steed(
|
||||
|
||||
/* 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. */
|
||||
|
||||
@@ -1288,7 +1288,7 @@ rloc_to_core(struct monst* mtmp,
|
||||
|
||||
/* trapped monster teleported away */
|
||||
if (mtmp->mtrapped && !mtmp->wormno)
|
||||
(void) mintrap(mtmp);
|
||||
(void) mintrap(mtmp, NO_TRAP_FLAGS);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
41
src/trap.c
41
src/trap.c
@@ -1248,7 +1248,7 @@ trapeffect_bear_trap(
|
||||
|| 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]);
|
||||
@@ -1640,7 +1640,8 @@ trapeffect_pit(
|
||||
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;
|
||||
@@ -1648,7 +1649,7 @@ trapeffect_pit(
|
||||
|
||||
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);
|
||||
@@ -1699,7 +1700,8 @@ trapeffect_hole(
|
||||
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));
|
||||
|
||||
@@ -1710,7 +1712,7 @@ trapeffect_hole(
|
||||
}
|
||||
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);
|
||||
@@ -1769,7 +1771,8 @@ trapeffect_level_telep(
|
||||
} 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));
|
||||
|
||||
@@ -1845,7 +1848,7 @@ trapeffect_web(
|
||||
|
||||
/* 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;
|
||||
@@ -1883,6 +1886,7 @@ trapeffect_web(
|
||||
/* 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))
|
||||
@@ -1935,7 +1939,7 @@ trapeffect_web(
|
||||
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]);
|
||||
@@ -2243,7 +2247,7 @@ trapeffect_landmine(
|
||||
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 */
|
||||
@@ -3069,7 +3073,7 @@ isclearpath(
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -3125,7 +3129,8 @@ mintrap(register struct monst *mtmp)
|
||||
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));
|
||||
|
||||
@@ -3146,7 +3151,7 @@ mintrap(register struct monst *mtmp)
|
||||
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;
|
||||
}
|
||||
@@ -5221,9 +5226,7 @@ closeholdingtrap(
|
||||
/* 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)
|
||||
@@ -5231,9 +5234,7 @@ closeholdingtrap(
|
||||
/* 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;
|
||||
}
|
||||
@@ -5274,9 +5275,7 @@ openfallingtrap(
|
||||
*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;
|
||||
|
||||
@@ -1365,7 +1365,7 @@ hmon_hitmon(
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user