potion or spell of restore ability; for spell, otmp is a temporary spellbook object that will be blessed if hero is skilled in healing */
| 643 | /* potion or spell of restore ability; for spell, otmp is a temporary |
| 644 | spellbook object that will be blessed if hero is skilled in healing */ |
| 645 | staticfn void |
| 646 | peffect_restore_ability(struct obj *otmp) |
| 647 | { |
| 648 | gp.potion_unkn++; |
| 649 | if (otmp->cursed) { |
| 650 | pline("Ulch! This makes you feel mediocre!"); |
| 651 | return; |
| 652 | } else { |
| 653 | int i, ii; |
| 654 | |
| 655 | /* unlike unicorn horn, overrides Fixed_abil; |
| 656 | does not recover temporary strength loss due to hunger |
| 657 | or temporary dexterity loss due to wounded legs */ |
| 658 | pline("Wow! This makes you feel %s!", |
| 659 | (!otmp->blessed) ? "good" |
| 660 | : unfixable_trouble_count(FALSE) ? "better" |
| 661 | : "great"); |
| 662 | i = rn2(A_MAX); /* start at a random point */ |
| 663 | for (ii = 0; ii < A_MAX; ii++) { |
| 664 | int lim = AMAX(i); |
| 665 | |
| 666 | /* this used to adjust 'lim' for A_STR when u.uhs was |
| 667 | WEAK or worse, but that's handled via ATEMP(A_STR) now */ |
| 668 | if (ABASE(i) < lim) { |
| 669 | ABASE(i) = lim; |
| 670 | /* reset stat abuse (but not exercise) to 0 as well */ |
| 671 | AEXE(i) = max(AEXE(i), 0); |
| 672 | |
| 673 | disp.botl = TRUE; |
| 674 | /* only first found if not blessed */ |
| 675 | if (!otmp->blessed) |
| 676 | break; |
| 677 | } |
| 678 | if (++i >= A_MAX) |
| 679 | i = 0; |
| 680 | } |
| 681 | |
| 682 | /* when using the potion (not the spell) also restore lost levels, |
| 683 | to make the potion more worth keeping around for players with |
| 684 | the spell or with a unihorn; this is better than full healing |
| 685 | in that it can restore all of them, not just half, and a |
| 686 | blessed potion restores them all at once */ |
| 687 | if (otmp->otyp == POT_RESTORE_ABILITY && u.ulevel < u.ulevelmax) { |
| 688 | do { |
| 689 | pluslvl(FALSE); |
| 690 | } while (u.ulevel < u.ulevelmax && otmp->blessed); |
| 691 | } |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | staticfn void |
| 696 | peffect_hallucination(struct obj *otmp) |
no test coverage detected