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

@@ -844,7 +844,7 @@ register struct trap *trap;
unsigned trflags;
{
register int ttype = trap->ttyp;
register struct obj *otmp;
struct obj *otmp;
boolean already_seen = trap->tseen,
forcetrap = (trflags & FORCETRAP) != 0,
webmsgok = (trflags & NOWEBMSG) == 0,
@@ -915,8 +915,9 @@ unsigned trflags;
otmp->opoisoned = 0;
if (u.usteed && !rn2(2) && steedintrap(trap, otmp)) { /* nothing */
;
} else if (thitu(8, dmgval(otmp, &youmonst), otmp, "arrow")) {
obfree(otmp, (struct obj *) 0);
} else if (thitu(8, dmgval(otmp, &youmonst), &otmp, "arrow")) {
if (otmp)
obfree(otmp, (struct obj *) 0);
} else {
place_object(otmp, u.ux, u.uy);
if (!Blind)
@@ -944,13 +945,15 @@ unsigned trflags;
oldumort = u.umortality;
if (u.usteed && !rn2(2) && steedintrap(trap, otmp)) { /* nothing */
;
} else if (thitu(7, dmgval(otmp, &youmonst), otmp, "little dart")) {
if (otmp->opoisoned)
poisoned("dart", A_CON, "little dart",
/* if damage triggered life-saving,
poison is limited to attrib loss */
(u.umortality > oldumort) ? 0 : 10, TRUE);
obfree(otmp, (struct obj *) 0);
} else if (thitu(7, dmgval(otmp, &youmonst), &otmp, "little dart")) {
if (otmp) {
if (otmp->opoisoned)
poisoned("dart", A_CON, "little dart",
/* if damage triggered life-saving,
poison is limited to attrib loss */
(u.umortality > oldumort) ? 0 : 10, TRUE);
obfree(otmp, (struct obj *) 0);
}
} else {
place_object(otmp, u.ux, u.uy);
if (!Blind)
@@ -1802,7 +1805,7 @@ int style;
if (multi)
nomul(0);
if (thitu(9 + singleobj->spe, dmgval(singleobj, &youmonst),
singleobj, (char *) 0))
&singleobj, (char *) 0))
stop_occupation();
}
if (style == ROLL) {