Fixed some MEs

This commit is contained in:
Wlowscha 2025-06-15 20:51:31 +02:00
parent 0e5499bf25
commit 694e82f280
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
3 changed files with 11 additions and 61 deletions

View File

@ -7,10 +7,7 @@ import {
setEncounterExp,
setEncounterRewards,
transitionMysteryEncounterIntroVisuals,
generateModifierType,
} from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import type { AttackTypeBoosterModifierType } from "#app/modifier/modifier-type";
import { modifierTypes } from "#app/data/data-lists";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { globalScene } from "#app/global-scene";
import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter";
@ -36,7 +33,6 @@ import { queueEncounterMessage } from "#app/data/mystery-encounters/utils/encoun
import {
applyAbilityOverrideToPokemon,
applyDamageToPokemon,
applyModifierTypeToPlayerPokemon,
} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
@ -46,6 +42,9 @@ import { AbilityId } from "#enums/ability-id";
import { BattlerTagType } from "#enums/battler-tag-type";
import { Stat } from "#enums/stat";
import { FIRE_RESISTANT_ABILITIES } from "#app/data/mystery-encounters/requirements/requirement-groups";
import { HeldItemCategoryId, HeldItemId } from "#enums/held-item-id";
import { getNewHeldItemFromCategory } from "#app/items/held-item-pool";
import { allHeldItems } from "#app/items/all-held-items";
import { allAbilities } from "#app/data/data-lists";
/** the i18n namespace for the encounter */
@ -302,16 +301,14 @@ function giveLeadPokemonAttackTypeBoostItem() {
const leadPokemon = globalScene.getPlayerParty()?.[0];
if (leadPokemon) {
// Generate type booster held item, default to Charcoal if item fails to generate
let boosterModifierType = generateModifierType(modifierTypes.ATTACK_TYPE_BOOSTER) as AttackTypeBoosterModifierType;
if (!boosterModifierType) {
boosterModifierType = generateModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, [
PokemonType.FIRE,
]) as AttackTypeBoosterModifierType;
let item = getNewHeldItemFromCategory(HeldItemCategoryId.TYPE_ATTACK_BOOSTER, leadPokemon);
if (!item) {
item = HeldItemId.CHARCOAL;
}
applyModifierTypeToPlayerPokemon(leadPokemon, boosterModifierType);
leadPokemon.heldItemManager.add(item);
const encounter = globalScene.currentBattle.mysteryEncounter!;
encounter.setDialogueToken("itemName", boosterModifierType.name);
encounter.setDialogueToken("itemName", allHeldItems[item].name);
encounter.setDialogueToken("leadPokemon", leadPokemon.getNameToRender());
queueEncounterMessage(`${namespace}:found_item`);
}

View File

@ -53,7 +53,7 @@ import { PokemonType } from "#enums/pokemon-type";
import { getNatureName } from "#app/data/nature";
import { getPokemonNameWithAffix } from "#app/messages";
import { timedEventManager } from "#app/global-event-manager";
import type { HeldItemPropertyMap } from "#app/field/pokemon-held-item-manager";
import type { HeldItemConfiguration } from "#app/items/held-item-data-types";
/**
* Animates exclamation sprite over trainer's head at start of encounter
@ -103,7 +103,7 @@ export interface EnemyPokemonConfig {
/** Can set just the status, or pass a timer on the status turns */
status?: StatusEffect | [StatusEffect, number];
mysteryEncounterBattleEffects?: (pokemon: Pokemon) => void;
heldItemConfig?: HeldItemPropertyMap;
heldItemConfig?: HeldItemConfiguration;
tags?: BattlerTagType[];
dataSource?: PokemonData;
tera?: PokemonType;

View File

@ -1,7 +1,6 @@
import { globalScene } from "#app/global-scene";
import i18next from "i18next";
import { isNullOrUndefined, randSeedInt } from "#app/utils/common";
import { PokemonHeldItemModifier } from "#app/modifier/modifier";
import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
import type Pokemon from "#app/field/pokemon";
import {
@ -387,42 +386,6 @@ export async function modifyPlayerPokemonBST(pokemon: PlayerPokemon, value: numb
}
}
/**
* Will attempt to add a new modifier to a Pokemon.
* If the Pokemon already has max stacks of that item, it will instead apply 'fallbackModifierType', if specified.
* @param scene
* @param pokemon
* @param modType
* @param fallbackModifierType
*/
export async function applyModifierTypeToPlayerPokemon(
pokemon: PlayerPokemon,
modType: PokemonHeldItemModifierType,
fallbackModifierType?: PokemonHeldItemModifierType,
) {
// Check if the Pokemon has max stacks of that item already
const modifier = modType.newModifier(pokemon);
const existing = globalScene.findModifier(
m =>
m instanceof PokemonHeldItemModifier &&
m.type.id === modType.id &&
m.pokemonId === pokemon.id &&
m.matchType(modifier),
) as PokemonHeldItemModifier;
// At max stacks
if (existing && existing.getStackCount() >= existing.getMaxStackCount()) {
if (!fallbackModifierType) {
return;
}
// Apply fallback
return applyModifierTypeToPlayerPokemon(pokemon, fallbackModifierType);
}
globalScene.addModifier(modifier, false, false, false, true);
}
export function applyHeldItemWithFallback(pokemon: Pokemon, item: HeldItemId, fallbackItem?: HeldItemId) {
const added = pokemon.heldItemManager.add(item);
if (!added && fallbackItem) {
@ -694,20 +657,10 @@ export async function catchPokemon(
}
};
const addToParty = (slotIndex?: number) => {
const newPokemon = pokemon.addToParty(pokeballType, slotIndex);
const modifiers = globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier, false);
pokemon.addToParty(pokeballType, slotIndex);
if (globalScene.getPlayerParty().filter(p => p.isShiny()).length === 6) {
globalScene.validateAchv(achvs.SHINY_PARTY);
}
Promise.all(modifiers.map(m => globalScene.addModifier(m, true))).then(() => {
globalScene.updateModifiers(true);
removePokemon();
if (newPokemon) {
newPokemon.loadAssets().then(end);
} else {
end();
}
});
};
Promise.all([pokemon.hideInfo(), globalScene.gameData.setPokemonCaught(pokemon)]).then(() => {
if (globalScene.getPlayerParty().length === 6) {