maybe recover some lost health (or lose some when an eel out of water) */
| 622 | |
| 623 | /* maybe recover some lost health (or lose some when an eel out of water) */ |
| 624 | staticfn void |
| 625 | regen_hp(int wtcap) |
| 626 | { |
| 627 | int heal = 0; |
| 628 | boolean reached_full = FALSE, |
| 629 | encumbrance_ok = (wtcap < MOD_ENCUMBER || !u.umoved); |
| 630 | |
| 631 | if (Upolyd) { |
| 632 | if (u.mh < 1) { /* shouldn't happen... */ |
| 633 | rehumanize(); |
| 634 | } else if (gy.youmonst.data->mlet == S_EEL |
| 635 | && !is_pool(u.ux, u.uy) && !Is_waterlevel(&u.uz) |
| 636 | && !Breathless) { |
| 637 | /* eel out of water loses hp, similar to monster eels; |
| 638 | as hp gets lower, rate of further loss slows down */ |
| 639 | if (u.mh > 1 && !Regeneration && rn2(u.mh) > rn2(8) |
| 640 | && (!Half_physical_damage || !(svm.moves % 2L))) |
| 641 | heal = -1; |
| 642 | } else if (u.mh < u.mhmax) { |
| 643 | if (U_CAN_REGEN() || (encumbrance_ok && !(svm.moves % 20L))) |
| 644 | heal = 1; |
| 645 | } |
| 646 | if (heal) { |
| 647 | disp.botl = TRUE; |
| 648 | u.mh += heal; |
| 649 | reached_full = (u.mh == u.mhmax); |
| 650 | } |
| 651 | |
| 652 | /* !Upolyd */ |
| 653 | } else { |
| 654 | /* [when this code was in-line within moveloop(), there was |
| 655 | no !Upolyd check here, so poly'd hero recovered lost u.uhp |
| 656 | once u.mh reached u.mhmax; that may have been convenient |
| 657 | for the player, but it didn't make sense for gameplay...] */ |
| 658 | if (u.uhp < u.uhpmax && (encumbrance_ok || U_CAN_REGEN())) { |
| 659 | heal = (u.ulevel + (int)ACURR(A_CON)) > rn2(100); |
| 660 | |
| 661 | if (U_CAN_REGEN()) |
| 662 | heal += 1; |
| 663 | if (Sleepy && u.usleep) |
| 664 | heal++; |
| 665 | |
| 666 | if (heal) { |
| 667 | disp.botl = TRUE; |
| 668 | u.uhp += heal; |
| 669 | if (u.uhp > u.uhpmax) |
| 670 | u.uhp = u.uhpmax; |
| 671 | /* stop voluntary multi-turn activity if now fully healed */ |
| 672 | reached_full = (u.uhp == u.uhpmax); |
| 673 | } |
| 674 | } |
| 675 | } |
| 676 | |
| 677 | if (reached_full) |
| 678 | interrupt_multi("You are in full health."); |
| 679 | } |
| 680 | |
| 681 | #undef U_CAN_REGEN |
no test coverage detected