More animation fixes (mostly for Roar)

This commit is contained in:
innerthunder 2024-09-12 02:33:05 -07:00
parent bd9d5931e5
commit 9d2f309f75
2 changed files with 14 additions and 4 deletions

View File

@ -802,11 +802,20 @@ export abstract class BattleAnim {
} }
targetSprite.pipelineData["tone"] = [ 0.0, 0.0, 0.0, 0.0 ]; targetSprite.pipelineData["tone"] = [ 0.0, 0.0, 0.0, 0.0 ];
targetSprite.setAngle(0); targetSprite.setAngle(0);
if (!this.isHideUser() && userSprite) {
userSprite.setVisible(true); // using this.user to fix context loss due to isOppAnim swap (#481) /**
* This and `targetSpriteToShow` are used to restore context lost
* from the `isOppAnim` swap. Using these references instead of `this.user`
* and `this.target` prevent the target's Substitute doll from disappearing
* after being the target of an animation.
*/
const userSpriteToShow = !isOppAnim ? userSprite : targetSprite;
const targetSpriteToShow = !isOppAnim ? targetSprite : userSprite;
if (!this.isHideUser() && userSpriteToShow) {
userSpriteToShow.setVisible(true);
} }
if (!this.isHideTarget() && (targetSprite !== userSprite || !this.isHideUser())) { if (!this.isHideTarget() && (targetSpriteToShow !== userSpriteToShow || !this.isHideUser())) {
targetSprite.setVisible(true); // using this.target to fix context loss due to isOppAnim swap (#481) targetSpriteToShow.setVisible(true);
} }
for (const ms of Object.values(spriteCache).flat()) { for (const ms of Object.values(spriteCache).flat()) {
if (ms) { if (ms) {

View File

@ -3587,6 +3587,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.resetSprite(); this.resetSprite();
this.resetTurnData(); this.resetTurnData();
if (clearEffects) { if (clearEffects) {
this.destroySubstitute();
this.resetSummonData(); this.resetSummonData();
this.resetBattleData(); this.resetBattleData();
} }