fix issue #1459 - Half_physical_damage vs missiles

Issue reported by Tomsod nearly six months ago: missile damage against
hero was not honoring the Half_physical_damage attribute when hero had
that.

Fixes #1459
This commit is contained in:
PatR
2026-04-18 19:22:07 -07:00
parent 2b88cf0475
commit 84c7e96644
6 changed files with 25 additions and 14 deletions
+1
View File
@@ -2203,6 +2203,7 @@ mounted hero was able to deliver joust hits when trapped
timer sanity check for melting ice gave false complaint about non-ice for timer sanity check for melting ice gave false complaint about non-ice for
frozen moat under open drawbridge frozen moat under open drawbridge
mhitm_ad_phys() was not applying Half_physical_damage when hero was target mhitm_ad_phys() was not applying Half_physical_damage when hero was target
callers of thitu() were not applyibg Half_physical_damage either
throwing crystal plate mail or helm of brilliance up against the ceiling could throwing crystal plate mail or helm of brilliance up against the ceiling could
result in the item being cracked and then vanishing result in the item being cracked and then vanishing
yn_function (used all over the place) sometimes triggered an impossible() yn_function (used all over the place) sometimes triggered an impossible()
+3 -2
View File
@@ -3190,10 +3190,11 @@ use_whip(struct obj *obj)
if (!rn2(25)) { if (!rn2(25)) {
/* proficient with whip, but maybe not /* proficient with whip, but maybe not
so proficient at catching weapons */ so proficient at catching weapons */
int hitu, hitvalu; int dam, hitvalu, hitu;
dam = dmgval(otmp, &gy.youmonst);
hitvalu = 8 + otmp->spe; hitvalu = 8 + otmp->spe;
hitu = thitu(hitvalu, dmgval(otmp, &gy.youmonst), hitu = thitu(hitvalu, Maybe_Half_Phys(dam),
&otmp, (char *) 0); &otmp, (char *) 0);
if (hitu) { if (hitu) {
pline_The("%s hits you as you try to snatch it!", pline_The("%s hits you as you try to snatch it!",
+8 -6
View File
@@ -718,10 +718,11 @@ struct scatter_chain {
/* returns number of scattered objects */ /* returns number of scattered objects */
long long
scatter(coordxy sx, coordxy sy, /* location of objects to scatter */ scatter(
int blastforce, /* force behind the scattering */ coordxy sx, coordxy sy, /* location of objects to scatter */
unsigned int scflags, int blastforce, /* force behind the scattering */
struct obj *obj) /* only scatter this obj */ unsigned int scflags,
struct obj *obj) /* only scatter this obj */
{ {
struct obj *otmp; struct obj *otmp;
int tmp; int tmp;
@@ -864,14 +865,15 @@ scatter(coordxy sx, coordxy sy, /* location of objects to scatter */
} }
} else if (u_at(gb.bhitpos.x, gb.bhitpos.y)) { } else if (u_at(gb.bhitpos.x, gb.bhitpos.y)) {
if (scflags & MAY_HITYOU) { if (scflags & MAY_HITYOU) {
int hitvalu, hitu; int dam, hitvalu, hitu;
if (gm.multi) if (gm.multi)
nomul(0); nomul(0);
dam = dmgval(stmp->obj, &gy.youmonst);
hitvalu = 8 + stmp->obj->spe; hitvalu = 8 + stmp->obj->spe;
if (bigmonst(gy.youmonst.data)) if (bigmonst(gy.youmonst.data))
hitvalu++; hitvalu++;
hitu = thitu(hitvalu, dmgval(stmp->obj, &gy.youmonst), hitu = thitu(hitvalu, Maybe_Half_Phys(dam),
&stmp->obj, (char *) 0); &stmp->obj, (char *) 0);
if (!stmp->obj) if (!stmp->obj)
stmp->stopped = TRUE; stmp->stopped = TRUE;
+1 -1
View File
@@ -93,7 +93,7 @@ thitu(
kprefix = KILLED_BY; /* killer_name supplies "an" if warranted */ kprefix = KILLED_BY; /* killer_name supplies "an" if warranted */
} else { } else {
knm = name; knm = name;
/* [perhaps ought to check for plural here to] */ /* [perhaps ought to check for plural here too] */
if (!strncmpi(name, "the ", 4) || !strncmpi(name, "an ", 3) if (!strncmpi(name, "the ", 4) || !strncmpi(name, "an ", 3)
|| !strncmpi(name, "a ", 2)) || !strncmpi(name, "a ", 2))
kprefix = KILLED_BY; kprefix = KILLED_BY;
+9 -4
View File
@@ -1193,6 +1193,7 @@ trapeffect_arrow_trap(
unsigned trflags UNUSED) unsigned trflags UNUSED)
{ {
struct obj *otmp; struct obj *otmp;
int dam;
if (mtmp == &gy.youmonst) { if (mtmp == &gy.youmonst) {
if (trap->once && trap->tseen && !rn2(15)) { if (trap->once && trap->tseen && !rn2(15)) {
@@ -1206,9 +1207,10 @@ trapeffect_arrow_trap(
seetrap(trap); seetrap(trap);
pline("An arrow shoots out at you!"); pline("An arrow shoots out at you!");
otmp = t_missile(ARROW, trap); otmp = t_missile(ARROW, trap);
dam = dmgval(otmp, &gy.youmonst);
if (u.usteed && !rn2(2) && steedintrap(trap, otmp)) { if (u.usteed && !rn2(2) && steedintrap(trap, otmp)) {
; /* nothing */ ; /* nothing */
} else if (thitu(8, dmgval(otmp, &gy.youmonst), &otmp, "arrow")) { } else if (thitu(8, Maybe_Half_Phys(dam), &otmp, "arrow")) {
if (otmp) if (otmp)
obfree(otmp, (struct obj *) 0); obfree(otmp, (struct obj *) 0);
} else { } else {
@@ -1252,6 +1254,7 @@ trapeffect_dart_trap(
unsigned int trflags UNUSED) unsigned int trflags UNUSED)
{ {
struct obj *otmp; struct obj *otmp;
int dam;
if (mtmp == &gy.youmonst) { if (mtmp == &gy.youmonst) {
int oldumort = u.umortality; int oldumort = u.umortality;
@@ -1269,10 +1272,10 @@ trapeffect_dart_trap(
otmp = t_missile(DART, trap); otmp = t_missile(DART, trap);
if (!rn2(6)) if (!rn2(6))
otmp->opoisoned = 1; otmp->opoisoned = 1;
dam = dmgval(otmp, &gy.youmonst);
if (u.usteed && !rn2(2) && steedintrap(trap, otmp)) { if (u.usteed && !rn2(2) && steedintrap(trap, otmp)) {
; /* nothing */ ; /* nothing */
} else if (thitu(7, dmgval(otmp, &gy.youmonst), } else if (thitu(7, Maybe_Half_Phys(dam), &otmp, "little dart")) {
&otmp, "little dart")) {
if (otmp) { if (otmp) {
if (otmp->opoisoned) if (otmp->opoisoned)
poisoned("dart", A_CON, "little dart", poisoned("dart", A_CON, "little dart",
@@ -3395,9 +3398,11 @@ launch_obj(
break; break;
} }
} else if (u_at(x, y)) { } else if (u_at(x, y)) {
int dam = dmgval(singleobj, &gy.youmonst);
if (gm.multi) if (gm.multi)
nomul(0); nomul(0);
if (thitu(9 + singleobj->spe, dmgval(singleobj, &gy.youmonst), if (thitu(9 + singleobj->spe, Maybe_Half_Phys(dam),
&singleobj, (char *) 0)) &singleobj, (char *) 0))
stop_occupation(); stop_occupation();
} }
+3 -1
View File
@@ -4201,8 +4201,10 @@ boomhit(struct obj *obj, int dx, int dy)
} }
if (u_at(gb.bhitpos.x, gb.bhitpos.y)) { /* ct == 9 */ if (u_at(gb.bhitpos.x, gb.bhitpos.y)) { /* ct == 9 */
if (Fumbling || rn2(20) >= ACURR(A_DEX)) { if (Fumbling || rn2(20) >= ACURR(A_DEX)) {
int dam = dmgval(obj, &gy.youmonst);
/* we hit ourselves */ /* we hit ourselves */
(void) thitu(10 + obj->spe, dmgval(obj, &gy.youmonst), &obj, (void) thitu(10 + obj->spe, Maybe_Half_Phys(dam), &obj,
"boomerang"); "boomerang");
endmultishot(TRUE); endmultishot(TRUE);
break; break;