Fix charge animation targeting issue

This commit is contained in:
Flashfyre 2023-05-01 10:53:52 -04:00
parent 064cf9588e
commit f9c895c0cd
4 changed files with 12443 additions and 6222 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -559,8 +559,6 @@ export abstract class BattleAnim {
abstract isOppAnim(): boolean;
abstract isReverseCoords(): boolean;
private getGraphicFrameData(scene: BattleScene, frames: AnimFrame[]): Map<integer, Map<AnimFrameTarget, GraphicFrameData>> {
const ret: Map<integer, Map<AnimFrameTarget, GraphicFrameData>> = new Map([
[AnimFrameTarget.GRAPHIC, new Map<AnimFrameTarget, GraphicFrameData>() ],
@ -678,6 +676,8 @@ export abstract class BattleAnim {
pokemonSprite.setAngle(graphicFrameData.angle);
pokemonSprite.setScale(graphicFrameData.scaleX, graphicFrameData.scaleY);
pokemonSprite.setData('locked', frame.locked);
pokemonSprite.setAlpha(frame.opacity / 255);
pokemonSprite.setVisible(frame.visible && (isUser ? user.visible : target.visible));
pokemonSprite.setBlendMode(frame.blendType === AnimBlendType.NORMAL ? Phaser.BlendModes.NORMAL : frame.blendType === AnimBlendType.ADD ? Phaser.BlendModes.ADD : Phaser.BlendModes.DIFFERENCE);
@ -762,7 +762,7 @@ export abstract class BattleAnim {
if (i === AnimFrameTarget.GRAPHIC)
spritePriorities.splice(count, spriteCache[i].length - count);
for (let rs of removedSprites) {
if (rs !== userSprite && rs !== targetSprite)
if (!rs.getData('locked') as boolean)
rs.destroy();
}
}
@ -771,8 +771,6 @@ export abstract class BattleAnim {
r--;
},
onComplete: () => {
userSprite.setVisible(true);
targetSprite.setVisible(true);
const cleanUpAndComplete = () => {
userSprite.setPosition(0, 0);
userSprite.setScale(1);
@ -782,13 +780,19 @@ export abstract class BattleAnim {
targetSprite.setScale(1);
targetSprite.setAlpha(1);
targetSprite.setAngle(0);
userSprite.setVisible(true);
targetSprite.setVisible(true);
for (let ms of Object.values(spriteCache).flat()) {
if (ms)
ms.destroy();
}
if (this.bgSprite)
this.bgSprite.destroy();
if (callback)
callback();
};
for (let ms of Object.values(spriteCache).flat()) {
if (ms && ms !== userSprite && ms !== targetSprite)
if (ms && !ms.getData('locked'))
ms.destroy();
}
if (r) {
@ -820,10 +824,6 @@ export class CommonBattleAnim extends BattleAnim {
isOppAnim(): boolean {
return false;
}
isReverseCoords(): boolean {
return false;
}
}
export class MoveAnim extends BattleAnim {
@ -844,10 +844,6 @@ export class MoveAnim extends BattleAnim {
isOppAnim(): boolean {
return !this.user.isPlayer() && Array.isArray(moveAnims.get(this.move));
}
isReverseCoords(): boolean {
return !this.user.isPlayer() === !this.isOppAnim();
}
}
export class MoveChargeAnim extends MoveAnim {
@ -859,6 +855,10 @@ export class MoveChargeAnim extends MoveAnim {
this.chargeAnim = chargeAnim;
}
isOppAnim(): boolean {
return !this.user.isPlayer() && Array.isArray(chargeAnims.get(this.chargeAnim));
}
getAnim(): AnimConfig {
return chargeAnims.get(this.chargeAnim) instanceof AnimConfig
? chargeAnims.get(this.chargeAnim) as AnimConfig
@ -892,9 +892,11 @@ export function populateAnims() {
const name = nameMatch[2].toLowerCase();
if (commonAnimMatchNames.indexOf(name) > -1)
commonAnimId = commonAnimIds[commonAnimMatchNames.indexOf(name)];
else if (chargeAnimMatchNames.indexOf(name) > -1)
else if (chargeAnimMatchNames.indexOf(name) > -1) {
isOppMove = fields[1].startsWith('name: Opp ');
chargeAnimId = chargeAnimIds[chargeAnimMatchNames.indexOf(name)];
}
}
const nameIndex = fields[1].indexOf(':', 5) + 1;
const animName = fields[1].slice(nameIndex, fields[1].indexOf('\n', nameIndex));
if (!moveNameToId.hasOwnProperty(animName) && !commonAnimId && !chargeAnimId)