From edd11009e96e92948d79b75278b21cdee73a929f Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 25 Sep 2025 09:59:15 -0700 Subject: [PATCH] issue #1447 - physical damage when polymorphed Isssue reported by Tomsod: hero-as-target section of mhitm_ad_phys() was not handling hero's Half_physical_damage attribute. The issue was about cloning a pet from hero who is poly'd into a pudding but it was more general than that. Half_physical_damage was ignored for any hit by a monster-wielded weapon against poly'd hero. It took a while to convince myself that Half_physical_damage wasn't aleady being applied elsewhere but it doesn't seem to be. Fixes #1447 --- doc/fixes3-7-0.txt | 1 + src/mhitu.c | 3 ++- src/uhitm.c | 12 ++++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 98d309738..15447eac8 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -2132,6 +2132,7 @@ don't try to split a pudding that got jousted into a hole and is off the map mounted hero was able to deliver joust hits when trapped timer sanity check for melting ice gave false complaint about non-ice for frozen moat under open drawbridge +mhitm_ad_phys() was not applying Half_physical_damage when hero was target Fixes to 3.7.0-x Platform and/or Interface Problems Exposed Via git Repository diff --git a/src/mhitu.c b/src/mhitu.c index d6332c18d..480d616fe 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1199,7 +1199,8 @@ hitmu(struct monst *mtmp, struct attack *mattk) mhm.damage = 1; } - if (mhm.damage) { + if (mhm.damage > 0) { + /* [Half_physical_damage isn't applied to mhm.permdmg] */ if (Half_physical_damage /* Mitre of Holiness, even if not currently blessed */ || (Role_if(PM_CLERIC) && uarmh && is_quest_artifact(uarmh) diff --git a/src/uhitm.c b/src/uhitm.c index cca56b435..26f3cfeac 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -4008,7 +4008,8 @@ mhitm_ad_phys( if (mattk->aatyp == AT_WEAP && otmp) { struct obj *marmg; int tmp; - boolean was_poisoned = (otmp->opoisoned || permapoisoned(otmp)); + boolean was_poisoned = (otmp->opoisoned + || permapoisoned(otmp)); if (otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm])) { @@ -4051,6 +4052,9 @@ mhitm_ad_phys( tmp -= rnd(-u.uac); if (tmp < 1) tmp = 1; + if (Half_physical_damage) + tmp = (tmp + 1) / 2; + if (u.mh - tmp > 1 && (objects[otmp->otyp].oc_material == IRON /* relevant 'metal' objects are scalpel and tsurugi */ @@ -4071,13 +4075,13 @@ mhitm_ad_phys( char buf[BUFSZ]; /* similar to mhitm_really_poison, but we don't use the - * exact same values, nor do we want the same 1/8 chance of - * the poison taking (use 1/4, same as in the mhitm case). */ + * exact same values, nor do we want same 1/8 chance of + * poison taking (use 1/4, same as in the mhitm case). */ Sprintf(buf, "%s %s", s_suffix(Monnam(magr)), mpoisons_subj(magr, mattk)); /* arbitrary, but most poison sources in the game are * strength-based. With hpdamchance = 10, HP damage occurs - * 1/2 of the time and it will hit Str the rest of the time. + * 1/2 of the time and it will hit Str rest of the time. * (This is the same as poisoned ammo.) */ poisoned(buf, A_STR, pmname(magr->data, Mgender(magr)), 10, FALSE);