[Balance] [QoL] [Feature] Allow mons to track and relearn used TMs (#3656)
* Allow mons to track and relearn used TMs * Fix issue getting level moves * Apply suggested safety measures
This commit is contained in:
parent
60becf54f8
commit
b0360123e0
|
@ -119,6 +119,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
public maskEnabled: boolean;
|
||||
public maskSprite: Phaser.GameObjects.Sprite | null;
|
||||
|
||||
public usedTMs: Moves[];
|
||||
|
||||
private shinySparkle: Phaser.GameObjects.Sprite;
|
||||
|
||||
constructor(scene: BattleScene, x: number, y: number, species: PokemonSpecies, level: integer, abilityIndex?: integer, formIndex?: integer, gender?: Gender, shiny?: boolean, variant?: Variant, ivs?: integer[], nature?: Nature, dataSource?: Pokemon | PokemonData) {
|
||||
|
@ -195,6 +197,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
this.fusionVariant = dataSource.fusionVariant || 0;
|
||||
this.fusionGender = dataSource.fusionGender;
|
||||
this.fusionLuck = dataSource.fusionLuck;
|
||||
this.usedTMs = dataSource.usedTMs ?? [];
|
||||
} else {
|
||||
this.id = Utils.randSeedInt(4294967296);
|
||||
this.ivs = ivs || Utils.getIvsFromId(this.id);
|
||||
|
@ -935,7 +938,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
if (this.metBiome === -1 && !this.scene.gameMode.isFreshStartChallenge() && !this.scene.gameMode.isDaily) {
|
||||
levelMoves = this.getUnlockedEggMoves().concat(levelMoves);
|
||||
}
|
||||
return levelMoves.filter(lm => !this.moveset.some(m => m?.moveId === lm));
|
||||
if (Array.isArray(this.usedTMs) && this.usedTMs.length > 0) {
|
||||
levelMoves = this.usedTMs.filter(m => !levelMoves.includes(m)).concat(levelMoves);
|
||||
}
|
||||
levelMoves = levelMoves.filter(lm => !this.moveset.some(m => m?.moveId === lm));
|
||||
return levelMoves;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3357,6 +3364,7 @@ export default interface Pokemon {
|
|||
|
||||
export class PlayerPokemon extends Pokemon {
|
||||
public compatibleTms: Moves[];
|
||||
public usedTms: Moves[];
|
||||
|
||||
constructor(scene: BattleScene, species: PokemonSpecies, level: integer, abilityIndex?: integer, formIndex?: integer, gender?: Gender, shiny?: boolean, variant?: Variant, ivs?: integer[], nature?: Nature, dataSource?: Pokemon | PokemonData) {
|
||||
super(scene, 106, 148, species, level, abilityIndex, formIndex, gender, shiny, variant, ivs, nature, dataSource);
|
||||
|
@ -3380,6 +3388,7 @@ export class PlayerPokemon extends Pokemon {
|
|||
}
|
||||
}
|
||||
this.generateCompatibleTms();
|
||||
this.usedTms = [];
|
||||
}
|
||||
|
||||
initBattleInfo(): void {
|
||||
|
|
|
@ -1625,7 +1625,7 @@ export class TmModifier extends ConsumablePokemonModifier {
|
|||
apply(args: any[]): boolean {
|
||||
const pokemon = args[0] as PlayerPokemon;
|
||||
|
||||
pokemon.scene.unshiftPhase(new LearnMovePhase(pokemon.scene, pokemon.scene.getParty().indexOf(pokemon), (this.type as ModifierTypes.TmModifierType).moveId));
|
||||
pokemon.scene.unshiftPhase(new LearnMovePhase(pokemon.scene, pokemon.scene.getParty().indexOf(pokemon), (this.type as ModifierTypes.TmModifierType).moveId, true));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -12,11 +12,13 @@ import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-pha
|
|||
|
||||
export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
|
||||
private moveId: Moves;
|
||||
private fromTM: boolean;
|
||||
|
||||
constructor(scene: BattleScene, partyMemberIndex: integer, moveId: Moves) {
|
||||
constructor(scene: BattleScene, partyMemberIndex: integer, moveId: Moves, fromTM?: boolean) {
|
||||
super(scene, partyMemberIndex);
|
||||
|
||||
this.moveId = moveId;
|
||||
this.fromTM = fromTM ?? false;
|
||||
}
|
||||
|
||||
start() {
|
||||
|
@ -41,6 +43,9 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
|
|||
|
||||
if (emptyMoveIndex > -1) {
|
||||
pokemon.setMove(emptyMoveIndex, this.moveId);
|
||||
if (this.fromTM) {
|
||||
pokemon.usedTMs.push(this.moveId);
|
||||
}
|
||||
initMoveAnim(this.scene, this.moveId).then(() => {
|
||||
loadMoveAnimAssets(this.scene, [this.moveId], true)
|
||||
.then(() => {
|
||||
|
@ -85,6 +90,9 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
|
|||
this.scene.ui.showText(i18next.t("battle:countdownPoof"), null, () => {
|
||||
this.scene.ui.showText(i18next.t("battle:learnMoveForgetSuccess", { pokemonName: getPokemonNameWithAffix(pokemon), moveName: pokemon.moveset[moveIndex]!.getName() }), null, () => { // TODO: is the bang correct?
|
||||
this.scene.ui.showText(i18next.t("battle:learnMoveAnd"), null, () => {
|
||||
if (this.fromTM) {
|
||||
pokemon.usedTMs.push(this.moveId);
|
||||
}
|
||||
pokemon.setMove(moveIndex, Moves.NONE);
|
||||
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, this.moveId));
|
||||
this.end();
|
||||
|
|
|
@ -42,6 +42,7 @@ export default class PokemonData {
|
|||
public luck: integer;
|
||||
public pauseEvolutions: boolean;
|
||||
public pokerus: boolean;
|
||||
public usedTMs: Moves[];
|
||||
|
||||
public fusionSpecies: Species;
|
||||
public fusionFormIndex: integer;
|
||||
|
@ -98,6 +99,7 @@ export default class PokemonData {
|
|||
this.fusionVariant = source.fusionVariant;
|
||||
this.fusionGender = source.fusionGender;
|
||||
this.fusionLuck = source.fusionLuck !== undefined ? source.fusionLuck : (source.fusionShiny ? source.fusionVariant + 1 : 0);
|
||||
this.usedTMs = source.usedTMs ?? [];
|
||||
|
||||
if (!forHistory) {
|
||||
this.boss = (source instanceof EnemyPokemon && !!source.bossSegments) || (!this.player && !!source.boss);
|
||||
|
|
Loading…
Reference in New Issue