pokerogue icon indicating copy to clipboard operation
pokerogue copied to clipboard

Move effectiveness text displays after fainting, etc.

Open Zeimyth opened this issue 9 months ago • 3 comments

Text describing the effectiveness of a move ("Critical hit!", "It's super effective!", etc.) shows up after "<Pokemon> fainted." and all of the xp-gaining and related processing has completed. It's particularly amusing when you gain a lot of xp, level up several pokemon, maybe learn a new move or evolve, and then finally see that you landed a critical hit.

This feels like a fairly easy bug to spot (I noticed it within just a few minutes of playing the game), and I'm sure I'm not the only user who finds the incorrect order of the text to be somewhat annoying, so I did try to see if there was an existing issue or pull request to address it but didn't see any. I don't mean to duplicate issues or try to fix something that's already being worked on, though, so feel free to indicate if this is a duplicate or isn't going to be fixed right now for some reason.

I did track down the code responsible for this misordering in pokemon.ts and am happy to try my hand at resolving it if that wouldn't get in anyone's way.

Zeimyth avatar Apr 30 '24 18:04 Zeimyth

I've started digging into this issue. I'm seeing that there is a lot of coupling in the code, which is making it tricky to break things out the way I'd like. A pokemon can't faint properly without all of the post-faint processing taking place, and it looks like a lot of battle mechanics depend on the fainting happening at a certain time. I moved the queueing of the FaintPhase to after a pokemon's move is handled, but this introduced some new bugs. For example, an early change of mine could apply status conditions after a pokemon's health hit 0 and before fainting was fully processed. I addressed that (undiscovered side-effects pending), but, currently, I'm dealing with the fact that tag handling depended on the existing location of the fainting processing; damage over time statuses no longer cause pokemon to faint since I moved fainting out of the damageAndUpdate method.

I'm looking for suggestions and advice. I'm realizing that something as simple as text ordering is actually going to be really complex to fix without potentially introducing some ugly bugs. Any suggestions regarding either

  • thoughts people have had about tidying up fainting/damage processing, or
  • suggestions on other stray sources of damage I might not think to account for at first?

Zeimyth avatar May 09 '24 02:05 Zeimyth

FYI, this is also being tracked in #680

David-C-Lee avatar May 18 '24 22:05 David-C-Lee

Glad to see it's getting additional attention. I have put my work on this on hold because it feels like correctly fixing this involves making some very deep changes in some complicated code and I don't want to cause conflicts. If #680 is going to get more activity, then this issue could probably just be closed.

Zeimyth avatar May 21 '24 15:05 Zeimyth

Fixed in https://github.com/pagefaultgames/pokerogue/commit/7ac4900a3eceb64d48170350a4d5b1caf4e02410

Dakurei avatar Jun 17 '24 20:06 Dakurei