pagefaultgames / pokerogue

A browser based Pokémon fangame heavily inspired by the roguelite genre.
https://pokerogue.net
GNU Affero General Public License v3.0
3.98k stars 1.59k forks source link

[BUG] HP not displaying correctly after evolution #2352

Open PLMMJ-FH opened 3 weeks ago

PLMMJ-FH commented 3 weeks ago

This really bizarre bug happened while I wasn't paying attention. So I was fighting Surge, and my Toxtricity evolved. But when I had to send it out, until he hit me, its HP says 71/71, but its bar displays a bit of damage. It leveled up immediately after and everything was resolved (HP at proper max of 95) PokerogueWhyAreYouSoBroken

DayKev commented 2 weeks ago

It leveled up immediately after and everything was resolved (HP at proper max of 95)

That's because you get auto-healed after a boss wave. If you had checked your Pokémon's HP from the party menu you would have seen it at 71/95 (or something similar).


For some reason when a Pokémon evolves there's a stale reference somewhere causing the Pokémon's HP to not be updated properly when it evolves.

After investigating for a bit, a possible reason is here in src/field/pokemon.ts/PlayerPokemon:getPossibleEvolution() (specifically line 3151 -> 3153): https://github.com/pagefaultgames/pokerogue/blob/fd7e547750a6109a955343a77d75c5994fceaf34/src/field/pokemon.ts#L3136-L3155

image

First the HP is calculated properly, but then it re-calculates using the original HP value and doesn't re-increase it to where it should be. I think the line(s) mentioned are causing the unnecessary first calculateStats() call and/or the stale reference which is messing things up.

The Pokémon I tested with in the image was Bulbasaur->Ivysaur Lv15->16.