| 595 | }; |
| 596 | |
| 597 | void |
| 598 | exerchk(void) |
| 599 | { |
| 600 | int i, ax, mod_val, lolim, hilim; |
| 601 | |
| 602 | /* Check out the periodic accumulations */ |
| 603 | exerper(); |
| 604 | |
| 605 | if (svm.moves >= svc.context.next_attrib_check) { |
| 606 | debugpline1("exerchk: ready to test. multi = %ld.", gm.multi); |
| 607 | } |
| 608 | /* Are we ready for a test? */ |
| 609 | if (svm.moves >= svc.context.next_attrib_check && !gm.multi) { |
| 610 | debugpline0("exerchk: testing."); |
| 611 | /* |
| 612 | * Law of diminishing returns (Part II): |
| 613 | * |
| 614 | * The effects of "exercise" and "abuse" wear |
| 615 | * off over time. Even if you *don't* get an |
| 616 | * increase/decrease, you lose some of the |
| 617 | * accumulated effects. |
| 618 | */ |
| 619 | for (i = 0; i < A_MAX; ++i) { |
| 620 | ax = AEXE(i); |
| 621 | /* nothing to do here if no exercise or abuse has occurred |
| 622 | (Int and Cha always fall into this category) */ |
| 623 | if (!ax) |
| 624 | continue; /* ok to skip nextattrib */ |
| 625 | |
| 626 | mod_val = sgn(ax); /* +1 or -1; used below */ |
| 627 | /* no further effect for exercise if at max or abuse if at min; |
| 628 | can't exceed 18 via exercise even if actual max is higher */ |
| 629 | lolim = ATTRMIN(i); /* usually 3; might be higher */ |
| 630 | hilim = ATTRMAX(i); /* usually 18; maybe lower or higher */ |
| 631 | if (hilim > 18) |
| 632 | hilim = 18; |
| 633 | if ((ax < 0) ? (ABASE(i) <= lolim) : (ABASE(i) >= hilim)) |
| 634 | goto nextattrib; |
| 635 | /* can't exercise non-Wisdom while polymorphed; previous |
| 636 | exercise/abuse gradually wears off without impact then */ |
| 637 | if (Upolyd && i != A_WIS) |
| 638 | goto nextattrib; |
| 639 | |
| 640 | debugpline2("exerchk: testing %s (%d).", |
| 641 | (i == A_STR) ? "Str" |
| 642 | : (i == A_INT) ? "Int?" |
| 643 | : (i == A_WIS) ? "Wis" |
| 644 | : (i == A_DEX) ? "Dex" |
| 645 | : (i == A_CON) ? "Con" |
| 646 | : (i == A_CHA) ? "Cha?" |
| 647 | : "???", |
| 648 | ax); |
| 649 | /* |
| 650 | * Law of diminishing returns (Part III): |
| 651 | * |
| 652 | * You don't *always* gain by exercising. |
| 653 | * [MRS 92/10/28 - Treat Wisdom specially for balance.] |
| 654 | */ |