From 2fcdb80b0e4bf00b6a32fff7746a919b0b49a144 Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Wed, 22 May 2024 05:58:52 +1000 Subject: [PATCH] Implements Supreme Overlord Also fixes count for Last Respects --- src/battle.ts | 4 ++++ src/data/ability.ts | 34 +++++++++++++++++++++++++++++++++- src/data/move.ts | 5 +---- src/phases.ts | 6 ++++++ 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/battle.ts b/src/battle.ts index 601cbeb9cb6..72e4833f5d4 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; + public enemyFaints: number; 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 c236aa85805..91b8ecf72ef 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -1070,6 +1070,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; @@ -3899,7 +3930,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 2d27afcbe47..ac6422fa9f0 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -7269,10 +7269,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 b861c82f0e8..81696a88715 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -3226,6 +3226,12 @@ 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) {