From e9b94f47f09ce33f6dd8feca222a079943b90b0c Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 26 Mar 2024 17:45:43 -0400 Subject: [PATCH] Fix battle animation Pokemon sprites losing shadow --- src/data/battle-anims.ts | 1 + src/pipelines/sprite.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/data/battle-anims.ts b/src/data/battle-anims.ts index cec80190c..81a8da36c 100644 --- a/src/data/battle-anims.ts +++ b/src/data/battle-anims.ts @@ -769,6 +769,7 @@ export abstract class BattleAnim { let sprite: Phaser.GameObjects.Sprite; sprite = scene.addPokemonSprite(isUser ? user : target, 0, 0, spriteSource.texture, spriteSource.frame.name, true); [ 'spriteColors', 'fusionSpriteColors' ].map(k => sprite.pipelineData[k] = (isUser ? user : target).getSprite().pipelineData[k]); + sprite.pipelineData['ignoreFieldPos'] = true; spriteSource.on('animationupdate', (_anim, frame) => sprite.setFrame(frame.textureFrame)); scene.field.add(sprite); sprites.push(sprite); diff --git a/src/pipelines/sprite.ts b/src/pipelines/sprite.ts index f51d75412..819efd0d8 100644 --- a/src/pipelines/sprite.ts +++ b/src/pipelines/sprite.ts @@ -335,6 +335,7 @@ export default class SpritePipeline extends FieldSpritePipeline { const tone = data['tone'] as number[]; const teraColor = data['teraColor'] as integer[] ?? [ 0, 0, 0 ]; const hasShadow = data['hasShadow'] as boolean; + const ignoreFieldPos = data['ignoreFieldPos'] as boolean; const ignoreOverride = data['ignoreOverride'] as boolean; const isEntityObj = sprite.parentContainer instanceof Pokemon || sprite.parentContainer instanceof Trainer; @@ -346,9 +347,9 @@ export default class SpritePipeline extends FieldSpritePipeline { position[0] += field.x / field.scale; position[1] += field.y / field.scale; } - position[0] += -(sprite.width - (sprite.frame.width)) / 2 + sprite.frame.x + (sprite.x - field.x); + position[0] += -(sprite.width - (sprite.frame.width)) / 2 + sprite.frame.x + (!ignoreFieldPos ? (sprite.x - field.x) : 0); if (sprite.originY === 0.5) - position[1] += (sprite.height / 2) * ((isEntityObj ? sprite.parentContainer : sprite).scale - 1) + (sprite.y - field.y); + position[1] += (sprite.height / 2) * ((isEntityObj ? sprite.parentContainer : sprite).scale - 1) + (!ignoreFieldPos ? (sprite.y - field.y) : 0); this.set1f('teraTime', (this.game.getTime() % 500000) / 500000); this.set3fv('teraColor', teraColor.map(c => c / 255)); this.set1i('hasShadow', hasShadow ? 1 : 0);