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:
@@ -114,7 +114,7 @@ extern struct obj *has_magic_key(struct monst *);
|
|||||||
|
|
||||||
extern boolean adjattrib(int, int, int);
|
extern boolean adjattrib(int, int, int);
|
||||||
extern void gainstr(struct obj *, int, boolean);
|
extern void gainstr(struct obj *, int, boolean);
|
||||||
extern void losestr(int);
|
extern void losestr(int, const char *, schar);
|
||||||
extern void poisontell(int, boolean);
|
extern void poisontell(int, boolean);
|
||||||
extern void poisoned(const char *, int, const char *, int, boolean);
|
extern void poisoned(const char *, int, const char *, int, boolean);
|
||||||
extern void change_luck(schar);
|
extern void change_luck(schar);
|
||||||
|
|||||||
11
src/attrib.c
11
src/attrib.c
@@ -211,19 +211,24 @@ gainstr(struct obj *otmp, int incr, boolean givemsg)
|
|||||||
|
|
||||||
/* may kill you; cause may be poison or monster like 'a' */
|
/* may kill you; cause may be poison or monster like 'a' */
|
||||||
void
|
void
|
||||||
losestr(int num)
|
losestr(int num, const char *knam, schar k_format)
|
||||||
{
|
{
|
||||||
int uhpmin = minuhpmax(1), olduhpmax = u.uhpmax;
|
int uhpmin = minuhpmax(1), olduhpmax = u.uhpmax;
|
||||||
int ustr = ABASE(A_STR) - num;
|
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) {
|
while (ustr < 3) {
|
||||||
++ustr;
|
++ustr;
|
||||||
--num;
|
--num;
|
||||||
|
losehp(6, knam, k_format);
|
||||||
if (Upolyd) {
|
if (Upolyd) {
|
||||||
u.mh -= 6;
|
|
||||||
u.mhmax -= 6;
|
u.mhmax -= 6;
|
||||||
} else {
|
} else {
|
||||||
u.uhp -= 6;
|
|
||||||
setuhpmax(u.uhpmax - 6);
|
setuhpmax(u.uhpmax - 6);
|
||||||
}
|
}
|
||||||
g.context.botl = TRUE;
|
g.context.botl = TRUE;
|
||||||
|
|||||||
11
src/eat.c
11
src/eat.c
@@ -1815,9 +1815,9 @@ eatcorpse(struct obj *otmp)
|
|||||||
tp++;
|
tp++;
|
||||||
pline("Ecch - that must have been poisonous!");
|
pline("Ecch - that must have been poisonous!");
|
||||||
if (!Poison_resistance) {
|
if (!Poison_resistance) {
|
||||||
losestr(rnd(4));
|
const char *knam = !glob ? "poisonous corpse" : "poisonous glob";
|
||||||
losehp(rnd(15), !glob ? "poisonous corpse" : "poisonous glob",
|
losestr(rnd(4), knam, KILLED_BY_AN);
|
||||||
KILLED_BY_AN);
|
losehp(rnd(15), knam, KILLED_BY_AN);
|
||||||
} else
|
} else
|
||||||
You("seem unaffected by the poison.");
|
You("seem unaffected by the poison.");
|
||||||
|
|
||||||
@@ -2753,8 +2753,9 @@ doeat(void)
|
|||||||
if (otmp->oclass == WEAPON_CLASS && otmp->opoisoned) {
|
if (otmp->oclass == WEAPON_CLASS && otmp->opoisoned) {
|
||||||
pline("Ecch - that must have been poisonous!");
|
pline("Ecch - that must have been poisonous!");
|
||||||
if (!Poison_resistance) {
|
if (!Poison_resistance) {
|
||||||
losestr(rnd(4));
|
const char *knam = xname(otmp);
|
||||||
losehp(rnd(15), xname(otmp), KILLED_BY_AN);
|
losestr(rnd(4), knam, KILLED_BY_AN);
|
||||||
|
losehp(rnd(15), knam, KILLED_BY_AN);
|
||||||
} else
|
} else
|
||||||
You("seem unaffected by the poison.");
|
You("seem unaffected by the poison.");
|
||||||
} else if (!nodelicious) {
|
} else if (!nodelicious) {
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ drinkfountain(void)
|
|||||||
losehp(rnd(4), "unrefrigerated sip of juice", KILLED_BY_AN);
|
losehp(rnd(4), "unrefrigerated sip of juice", KILLED_BY_AN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
losestr(rn1(4, 3));
|
losestr(rn1(4, 3), "contaminated water", KILLED_BY);
|
||||||
losehp(rnd(10), "contaminated water", KILLED_BY);
|
losehp(rnd(10), "contaminated water", KILLED_BY);
|
||||||
exercise(A_CON, FALSE);
|
exercise(A_CON, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -465,11 +465,7 @@ cast_wizard_spell(struct monst *mtmp, int dmg, int spellnum)
|
|||||||
dmg = mtmp->m_lev - 6;
|
dmg = mtmp->m_lev - 6;
|
||||||
if (Half_spell_damage)
|
if (Half_spell_damage)
|
||||||
dmg = (dmg + 1) / 2;
|
dmg = (dmg + 1) / 2;
|
||||||
losestr(rnd(dmg));
|
losestr(rnd(dmg), (const char *) 0, 0);
|
||||||
if (u.uhp < 1)
|
|
||||||
done_in_by(mtmp, DIED);
|
|
||||||
else if (Upolyd && u.mh < 1)
|
|
||||||
rehumanize();
|
|
||||||
}
|
}
|
||||||
dmg = 0;
|
dmg = 0;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -152,7 +152,8 @@ cursed_book(struct obj* bp)
|
|||||||
/* temp disable in_use; death should not destroy the book */
|
/* temp disable in_use; death should not destroy the book */
|
||||||
was_in_use = bp->in_use;
|
was_in_use = bp->in_use;
|
||||||
bp->in_use = FALSE;
|
bp->in_use = FALSE;
|
||||||
losestr(Poison_resistance ? rn1(2, 1) : rn1(4, 3));
|
losestr(Poison_resistance ? rn1(2, 1) : rn1(4, 3),
|
||||||
|
"contact-poisoned spellbook", KILLED_BY_AN);
|
||||||
losehp(rnd(Poison_resistance ? 6 : 10), "contact-poisoned spellbook",
|
losehp(rnd(Poison_resistance ? 6 : 10), "contact-poisoned spellbook",
|
||||||
KILLED_BY_AN);
|
KILLED_BY_AN);
|
||||||
bp->in_use = was_in_use;
|
bp->in_use = was_in_use;
|
||||||
|
|||||||
Reference in New Issue
Block a user