fix #6144 - strength loss from severe hunger
It was possible to arbitrarily boost strength (up to its race-specific limit) by wearing a ring of sustain ability, becoming weak from hunger (but not actually losing strength due to Fixed_abil), removing the ring, eating enough to stop being Weak, then repeat as desired. I think you could substitute polymorph for wearing ring, and rehumanize for removing ring and get similar results, although that would be more tedious. My first attempt to fix this was a lot more complicated. This one puts the temporary strength loss in ATEMP(A_STR) where it carries over from normal form to polymophed form and back. Fixed_abil doesn't prevent the loss any more, nor its recovery. One side-effect of the change is that the possibility of dying when becoming weak from hunger (if Str gets down to 3, further attempts to lower it take away HP instead of Str) no longer exists. Using ATEMP() instead of directly manipulating ABASE() means that current strength is less but underlying base strength does not actually drop any more.
This commit is contained in:
24
src/eat.c
24
src/eat.c
@@ -112,8 +112,11 @@ register struct obj *obj;
|
||||
void
|
||||
init_uhunger()
|
||||
{
|
||||
context.botl = (u.uhs != NOT_HUNGRY || ATEMP(A_STR) < 0);
|
||||
u.uhunger = 900;
|
||||
u.uhs = NOT_HUNGRY;
|
||||
if (ATEMP(A_STR) < 0)
|
||||
ATEMP(A_STR) = 0;
|
||||
}
|
||||
|
||||
/* tin types [SPINACH_TIN = -1, overrides corpsenm, nut==600] */
|
||||
@@ -2961,10 +2964,23 @@ boolean incr;
|
||||
}
|
||||
|
||||
if (newhs != u.uhs) {
|
||||
if (newhs >= WEAK && u.uhs < WEAK)
|
||||
losestr(1); /* this may kill you -- see below */
|
||||
else if (newhs < WEAK && u.uhs >= WEAK)
|
||||
losestr(-1);
|
||||
if (newhs >= WEAK && u.uhs < WEAK) {
|
||||
/* this used to be losestr(1) which had the potential to
|
||||
be fatal (still handled below) by reducing HP if it
|
||||
tried to take base strength below minimum of 3 */
|
||||
ATEMP(A_STR) = -1; /* temporary loss overrides Fixed_abil */
|
||||
/* defer context.botl status update until after hunger message */
|
||||
} else if (newhs < WEAK && u.uhs >= WEAK) {
|
||||
/* this used to be losestr(-1) which could be abused by
|
||||
becoming weak while wearing ring of sustain ability,
|
||||
removing ring, eating to 'restore' strength which boosted
|
||||
strength by a point each time the cycle was performed;
|
||||
substituting "while polymorphed" for sustain ability and
|
||||
"rehumanize" for ring removal might have done that too */
|
||||
ATEMP(A_STR) = 0; /* repair of loss also overrides Fixed_abil */
|
||||
/* defer context.botl status update until after hunger message */
|
||||
}
|
||||
|
||||
switch (newhs) {
|
||||
case HUNGRY:
|
||||
if (Hallucination) {
|
||||
|
||||
Reference in New Issue
Block a user