[Bug] Moved code preventing MBH's transfer to post modifier generation (#4858)

* Moved code preventing MBH's transfer to after enemy modifiers were generated.

* Removed unnecessary !

* Removed unnecessary ?

* Created a new enum and functions for retrieving final bosses.

* Moved isBattleClassicFinalBoss to game-mode.ts and reverted battle.ts

* Preventing item transfer with tryTransferModifier instead

* Added filtering to modifier-retrieve methods.

* Revised logic in tryTransferHeldItemModifier

* Adding what works to the game even though it's not the best.

* Added comments

* Removing past changes to files.

* Added check for Classic Final Boss.

---------

Co-authored-by: frutescens <info@laptop>
This commit is contained in:
Mumble 2024-11-16 15:32:05 -08:00 committed by GitHub
parent c22b48f903
commit c2afac8b02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 4 deletions

View File

@ -230,6 +230,13 @@ export class GameMode implements GameModeConfig {
return waveIndex % 10 === 0;
}
/**
* @returns `true` if the current battle is against classic mode's final boss
*/
isBattleClassicFinalBoss(waveIndex: number): boolean {
return (this.modeId === GameModes.CLASSIC || this.modeId === GameModes.CHALLENGE) && this.isWaveFinal(waveIndex);
}
/**
* Every 50 waves of an Endless mode is a boss
* At this time it is paradox pokemon

View File

@ -141,10 +141,6 @@ export class EncounterPhase extends BattlePhase {
} else if (!(battle.waveIndex % 1000)) {
enemyPokemon.formIndex = 1;
enemyPokemon.updateScale();
const bossMBH = this.scene.findModifier(m => m instanceof TurnHeldItemTransferModifier && m.pokemonId === enemyPokemon.id, false) as TurnHeldItemTransferModifier;
this.scene.removeModifier(bossMBH!);
bossMBH?.setTransferrableFalse();
this.scene.addEnemyModifier(bossMBH!);
}
}
@ -443,6 +439,15 @@ export class EncounterPhase extends BattlePhase {
if (enemyPokemon.isShiny()) {
this.scene.unshiftPhase(new ShinySparklePhase(this.scene, BattlerIndex.ENEMY + e));
}
/** This sets Eternatus' held item to be untransferrable, preventing it from being stolen */
if (enemyPokemon.species.speciesId === Species.ETERNATUS && (this.scene.gameMode.isBattleClassicFinalBoss(this.scene.currentBattle.waveIndex) || this.scene.gameMode.isEndlessMajorBoss(this.scene.currentBattle.waveIndex))) {
const enemyMBH = this.scene.findModifier(m => m instanceof TurnHeldItemTransferModifier, false) as TurnHeldItemTransferModifier;
if (enemyMBH) {
this.scene.removeModifier(enemyMBH, true);
enemyMBH.setTransferrableFalse();
this.scene.addEnemyModifier(enemyMBH);
}
}
});
if (![ BattleType.TRAINER, BattleType.MYSTERY_ENCOUNTER ].includes(this.scene.currentBattle.battleType)) {