From 1b7b539d68025d97c1673ebb1440b7151d8be6a2 Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Thu, 30 May 2024 01:07:59 +1000 Subject: [PATCH] Implements Supreme Overlord and fixes Last Respects (#1219) * Implements Supreme Overlord Also fixes count for Last Respects * Add comments --- src/battle.ts | 4 ++++ src/data/ability.ts | 34 +++++++++++++++++++++++++++++++++- src/data/move.ts | 5 +---- src/phases.ts | 7 +++++++ 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/battle.ts b/src/battle.ts index abca1a65b89..0f893fc5016 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -63,6 +63,8 @@ export default class Battle { private battleSeedState: string; public moneyScattered: number; public lastUsedPokeball: PokeballType; + public playerFaints: number; // The amount of times pokemon on the players side have fainted + public enemyFaints: number; // The amount of times pokemon on the enemies side have fainted private rngCounter: integer = 0; @@ -89,6 +91,8 @@ export default class Battle { this.battleSeedState = null; this.moneyScattered = 0; this.lastUsedPokeball = null; + this.playerFaints = 0; + this.enemyFaints = 0; } private initBattleSpec(): void { diff --git a/src/data/ability.ts b/src/data/ability.ts index 86b1018dbb1..21d9c16b7df 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -1083,6 +1083,37 @@ export class LowHpMoveTypePowerBoostAbAttr extends MoveTypePowerBoostAbAttr { } } +/** + * Abilities which cause a variable amount of power increase. + * @extends VariableMovePowerAbAttr + * @see {@link applyPreAttack} + */ +export class VariableMovePowerBoostAbAttr extends VariableMovePowerAbAttr { + private mult: (user: Pokemon, target: Pokemon, move: Move) => number; + + /** + * @param mult A function which takes the user, target, and move, and returns the power multiplier. 1 means no multiplier. + * @param {boolean} showAbility Whether to show the ability when it activates. + */ + constructor(mult: (user: Pokemon, target: Pokemon, move: Move) => number, showAbility: boolean = true) { + super(showAbility); + this.mult = mult; + } + + /** + * @override + */ + applyPreAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: PokemonMove, args: any[]): boolean { + const multiplier = this.mult(pokemon, defender, move.getMove()); + if (multiplier !== 1) { + (args[0] as Utils.NumberHolder).value *= multiplier; + return true; + } + + return false; + } +} + export class FieldVariableMovePowerAbAttr extends AbAttr { applyPreAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: PokemonMove, args: any[]): boolean { //const power = args[0] as Utils.NumberHolder; @@ -4251,7 +4282,8 @@ export function initAbilities() { new Ability(Abilities.SHARPNESS, 9) .attr(MovePowerBoostAbAttr, (user, target, move) => move.hasFlag(MoveFlags.SLICING_MOVE), 1.5), new Ability(Abilities.SUPREME_OVERLORD, 9) - .unimplemented(), + .attr(VariableMovePowerBoostAbAttr, (user, target, move) => 1 + 0.1 * Math.min(user.isPlayer() ? user.scene.currentBattle.playerFaints : user.scene.currentBattle.enemyFaints, 5)) + .partial(), new Ability(Abilities.COSTAR, 9) .unimplemented(), new Ability(Abilities.TOXIC_DEBRIS, 9) diff --git a/src/data/move.ts b/src/data/move.ts index 78f23effa81..3fca2869ea3 100755 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -7508,10 +7508,7 @@ export function initMoves() { .attr(ConfuseAttr) .recklessMove(), new AttackMove(Moves.LAST_RESPECTS, Type.GHOST, MoveCategory.PHYSICAL, 50, 100, 10, -1, 0, 9) - .attr(MovePowerMultiplierAttr, (user, target, move) => { - return user.scene.getParty().reduce((acc, pokemonInParty) => acc + (pokemonInParty.status?.effect === StatusEffect.FAINT ? 1 : 0), - 1,); - }) + .attr(MovePowerMultiplierAttr, (user, target, move) => 1 + Math.min(user.isPlayer() ? user.scene.currentBattle.playerFaints : user.scene.currentBattle.enemyFaints, 100)) .makesContact(false), new AttackMove(Moves.LUMINA_CRASH, Type.PSYCHIC, MoveCategory.SPECIAL, 80, 100, 10, 100, 0, 9) .attr(StatChangeAttr, BattleStat.SPDEF, -2), diff --git a/src/phases.ts b/src/phases.ts index 055538423be..b6d03561993 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -3491,6 +3491,13 @@ export class FaintPhase extends PokemonPhase { doFaint(): void { const pokemon = this.getPokemon(); + // Track total times pokemon have been KO'd for supreme overlord/last respects + if (pokemon.isPlayer()) { + this.scene.currentBattle.playerFaints += 1; + } else { + this.scene.currentBattle.enemyFaints += 1; + } + this.scene.queueMessage(getPokemonMessage(pokemon, " fainted!"), null, true); if (pokemon.turnData?.attacksReceived?.length) {