Define engulfing_u, making clearer code
This commit is contained in:
@@ -233,6 +233,8 @@ struct monst {
|
||||
#define troll_baned(m,o) \
|
||||
((m)->data->mlet == S_TROLL && (o) && (o)->oartifact == ART_TROLLSBANE)
|
||||
|
||||
#define engulfing_u(mon) (u.uswallow && (u.ustuck == (mon)))
|
||||
|
||||
/* Get the maximum difficulty monsters that can currently be generated,
|
||||
given the current level difficulty and the hero's level. */
|
||||
#define monmax_difficulty(levdif) (((levdif) + u.ulevel) / 2)
|
||||
|
||||
@@ -1147,7 +1147,7 @@ artifact_hit(struct monst *magr, struct monst *mdef, struct obj *otmp,
|
||||
boolean youdefend = (mdef == &g.youmonst);
|
||||
boolean vis = (!youattack && magr && cansee(magr->mx, magr->my))
|
||||
|| (!youdefend && cansee(mdef->mx, mdef->my))
|
||||
|| (youattack && u.uswallow && mdef == u.ustuck && !Blind);
|
||||
|| (youattack && engulfing_u(mdef) && !Blind);
|
||||
boolean realizes_damage;
|
||||
const char *wepdesc;
|
||||
static const char you[] = "you";
|
||||
@@ -1241,7 +1241,7 @@ artifact_hit(struct monst *magr, struct monst *mdef, struct obj *otmp,
|
||||
if (otmp->oartifact == ART_TSURUGI_OF_MURAMASA && dieroll == 1) {
|
||||
wepdesc = "The razor-sharp blade";
|
||||
/* not really beheading, but so close, why add another SPFX */
|
||||
if (youattack && u.uswallow && mdef == u.ustuck) {
|
||||
if (youattack && engulfing_u(mdef)) {
|
||||
You("slice %s wide open!", mon_nam(mdef));
|
||||
*dmgptr = 2 * mdef->mhp + FATAL_DAMAGE_MODIFIER;
|
||||
return TRUE;
|
||||
@@ -1287,7 +1287,7 @@ artifact_hit(struct monst *magr, struct monst *mdef, struct obj *otmp,
|
||||
static const char *const behead_msg[2] = { "%s beheads %s!",
|
||||
"%s decapitates %s!" };
|
||||
|
||||
if (youattack && u.uswallow && mdef == u.ustuck)
|
||||
if (youattack && engulfing_u(mdef))
|
||||
return FALSE;
|
||||
wepdesc = artilist[ART_VORPAL_BLADE].name;
|
||||
if (!youdefend) {
|
||||
|
||||
@@ -1734,7 +1734,7 @@ x_monnam(
|
||||
do_invis = mtmp->minvis && !(suppress & SUPPRESS_INVISIBLE);
|
||||
do_it = !canspotmon(mtmp) && article != ARTICLE_YOUR
|
||||
&& !g.program_state.gameover && mtmp != u.usteed
|
||||
&& !(u.uswallow && mtmp == u.ustuck) && !(suppress & SUPPRESS_IT);
|
||||
&& !engulfing_u(mtmp) && !(suppress & SUPPRESS_IT);
|
||||
do_saddle = !(suppress & SUPPRESS_SADDLE);
|
||||
do_name = !(suppress & SUPPRESS_NAME) || type_is_pname(mdat);
|
||||
augment_it = (suppress & AUGMENT_IT) != 0;
|
||||
|
||||
@@ -924,7 +924,7 @@ dokick(void)
|
||||
to an unseen square doesn't leave an I behind */
|
||||
&& mtmp->mx == x && mtmp->my == y
|
||||
&& !glyph_is_invisible(glyph)
|
||||
&& !(u.uswallow && mtmp == u.ustuck)) {
|
||||
&& !engulfing_u(mtmp)) {
|
||||
map_invisible(x, y);
|
||||
}
|
||||
/* recoil if floating */
|
||||
|
||||
@@ -1678,7 +1678,7 @@ thitmonst(register struct monst *mon,
|
||||
register int tmp; /* Base chance to hit */
|
||||
register int disttmp; /* distance modifier */
|
||||
int otyp = obj->otyp, hmode;
|
||||
boolean guaranteed_hit = (u.uswallow && mon == u.ustuck);
|
||||
boolean guaranteed_hit = engulfing_u(mon);
|
||||
int dieroll;
|
||||
|
||||
hmode = (obj == uwep) ? HMON_APPLIED
|
||||
|
||||
@@ -363,7 +363,7 @@ explode(
|
||||
} while (*hallu_buf != lowc(*hallu_buf));
|
||||
str = hallu_buf;
|
||||
}
|
||||
if (u.uswallow && mtmp == u.ustuck) {
|
||||
if (engulfing_u(mtmp)) {
|
||||
const char *adj = (char *) 0;
|
||||
|
||||
if (is_animal(u.ustuck->data)) {
|
||||
|
||||
@@ -4428,7 +4428,7 @@ display_minventory(struct monst *mon, int dflags, char *title)
|
||||
int n;
|
||||
menu_item *selected = 0;
|
||||
int do_all = (dflags & MINV_ALL) != 0,
|
||||
incl_hero = (do_all && u.uswallow && mon == u.ustuck),
|
||||
incl_hero = (do_all && engulfing_u(mon)),
|
||||
have_inv = (mon->minvent != 0), have_any = (have_inv || incl_hero),
|
||||
pickings = (dflags & MINV_PICKMASK);
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ fightm(register struct monst *mtmp)
|
||||
if (itsstuck(mtmp))
|
||||
return 0;
|
||||
}
|
||||
has_u_swallowed = (u.uswallow && (mtmp == u.ustuck));
|
||||
has_u_swallowed = engulfing_u(mtmp);
|
||||
|
||||
for (mon = fmon; mon; mon = nmon) {
|
||||
nmon = mon->nmon;
|
||||
@@ -486,7 +486,7 @@ mattackm(register struct monst *magr, register struct monst *mdef)
|
||||
if (distmin(magr->mx, magr->my, mdef->mx, mdef->my) > 1)
|
||||
continue;
|
||||
/* Engulfing attacks are directed at the hero if possible. -dlc */
|
||||
if (u.uswallow && magr == u.ustuck)
|
||||
if (engulfing_u(magr))
|
||||
strike = 0;
|
||||
else if ((strike = (tmp > rnd(20 + i))) != 0)
|
||||
res[i] = gulpmm(magr, mdef, mattk);
|
||||
|
||||
10
src/mon.c
10
src/mon.c
@@ -808,7 +808,7 @@ minliquid_core(struct monst* mtmp)
|
||||
/* hero used fire to melt ice that monster was on */
|
||||
You("drown %s.", mon_nam(mtmp));
|
||||
}
|
||||
if (u.ustuck && u.uswallow && u.ustuck == mtmp) {
|
||||
if (engulfing_u(mtmp)) {
|
||||
/* This can happen after a purple worm plucks you off a
|
||||
flying steed while you are over water. */
|
||||
pline("%s sinks as %s rushes in and flushes you out.",
|
||||
@@ -907,7 +907,7 @@ mcalcdistress(void)
|
||||
/* possibly polymorph shapechangers and lycanthropes */
|
||||
if (mtmp->cham >= LOW_PM)
|
||||
decide_to_shapeshift(mtmp, (canspotmon(mtmp)
|
||||
|| (u.uswallow && mtmp == u.ustuck))
|
||||
|| engulfing_u(mtmp))
|
||||
? SHIFT_MSG : 0);
|
||||
were_change(mtmp);
|
||||
|
||||
@@ -2748,7 +2748,7 @@ monstone(struct monst* mdef)
|
||||
newsym(x, y);
|
||||
/* We don't currently trap the hero in the statue in this case but we
|
||||
* could */
|
||||
if (u.uswallow && u.ustuck == mdef)
|
||||
if (engulfing_u(mdef))
|
||||
wasinside = TRUE;
|
||||
mondead(mdef);
|
||||
if (wasinside) {
|
||||
@@ -2864,7 +2864,7 @@ xkilled(
|
||||
struct obj *otmp;
|
||||
struct trap *t;
|
||||
boolean be_sad;
|
||||
boolean wasinside = u.uswallow && (u.ustuck == mtmp),
|
||||
boolean wasinside = engulfing_u(mtmp),
|
||||
burycorpse = FALSE,
|
||||
nomsg = (xkill_flags & XKILL_NOMSG) != 0,
|
||||
nocorpse = (xkill_flags & XKILL_NOCORPSE) != 0,
|
||||
@@ -3111,7 +3111,7 @@ vamp_stone(struct monst* mtmp)
|
||||
set_mon_min_mhpmax(mtmp, 10); /* mtmp->mhpmax=max(m_lev+1,10) */
|
||||
mtmp->mhp = mtmp->mhpmax;
|
||||
/* this can happen if previously a fog cloud */
|
||||
if (u.uswallow && (mtmp == u.ustuck))
|
||||
if (engulfing_u(mtmp))
|
||||
expels(mtmp, mtmp->data, FALSE);
|
||||
if (in_door) {
|
||||
coord new_xy;
|
||||
|
||||
@@ -1136,7 +1136,7 @@ m_move(register struct monst* mtmp, register int after)
|
||||
gx = mtmp->mux;
|
||||
gy = mtmp->muy;
|
||||
appr = mtmp->mflee ? -1 : 1;
|
||||
if (mtmp->mconf || (u.uswallow && mtmp == u.ustuck)) {
|
||||
if (mtmp->mconf || engulfing_u(mtmp)) {
|
||||
appr = 0;
|
||||
} else {
|
||||
boolean should_see = (couldsee(omx, omy)
|
||||
@@ -1617,7 +1617,7 @@ m_move(register struct monst* mtmp, register int after)
|
||||
return 2; /* mon died (position already updated) */
|
||||
|
||||
/* set also in domove(), hack.c */
|
||||
if (u.uswallow && mtmp == u.ustuck
|
||||
if (engulfing_u(mtmp)
|
||||
&& (mtmp->mx != omx || mtmp->my != omy)) {
|
||||
/* If the monster moved, then update */
|
||||
u.ux0 = u.ux;
|
||||
|
||||
@@ -950,7 +950,7 @@ query_objlist(const char *qstr, /* query string */
|
||||
/* can't depend upon 'engulfer' because that's used to indicate whether
|
||||
hero should be shown as an extra, fake item */
|
||||
engulfer_minvent = (olist && olist->where == OBJ_MINVENT
|
||||
&& u.uswallow && olist->ocarry == u.ustuck);
|
||||
&& engulfing_u(olist->ocarry));
|
||||
if (engulfer_minvent && n == 1 && olist->owornmask != 0L) {
|
||||
qflags &= ~AUTOSELECT_SINGLE;
|
||||
}
|
||||
@@ -1629,7 +1629,7 @@ pickup_object(struct obj *obj, long count,
|
||||
if (obj == uchain) { /* do not pick up attached chain */
|
||||
return 0;
|
||||
} else if (obj->where == OBJ_MINVENT && obj->owornmask != 0L
|
||||
&& u.uswallow && obj->ocarry == u.ustuck) {
|
||||
&& engulfing_u(obj->ocarry)) {
|
||||
You_cant("pick %s up.", ysimple_name(obj));
|
||||
return 0;
|
||||
} else if (obj->oartifact && !touch_artifact(obj, &g.youmonst)) {
|
||||
|
||||
@@ -2152,7 +2152,7 @@ drop_boulder_on_monster(int x, int y, boolean confused, boolean byu)
|
||||
pline("%s is hit by %s!", Monnam(mtmp), doname(otmp2));
|
||||
if (mtmp->minvis && !canspotmon(mtmp))
|
||||
map_invisible(mtmp->mx, mtmp->my);
|
||||
} else if (u.uswallow && mtmp == u.ustuck)
|
||||
} else if (engulfing_u(mtmp))
|
||||
You_hear("something hit %s %s over your %s!",
|
||||
s_suffix(mon_nam(mtmp)), mbodypart(mtmp, STOMACH),
|
||||
body_part(HEAD));
|
||||
@@ -2185,7 +2185,7 @@ drop_boulder_on_monster(int x, int y, boolean confused, boolean byu)
|
||||
wakeup(mtmp, byu);
|
||||
}
|
||||
wake_nearto(x, y, 4 * 4);
|
||||
} else if (u.uswallow && mtmp == u.ustuck) {
|
||||
} else if (engulfing_u(mtmp)) {
|
||||
obfree(otmp2, (struct obj *) 0);
|
||||
/* fall through to player */
|
||||
drop_boulder_on_player(confused, TRUE, FALSE, TRUE);
|
||||
|
||||
@@ -518,7 +518,7 @@ mpickobj(register struct monst* mtmp, register struct obj* otmp)
|
||||
the light to be extinguished rather than letting it shine thru */
|
||||
if (obj_sheds_light(otmp) && attacktype(mtmp->data, AT_ENGL)) {
|
||||
/* this is probably a burning object that you dropped or threw */
|
||||
if (u.uswallow && mtmp == u.ustuck && !Blind)
|
||||
if (engulfing_u(mtmp) && !Blind)
|
||||
pline("%s out.", Tobjnam(otmp, "go"));
|
||||
snuff_otmp = TRUE;
|
||||
}
|
||||
|
||||
@@ -1654,7 +1654,7 @@ u_teleport_mon(struct monst* mtmp, boolean give_feedback)
|
||||
if (give_feedback)
|
||||
pline("%s resists your magic!", Monnam(mtmp));
|
||||
return FALSE;
|
||||
} else if (u.uswallow && mtmp == u.ustuck && noteleport_level(mtmp)) {
|
||||
} else if (engulfing_u(mtmp) && noteleport_level(mtmp)) {
|
||||
if (give_feedback)
|
||||
You("are no longer inside %s!", mon_nam(mtmp));
|
||||
unstuck(mtmp);
|
||||
|
||||
11
src/uhitm.c
11
src/uhitm.c
@@ -124,7 +124,7 @@ attack_checks(
|
||||
/* if you're close enough to attack, alert any waiting monster */
|
||||
mtmp->mstrategy &= ~STRAT_WAITMASK;
|
||||
|
||||
if (u.uswallow && mtmp == u.ustuck)
|
||||
if (engulfing_u(mtmp))
|
||||
return FALSE;
|
||||
|
||||
if (g.context.forcefight) {
|
||||
@@ -503,7 +503,7 @@ do_attack(struct monst *mtmp)
|
||||
*/
|
||||
if (g.context.forcefight && !DEADMONSTER(mtmp) && !canspotmon(mtmp)
|
||||
&& !glyph_is_invisible(levl[u.ux + u.dx][u.uy + u.dy].glyph)
|
||||
&& !(u.uswallow && mtmp == u.ustuck))
|
||||
&& !engulfing_u(mtmp))
|
||||
map_invisible(u.ux + u.dx, u.uy + u.dy);
|
||||
|
||||
return TRUE;
|
||||
@@ -544,7 +544,7 @@ known_hitum(struct monst *mon, struct obj *weapon, int *mhit, int rollneeded,
|
||||
if (malive) {
|
||||
/* monster still alive */
|
||||
if (!rn2(25) && mon->mhp < mon->mhpmax / 2
|
||||
&& !(u.uswallow && mon == u.ustuck)) {
|
||||
&& !engulfing_u(mon)) {
|
||||
/* maybe should regurgitate if swallowed? */
|
||||
monflee(mon, !rn2(3) ? rnd(100) : 0, FALSE, TRUE);
|
||||
|
||||
@@ -2366,13 +2366,12 @@ mhitm_ad_tlpt(struct monst *magr, struct attack *mattk, struct monst *mdef,
|
||||
mhm->damage = 1;
|
||||
if (!negated) {
|
||||
char nambuf[BUFSZ];
|
||||
boolean u_saw_mon = (canseemon(mdef)
|
||||
|| (u.uswallow && u.ustuck == mdef));
|
||||
boolean u_saw_mon = (canseemon(mdef) || engulfing_u(mdef));
|
||||
|
||||
/* record the name before losing sight of monster */
|
||||
Strcpy(nambuf, Monnam(mdef));
|
||||
if (u_teleport_mon(mdef, FALSE) && u_saw_mon
|
||||
&& !(canseemon(mdef) || (u.uswallow && u.ustuck == mdef)))
|
||||
&& !(canseemon(mdef) || engulfing_u(mdef)))
|
||||
pline("%s suddenly disappears!", nambuf);
|
||||
if (mhm->damage >= mdef->mhp) { /* see hitmu(mhitu.c) */
|
||||
if (mdef->mhp == 1)
|
||||
|
||||
14
src/zap.c
14
src/zap.c
@@ -140,7 +140,7 @@ bhitm(struct monst *mtmp, struct obj *otmp)
|
||||
boolean disguised_mimic = (mtmp->data->mlet == S_MIMIC
|
||||
&& M_AP_TYPE(mtmp) != M_AP_NOTHING);
|
||||
|
||||
if (u.uswallow && mtmp == u.ustuck)
|
||||
if (engulfing_u(mtmp))
|
||||
reveal_invis = FALSE;
|
||||
|
||||
g.notonhead = (mtmp->mx != g.bhitpos.x || mtmp->my != g.bhitpos.y);
|
||||
@@ -177,7 +177,7 @@ bhitm(struct monst *mtmp, struct obj *otmp)
|
||||
seemimic(mtmp);
|
||||
mon_adjust_speed(mtmp, -1, otmp);
|
||||
m_dowear(mtmp, FALSE); /* might want speed boots */
|
||||
if (u.uswallow && (mtmp == u.ustuck) && is_whirly(mtmp->data)) {
|
||||
if (engulfing_u(mtmp) && is_whirly(mtmp->data)) {
|
||||
You("disrupt %s!", mon_nam(mtmp));
|
||||
pline("A huge hole opens up...");
|
||||
expels(mtmp, mtmp->data, TRUE);
|
||||
@@ -229,7 +229,7 @@ bhitm(struct monst *mtmp, struct obj *otmp)
|
||||
boolean polyspot = (otyp != POT_POLYMORPH),
|
||||
give_msg = (!Hallucination
|
||||
&& (canseemon(mtmp)
|
||||
|| (u.uswallow && mtmp == u.ustuck)));
|
||||
|| engulfing_u(mtmp)));
|
||||
|
||||
/* dropped inventory (due to death by system shock,
|
||||
or loss of wielded weapon and/or worn armor due to
|
||||
@@ -258,7 +258,7 @@ bhitm(struct monst *mtmp, struct obj *otmp)
|
||||
&& newcham(mtmp, &mons[mtmp->cham],
|
||||
polyspot, give_msg) != 0)) {
|
||||
if (give_msg && (canspotmon(mtmp)
|
||||
|| (u.uswallow && mtmp == u.ustuck)))
|
||||
|| engulfing_u(mtmp)))
|
||||
learn_it = TRUE;
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ probe_monster(struct monst *mtmp)
|
||||
(char *) 0);
|
||||
} else {
|
||||
pline("%s is not carrying anything%s.", noit_Monnam(mtmp),
|
||||
(u.uswallow && mtmp == u.ustuck) ? " besides you" : "");
|
||||
engulfing_u(mtmp) ? " besides you" : "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3308,7 +3308,7 @@ hit(const char *str, struct monst *mtmp,
|
||||
const char *force) /* usually either "." or "!" */
|
||||
{
|
||||
if ((!cansee(g.bhitpos.x, g.bhitpos.y) && !canspotmon(mtmp)
|
||||
&& !(u.uswallow && mtmp == u.ustuck)) || !flags.verbose)
|
||||
&& !engulfing_u(mtmp)) || !flags.verbose)
|
||||
pline("%s %s it.", The(str), vtense(str, "hit"));
|
||||
else
|
||||
pline("%s %s %s%s", The(str), vtense(str, "hit"),
|
||||
@@ -3860,7 +3860,7 @@ zhitm(
|
||||
if (spellcaster)
|
||||
tmp = spell_damage_bonus(tmp);
|
||||
if (!resists_blnd(mon)
|
||||
&& !(type > 0 && u.uswallow && mon == u.ustuck)) {
|
||||
&& !(type > 0 && engulfing_u(mon))) {
|
||||
register unsigned rnd_tmp = rnd(50);
|
||||
mon->mcansee = 0;
|
||||
if ((mon->mblinded + rnd_tmp) > 127)
|
||||
|
||||
Reference in New Issue
Block a user