[Refactor] Another Audio clean up (#4077)

* Cleaned up how cry keys were retrieved

* Legendary Pokemon Changes + Cry Cleanup

* Spelling mistake

* Fixed settings.

* correcting typedocs

* eslint

* eslint cleanup

* music pref

* gdfafa

* Music

* Apply suggestions from code review

Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com>

* Update src/battle.ts

Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com>

* Update src/battle.ts

Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com>

* fixed default

* Apply suggestions from code review

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* Added changes

* Update src/battle-scene.ts

Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com>

* Fix variable usage

* Fix `getFormSpriteKey()` and `.concat()` usage

Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com>

* asdsafafaf

* i need to do the dishes ughhh

---------

Co-authored-by: frutescens <info@laptop>
Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com>
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com>
Co-authored-by: Tempoanon <163687446+Tempo-anon@users.noreply.github.com>
This commit is contained in:
Mumble 2024-11-03 19:31:07 -08:00 committed by GitHub
parent 770f388c45
commit 3a767ed38a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 187 additions and 161 deletions

View File

@ -13,6 +13,7 @@ import { Arena, ArenaBase } from "#app/field/arena";
import { GameData } from "#app/system/game-data"; import { GameData } from "#app/system/game-data";
import { addTextObject, getTextColor, TextStyle } from "#app/ui/text"; import { addTextObject, getTextColor, TextStyle } from "#app/ui/text";
import { allMoves } from "#app/data/move"; import { allMoves } from "#app/data/move";
import { MusicPreference } from "#app/system/settings/settings";
import { getDefaultModifierTypeForTier, getEnemyModifierTypesForWave, getLuckString, getLuckTextTint, getModifierPoolForType, getModifierType, getPartyLuckValue, ModifierPoolType, modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; import { getDefaultModifierTypeForTier, getEnemyModifierTypesForWave, getLuckString, getLuckTextTint, getModifierPoolForType, getModifierType, getPartyLuckValue, ModifierPoolType, modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
import AbilityBar from "#app/ui/ability-bar"; import AbilityBar from "#app/ui/ability-bar";
import { allAbilities, applyAbAttrs, applyPostBattleInitAbAttrs, applyPostItemLostAbAttrs, BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, PostBattleInitAbAttr, PostItemLostAbAttr } from "#app/data/ability"; import { allAbilities, applyAbAttrs, applyPostBattleInitAbAttrs, applyPostItemLostAbAttrs, BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, PostBattleInitAbAttr, PostItemLostAbAttr } from "#app/data/ability";
@ -169,7 +170,7 @@ export default class BattleScene extends SceneBase {
public uiTheme: UiTheme = UiTheme.DEFAULT; public uiTheme: UiTheme = UiTheme.DEFAULT;
public windowType: integer = 0; public windowType: integer = 0;
public experimentalSprites: boolean = false; public experimentalSprites: boolean = false;
public musicPreference: integer = 0; public musicPreference: number = MusicPreference.MIXED;
public moveAnimations: boolean = true; public moveAnimations: boolean = true;
public expGainsSpeed: ExpGainsSpeed = ExpGainsSpeed.DEFAULT; public expGainsSpeed: ExpGainsSpeed = ExpGainsSpeed.DEFAULT;
public skipSeenDialogues: boolean = false; public skipSeenDialogues: boolean = false;
@ -2998,22 +2999,16 @@ export default class BattleScene extends SceneBase {
*/ */
getActiveKeys(): string[] { getActiveKeys(): string[] {
const keys: string[] = []; const keys: string[] = [];
const playerParty = this.getPlayerParty(); let activePokemon: (PlayerPokemon | EnemyPokemon)[] = this.getPlayerParty();
playerParty.forEach(p => { activePokemon = activePokemon.concat(this.getEnemyParty());
activePokemon.forEach((p) => {
keys.push(p.getSpriteKey(true)); keys.push(p.getSpriteKey(true));
if (p instanceof PlayerPokemon) {
keys.push(p.getBattleSpriteKey(true, true)); keys.push(p.getBattleSpriteKey(true, true));
keys.push("cry/" + p.species.getCryKey(p.formIndex));
if (p.fusionSpecies) {
keys.push("cry/" + p.fusionSpecies.getCryKey(p.fusionFormIndex));
} }
}); keys.push(p.species.getCryKey(p.formIndex));
// enemyParty has to be operated on separately from playerParty because playerPokemon =/= enemyPokemon
const enemyParty = this.getEnemyParty();
enemyParty.forEach(p => {
keys.push(p.getSpriteKey(true));
keys.push("cry/" + p.species.getCryKey(p.formIndex));
if (p.fusionSpecies) { if (p.fusionSpecies) {
keys.push("cry/" + p.fusionSpecies.getCryKey(p.fusionFormIndex)); keys.push(p.fusionSpecies.getCryKey(p.fusionFormIndex));
} }
}); });
return keys; return keys;

View File

@ -6,11 +6,13 @@ import { GameMode } from "./game-mode";
import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier"; import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier";
import { PokeballType } from "./data/pokeball"; import { PokeballType } from "./data/pokeball";
import { trainerConfigs } from "#app/data/trainer-config"; import { trainerConfigs } from "#app/data/trainer-config";
import { SpeciesFormKey } from "#enums/species-form-key";
import Pokemon, { EnemyPokemon, PlayerPokemon, QueuedMove } from "#app/field/pokemon"; import Pokemon, { EnemyPokemon, PlayerPokemon, QueuedMove } from "#app/field/pokemon";
import { ArenaTagType } from "#enums/arena-tag-type"; import { ArenaTagType } from "#enums/arena-tag-type";
import { BattleSpec } from "#enums/battle-spec"; import { BattleSpec } from "#enums/battle-spec";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { PlayerGender } from "#enums/player-gender"; import { PlayerGender } from "#enums/player-gender";
import { MusicPreference } from "#app/system/settings/settings";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { TrainerType } from "#enums/trainer-type"; import { TrainerType } from "#enums/trainer-type";
import i18next from "#app/plugins/i18n"; import i18next from "#app/plugins/i18n";
@ -212,7 +214,6 @@ export default class Battle {
} }
getBgmOverride(scene: BattleScene): string | null { getBgmOverride(scene: BattleScene): string | null {
const battlers = this.enemyParty.slice(0, this.getBattlerCount());
if (this.isBattleMysteryEncounter() && this.mysteryEncounter?.encounterMode === MysteryEncounterMode.DEFAULT) { if (this.isBattleMysteryEncounter() && this.mysteryEncounter?.encounterMode === MysteryEncounterMode.DEFAULT) {
// Music is overridden for MEs during ME onInit() // Music is overridden for MEs during ME onInit()
// Should not use any BGM overrides before swapping from DEFAULT mode // Should not use any BGM overrides before swapping from DEFAULT mode
@ -221,7 +222,7 @@ export default class Battle {
if (!this.started && this.trainer?.config.encounterBgm && this.trainer?.getEncounterMessages()?.length) { if (!this.started && this.trainer?.config.encounterBgm && this.trainer?.getEncounterMessages()?.length) {
return `encounter_${this.trainer?.getEncounterBgm()}`; return `encounter_${this.trainer?.getEncounterBgm()}`;
} }
if (scene.musicPreference === 0) { if (scene.musicPreference === MusicPreference.CONSISTENT) {
return this.trainer?.getBattleBgm() ?? null; return this.trainer?.getBattleBgm() ?? null;
} else { } else {
return this.trainer?.getMixedBattleBgm() ?? null; return this.trainer?.getMixedBattleBgm() ?? null;
@ -229,143 +230,163 @@ export default class Battle {
} else if (this.gameMode.isClassic && this.waveIndex > 195 && this.battleSpec !== BattleSpec.FINAL_BOSS) { } else if (this.gameMode.isClassic && this.waveIndex > 195 && this.battleSpec !== BattleSpec.FINAL_BOSS) {
return "end_summit"; return "end_summit";
} }
for (const pokemon of battlers) { const wildOpponents = scene.getEnemyParty();
for (const pokemon of wildOpponents) {
if (this.battleSpec === BattleSpec.FINAL_BOSS) { if (this.battleSpec === BattleSpec.FINAL_BOSS) {
if (pokemon.formIndex) { if (pokemon.species.getFormSpriteKey(pokemon.formIndex) === SpeciesFormKey.ETERNAMAX) {
return "battle_final"; return "battle_final";
} }
return "battle_final_encounter"; return "battle_final_encounter";
} }
if (pokemon.species.legendary || pokemon.species.subLegendary || pokemon.species.mythical) { if (pokemon.species.legendary || pokemon.species.subLegendary || pokemon.species.mythical) {
if (scene.musicPreference === 0) { if (scene.musicPreference === MusicPreference.CONSISTENT) {
if (pokemon.species.speciesId === Species.REGIROCK || pokemon.species.speciesId === Species.REGICE || pokemon.species.speciesId === Species.REGISTEEL || pokemon.species.speciesId === Species.REGIGIGAS || pokemon.species.speciesId === Species.REGIELEKI || pokemon.species.speciesId === Species.REGIDRAGO) { switch (pokemon.species.speciesId) {
case Species.REGIROCK:
case Species.REGICE:
case Species.REGISTEEL:
case Species.REGIGIGAS:
case Species.REGIDRAGO:
case Species.REGIELEKI:
return "battle_legendary_regis_g5"; return "battle_legendary_regis_g5";
} case Species.KYUREM:
if (pokemon.species.speciesId === Species.COBALION || pokemon.species.speciesId === Species.TERRAKION || pokemon.species.speciesId === Species.VIRIZION || pokemon.species.speciesId === Species.TORNADUS || pokemon.species.speciesId === Species.THUNDURUS || pokemon.species.speciesId === Species.LANDORUS || pokemon.species.speciesId === Species.KELDEO || pokemon.species.speciesId === Species.MELOETTA || pokemon.species.speciesId === Species.GENESECT) {
return "battle_legendary_unova";
}
if (pokemon.species.speciesId === Species.KYUREM) {
return "battle_legendary_kyurem"; return "battle_legendary_kyurem";
} default:
if (pokemon.species.legendary) { if (pokemon.species.legendary) {
return "battle_legendary_res_zek"; return "battle_legendary_res_zek";
} }
return "battle_legendary_unova"; return "battle_legendary_unova";
} else { }
if (pokemon.species.speciesId === Species.ARTICUNO || pokemon.species.speciesId === Species.ZAPDOS || pokemon.species.speciesId === Species.MOLTRES || pokemon.species.speciesId === Species.MEWTWO || pokemon.species.speciesId === Species.MEW) { } else if (scene.musicPreference === MusicPreference.MIXED) {
switch (pokemon.species.speciesId) {
case Species.ARTICUNO:
case Species.ZAPDOS:
case Species.MOLTRES:
case Species.MEWTWO:
case Species.MEW:
return "battle_legendary_kanto"; return "battle_legendary_kanto";
} case Species.RAIKOU:
if (pokemon.species.speciesId === Species.RAIKOU) {
return "battle_legendary_raikou"; return "battle_legendary_raikou";
} case Species.ENTEI:
if (pokemon.species.speciesId === Species.ENTEI) {
return "battle_legendary_entei"; return "battle_legendary_entei";
} case Species.SUICUNE:
if (pokemon.species.speciesId === Species.SUICUNE) {
return "battle_legendary_suicune"; return "battle_legendary_suicune";
} case Species.LUGIA:
if (pokemon.species.speciesId === Species.LUGIA) {
return "battle_legendary_lugia"; return "battle_legendary_lugia";
} case Species.HO_OH:
if (pokemon.species.speciesId === Species.HO_OH) {
return "battle_legendary_ho_oh"; return "battle_legendary_ho_oh";
} case Species.REGIROCK:
if (pokemon.species.speciesId === Species.REGIROCK || pokemon.species.speciesId === Species.REGICE || pokemon.species.speciesId === Species.REGISTEEL || pokemon.species.speciesId === Species.REGIGIGAS || pokemon.species.speciesId === Species.REGIELEKI || pokemon.species.speciesId === Species.REGIDRAGO) { case Species.REGICE:
case Species.REGISTEEL:
case Species.REGIGIGAS:
case Species.REGIDRAGO:
case Species.REGIELEKI:
return "battle_legendary_regis_g6"; return "battle_legendary_regis_g6";
} case Species.GROUDON:
if (pokemon.species.speciesId === Species.GROUDON || pokemon.species.speciesId === Species.KYOGRE) { case Species.KYOGRE:
return "battle_legendary_gro_kyo"; return "battle_legendary_gro_kyo";
} case Species.RAYQUAZA:
if (pokemon.species.speciesId === Species.RAYQUAZA) {
return "battle_legendary_rayquaza"; return "battle_legendary_rayquaza";
} case Species.DEOXYS:
if (pokemon.species.speciesId === Species.DEOXYS) {
return "battle_legendary_deoxys"; return "battle_legendary_deoxys";
} case Species.UXIE:
if (pokemon.species.speciesId === Species.UXIE || pokemon.species.speciesId === Species.MESPRIT || pokemon.species.speciesId === Species.AZELF) { case Species.MESPRIT:
case Species.AZELF:
return "battle_legendary_lake_trio"; return "battle_legendary_lake_trio";
} case Species.HEATRAN:
if (pokemon.species.speciesId === Species.HEATRAN || pokemon.species.speciesId === Species.CRESSELIA || pokemon.species.speciesId === Species.DARKRAI || pokemon.species.speciesId === Species.SHAYMIN) { case Species.CRESSELIA:
case Species.DARKRAI:
case Species.SHAYMIN:
return "battle_legendary_sinnoh"; return "battle_legendary_sinnoh";
} case Species.DIALGA:
if (pokemon.species.speciesId === Species.DIALGA || pokemon.species.speciesId === Species.PALKIA) { case Species.PALKIA:
if (pokemon.getFormKey() === "") { if (pokemon.species.getFormSpriteKey(pokemon.formIndex) === SpeciesFormKey.ORIGIN) {
return "battle_legendary_dia_pal";
}
if (pokemon.getFormKey() === "origin") {
return "battle_legendary_origin_forme"; return "battle_legendary_origin_forme";
} }
} return "battle_legendary_dia_pal";
if (pokemon.species.speciesId === Species.GIRATINA) { case Species.GIRATINA:
return "battle_legendary_giratina"; return "battle_legendary_giratina";
} case Species.ARCEUS:
if (pokemon.species.speciesId === Species.ARCEUS) {
return "battle_legendary_arceus"; return "battle_legendary_arceus";
} case Species.COBALION:
if (pokemon.species.speciesId === Species.COBALION || pokemon.species.speciesId === Species.TERRAKION || pokemon.species.speciesId === Species.VIRIZION || pokemon.species.speciesId === Species.TORNADUS || pokemon.species.speciesId === Species.THUNDURUS || pokemon.species.speciesId === Species.LANDORUS || pokemon.species.speciesId === Species.KELDEO || pokemon.species.speciesId === Species.MELOETTA || pokemon.species.speciesId === Species.GENESECT) { case Species.TERRAKION:
case Species.VIRIZION:
case Species.KELDEO:
case Species.TORNADUS:
case Species.LANDORUS:
case Species.THUNDURUS:
case Species.MELOETTA:
case Species.GENESECT:
return "battle_legendary_unova"; return "battle_legendary_unova";
} case Species.KYUREM:
if (pokemon.species.speciesId === Species.KYUREM) {
return "battle_legendary_kyurem"; return "battle_legendary_kyurem";
} case Species.XERNEAS:
if (pokemon.species.speciesId === Species.XERNEAS || pokemon.species.speciesId === Species.YVELTAL || pokemon.species.speciesId === Species.ZYGARDE) { case Species.YVELTAL:
case Species.ZYGARDE:
return "battle_legendary_xern_yvel"; return "battle_legendary_xern_yvel";
} case Species.TAPU_KOKO:
if (pokemon.species.speciesId === Species.TAPU_KOKO || pokemon.species.speciesId === Species.TAPU_LELE || pokemon.species.speciesId === Species.TAPU_BULU || pokemon.species.speciesId === Species.TAPU_FINI) { case Species.TAPU_LELE:
case Species.TAPU_BULU:
case Species.TAPU_FINI:
return "battle_legendary_tapu"; return "battle_legendary_tapu";
} case Species.SOLGALEO:
if ([ Species.COSMOG, Species.COSMOEM, Species.SOLGALEO, Species.LUNALA ].includes(pokemon.species.speciesId)) { case Species.LUNALA:
return "battle_legendary_sol_lun"; return "battle_legendary_sol_lun";
} case Species.NECROZMA:
if (pokemon.species.speciesId === Species.NECROZMA) { switch (pokemon.getFormKey()) {
if (pokemon.getFormKey() === "") { case "dusk-mane":
return "battle_legendary_sol_lun"; case "dawn-wings":
}
if (pokemon.getFormKey() === "dusk-mane" || pokemon.getFormKey() === "dawn-wings") {
return "battle_legendary_dusk_dawn"; return "battle_legendary_dusk_dawn";
} case "ultra":
if (pokemon.getFormKey() === "ultra") {
return "battle_legendary_ultra_nec"; return "battle_legendary_ultra_nec";
default:
return "battle_legendary_sol_lun";
} }
} case Species.NIHILEGO:
if ([ Species.NIHILEGO, Species.BUZZWOLE, Species.PHEROMOSA, Species.XURKITREE, Species.CELESTEELA, Species.KARTANA, Species.GUZZLORD, Species.POIPOLE, Species.NAGANADEL, Species.STAKATAKA, Species.BLACEPHALON ].includes(pokemon.species.speciesId)) { case Species.PHEROMOSA:
case Species.BUZZWOLE:
case Species.XURKITREE:
case Species.CELESTEELA:
case Species.KARTANA:
case Species.GUZZLORD:
case Species.POIPOLE:
case Species.NAGANADEL:
case Species.STAKATAKA:
case Species.BLACEPHALON:
return "battle_legendary_ub"; return "battle_legendary_ub";
} case Species.ZACIAN:
if (pokemon.species.speciesId === Species.ZACIAN || pokemon.species.speciesId === Species.ZAMAZENTA) { case Species.ZAMAZENTA:
return "battle_legendary_zac_zam"; return "battle_legendary_zac_zam";
} case Species.GLASTRIER:
if (pokemon.species.speciesId === Species.GLASTRIER || pokemon.species.speciesId === Species.SPECTRIER) { case Species.SPECTRIER:
return "battle_legendary_glas_spec"; return "battle_legendary_glas_spec";
} case Species.CALYREX:
if (pokemon.species.speciesId === Species.CALYREX) {
if (pokemon.getFormKey() === "") {
return "battle_legendary_calyrex";
}
if (pokemon.getFormKey() === "ice" || pokemon.getFormKey() === "shadow") { if (pokemon.getFormKey() === "ice" || pokemon.getFormKey() === "shadow") {
return "battle_legendary_riders"; return "battle_legendary_riders";
} }
} return "battle_legendary_calyrex";
if (pokemon.species.speciesId === Species.GALAR_ARTICUNO || pokemon.species.speciesId === Species.GALAR_ZAPDOS || pokemon.species.speciesId === Species.GALAR_MOLTRES) { case Species.GALAR_ARTICUNO:
case Species.GALAR_ZAPDOS:
case Species.GALAR_MOLTRES:
return "battle_legendary_birds_galar"; return "battle_legendary_birds_galar";
} case Species.WO_CHIEN:
if (pokemon.species.speciesId === Species.WO_CHIEN || pokemon.species.speciesId === Species.CHIEN_PAO || pokemon.species.speciesId === Species.TING_LU || pokemon.species.speciesId === Species.CHI_YU) { case Species.CHIEN_PAO:
case Species.TING_LU:
case Species.CHI_YU:
return "battle_legendary_ruinous"; return "battle_legendary_ruinous";
} case Species.KORAIDON:
if (pokemon.species.speciesId === Species.KORAIDON || pokemon.species.speciesId === Species.MIRAIDON) { case Species.MIRAIDON:
return "battle_legendary_kor_mir"; return "battle_legendary_kor_mir";
} case Species.OKIDOGI:
if (pokemon.species.speciesId === Species.OKIDOGI || pokemon.species.speciesId === Species.MUNKIDORI || pokemon.species.speciesId === Species.FEZANDIPITI) { case Species.MUNKIDORI:
case Species.FEZANDIPITI:
return "battle_legendary_loyal_three"; return "battle_legendary_loyal_three";
} case Species.OGERPON:
if (pokemon.species.speciesId === Species.OGERPON) {
return "battle_legendary_ogerpon"; return "battle_legendary_ogerpon";
} case Species.TERAPAGOS:
if (pokemon.species.speciesId === Species.TERAPAGOS) {
return "battle_legendary_terapagos"; return "battle_legendary_terapagos";
} case Species.PECHARUNT:
if (pokemon.species.speciesId === Species.PECHARUNT) {
return "battle_legendary_pecharunt"; return "battle_legendary_pecharunt";
} default:
if (pokemon.species.legendary) { if (pokemon.species.legendary) {
return "battle_legendary_res_zek"; return "battle_legendary_res_zek";
} }
@ -373,6 +394,7 @@ export default class Battle {
} }
} }
} }
}
if (scene.gameMode.isClassic && this.waveIndex <= 4) { if (scene.gameMode.isClassic && this.waveIndex <= 4) {
return "battle_wild"; return "battle_wild";

View File

@ -1,6 +1,7 @@
import { leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterRewards } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterRewards } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { TrainerSlot, } from "#app/data/trainer-config"; import { TrainerSlot, } from "#app/data/trainer-config";
import { ModifierTier } from "#app/modifier/modifier-tier"; import { ModifierTier } from "#app/modifier/modifier-tier";
import { MusicPreference } from "#app/system/settings/settings";
import { getPlayerModifierTypeOptions, ModifierPoolType, ModifierTypeOption, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type"; import { getPlayerModifierTypeOptions, ModifierPoolType, ModifierTypeOption, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type";
import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import BattleScene from "#app/battle-scene"; import BattleScene from "#app/battle-scene";
@ -105,7 +106,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
// Load bgm // Load bgm
let bgmKey: string; let bgmKey: string;
if (scene.musicPreference === 0) { if (scene.musicPreference === MusicPreference.CONSISTENT) {
bgmKey = "mystery_encounter_gen_5_gts"; bgmKey = "mystery_encounter_gen_5_gts";
scene.loadBgm(bgmKey, `${bgmKey}.mp3`); scene.loadBgm(bgmKey, `${bgmKey}.mp3`);
} else { } else {

View File

@ -460,7 +460,7 @@ export abstract class PokemonSpeciesForm {
break; break;
} }
} }
return ret; return `cry/${ret}`;
} }
validateStarterMoveset(moveset: StarterMoveset, eggMoves: number): boolean { validateStarterMoveset(moveset: StarterMoveset, eggMoves: number): boolean {
@ -488,7 +488,7 @@ export abstract class PokemonSpeciesForm {
return new Promise(resolve => { return new Promise(resolve => {
const spriteKey = this.getSpriteKey(female, formIndex, shiny, variant); const spriteKey = this.getSpriteKey(female, formIndex, shiny, variant);
scene.loadPokemonAtlas(spriteKey, this.getSpriteAtlasPath(female, formIndex, shiny, variant)); scene.loadPokemonAtlas(spriteKey, this.getSpriteAtlasPath(female, formIndex, shiny, variant));
scene.load.audio(`cry/${this.getCryKey(formIndex)}`, `audio/cry/${this.getCryKey(formIndex)}.m4a`); scene.load.audio(`${this.getCryKey(formIndex)}`, `audio/${this.getCryKey(formIndex)}.m4a`);
scene.load.once(Phaser.Loader.Events.COMPLETE, () => { scene.load.once(Phaser.Loader.Events.COMPLETE, () => {
const originalWarn = console.warn; const originalWarn = console.warn;
// Ignore warnings for missing frames, because there will be a lot // Ignore warnings for missing frames, because there will be a lot
@ -546,7 +546,7 @@ export abstract class PokemonSpeciesForm {
if (cry?.pendingRemove) { if (cry?.pendingRemove) {
cry = null; cry = null;
} }
cry = scene.playSound(`cry/${(cry ?? cryKey)}`, soundConfig); cry = scene.playSound(cry ?? cryKey, soundConfig);
if (ignorePlay) { if (ignorePlay) {
cry.stop(); cry.stop();
} }

View File

@ -3266,7 +3266,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
try { try {
SoundFade.fadeOut(scene, cry, Utils.fixedInt(Math.ceil(duration * 0.2))); SoundFade.fadeOut(scene, cry, Utils.fixedInt(Math.ceil(duration * 0.2)));
fusionCry = this.getFusionSpeciesForm().cry(scene, Object.assign({ seek: Math.max(fusionCry.totalDuration * 0.4, 0) }, soundConfig)); fusionCry = this.getFusionSpeciesForm().cry(scene, Object.assign({ seek: Math.max(fusionCry.totalDuration * 0.4, 0) }, soundConfig));
SoundFade.fadeIn(scene, fusionCry, Utils.fixedInt(Math.ceil(duration * 0.2)), scene.masterVolume * scene.seVolume, 0); SoundFade.fadeIn(scene, fusionCry, Utils.fixedInt(Math.ceil(duration * 0.2)), scene.masterVolume * scene.fieldVolume, 0);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
} }
@ -3281,11 +3281,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return this.fusionFaintCry(callback); return this.fusionFaintCry(callback);
} }
const key = `cry/${this.species.getCryKey(this.formIndex)}`; const key = this.species.getCryKey(this.formIndex);
//eslint-disable-next-line @typescript-eslint/no-unused-vars
let i = 0;
let rate = 0.85; let rate = 0.85;
const cry = this.scene.playSound(key, { rate: rate }) as AnySound; const cry = this.scene.playSound(key, { rate: rate }) as AnySound;
if (!cry || this.scene.fieldVolume === 0) {
return callback();
}
const sprite = this.getSprite(); const sprite = this.getSprite();
const tintSprite = this.getTintSprite(); const tintSprite = this.getTintSprite();
const delay = Math.max(this.scene.sound.get(key).totalDuration * 50, 25); const delay = Math.max(this.scene.sound.get(key).totalDuration * 50, 25);
@ -3300,7 +3301,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
delay: Utils.fixedInt(delay), delay: Utils.fixedInt(delay),
repeat: -1, repeat: -1,
callback: () => { callback: () => {
++i;
frameThreshold = sprite.anims.msPerFrame / rate; frameThreshold = sprite.anims.msPerFrame / rate;
frameProgress += delay; frameProgress += delay;
while (frameProgress > frameThreshold) { while (frameProgress > frameThreshold) {
@ -3339,7 +3339,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
} }
private fusionFaintCry(callback: Function): void { private fusionFaintCry(callback: Function): void {
const key = `cry/${this.species.getCryKey(this.formIndex)}`; const key = this.species.getCryKey(this.formIndex);
let i = 0; let i = 0;
let rate = 0.85; let rate = 0.85;
const cry = this.scene.playSound(key, { rate: rate }) as AnySound; const cry = this.scene.playSound(key, { rate: rate }) as AnySound;
@ -3347,12 +3347,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
const tintSprite = this.getTintSprite(); const tintSprite = this.getTintSprite();
let duration = cry.totalDuration * 1000; let duration = cry.totalDuration * 1000;
const fusionCryKey = `cry/${this.fusionSpecies?.getCryKey(this.fusionFormIndex)}`; const fusionCryKey = this.fusionSpecies!.getCryKey(this.fusionFormIndex);
let fusionCry = this.scene.playSound(fusionCryKey, { rate: rate }) as AnySound; let fusionCry = this.scene.playSound(fusionCryKey, { rate: rate }) as AnySound;
if (!cry || !fusionCry || this.scene.fieldVolume === 0) {
return callback();
}
fusionCry.stop(); fusionCry.stop();
duration = Math.min(duration, fusionCry.totalDuration * 1000); duration = Math.min(duration, fusionCry.totalDuration * 1000);
fusionCry.destroy(); fusionCry.destroy();
const delay = Math.max(duration * 0.05, 25); const delay = Math.max(duration * 0.05, 25);
let transitionIndex = 0; let transitionIndex = 0;
@ -3390,10 +3392,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
} }
frameProgress -= frameThreshold; frameProgress -= frameThreshold;
} }
if (i === transitionIndex) { if (i === transitionIndex && fusionCryKey) {
SoundFade.fadeOut(this.scene, cry, Utils.fixedInt(Math.ceil((duration / rate) * 0.2))); SoundFade.fadeOut(this.scene, cry, Utils.fixedInt(Math.ceil((duration / rate) * 0.2)));
fusionCry = this.scene.playSound(fusionCryKey, Object.assign({ seek: Math.max(fusionCry.totalDuration * 0.4, 0), rate: rate })); fusionCry = this.scene.playSound(fusionCryKey, Object.assign({ seek: Math.max(fusionCry.totalDuration * 0.4, 0), rate: rate }));
SoundFade.fadeIn(this.scene, fusionCry, Utils.fixedInt(Math.ceil((duration / rate) * 0.2)), this.scene.masterVolume * this.scene.seVolume, 0); SoundFade.fadeIn(this.scene, fusionCry, Utils.fixedInt(Math.ceil((duration / rate) * 0.2)), this.scene.masterVolume * this.scene.fieldVolume, 0);
} }
rate *= 0.99; rate *= 0.99;
if (cry && !cry.pendingRemove) { if (cry && !cry.pendingRemove) {

View File

@ -163,6 +163,11 @@ export const SettingKeys = {
Shop_Overlay_Opacity: "SHOP_OVERLAY_OPACITY" Shop_Overlay_Opacity: "SHOP_OVERLAY_OPACITY"
}; };
export enum MusicPreference {
CONSISTENT,
MIXED
}
/** /**
* All Settings not related to controls * All Settings not related to controls
*/ */
@ -634,7 +639,7 @@ export const Setting: Array<Setting> = [
label: i18next.t("settings:mixed") label: i18next.t("settings:mixed")
} }
], ],
default: 0, default: MusicPreference.MIXED,
type: SettingType.AUDIO, type: SettingType.AUDIO,
requireReload: true requireReload: true
}, },

View File

@ -156,6 +156,7 @@ export default class GameManager {
this.scene.enableTutorials = false; this.scene.enableTutorials = false;
this.scene.gameData.gender = PlayerGender.MALE; // set initial player gender this.scene.gameData.gender = PlayerGender.MALE; // set initial player gender
this.scene.battleStyle = this.settings.battleStyle; this.scene.battleStyle = this.settings.battleStyle;
this.scene.fieldVolume = 0;
} }
/** /**