-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crash with Psych Up, Focus Energy, and Dragon Cheer #10573
Fix crash with Psych Up, Focus Energy, and Dragon Cheer #10573
Conversation
This does match cartridge behavior; a Pokemon with Focus Energy that uses Psych Up into +1 Dragon Cheer will have +1 crit ratio after the move resolves. So it's fine to clear everything first, then add the new volatiles. You will need to also do this in Costar and all the areas where Psych Up, etc. is overriden. This PR should give you a good idea of those places: #10412 I would like to see some tests as well. I can write those for you. |
for (const volatile of volatilesToCopy) source.removeVolatile(volatile); | ||
for (const volatile of volatilesToCopy) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (const volatile of volatilesToCopy) source.removeVolatile(volatile); | |
for (const volatile of volatilesToCopy) { | |
for (const volatile of volatilesToCopy) { | |
source.removeVolatile(volatile); |
wouldn't this functionally do the same thing with one less iteration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is this a concern for Costar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is that you need to remove the Focus Energy volatile in order to be able to properly copy the Dragon Cheer volatile and vice versa. Costar can presumably activate after having volatiles though use of Neutralising Gas or other methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I guess the other approach would be to avoid having codependent volatiles altogether by putting all of the logic in the Psych Up volatile which would have to work out whether it had been set by Dragon Cheer on a non-Dragon type in which case it would only add 1 to the crit ratio.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't move the removeVolatile
call inside the same loop that tries to add volatiles since that would not remove focusenergy
before dragoncheer
is added; in this case fusing the loop changes the behavior. We could re-order the volatilesToCopy
list, but I'm not sure (or tbh willing to exhaustively test) that would be robust, and it definitely wouldn't be robust against possible future additions or list re-orderings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the cartridge behavior of Costar after neutralizing gas?
e.g. roaring moon has 2 dd's and dragoncheer effect, flamigo switches in and copies all three boosts (+2 atk, +2 spe, +2 crit).
opponent switches weezing-galar (neutralizing gas) in
roaring moon switches out to hydreigon
weezing galar switches out
should flamigo after costar re-ups have no boosts? volatiles only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the cartridge behavior of Costar after neutralizing gas? e.g. roaring moon has 2 dd's and dragoncheer effect, flamigo switches in and copies all three boosts (+2 atk, +2 spe, +2 crit). opponent switches weezing-galar (neutralizing gas) in roaring moon switches out to hydreigon weezing galar switches out
should flamigo after costar re-ups have no boosts? volatiles only?
It should have attempted to copy Hydreigon's stats, which in this case would be +0 Atk and +0 Spe. It also would copy Hydreigon's lack of crit volatile, so it should have a +0 crit rate again after Costar activates. It's identical to how Psych Up behaves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, that's the current behavior I have tested, then.
If a pokemon under the effect of
focus energy
tries to copy thedragon cheer
effect, the server crashes. Removing the possible crit stage modifiers first protects againstdragon cheer
trying to set the property of a volatile that was never successfully added.I didn't test this for faithfulness against the in-game behavior.
Replication instructions:
start a local server.
create two doubles teams. One must have a mon that can use both
focus energy
andpsych up
, e.g. hydreigon. The other must have a pokemon that can usedragon cheer
. Challenge yourself with the two teams.Turn 1: use
dragon cheer
andfocus energy
Turn 2: use
psych up
from the mon underfocus energy
, targeting the opposing mon under the effect ofdragon cheer
Sample crash log/replay below: