dungeons-of-moria / umoria

Moria: a roguelike Dungeon Crawler game | Umoria Source Code
https://umoria.org
GNU General Public License v3.0
342 stars 71 forks source link

Heroism potion failed #73

Open takosalad opened 1 year ago

takosalad commented 1 year ago

Level 3 dwarven priest, taking around 6 damage per turn from the two centipede attacks, down to 2 HP. I drink a potion of heroism. From what I understand it gives +10 HP. However, the centipede kills me with the next attack.

mrcook commented 9 months ago

Thanks or the issue. I'm not sure when I'll get around to looking into this but I'll leave this here for future reference.

awjackson commented 5 months ago

I can't reproduce this, and I wonder if the person reporting it misunderstands how heroism works.

Heroism is a status that temporarily gives +10 max HP (among other buffs). When you gain it you gain both max HP and current HP; when it wears off you lose the max HP, and then your current HP is capped if it's above your reverted max HP. The heroism status is binary (on or off), it doesn't stack. Drinking a second potion of heroism when you already have the status doesn't give you another 10 HP, it only increases the duration.

awjackson commented 5 months ago

Never mind, I managed to reproduce the described situation (died the same turn as quaffing a heroism potion) without multiple potions being involved, and I understand why it happens now.

The main game loop in umoria looks like this:

Update player status (hunger, light, hp/mp regen, buff durations, etc) Accept and execute player command Move monsters (repeat)

The changes to the player's maximum and current HP from heroism kicking in or wearing off are not applied immediately when you quaff the potion (unlike, say, using a healing potion or spell) but rather in the "update player status" part of the game loop. Thus, it's possible for monsters to kill you after you quaff the potion but before you gain the temporary HP from it.

This is unintuitive but it's the same way 5.5.2 and previous versions of the game worked. Another buff that works a similar way is blessing: monsters will still attack your unbuffed AC during the turn when you first cast the spell or read the scroll, because the buff is only applied at the start of the next turn.

mrcook commented 5 months ago

Hi @awjackson, many thanks for looking into this and for clarifying the behaviour. As my original goal for this repository was to not change the original gameplay, I think this one is best left alone. I will however leave this issue open.