Skip to content

Commit

Permalink
[Bug] Fix for Expert Breeder's Pokemon being invisible and IV scanner…
Browse files Browse the repository at this point in the history
… in safari zone (#4661)

* [Bug] Potential fix for Expert Breeder's Pokemon being invisible

* PR Feedback

* Consistency with await
  • Loading branch information
PigeonBar authored Oct 16, 2024
1 parent 50ff6e7 commit c6ec019
Show file tree
Hide file tree
Showing 20 changed files with 120 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/battle-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ export default class BattleScene extends SceneBase {
}

getEnemyParty(): EnemyPokemon[] {
return this.currentBattle?.enemyParty || [];
return this.currentBattle?.enemyParty ?? [];
}

getEnemyPokemon(): EnemyPokemon | undefined {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export const ATrainersTestEncounter: MysteryEncounter =
};
encounter.setDialogueToken("eggType", i18next.t(`${namespace}:eggTypes.epic`));
setEncounterRewards(scene, { guaranteedModifierTypeFuncs: [ modifierTypes.SACRED_ASH ], guaranteedModifierTiers: [ ModifierTier.ROGUE, ModifierTier.ULTRA ], fillRemaining: true }, [ eggOptions ]);
return initBattleWithEnemyConfig(scene, config);
await initBattleWithEnemyConfig(scene, config);
}
)
.withSimpleOption(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export const AbsoluteAvariceEncounter: MysteryEncounter =
ignorePp: true
});

transitionMysteryEncounterIntroVisuals(scene, true, true, 500);
await transitionMysteryEncounterIntroVisuals(scene, true, true, 500);
await initBattleWithEnemyConfig(scene, encounter.enemyPartyConfigs[0]);
})
.build()
Expand Down Expand Up @@ -328,7 +328,7 @@ export const AbsoluteAvariceEncounter: MysteryEncounter =
});
await scene.updateModifiers(true);

transitionMysteryEncounterIntroVisuals(scene, true, true, 500);
await transitionMysteryEncounterIntroVisuals(scene, true, true, 500);
leaveEncounterWithoutBattle(scene, true);
})
.build()
Expand Down Expand Up @@ -359,7 +359,7 @@ export const AbsoluteAvariceEncounter: MysteryEncounter =
greedent.moveset = [ new PokemonMove(Moves.THRASH), new PokemonMove(Moves.BODY_PRESS), new PokemonMove(Moves.STUFF_CHEEKS), new PokemonMove(Moves.SLACK_OFF) ];
greedent.passive = true;

transitionMysteryEncounterIntroVisuals(scene, true, true, 500);
await transitionMysteryEncounterIntroVisuals(scene, true, true, 500);
await catchPokemon(scene, greedent, null, PokeballType.POKEBALL, false);
leaveEncounterWithoutBattle(scene, true);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export const DancingLessonsEncounter: MysteryEncounter =
})
.withOptionPhase(async (scene: BattleScene) => {
// Learn its Dance
hideOricorioPokemon(scene);
await hideOricorioPokemon(scene);
leaveEncounterWithoutBattle(scene, true);
})
.build()
Expand Down Expand Up @@ -303,7 +303,7 @@ export const DancingLessonsEncounter: MysteryEncounter =
}
}

hideOricorioPokemon(scene);
await hideOricorioPokemon(scene);
await catchPokemon(scene, oricorio, null, PokeballType.POKEBALL, false);
leaveEncounterWithoutBattle(scene, true);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export const DarkDealEncounter: MysteryEncounter =
const config: EnemyPartyConfig = {
pokemonConfigs: [ pokemonConfig ],
};
return initBattleWithEnemyConfig(scene, config);
await initBattleWithEnemyConfig(scene, config);
})
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,13 @@ export const FieryFalloutEncounter: MysteryEncounter =
],
})
.withPreOptionPhase(async (scene: BattleScene) => {
// Do NOT await this, to prevent player from repeatedly pressing options
transitionMysteryEncounterIntroVisuals(scene, false, false, 2000);
})
.withOptionPhase(async (scene: BattleScene) => {
// Fire types help calm the Volcarona
const encounter = scene.currentBattle.mysteryEncounter!;
transitionMysteryEncounterIntroVisuals(scene);
await transitionMysteryEncounterIntroVisuals(scene);
setEncounterRewards(scene,
{ fillRemaining: true },
undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const FunAndGamesEncounter: MysteryEncounter =
},
async (scene: BattleScene) => {
// Leave encounter with no rewards or exp
transitionMysteryEncounterIntroVisuals(scene, true, true);
await transitionMysteryEncounterIntroVisuals(scene, true, true);
leaveEncounterWithoutBattle(scene, true);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
if (modifier.stackCount === 0) {
scene.removeModifier(modifier);
}
scene.updateModifiers(true, true);
await scene.updateModifiers(true, true);

// Generate a trainer name
const traderName = generateRandomTraderName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const LostAtSeaEncounter: MysteryEncounter = MysteryEncounterBuilder.with
*
* @param scene Battle scene
*/
async function handlePokemonGuidingYouPhase(scene: BattleScene) {
function handlePokemonGuidingYouPhase(scene: BattleScene) {
const laprasSpecies = getPokemonSpecies(Species.LAPRAS);
const { mysteryEncounter } = scene.currentBattle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ export const MysteriousChallengersEncounter: MysteryEncounter =
setEncounterRewards(scene, { guaranteedModifierTypeFuncs: [ modifierTypes.TM_COMMON, modifierTypes.TM_GREAT, modifierTypes.MEMORY_MUSHROOM ], fillRemaining: true });

// Seed offsets to remove possibility of different trainers having exact same teams
let ret;
let initBattlePromise: Promise<void>;
scene.executeWithSeedOffset(() => {
ret = initBattleWithEnemyConfig(scene, config);
initBattlePromise = initBattleWithEnemyConfig(scene, config);
}, scene.currentBattle.waveIndex * 10);
return ret;
await initBattlePromise!;
}
)
.withSimpleOption(
Expand All @@ -172,11 +172,11 @@ export const MysteriousChallengersEncounter: MysteryEncounter =
setEncounterRewards(scene, { guaranteedModifierTiers: [ ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.GREAT, ModifierTier.GREAT ], fillRemaining: true });

// Seed offsets to remove possibility of different trainers having exact same teams
let ret;
let initBattlePromise: Promise<void>;
scene.executeWithSeedOffset(() => {
ret = initBattleWithEnemyConfig(scene, config);
initBattlePromise = initBattleWithEnemyConfig(scene, config);
}, scene.currentBattle.waveIndex * 100);
return ret;
await initBattlePromise!;
}
)
.withSimpleOption(
Expand All @@ -200,11 +200,11 @@ export const MysteriousChallengersEncounter: MysteryEncounter =
setEncounterRewards(scene, { guaranteedModifierTiers: [ ModifierTier.ROGUE, ModifierTier.ROGUE, ModifierTier.ULTRA, ModifierTier.GREAT ], fillRemaining: true });

// Seed offsets to remove possibility of different trainers having exact same teams
let ret;
let initBattlePromise: Promise<void>;
scene.executeWithSeedOffset(() => {
ret = initBattleWithEnemyConfig(scene, config);
initBattlePromise = initBattleWithEnemyConfig(scene, config);
}, scene.currentBattle.waveIndex * 1000);
return ret;
await initBattlePromise!;
}
)
.withOutroDialogue([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export const MysteriousChestEncounter: MysteryEncounter =
scene.unshiftPhase(new GameOverPhase(scene));
} else {
// Show which Pokemon was KOed, then start battle against Gimmighoul
transitionMysteryEncounterIntroVisuals(scene, true, true, 500);
await transitionMysteryEncounterIntroVisuals(scene, true, true, 500);
setEncounterRewards(scene, { fillRemaining: true });
await initBattleWithEnemyConfig(scene, encounter.enemyPartyConfigs[0]);
}
Expand Down
23 changes: 16 additions & 7 deletions src/data/mystery-encounters/encounters/safari-zone-encounter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,22 @@ async function summonSafariPokemon(scene: BattleScene) {
scene.unshiftPhase(new SummonPhase(scene, 0, false));

encounter.setDialogueToken("pokemonName", getPokemonNameWithAffix(pokemon));
showEncounterText(scene, getEncounterText(scene, "battle:singleWildAppeared") ?? "", null, 1500, false)
.then(() => {
const ivScannerModifier = scene.findModifier(m => m instanceof IvScannerModifier);
if (ivScannerModifier) {
scene.pushPhase(new ScanIvsPhase(scene, pokemon.getBattlerIndex(), Math.min(ivScannerModifier.getStackCount() * 2, 6)));
}
});
// TODO: If we await this showEncounterText, then the text will display without
// the wild Pokemon on screen, but if we don't await it, then the text never
// shows up and the IV scanner breaks. For now, we place the IV scanner code
// separately so that at least the IV scanner works.
//
// showEncounterText(scene, getEncounterText(scene, "battle:singleWildAppeared") ?? "", null, 0, false)
// .then(() => {
// const ivScannerModifier = scene.findModifier(m => m instanceof IvScannerModifier);
// if (ivScannerModifier) {
// scene.pushPhase(new ScanIvsPhase(scene, pokemon.getBattlerIndex(), Math.min(ivScannerModifier.getStackCount() * 2, 6)));
// }
// });
const ivScannerModifier = scene.findModifier(m => m instanceof IvScannerModifier);
if (ivScannerModifier) {
scene.pushPhase(new ScanIvsPhase(scene, pokemon.getBattlerIndex(), Math.min(ivScannerModifier.getStackCount() * 2, 6)));
}
}

function throwPokeball(scene: BattleScene, pokemon: EnemyPokemon): Promise<boolean> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const ShadyVitaminDealerEncounter: MysteryEncounter =
encounter.setDialogueToken("newNature", getNatureName(newNature));
queueEncounterMessage(scene, `${namespace}:cheap_side_effects`);
setEncounterExp(scene, [ chosenPokemon.id ], 100);
chosenPokemon.updateInfo();
await chosenPokemon.updateInfo();
})
.build()
)
Expand Down Expand Up @@ -204,7 +204,7 @@ export const ShadyVitaminDealerEncounter: MysteryEncounter =
queueEncounterMessage(scene, `${namespace}:no_bad_effects`);
setEncounterExp(scene, [ chosenPokemon.id ], 100);

chosenPokemon.updateInfo();
await chosenPokemon.updateInfo();
})
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const TeleportingHijinksEncounter: MysteryEncounter =
const magnet = generateModifierTypeOption(scene, modifierTypes.ATTACK_TYPE_BOOSTER, [ Type.STEEL ])!;
const metalCoat = generateModifierTypeOption(scene, modifierTypes.ATTACK_TYPE_BOOSTER, [ Type.ELECTRIC ])!;
setEncounterRewards(scene, { guaranteedModifierTypeOptions: [ magnet, metalCoat ], fillRemaining: true });
transitionMysteryEncounterIntroVisuals(scene, true, true);
await transitionMysteryEncounterIntroVisuals(scene, true, true);
await initBattleWithEnemyConfig(scene, config);
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export const TheExpertPokemonBreederEncounter: MysteryEncounter =
}

encounter.onGameOver = onGameOver;
initBattleWithEnemyConfig(scene, config);
await initBattleWithEnemyConfig(scene, config);
})
.withPostOptionPhase(async (scene: BattleScene) => {
await doPostEncounterCleanup(scene);
Expand Down Expand Up @@ -297,7 +297,7 @@ export const TheExpertPokemonBreederEncounter: MysteryEncounter =
}

encounter.onGameOver = onGameOver;
initBattleWithEnemyConfig(scene, config);
await initBattleWithEnemyConfig(scene, config);
})
.withPostOptionPhase(async (scene: BattleScene) => {
await doPostEncounterCleanup(scene);
Expand Down Expand Up @@ -349,7 +349,7 @@ export const TheExpertPokemonBreederEncounter: MysteryEncounter =
}

encounter.onGameOver = onGameOver;
initBattleWithEnemyConfig(scene, config);
await initBattleWithEnemyConfig(scene, config);
})
.withPostOptionPhase(async (scene: BattleScene) => {
await doPostEncounterCleanup(scene);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export const TheStrongStuffEncounter: MysteryEncounter =
});

encounter.dialogue.outro = [];
transitionMysteryEncounterIntroVisuals(scene, true, true, 500);
await transitionMysteryEncounterIntroVisuals(scene, true, true, 500);
await initBattleWithEnemyConfig(scene, encounter.enemyPartyConfigs[0]);
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ export const TheWinstrateChallengeEncounter: MysteryEncounter =
},
async (scene: BattleScene) => {
// Spawn 5 trainer battles back to back with Macho Brace in rewards
scene.currentBattle.mysteryEncounter!.doContinueEncounter = (scene: BattleScene) => {
return endTrainerBattleAndShowDialogue(scene);
scene.currentBattle.mysteryEncounter!.doContinueEncounter = async (scene: BattleScene) => {
await endTrainerBattleAndShowDialogue(scene);
};
await transitionMysteryEncounterIntroVisuals(scene, true, false);
await spawnNextTrainerOrEndEncounter(scene);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const TrainingSessionEncounter: MysteryEncounter =

setEncounterRewards(scene, { fillRemaining: true }, undefined, onBeforeRewardsPhase);

return initBattleWithEnemyConfig(scene, config);
await initBattleWithEnemyConfig(scene, config);
})
.build()
)
Expand Down Expand Up @@ -238,7 +238,7 @@ export const TrainingSessionEncounter: MysteryEncounter =

setEncounterRewards(scene, { fillRemaining: true }, undefined, onBeforeRewardsPhase);

return initBattleWithEnemyConfig(scene, config);
await initBattleWithEnemyConfig(scene, config);
})
.build()
)
Expand Down Expand Up @@ -351,7 +351,7 @@ export const TrainingSessionEncounter: MysteryEncounter =

setEncounterRewards(scene, { fillRemaining: true }, undefined, onBeforeRewardsPhase);

return initBattleWithEnemyConfig(scene, config);
await initBattleWithEnemyConfig(scene, config);
})
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const TrashToTreasureEncounter: MysteryEncounter =
})
.withOptionPhase(async (scene: BattleScene) => {
// Gain 2 Leftovers and 2 Shell Bell
transitionMysteryEncounterIntroVisuals(scene);
await transitionMysteryEncounterIntroVisuals(scene);
await tryApplyDigRewardItems(scene);

const blackSludge = generateModifierType(scene, modifierTypes.MYSTERY_ENCOUNTER_BLACK_SLUDGE, [ SHOP_ITEM_COST_MULTIPLIER ]);
Expand Down Expand Up @@ -136,7 +136,7 @@ export const TrashToTreasureEncounter: MysteryEncounter =
// Investigate garbage, battle Gmax Garbodor
scene.setFieldScale(0.75);
await showEncounterText(scene, `${namespace}:option.2.selected_2`);
transitionMysteryEncounterIntroVisuals(scene);
await transitionMysteryEncounterIntroVisuals(scene);

const encounter = scene.currentBattle.mysteryEncounter!;

Expand Down Expand Up @@ -222,7 +222,7 @@ async function tryApplyDigRewardItems(scene: BattleScene) {
await showEncounterText(scene, i18next.t("battle:rewardGainCount", { modifierName: shellBell.name, count: 2 }), null, undefined, true);
}

async function doGarbageDig(scene: BattleScene) {
function doGarbageDig(scene: BattleScene) {
scene.playSound("battle_anims/PRSFX- Dig2");
scene.time.delayedCall(SOUND_EFFECT_WAIT_TIME, () => {
scene.playSound("battle_anims/PRSFX- Dig2");
Expand Down
Loading

0 comments on commit c6ec019

Please sign in to comment.