diff --git a/src/battle-scene.ts b/src/battle-scene.ts index bbd9e2a26e5..17ebfaa8ab5 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1160,14 +1160,6 @@ export default class BattleScene extends SceneBase { this.field.add(newTrainer); } - // TODO: remove these once ME spawn rates are finalized - // let testStartingWeight = 3; - // while (testStartingWeight < 4) { - // calculateMEAggregateStats(this, testStartingWeight); - // testStartingWeight += 1; - // } - // calculateRareSpawnAggregateStats(this, 14); - // Check for mystery encounter // Can only occur in place of a standard (non-boss) wild battle, waves 10-180 const highestMysteryEncounterWave = 180; @@ -2582,19 +2574,18 @@ export default class BattleScene extends SceneBase { party.forEach((enemyPokemon: EnemyPokemon, i: integer) => { if (heldModifiersConfigs && i < heldModifiersConfigs.length && heldModifiersConfigs[i] && heldModifiersConfigs[i].length > 0) { heldModifiersConfigs[i].forEach(mt => { + let modifier: PokemonHeldItemModifier; if (mt.modifier instanceof PokemonHeldItemModifierType) { - const stackCount = mt.stackCount ?? 1; - // const isTransferable = mt.isTransferable ?? true; - const modifier = mt.modifier.newModifier(enemyPokemon); - modifier.stackCount = stackCount; - // TODO: set isTransferable - // modifier.setIsTransferable(isTransferable); - this.addEnemyModifier(modifier, true); + modifier = mt.modifier.newModifier(enemyPokemon); } else { - const modifier = mt.modifier as PokemonHeldItemModifier; + modifier = mt.modifier as PokemonHeldItemModifier; modifier.pokemonId = enemyPokemon.id; - this.addEnemyModifier(modifier, true); } + const stackCount = mt.stackCount ?? 1; + modifier.stackCount = stackCount; + // TODO: set isTransferable + // modifier.isTransferrable = mt.isTransferable ?? true; + this.addEnemyModifier(modifier, true); }); } else { const isBoss = enemyPokemon.isBoss() || (this.currentBattle.battleType === BattleType.TRAINER && !!this.currentBattle.trainer?.config.isBoss); @@ -2957,7 +2948,7 @@ export default class BattleScene extends SceneBase { // See Enum values for base tier weights const tierWeights = [MysteryEncounterTier.COMMON, MysteryEncounterTier.GREAT, MysteryEncounterTier.ULTRA, MysteryEncounterTier.ROGUE]; - // Adjust tier weights by previously encountered events to lower odds of only common/uncommons in run + // Adjust tier weights by previously encountered events to lower odds of only Common/Great in run this.mysteryEncounterData.encounteredEvents.forEach(seenEncounterData => { if (seenEncounterData.tier === MysteryEncounterTier.COMMON) { tierWeights[0] = tierWeights[0] - 6; @@ -2969,9 +2960,9 @@ export default class BattleScene extends SceneBase { const totalWeight = tierWeights.reduce((a, b) => a + b); const tierValue = Utils.randSeedInt(totalWeight); const commonThreshold = totalWeight - tierWeights[0]; - const uncommonThreshold = totalWeight - tierWeights[0] - tierWeights[1]; - const rareThreshold = totalWeight - tierWeights[0] - tierWeights[1] - tierWeights[2]; - let tier: MysteryEncounterTier | null = tierValue > commonThreshold ? MysteryEncounterTier.COMMON : tierValue > uncommonThreshold ? MysteryEncounterTier.GREAT : tierValue > rareThreshold ? MysteryEncounterTier.ULTRA : MysteryEncounterTier.ROGUE; + const greatThreshold = totalWeight - tierWeights[0] - tierWeights[1]; + const ultraThreshold = totalWeight - tierWeights[0] - tierWeights[1] - tierWeights[2]; + let tier: MysteryEncounterTier | null = tierValue > commonThreshold ? MysteryEncounterTier.COMMON : tierValue > greatThreshold ? MysteryEncounterTier.GREAT : tierValue > ultraThreshold ? MysteryEncounterTier.ULTRA : MysteryEncounterTier.ROGUE; if (!isNullOrUndefined(Overrides.MYSTERY_ENCOUNTER_TIER_OVERRIDE)) { tier = Overrides.MYSTERY_ENCOUNTER_TIER_OVERRIDE!; diff --git a/src/battle.ts b/src/battle.ts index fa1406bb946..f97f43efe6c 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -195,8 +195,8 @@ export default class Battle { getBgmOverride(scene: BattleScene): string | null { const battlers = this.enemyParty.slice(0, this.getBattlerCount()); if (this.battleType === BattleType.MYSTERY_ENCOUNTER && this.mysteryEncounter?.encounterMode === MysteryEncounterMode.DEFAULT) { - // Music is overridden MEs during ME onInit() - // Should not use BGM overrides before swapping from DEFAULT mode + // Music is overridden for MEs during ME onInit() + // Should not use any BGM overrides before swapping from DEFAULT mode return null; } else if (this.battleType === BattleType.TRAINER || this.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE) { if (!this.started && this.trainer?.config.encounterBgm && this.trainer?.getEncounterMessages()?.length) { diff --git a/src/data/mystery-encounters/utils/encounter-phase-utils.ts b/src/data/mystery-encounters/utils/encounter-phase-utils.ts index 692fdec8e28..d5c246934d1 100644 --- a/src/data/mystery-encounters/utils/encounter-phase-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-phase-utils.ts @@ -991,7 +991,7 @@ export function calculateMEAggregateStats(scene: BattleScene, baseSpawnWeight: n // Common / Uncommon / Rare / Super Rare (base is out of 128) const tierWeights = [66, 40, 19, 3]; - // Adjust tier weights by currently encountered events (pity system that lowers odds of multiple common/uncommons) + // Adjust tier weights by currently encountered events (pity system that lowers odds of multiple Common/Great) tierWeights[0] = tierWeights[0] - 6 * numEncounters[0]; tierWeights[1] = tierWeights[1] - 4 * numEncounters[1]; diff --git a/src/data/trainer-config.ts b/src/data/trainer-config.ts index 23ea5ab91fa..8ca1bdfbd0e 100644 --- a/src/data/trainer-config.ts +++ b/src/data/trainer-config.ts @@ -685,7 +685,6 @@ export class TrainerConfig { } const nameForCall = this.name.toLowerCase().replace(/\s/g, "_"); this.name = i18next.t(`trainerNames:${nameForCall}`); - // this.setTitle(title); this.setMoneyMultiplier(2); this.setBoss(); this.setStaticParty(); diff --git a/src/field/arena.ts b/src/field/arena.ts index 11c6074c4f7..9a0eb19c910 100644 --- a/src/field/arena.ts +++ b/src/field/arena.ts @@ -149,7 +149,7 @@ export class Arena { return this.randomSpecies(waveIndex, level, (attempt || 0) + 1); } - const newSpeciesId = ret.getWildSpeciesForLevel(level, true, !!isBoss, this.scene.gameMode); + const newSpeciesId = ret.getWildSpeciesForLevel(level, true, isBoss ?? isBossSpecies, this.scene.gameMode); if (newSpeciesId !== ret.speciesId) { console.log("Replaced", Species[ret.speciesId], "with", Species[newSpeciesId]); ret = getPokemonSpecies(newSpeciesId); diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index d0c0e537f70..2362c3bdda6 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -335,7 +335,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { isAllowed(): boolean { const challengeAllowed = new Utils.BooleanHolder(true); applyChallenges(this.scene.gameMode, ChallengeType.POKEMON_IN_BATTLE, this, challengeAllowed); - return !this.isFainted() && !this.wildFlee && challengeAllowed.value; + return !this.wildFlee && challengeAllowed.value; } isActive(onField?: boolean): boolean { diff --git a/src/game-mode.ts b/src/game-mode.ts index ac2132d5395..9bd2ddac18e 100644 --- a/src/game-mode.ts +++ b/src/game-mode.ts @@ -346,6 +346,6 @@ export function getGameMode(gameMode: GameModes): GameMode { case GameModes.DAILY: return new GameMode(GameModes.DAILY, { isDaily: true, hasTrainers: true, hasNoShop: true }); case GameModes.CHALLENGE: - return new GameMode(GameModes.CHALLENGE, { isClassic: true, hasTrainers: true, isChallenge: true, hasMysteryEncounters: true }, classicFixedBattles); + return new GameMode(GameModes.CHALLENGE, { isClassic: true, hasTrainers: true, isChallenge: true }, classicFixedBattles); } } diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 39711cc9b2e..f9c5702ff31 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -136,8 +136,6 @@ export class ModifierType { } } - // Fallback to COMMON tier if no tier found - this.tier = ModifierTier.COMMON; return this; } diff --git a/src/phases/victory-phase.ts b/src/phases/victory-phase.ts index 761a43fcb57..4c0ce43eb76 100644 --- a/src/phases/victory-phase.ts +++ b/src/phases/victory-phase.ts @@ -124,8 +124,7 @@ export class VictoryPhase extends PokemonPhase { if (this.scene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER) { handleMysteryEncounterVictory(this.scene, false, this.isExpOnly); - this.end(); - return; + return this.end(); } if (!this.scene.getEnemyParty().find(p => this.scene.currentBattle.battleType === BattleType.WILD ? p.isOnField() : !p?.isFainted(true))) { diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 6122ffe3cbb..8688fed7a6c 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -91,7 +91,7 @@ export function encrypt(data: string, bypassLogin: boolean): string { export function decrypt(data: string, bypassLogin: boolean): string { return (bypassLogin - ? (data: string) => decodeURIComponent(atob(data)) + ? (data: string) => atob(data) : (data: string) => AES.decrypt(data, saveKey).toString(enc.Utf8))(data); }