Don't make callers responsible for losestr death

Remove callers' responsibility to deal with possible hero death when
calling losestr.  This is less fragile and error-prone than leaving it
in the caller's hands, but it means that death from the monster spell
'weaken target' no longer goes through done_in_by, and the death reason
is no longer "killed by <monster name>".
This commit is contained in:
Michael Meyer
2022-10-04 17:37:35 -04:00
committed by PatR
parent c0dfa40cd3
commit 70fe2ce5cd
6 changed files with 19 additions and 16 deletions

View File

@@ -211,19 +211,24 @@ gainstr(struct obj *otmp, int incr, boolean givemsg)
/* may kill you; cause may be poison or monster like 'a' */
void
losestr(int num)
losestr(int num, const char *knam, schar k_format)
{
int uhpmin = minuhpmax(1), olduhpmax = u.uhpmax;
int ustr = ABASE(A_STR) - num;
/* in case HP loss kills the hero once Str hits the minimum */
if (!knam || !*knam) {
knam = "terminal frailty";
k_format = KILLED_BY;
}
while (ustr < 3) {
++ustr;
--num;
losehp(6, knam, k_format);
if (Upolyd) {
u.mh -= 6;
u.mhmax -= 6;
} else {
u.uhp -= 6;
setuhpmax(u.uhpmax - 6);
}
g.context.botl = TRUE;