Skip to content

Commit

Permalink
Buff gain energy potions
Browse files Browse the repository at this point in the history
Note by copperwater: This is intended to make them more reliable as a
method of recovering a good chunk of energy quickly by a spellcaster;
since they're consumable, it's fine for them to be pretty good and a lot
better than ordinary energy regeneration.

Adding a (expensive, top-level) way to alchemize them is from Fourk.
  • Loading branch information
Nephi Allred authored and copperwater committed Mar 23, 2024
1 parent 153f199 commit 8e2003d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
5 changes: 5 additions & 0 deletions doc/xnh-changelog-9.0.md
Expand Up @@ -44,6 +44,11 @@ changes:
marble wands). Dilithium crystals grant them extra speed. The player can eat
boulders and (empty) statues when polymorphed into one, but other rock moles
won't.
- Gain energy potions are guaranteed to restore more energy. A blessed one
restores at least 40% of your energy maximum and an uncursed one restores at
least 25%.
- The potion of gain energy can be alchemized by combining the potions of full
healing and gain ability.

### Interface changes

Expand Down
38 changes: 23 additions & 15 deletions src/potion.c
Expand Up @@ -1427,31 +1427,36 @@ peffect_levitation(struct obj *otmp)
static void
peffect_gain_energy(struct obj *otmp)
{
int num;
int max_change, current_change;

if (otmp->cursed)
You_feel("lackluster.");
else
pline("Magical energies course through your body.");

/* old: num = rnd(5) + 5 * otmp->blessed + 1;
* blessed: +7..11 max & current (+9 avg)
* uncursed: +2.. 6 max & current (+4 avg)
* cursed: -2.. 6 max & current (-4 avg)
* new: (3.6.0)
* blessed: +3..18 max (+10.5 avg), +9..54 current (+31.5 avg)
* uncursed: +2..12 max (+ 7 avg), +6..36 current (+21 avg)
* cursed: -1.. 6 max (- 3.5 avg), -3..18 current (-10.5 avg)
/* blessed: +3..18 max (+10.5 avg), +9..54 current (+31.5 avg) OR 40% uenmax
* uncursed: +2..12 max (+ 7 avg), +6..36 current (+21 avg) OR 25% uenmax
* cursed: -1.. 6 max (- 3.5 avg), -3..18 current (-10.5 avg)
*/
num = d(otmp->blessed ? 3 : !otmp->cursed ? 2 : 1, 6);
if (otmp->cursed)
num = -num; /* subtract instead of add when cursed */
u.uenmax += num;
if (otmp->blessed) {
max_change = d(3, 6);
current_change = 2 * u.uenmax / 5;
} else if(!otmp->cursed) {
max_change = d(2, 6);
current_change = u.uenmax / 4;
} else {
max_change = -1 * d(1, 6);
current_change = 3 * max_change;
}
if (current_change < 3 * max_change) {
current_change = 3 * max_change;
}
u.uenmax += max_change;
if (u.uenmax > u.uenpeak)
u.uenpeak = u.uenmax;
else if (u.uenmax <= 0)
u.uenmax = 0;
u.uen += 3 * num;
u.uen += current_change;
if (u.uen > u.uenmax)
u.uen = u.uenmax;
else if (u.uen <= 0)
Expand Down Expand Up @@ -2471,10 +2476,13 @@ mixtype(struct obj *o1, struct obj *o2)
/*FALLTHRU*/
case POT_EXTRA_HEALING:
case POT_FULL_HEALING:
if (o2typ == POT_GAIN_LEVEL || o2typ == POT_GAIN_ENERGY)
if (o2typ == POT_GAIN_LEVEL || o2typ == POT_GAIN_ENERGY) {
return (o1typ == POT_HEALING) ? POT_EXTRA_HEALING
: (o1typ == POT_EXTRA_HEALING) ? POT_FULL_HEALING
: POT_GAIN_ABILITY;
} else if (o1typ == POT_FULL_HEALING && o2typ == POT_GAIN_ABILITY) {
return POT_GAIN_ENERGY;
}
/*FALLTHRU*/
case UNICORN_HORN:
switch (o2typ) {
Expand Down

0 comments on commit 8e2003d

Please sign in to comment.