[Bug] [Fix] Metal Burst always hitting left target. (#3182)
* [Fix] Metal Burst always hitting left target. Fixed Metal Burst always hitting left target, and the related freeze/crash. * Prevent enemy redirection to their ally. Co-Authored-By: innerthunder <168692175+innerthunder@users.noreply.github.com> * Rename attackingPosition per chriSS's comment --------- Co-authored-by: innerthunder <168692175+innerthunder@users.noreply.github.com>
This commit is contained in:
parent
37a27c773e
commit
e3fb55834f
|
@ -2084,7 +2084,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
source.turnData.damageDealt += damage.value;
|
||||
source.turnData.currDamageDealt = damage.value;
|
||||
this.battleData.hitCount++;
|
||||
const attackResult = { move: move.id, result: result as DamageResult, damage: damage.value, critical: isCritical, sourceId: source.id, attackingPosition: source.getBattlerIndex() };
|
||||
const attackResult = { move: move.id, result: result as DamageResult, damage: damage.value, critical: isCritical, sourceId: source.id, sourceBattlerIndex: source.getBattlerIndex() };
|
||||
this.turnData.attacksReceived.unshift(attackResult);
|
||||
if (source.isPlayer() && !this.isPlayer()) {
|
||||
this.scene.applyModifiers(DamageMoneyRewardModifier, true, source, damage);
|
||||
|
@ -4021,7 +4021,7 @@ export interface AttackMoveResult {
|
|||
damage: integer;
|
||||
critical: boolean;
|
||||
sourceId: integer;
|
||||
attackingPosition: BattlerIndex;
|
||||
sourceBattlerIndex: BattlerIndex;
|
||||
}
|
||||
|
||||
export class PokemonSummonData {
|
||||
|
|
|
@ -2666,13 +2666,14 @@ export class MovePhase extends BattlePhase {
|
|||
if (this.targets.length === 1 && this.targets[0] === BattlerIndex.ATTACKER) {
|
||||
if (this.pokemon.turnData.attacksReceived.length) {
|
||||
const attack = this.pokemon.turnData.attacksReceived[0];
|
||||
this.targets[0] = attack.attackingPosition;
|
||||
this.targets[0] = attack.sourceBattlerIndex;
|
||||
|
||||
// account for metal burst and comeuppance hitting remaining targets in double battles
|
||||
// counterattack will redirect to remaining ally if original attacker faints
|
||||
if (this.scene.currentBattle.double && this.move.getMove().hasFlag(MoveFlags.REDIRECT_COUNTER)) {
|
||||
if (!this.scene.getEnemyField()[this.targets[0]]) {
|
||||
this.targets[0] = this.scene.getEnemyField().find(p => p.isActive(true)).getBattlerIndex();
|
||||
if (this.scene.getField()[this.targets[0]].hp === 0) {
|
||||
const opposingField = this.pokemon.isPlayer() ? this.scene.getEnemyField() : this.scene.getPlayerField();
|
||||
this.targets[0] = opposingField.find(p => p.hp > 0)?.getBattlerIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue