suppress obsolete restore_attrib()

moveloop() has been calling restore_attrib() every turn, and
restore_attrib() loops through all six characteristics every time
to check for ones that have temporary adjustments timing out.  But
ATIME(characteristic) is never set anywhere and no time outs would
occur.  So delete the call to restore_attrib() from moveloop().

This leaves that no-longer-called routine in place and updates it
to handle Wounded_legs properly in case it ever does get used.

Also, add a comment about "restore ability" not fixing temporarily
lost characteristics due to hunger or wounded legs.  And update
unfixable_trouble_count() to check for those so that restore ability
won't say "you feel great" when it fails to fix them.
This commit is contained in:
PatR
2022-01-11 11:25:04 -08:00
parent ffeb0e27a8
commit a8e9e1b488
4 changed files with 22 additions and 10 deletions

View File

@@ -322,7 +322,6 @@ moveloop_core(void)
u.udg_cnt = rn1(200, 50);
}
}
restore_attrib();
/* XXX This should be recoded to use something like regions - a list of
* things that are active and need to be handled that is dynamically
* maintained and not a list of special cases. */

View File

@@ -3982,7 +3982,9 @@ unfixable_trouble_count(boolean is_horn)
unfixable_trbl++;
if (Strangled)
unfixable_trbl++;
if (Wounded_legs && !u.usteed)
if (ATEMP(A_DEX) < 0 && Wounded_legs)
unfixable_trbl++;
if (ATEMP(A_STR) < 0 && u.uhs >= WEAK)
unfixable_trbl++;
/* lycanthropy is undesirable, but it doesn't actually make you feel bad
so don't count it as a trouble which can't be fixed */

View File

@@ -377,19 +377,26 @@ set_moreluck(void)
u.moreluck = -LUCKADD;
}
/* (not used) */
void
restore_attrib(void)
{
int i, equilibrium;;
/*
* Note: this gets called on every turn but ATIME() is never set
* to non-zero anywhere, and ATEMP() is only used for strength loss
* from hunger, so it doesn't actually do anything.
* Note: this used to get called by moveloop() on every turn but
* ATIME() is never set to non-zero anywhere so didn't do anything.
* Presumably it once supported something like potion of heroism
* which conferred temporary characteristics boost(s).
*
* ATEMP() is used for strength loss from hunger, which doesn't
* time out, and for dexterity loss from wounded legs, which has
* its own timeout routine.
*/
for (i = 0; i < A_MAX; i++) { /* all temporary losses/gains */
equilibrium = (i == A_STR && u.uhs >= WEAK) ? -1 : 0;
equilibrium = ((i == A_STR && u.uhs >= WEAK)
|| (i == A_DEX && Wounded_legs)) ? -1 : 0;
if (ATEMP(i) != equilibrium && ATIME(i) != 0) {
if (!(--(ATIME(i)))) { /* countdown for change */
ATEMP(i) += (ATEMP(i) > 0) ? -1 : 1;

View File

@@ -598,6 +598,8 @@ dopotion(struct obj *otmp)
return ECMD_TIME;
}
/* potion or spell of restore ability; for spell, otmp is a temporary
spellbook object that will be blessed if hero is skilled in healing */
static void
peffect_restore_ability(struct obj *otmp)
{
@@ -608,11 +610,13 @@ peffect_restore_ability(struct obj *otmp)
} else {
int i, ii;
/* unlike unicorn horn, overrides Fixed_abil */
/* unlike unicorn horn, overrides Fixed_abil;
does not recover temporary strength loss due to hunger
or temporary dexterity loss due to wounded legs */
pline("Wow! This makes you feel %s!",
(otmp->blessed)
? (unfixable_trouble_count(FALSE) ? "better" : "great")
: "good");
(!otmp->blessed) ? "good"
: unfixable_trouble_count(FALSE) ? "better"
: "great");
i = rn2(A_MAX); /* start at a random point */
for (ii = 0; ii < A_MAX; ii++) {
int lim = AMAX(i);