Use function for combined str/hp loss from poison

Since losestr and losehp calls go together most of the time, this feels
like it probably makes more sense than repeating the killer name/format
twice in a row all over the place.
This commit is contained in:
Michael Meyer
2022-10-08 16:29:56 -07:00
committed by PatR
parent 70fe2ce5cd
commit 02367077bd
5 changed files with 18 additions and 12 deletions
+4 -6
View File
@@ -1815,9 +1815,9 @@ eatcorpse(struct obj *otmp)
tp++;
pline("Ecch - that must have been poisonous!");
if (!Poison_resistance) {
const char *knam = !glob ? "poisonous corpse" : "poisonous glob";
losestr(rnd(4), knam, KILLED_BY_AN);
losehp(rnd(15), knam, KILLED_BY_AN);
poison_strdmg(rnd(4), rnd(15),
!glob ? "poisonous corpse" : "poisonous glob",
KILLED_BY_AN);
} else
You("seem unaffected by the poison.");
@@ -2753,9 +2753,7 @@ doeat(void)
if (otmp->oclass == WEAPON_CLASS && otmp->opoisoned) {
pline("Ecch - that must have been poisonous!");
if (!Poison_resistance) {
const char *knam = xname(otmp);
losestr(rnd(4), knam, KILLED_BY_AN);
losehp(rnd(15), knam, KILLED_BY_AN);
poison_strdmg(rnd(4), rnd(15), xname(otmp), KILLED_BY_AN);
} else
You("seem unaffected by the poison.");
} else if (!nodelicious) {