From: PatR Date: Mon, 10 Oct 2022 23:46:33 +0000 (-0700) Subject: PR #892 - one more try... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2599c2e990a597cb7f815c0051152921e278720;p=nethack PR #892 - one more try... Try again to make losestr() do what's intended. If it would take strength below 3, it takes away HP and max HP instead. If hero is poly'd, those come from the hero-as-monst values. If hero was poly'd but isn't any more, hero-as-monst died and rehumanized as previous self; leave max HP alone. If hero wasn't poly'd, take HP and max HP from their usual values, but don't take max HP below the threshold of minimum max HP (experience level times 1). The old check for max HP going below minimum can't happen anymore, unless hero was below that threshold already (which shouldn't happen; if it does somehow, don't punish hero further). If this still isn't right, I'll throw up my hands and my lunch. --- diff --git a/src/attrib.c b/src/attrib.c index 0db15de8a..5b20419af 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -223,27 +223,38 @@ losestr(int num, const char *knam, schar k_format) --num; amt = rn1(4, 3); /* (0..(4-1))+3 => 3..6; used to use flat 6 here */ dmg += amt; - if (Upolyd) { - u.mhmax -= min(amt, u.mhmax - 1); - } else { - setuhpmax(u.uhpmax - amt); - } - g.context.botl = TRUE; } if (dmg) { + boolean waspolyd = Upolyd; + /* in case damage is fatal and caller didn't supply killer reason */ if (!knam || !*knam) { knam = "terminal frailty"; k_format = KILLED_BY; } losehp(dmg, knam, k_format); - } - if (u.uhpmax < uhpmin) { + if (Upolyd) { + /* if still polymorhed, reduce you-as-monst maxHP; never below 1 */ + u.mhmax -= min(dmg, u.mhmax - 1); + } else if (waspolyd) { + ; /* rehumanization was triggered; don't reduce no-polyd HP */ + } else { + /* not polymorphed; reduce max HP, but not below below uhpmin */ + if (u.uhpmax > uhpmin) + setuhpmax(max(u.uhpmax - dmg, uhpmin)); + } + g.context.botl = TRUE; + } +#if 0 /* only possible if uhpmax was already less than uhpmin */ + if (!Upolyd && u.uhpmax < uhpmin) { setuhpmax(min(olduhpmax, uhpmin)); if (!Drain_resistance) losexp(NULL); /* won't be fatal when no 'drainer' is supplied */ } +#else + nhUse(olduhpmax); +#endif (void) adjattrib(A_STR, -num, 1); }