non-digest engulfing

Be more consistent with the engulf attack feedback by creatures who
fold themselves around the victim (trapper, lurker above) rather than
swallow or directly engulf.

Replace an instance of a non-literal format string and the warnings
manipulation it needed with a literal one.
This commit is contained in:
PatR
2023-03-13 12:49:22 -07:00
parent 35273b8a8c
commit 01af084f43
3 changed files with 40 additions and 37 deletions

View File

@@ -9,6 +9,9 @@
static const char brief_feeling[] =
"have a %s feeling for a moment, then it passes.";
static void noises(struct monst *, struct attack *);
static void pre_mm_attack(struct monst *, struct monst *);
static void missmm(struct monst *, struct monst *, struct attack *);
static int hitmm(struct monst *, struct monst *, struct attack *,
struct obj *, int);
static int gazemm(struct monst *, struct monst *, struct attack *);
@@ -17,14 +20,11 @@ static int explmm(struct monst *, struct monst *, struct attack *);
static int mdamagem(struct monst *, struct monst *, struct attack *,
struct obj *, int);
static void mswingsm(struct monst *, struct monst *, struct obj *);
static void noises(struct monst *, struct attack *);
static void pre_mm_attack(struct monst *, struct monst *);
static void missmm(struct monst *, struct monst *, struct attack *);
static int passivemm(struct monst *, struct monst *, boolean, int,
struct obj *);
static void
noises(register struct monst *magr, register struct attack *mattk)
noises(struct monst *magr, struct attack *mattk)
{
boolean farq = (mdistu(magr) > 15);
@@ -71,30 +71,26 @@ pre_mm_attack(struct monst *magr, struct monst *mdef)
}
}
DISABLE_WARNING_FORMAT_NONLITERAL
/* feedback for when a monster-vs-monster attack misses */
static
void
missmm(register struct monst *magr, register struct monst *mdef,
struct attack *mattk)
missmm(
struct monst *magr, /* attacker */
struct monst *mdef, /* defender */
struct attack *mattk) /* attack and damage types */
{
const char *fmt;
char buf[BUFSZ];
pre_mm_attack(magr, mdef);
if (gv.vis) {
fmt = (could_seduce(magr, mdef, mattk) && !magr->mcan)
? "%s pretends to be friendly to"
: "%s misses";
Sprintf(buf, fmt, Monnam(magr));
pline("%s %s.", buf, mon_nam_too(mdef, magr));
} else
pline("%s %s %s.", Monnam(magr),
(magr->mcan || !could_seduce(magr, mdef, mattk)) ? "misses"
: "pretends to be friendly to",
mon_nam_too(mdef, magr));
} else {
noises(magr, mattk);
}
}
RESTORE_WARNING_FORMAT_NONLITERAL
/*
* fightm() -- fight some other monster
*
@@ -632,7 +628,7 @@ hitmm(
Strcat(mdef_name, " flesh");
}
pline("%s %s sears %s!", magr_name, /*s_suffix(magr_name), */
pline("%s %s sears %s!", magr_name, /* s_suffix(magr_name), */
simpleonames(mwep), mdef_name);
}
}
@@ -758,19 +754,17 @@ gulpmm(
{
coordxy ax, ay, dx, dy;
int status;
char buf[BUFSZ];
struct obj *obj;
if (!engulf_target(magr, mdef))
return MM_MISS;
if (gv.vis) {
/* [this two-part formatting dates back to when only one x_monnam
result could be included in an expression because the next one
would overwrite first's result -- that's no longer the case] */
Sprintf(buf, "%s %s", Monnam(magr),
digests(magr->data) ? "swallows" : "engulfs");
pline("%s %s.", buf, mon_nam(mdef));
pline("%s %s %s.", Monnam(magr),
digests(magr->data) ? "swallows"
: enfolds(magr->data) ? "encloses"
: "engulfs",
mon_nam(mdef));
}
if (!flaming(magr->data)) {
for (obj = mdef->minvent; obj; obj = obj->nobj)

View File

@@ -1203,6 +1203,7 @@ gulpmu(struct monst *mtmp, struct attack *mattk)
} else {
urgent_pline("%s %s!", Monnam(mtmp),
digests(mtmp->data) ? "swallows you whole"
: enfolds(mtmp->data) ? "folds itself around you"
: "engulfs you");
}
stop_occupation();
@@ -1210,7 +1211,7 @@ gulpmu(struct monst *mtmp, struct attack *mattk)
if (u.utrap) {
You("are released from the %s!",
u.utraptype == TT_WEB ? "web" : "trap");
(u.utraptype == TT_WEB) ? "web" : "trap");
reset_utrap(FALSE);
}

View File

@@ -4577,15 +4577,17 @@ explum(struct monst *mdef, struct attack *mattk)
static void
start_engulf(struct monst *mdef)
{
boolean u_digest = digests(gy.youmonst.data),
u_enfold = enfolds(gy.youmonst.data);
if (!Invisible) {
map_location(u.ux, u.uy, TRUE);
tmp_at(DISP_ALWAYS, mon_to_glyph(&gy.youmonst, rn2_on_display_rng));
tmp_at(mdef->mx, mdef->my);
}
if (digests(gy.youmonst.data))
You("swallow %s whole!", mon_nam(mdef));
else
You("engulf %s!", mon_nam(mdef));
You("%s %s%s!",
u_digest ? "swallow" : u_enfold ? "enclose" : "engulf",
mon_nam(mdef), u_digest ? " whole" : "");
delay_output();
delay_output();
}
@@ -4605,12 +4607,14 @@ gulpum(struct monst *mdef, struct attack *mattk)
static char msgbuf[BUFSZ]; /* for gn.nomovemsg */
register int tmp;
register int dam = d((int) mattk->damn, (int) mattk->damd);
boolean fatal_gulp, u_digest = digests(gy.youmonst.data);
boolean fatal_gulp,
u_digest = digests(gy.youmonst.data),
u_enfold = enfolds(gy.youmonst.data);
struct obj *otmp;
struct permonst *pd = mdef->data;
const char *expel_verb = u_digest ? "regurgitate"
: enfolds(gy.youmonst.data) ? "release"
: "expel";
: u_enfold ? "release"
: "expel";
/* Not totally the same as for real monsters. Specifically, these
* don't take multiple moves. (It's just too hard, for too little
@@ -4633,7 +4637,8 @@ gulpum(struct monst *mdef, struct attack *mattk)
vampire form now instead of dealing with that when it dies */
if (is_vampshifter(mdef)
&& newcham(mdef, &mons[mdef->cham], NO_NC_FLAGS)) {
You("%s it, then %s it.", u_digest ? "swallow" : "engulf",
You("%s it, then %s it.",
u_digest ? "swallow" : u_enfold ? "enclose" : "engulf",
expel_verb);
if (canspotmon(mdef)) {
/* Avoiding a_monnam here: if the target is named, it gives us
@@ -4665,7 +4670,10 @@ gulpum(struct monst *mdef, struct attack *mattk)
if (!type_is_pname(pd))
mnam = an(mnam);
You("%s %s.", u_digest ? "englut" : "engulf", mon_nam(mdef));
Sprintf(kbuf, "%s %s%s", u_digest ? "swallowing" : "engulfing",
Sprintf(kbuf, "%s %s%s",
u_digest ? "swallowing"
: u_enfold ? "enclosing"
: "engulfing",
mnam, u_digest ? " whole" : "");
instapetrify(kbuf);
} else {