fix #H6104 - no potion handling in thitu()

thitu() is mostly used for arrows and darts "thrown" by traps, but
scatter() uses it on items launched by a land mine explosion.  Traps
had no need for potion handling, but scattering does.  Changing thitu()
to call potionhit() required that more information be passed to the
latter in case killer reason was needed, and thitu()'s callers needed
to be updated since it now might use up its missile (only when that's
a potion, so scatter() is only caller which actually needed to care).

Quite a bit of work--especially the testing--for something which will
never be noticed in actual play.  In hindsight, it would have been
much simpler just to make scatter destroy all potions rather than
allow the 1% chance of remaining intact (via obj_resists()), or else
leave any intact ones at the explosion spot instead of launching them.
This commit is contained in:
PatR
2017-09-25 10:42:43 -07:00
parent 596bc64341
commit 719af503e7
11 changed files with 79 additions and 53 deletions

View File

@@ -1243,24 +1243,28 @@ const char *objphrase; /* "Your widget glows" or "Steed's saddle glows" */
return res;
}
/* potion obj hits monster mon, which might be youmounst; obj always use up */
void
potionhit(mon, obj, your_fault)
register struct monst *mon;
register struct obj *obj;
boolean your_fault;
potionhit(mon, obj, how)
struct monst *mon;
struct obj *obj;
int how;
{
const char *botlnam = bottlename();
boolean isyou = (mon == &youmonst);
int distance, tx, ty;
struct obj *saddle = (struct obj *) 0;
boolean hit_saddle = FALSE;
boolean hit_saddle = FALSE, your_fault = (how <= POTHIT_HERO_THROW);
if (isyou) {
tx = u.ux, ty = u.uy;
distance = 0;
pline_The("%s crashes on your %s and breaks into shards.", botlnam,
body_part(HEAD));
losehp(Maybe_Half_Phys(rnd(2)), "thrown potion", KILLED_BY_AN);
losehp(Maybe_Half_Phys(rnd(2)),
(how == POTHIT_OTHER_THROW) ? "propelled potion" /* scatter */
: "thrown potion",
KILLED_BY_AN);
} else {
tx = mon->mx, ty = mon->my;
/* sometimes it hits the saddle */
@@ -1314,6 +1318,7 @@ boolean your_fault;
case POT_ACID:
if (!Acid_resistance) {
int dmg;
pline("This burns%s!",
obj->blessed ? " a little"
: obj->cursed ? " a lot" : "");