Discourage enemy trainers from switching too much consecutively
This commit is contained in:
parent
a214e815bc
commit
dd2743bcf5
|
@ -49,6 +49,7 @@ export default class Battle {
|
||||||
public seenEnemyPartyMemberIds: Set<integer>;
|
public seenEnemyPartyMemberIds: Set<integer>;
|
||||||
public double: boolean;
|
public double: boolean;
|
||||||
public started: boolean;
|
public started: boolean;
|
||||||
|
public enemySwitchCounter: integer;
|
||||||
public turn: integer;
|
public turn: integer;
|
||||||
public turnCommands: TurnCommands;
|
public turnCommands: TurnCommands;
|
||||||
public playerParticipantIds: Set<integer>;
|
public playerParticipantIds: Set<integer>;
|
||||||
|
@ -73,6 +74,7 @@ export default class Battle {
|
||||||
this.enemyParty = [];
|
this.enemyParty = [];
|
||||||
this.seenEnemyPartyMemberIds = new Set<integer>();
|
this.seenEnemyPartyMemberIds = new Set<integer>();
|
||||||
this.double = double;
|
this.double = double;
|
||||||
|
this.enemySwitchCounter = 0;
|
||||||
this.turn = 0;
|
this.turn = 0;
|
||||||
this.playerParticipantIds = new Set<integer>();
|
this.playerParticipantIds = new Set<integer>();
|
||||||
this.battleScore = 0;
|
this.battleScore = 0;
|
||||||
|
|
|
@ -1658,7 +1658,9 @@ export class EnemyCommandPhase extends FieldPhase {
|
||||||
|
|
||||||
const enemyPokemon = this.scene.getEnemyField()[this.fieldIndex];
|
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) {
|
if (trainer && !enemyPokemon.getMoveQueue().length) {
|
||||||
const opponents = enemyPokemon.getOpponents();
|
const opponents = enemyPokemon.getOpponents();
|
||||||
|
@ -1675,11 +1677,15 @@ export class EnemyCommandPhase extends FieldPhase {
|
||||||
|
|
||||||
const sortedPartyMemberScores = trainer.getSortedPartyMemberMatchupScores(partyMemberScores);
|
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);
|
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 ] };
|
{ command: Command.POKEMON, cursor: index, args: [ false ] };
|
||||||
|
|
||||||
|
battle.enemySwitchCounter++;
|
||||||
|
|
||||||
return this.end();
|
return this.end();
|
||||||
}
|
}
|
||||||
|
@ -1692,6 +1698,8 @@ export class EnemyCommandPhase extends FieldPhase {
|
||||||
this.scene.currentBattle.turnCommands[this.fieldIndex + BattlerIndex.ENEMY] =
|
this.scene.currentBattle.turnCommands[this.fieldIndex + BattlerIndex.ENEMY] =
|
||||||
{ command: Command.FIGHT, move: nextMove };
|
{ command: Command.FIGHT, move: nextMove };
|
||||||
|
|
||||||
|
this.scene.currentBattle.enemySwitchCounter = Math.max(this.scene.currentBattle.enemySwitchCounter - 1, 0);
|
||||||
|
|
||||||
this.end();
|
this.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue