[Hotfix] Prevent Future Sight crash with new catches, attempt 2 #4910
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What are the changes the user will see?
Catching and releasing a Pokemon that used Future Sight on the turn FS was supposed to trigger will no longer freeze the game.
Why am I making these changes?
Discord bug report
What are the changes from a developer perspective?
At the moment FS goes through a move effect phase so it expects the user Pokemon to be around to perform hit checks and other things. For a Pokemon that was caught and released the turn FS would hit a lot of its attributes are gone at this point, causing the checks to crash the game.
One of the undefined attributes is the Pokemon's scene reference, which should get solved in the future with PR #4766
So hopefully this will just resolve itself with that in the future
As FS is still P and I'm not entirely sure that it should go through hit checks and everything in the first place, I don't really want to add null/undefined checks everywhere for this. So for now instead the Move Effect Phase is just ended and so FS will not hit in this specific scenario. Of note, FS already does not trigger if you catch and release the Pokemon one turn before FS is supposed to hit, so this makes the overall behavior a little more consistent.
Screenshots/Videos
Before:
After:
screen-20241118-190151.2.mp4
How to test the changes?
Overrides:
Start the run with a full team
Unchanged scenarios:
Release - 1 turn before FS hit
Keep - 1 turn before FS hit
Keep - turn of FS hit
Checklist
[ ] I'm usingbeta
as my base branch[ ] If I have text, did I make it translatable and add a key in the English locale file(s)?npm run test
)