diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 0f75447a500..8d81a9b9ac7 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -4,7 +4,7 @@ import { NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, MessagePh import Pokemon, { PlayerPokemon, EnemyPokemon } from './field/pokemon'; import PokemonSpecies, { PokemonSpeciesFilter, allSpecies, getPokemonSpecies, initSpecies, speciesStarters } from './data/pokemon-species'; import * as Utils from './utils'; -import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ModifierPredicate, DoubleBattleChanceBoosterModifier, FusePokemonModifier, PokemonFormChangeItemModifier, TerastallizeModifier, overrideModifiers, overrideHeldItems } from './modifier/modifier'; +import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ModifierPredicate, DoubleBattleChanceBoosterModifier, FusePokemonModifier, PokemonFormChangeItemModifier, TerastallizeModifier, overrideModifiers, overrideHeldItems, TrainerBattleChanceBoosterModifier } from './modifier/modifier'; import { PokeballType } from './data/pokeball'; import { initCommonAnims, initMoveAnim, loadCommonAnimAssets, loadMoveAnimAssets, populateAnims } from './data/battle-anims'; import { Phase } from './phase'; @@ -846,9 +846,11 @@ export default class BattleScene extends SceneBase { } else { if (!this.gameMode.hasTrainers) newBattleType = BattleType.WILD; - else if (battleType === undefined) - newBattleType = this.gameMode.isWaveTrainer(newWaveIndex, this.arena) ? BattleType.TRAINER : BattleType.WILD; - else + else if (battleType === undefined) { + const trainerChanceMod = new Utils.IntegerHolder(this.arena.getTrainerChance()); + this.applyModifiers(TrainerBattleChanceBoosterModifier, true, trainerChanceMod); + newBattleType = this.gameMode.isWaveTrainer(newWaveIndex, this.arena, trainerChanceMod.value) ? BattleType.TRAINER : BattleType.WILD; + } else newBattleType = battleType; if (newBattleType === BattleType.TRAINER) { diff --git a/src/game-mode.ts b/src/game-mode.ts index 888ae3b3c84..1fbb66987f2 100644 --- a/src/game-mode.ts +++ b/src/game-mode.ts @@ -96,13 +96,13 @@ export class GameMode implements GameModeConfig { } } - isWaveTrainer(waveIndex: integer, arena: Arena): boolean { + isWaveTrainer(waveIndex: integer, arena: Arena, trainerChanceMod: integer): boolean { if (this.isDaily) return waveIndex % 10 === 5 || (!(waveIndex % 10) && waveIndex > 10 && !this.isWaveFinal(waveIndex)); if ((waveIndex % 30) === (arena.scene.offsetGym ? 0 : 20) && !this.isWaveFinal(waveIndex)) return true; else if (waveIndex % 10 !== 1 && waveIndex % 10) { - const trainerChance = arena.getTrainerChance(); + const trainerChance = trainerChanceMod; let allowTrainerBattle = true; if (trainerChance) { const waveBase = Math.floor(waveIndex / 10) * 10; @@ -114,7 +114,7 @@ export class GameMode implements GameModeConfig { break; } else if (w < waveIndex) { arena.scene.executeWithSeedOffset(() => { - const waveTrainerChance = arena.getTrainerChance(); + const waveTrainerChance = trainerChanceMod; if (!Utils.randSeedInt(waveTrainerChance)) allowTrainerBattle = false; }, w); @@ -123,7 +123,7 @@ export class GameMode implements GameModeConfig { } } } - return allowTrainerBattle && trainerChance && !Utils.randSeedInt(trainerChance); + return allowTrainerBattle && trainerChance && !Utils.randSeedInt(trainerChanceMod); } return false; } diff --git a/src/locales/en/modifier-type.ts b/src/locales/en/modifier-type.ts index 31d4abbce29..cea22b23954 100644 --- a/src/locales/en/modifier-type.ts +++ b/src/locales/en/modifier-type.ts @@ -51,6 +51,9 @@ export const modifierType: ModifierTypeTranslationEntries = { "DoubleBattleChanceBoosterModifierType": { description: "Doubles the chance of an encounter being a double battle for {{battleCount}} battles", }, + "TrainerBattleChanceBoosterModifierType": { + description: "Doubles the chance of an encounter being a trainer battle for {{battleCount}} battles", + }, "TempBattleStatBoosterModifierType": { description: "Increases the {{tempBattleStatName}} of all party members by 1 stage for 5 battles", }, @@ -162,6 +165,10 @@ export const modifierType: ModifierTypeTranslationEntries = { "SUPER_LURE": { name: "Super Lure" }, "MAX_LURE": { name: "Max Lure" }, + "REPEL": { name: "Repel" }, + "SUPER_REPEL": { name: "Super Repel" }, + "MAX_REPEL": { name: "Max Repel" }, + "MEMORY_MUSHROOM": { name: "Memory Mushroom", description: "Recall one Pokémon's forgotten move" }, "EXP_SHARE": { name: "EXP. All", description: "Non-participants receive 20% of a single participant's EXP. Points" }, diff --git a/src/locales/it/modifier-type.ts b/src/locales/it/modifier-type.ts index 70303dd7acd..e8ac2610254 100644 --- a/src/locales/it/modifier-type.ts +++ b/src/locales/it/modifier-type.ts @@ -51,6 +51,9 @@ export const modifierType: ModifierTypeTranslationEntries = { "DoubleBattleChanceBoosterModifierType": { description: "Raddoppia la possibilità di imbattersi in doppie battaglie per {{battleCount}} battaglie", }, + "TrainerBattleChanceBoosterModifierType": { + description: "Raddoppia la possibilità di imbattersi in battaglie con allenatori per {{battleCount}} battaglie", + }, "TempBattleStatBoosterModifierType": { description: "Aumenta {{tempBattleStatName}} di un livello a tutti i Pokémon nel gruppo per 5 battaglie", }, @@ -162,6 +165,10 @@ export const modifierType: ModifierTypeTranslationEntries = { "SUPER_LURE": { name: "Profumo Invito Super" }, "MAX_LURE": { name: "Profumo Invito Max" }, + "REPEL": { name: "Repellente" }, + "SUPER_REPEL": { name: "Superrepellente" }, + "MAX_REPEL": { name: "Repellente max" }, + "MEMORY_MUSHROOM": { name: "Fungo della Memoria", description: "Ricorda la mossa dimenticata di un Pokémon" }, "EXP_SHARE": { name: "Condividi Esperienza", description: "Tutti i Pokémon della squadra ricevono il 20% dei Punti Esperienza dalla lotta anche se non vi hanno partecipato" }, diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 278de2f18e8..d55e42387da 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -407,6 +407,20 @@ export class DoubleBattleChanceBoosterModifierType extends ModifierType { } } +export class TrainerBattleChanceBoosterModifierType extends ModifierType { + public battleCount: integer; + + constructor(localeKey: string, iconImage: string, battleCount: integer) { + super(localeKey, iconImage, (_type, _args) => new Modifiers.TrainerBattleChanceBoosterModifier(this, this.battleCount), 'repel'); + + this.battleCount = battleCount; + } + + getDescription(scene: BattleScene): string { + return i18next.t(`modifierType:ModifierType.DoubleBattleChanceBoosterModifierType.description`, { battleCount: this.battleCount }); + } +} + export class TempBattleStatBoosterModifierType extends ModifierType implements GeneratedPersistentModifierType { public tempBattleStat: TempBattleStat; @@ -1031,9 +1045,9 @@ export const modifierTypes = { PP_UP: () => new PokemonPpUpModifierType(`modifierType:ModifierType.PP_UP`, 'pp_up', 1), PP_MAX: () => new PokemonPpUpModifierType(`modifierType:ModifierType.PP_MAX`, 'pp_max', 3), - /*REPEL: () => new DoubleBattleChanceBoosterModifierType('Repel', 5), - SUPER_REPEL: () => new DoubleBattleChanceBoosterModifierType('Super Repel', 10), - MAX_REPEL: () => new DoubleBattleChanceBoosterModifierType('Max Repel', 25),*/ + REPEL: () => new TrainerBattleChanceBoosterModifierType(`modifierType:ModifierType.REPEL`, 'repel', 5), + SUPER_REPEL: () => new DoubleBattleChanceBoosterModifierType(`modifierType:ModifierType.SUPER_REPEL`, 'super_repel', 10), + MAX_REPEL: () => new DoubleBattleChanceBoosterModifierType(`modifierType:ModifierType.MAX_REPEL`, 'max_repel', 25), LURE: () => new DoubleBattleChanceBoosterModifierType(`modifierType:ModifierType.LURE`, 'lure', 5), SUPER_LURE: () => new DoubleBattleChanceBoosterModifierType(`modifierType:ModifierType.SUPER_LURE`, 'super_lure', 10), @@ -1202,6 +1216,7 @@ const modifierPool: ModifierPool = { return thresholdPartyMemberCount; }, 3), new WeightedModifierType(modifierTypes.LURE, 2), + new WeightedModifierType(modifierTypes.REPEL, 2), new WeightedModifierType(modifierTypes.TEMP_STAT_BOOSTER, 4), new WeightedModifierType(modifierTypes.BERRY, 2), new WeightedModifierType(modifierTypes.TM_COMMON, 1), @@ -1246,6 +1261,7 @@ const modifierPool: ModifierPool = { }, 3), new WeightedModifierType(modifierTypes.DIRE_HIT, 4), new WeightedModifierType(modifierTypes.SUPER_LURE, 4), + new WeightedModifierType(modifierTypes.SUPER_REPEL, 4), new WeightedModifierType(modifierTypes.NUGGET, 5), new WeightedModifierType(modifierTypes.EVOLUTION_ITEM, (party: Pokemon[]) => { return Math.min(Math.ceil(party[0].scene.currentBattle.waveIndex / 15), 8); @@ -1265,6 +1281,7 @@ const modifierPool: ModifierPool = { [ModifierTier.ULTRA]: [ new WeightedModifierType(modifierTypes.ULTRA_BALL, 24), new WeightedModifierType(modifierTypes.MAX_LURE, 4), + new WeightedModifierType(modifierTypes.MAX_REPEL, 4), new WeightedModifierType(modifierTypes.BIG_NUGGET, 12), new WeightedModifierType(modifierTypes.PP_UP, 9), new WeightedModifierType(modifierTypes.PP_MAX, 3), diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 0736831a01e..5a36551972a 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -310,6 +310,33 @@ export class DoubleBattleChanceBoosterModifier extends LapsingPersistentModifier } } +export class TrainerBattleChanceBoosterModifier extends LapsingPersistentModifier { + constructor(type: ModifierTypes.TrainerBattleChanceBoosterModifierType, battlesLeft: integer, stackCount?: integer) { + super(type, battlesLeft, stackCount); + } + + match(modifier: Modifier): boolean { + if (modifier instanceof TrainerBattleChanceBoosterModifier) + return (modifier as TrainerBattleChanceBoosterModifier).battlesLeft === this.battlesLeft; + return false; + } + + clone(): TrainerBattleChanceBoosterModifier { + return new TrainerBattleChanceBoosterModifier(this.type as ModifierTypes.TrainerBattleChanceBoosterModifierType, this.battlesLeft, this.stackCount); + } + + getArgs(): any[] { + return [ this.battlesLeft ]; + } + + apply(args: any[]): boolean { + const trainerChance = args[0] as Utils.NumberHolder; + trainerChance.value = Math.ceil(trainerChance.value / 2); + + return true; + } +} + export class TempBattleStatBoosterModifier extends LapsingPersistentModifier { private tempBattleStat: TempBattleStat;