diff --git a/src/battle.ts b/src/battle.ts index b7c7090955a..1c485d862f4 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -49,6 +49,7 @@ export default class Battle { public seenEnemyPartyMemberIds: Set; public double: boolean; public started: boolean; + public enemySwitchCounter: integer; public turn: integer; public turnCommands: TurnCommands; public playerParticipantIds: Set; @@ -73,6 +74,7 @@ export default class Battle { this.enemyParty = []; this.seenEnemyPartyMemberIds = new Set(); this.double = double; + this.enemySwitchCounter = 0; this.turn = 0; this.playerParticipantIds = new Set(); this.battleScore = 0; diff --git a/src/phases.ts b/src/phases.ts index 8e8d74c0316..31f73bc2beb 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1658,7 +1658,9 @@ export class EnemyCommandPhase extends FieldPhase { const enemyPokemon = this.scene.getEnemyField()[this.fieldIndex]; - const trainer = this.scene.currentBattle.trainer; + const battle = this.scene.currentBattle; + + const trainer = battle.trainer; if (trainer && !enemyPokemon.getMoveQueue().length) { const opponents = enemyPokemon.getOpponents(); @@ -1675,11 +1677,15 @@ export class EnemyCommandPhase extends FieldPhase { const sortedPartyMemberScores = trainer.getSortedPartyMemberMatchupScores(partyMemberScores); - if (sortedPartyMemberScores[0][1] >= matchupScore * (trainer.config.isBoss ? 2 : 3)) { + const switchMultiplier = 1 - (battle.enemySwitchCounter ? Math.pow(0.1, (1 / battle.enemySwitchCounter)) : 0); + + if (sortedPartyMemberScores[0][1] * switchMultiplier >= matchupScore * (trainer.config.isBoss ? 2 : 3)) { const index = trainer.getNextSummonIndex(enemyPokemon.trainerSlot, partyMemberScores); - this.scene.currentBattle.turnCommands[this.fieldIndex + BattlerIndex.ENEMY] = + battle.turnCommands[this.fieldIndex + BattlerIndex.ENEMY] = { command: Command.POKEMON, cursor: index, args: [ false ] }; + + battle.enemySwitchCounter++; return this.end(); } @@ -1692,6 +1698,8 @@ export class EnemyCommandPhase extends FieldPhase { this.scene.currentBattle.turnCommands[this.fieldIndex + BattlerIndex.ENEMY] = { command: Command.FIGHT, move: nextMove }; + this.scene.currentBattle.enemySwitchCounter = Math.max(this.scene.currentBattle.enemySwitchCounter - 1, 0); + this.end(); } }