From 970d014bfda9656d9aad07ac81c64d498a4a6b4d Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Fri, 27 Oct 2023 16:20:51 -0400 Subject: [PATCH] Fix issue with generating enemy modifiers --- src/battle-phases.ts | 2 +- src/modifier/modifier-type.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/battle-phases.ts b/src/battle-phases.ts index 73f844668c9..59d5979ac40 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -635,7 +635,7 @@ export class SummonPhase extends PartyMemberPokemonPhase { this.scene.field.add(pokemon); if (!this.player) { const playerPokemon = this.scene.getPlayerPokemon() as Pokemon; - if (playerPokemon.visible) + if (playerPokemon?.visible) this.scene.field.moveBelow(pokemon, playerPokemon); this.scene.currentBattle.seenEnemyPartyMemberIds.add(pokemon.id); this.scene.updateModifiers(false); diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 76b636194b8..017fd90a7b2 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -813,8 +813,8 @@ export function regenerateModifierPoolThresholds(party: Pokemon[], poolType: Mod let i = 0; pool[t].reduce((total: integer, modifierType: WeightedModifierType) => { const weightedModifierType = modifierType as WeightedModifierType; - const existingModifier = party[0].scene.findModifier(m => (m.type.generatorId || m.type.id) === weightedModifierType.modifierType.id); - const weight = !existingModifier || existingModifier.stackCount < existingModifier.getMaxStackCount() + const existingModifiers = party[0].scene.findModifiers(m => (m.type.generatorId || m.type.id) === weightedModifierType.modifierType.id, player); + const weight = !existingModifiers.length || existingModifiers.filter(m => m.stackCount < m.getMaxStackCount()) ? weightedModifierType.weight instanceof Function ? (weightedModifierType.weight as Function)(party) : weightedModifierType.weight as integer