From c78e7af01378d5a54a080c5e5a9ef9f454f6b83f Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Mon, 26 Sep 2022 21:22:49 -0400 Subject: [PATCH] Digestion attack can grant hero intrinsics Monster purple worms can now gain intrinsics from swallowing foes whole, so maybe the hero should be able to do so too. Intrinsics aren't granted immediately upon swallowing (that would probably have been easier), but only once a corpse is created and then entirely digested. I'm not sure if this is too powerful and was being avoided deliberately for that reason, since it includes potential level gain from wraith corpses in addition to other intrinsics. That's consistent with monster purple worms but may be a bit too much in the hands of the hero, though it is limited by needing the corpse creation roll to succeed. --- include/decl.h | 1 + include/extern.h | 1 + src/decl.c | 1 + src/eat.c | 12 ++++++++++++ src/uhitm.c | 6 +++++- 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/decl.h b/include/decl.h index 9989a93dc..0a5e374f7 100644 --- a/include/decl.h +++ b/include/decl.h @@ -1257,6 +1257,7 @@ struct instance_globals { /* uhitm.c */ boolean override_confirmation; /* Used to flag attacks caused by * Stormbringer's maliciousness. */ + short corpsenm_digested; /* monster type being digested, set by gulpum */ /* vision.c */ seenV **viz_array; /* used in cansee() and couldsee() macros */ diff --git a/include/extern.h b/include/extern.h index 2c96fc639..68adedd8e 100644 --- a/include/extern.h +++ b/include/extern.h @@ -775,6 +775,7 @@ extern void set_tin_variety(struct obj *, int); extern int tin_variety_txt(char *, int *); extern void tin_details(struct obj *, int, char *); extern boolean Popeye(int); +extern int Finish_digestion(void); /* ### end.c ### */ diff --git a/src/decl.c b/src/decl.c index e2384a0da..40e04ec2e 100644 --- a/src/decl.c +++ b/src/decl.c @@ -674,6 +674,7 @@ const struct instance_globals g_init = { /* uhitm.c */ FALSE, /* override_confirmation */ + NON_PM, /* corpsenm_digested */ /* vision.c */ UNDEFINED_PTR, /* viz_array */ diff --git a/src/eat.c b/src/eat.c index c6f3f9a97..1ebf42014 100644 --- a/src/eat.c +++ b/src/eat.c @@ -3791,4 +3791,16 @@ Popeye(int threat) return FALSE; } +/* the hero has swallowed a monster whole as a purple worm or similar, and has + finished digesting its corpse (called via g.afternmv) */ +int +Finish_digestion(void) +{ + if (g.corpsenm_digested != NON_PM) { + cpostfx(g.corpsenm_digested); + g.corpsenm_digested = NON_PM; + } + return 0; +} + /*eat.c*/ diff --git a/src/uhitm.c b/src/uhitm.c index a267a43c7..c2fbd396d 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -4462,8 +4462,9 @@ gulpum(struct monst *mdef, struct attack *mattk) && !(g.mvitals[monsndx(pd)].mvflags & G_NOCORPSE)) { /* nutrition only if there can be a corpse */ u.uhunger += (pd->cnutrit + 1) / 2; - } else + } else { tmp = 0; + } Sprintf(msgbuf, "You totally digest %s.", mon_nam(mdef)); if (tmp != 0) { /* setting afternmv = end_engulf is tempting, @@ -4477,6 +4478,9 @@ gulpum(struct monst *mdef, struct attack *mattk) nomul(-tmp); g.multi_reason = "digesting something"; g.nomovemsg = msgbuf; + /* possible intrinsic once totally digested */ + g.corpsenm_digested = monsndx(pd); + g.afternmv = Finish_digestion; } else pline1(msgbuf); if (pd == &mons[PM_GREEN_SLIME]) { -- 2.50.0