Use nature override property instead of overwriting base nature

pull/28/head
Flashfyre 2024-04-02 23:00:56 -04:00
parent b248209743
commit 84f6456972
10 changed files with 26 additions and 17 deletions

View File

@ -1503,7 +1503,7 @@ export class SyncEncounterNatureAbAttr extends AbAttr {
}
apply(pokemon: Pokemon, cancelled: Utils.BooleanHolder, args: any[]): boolean {
(args[0] as Pokemon).setNature(pokemon.nature);
(args[0] as Pokemon).setNature(pokemon.getNature());
return true;
}

View File

@ -64,7 +64,7 @@ function getDailyRunStarter(scene: BattleScene, starterSpeciesForm: PokemonSpeci
const starter: Starter = {
species: starterSpecies,
dexAttr: pokemon.getDexAttr(),
nature: pokemon.nature,
nature: pokemon.getNature(),
pokerus: pokemon.pokerus
};
pokemon.destroy();

View File

@ -1038,7 +1038,7 @@ export const pokemonEvolutions: PokemonEvolutions = {
],
[Species.TOXEL]: [
new SpeciesFormEvolution(Species.TOXTRICITY, '', 'lowkey', 30, null,
new SpeciesEvolutionCondition(p => [ Nature.LONELY, Nature.BOLD, Nature.RELAXED, Nature.TIMID, Nature.SERIOUS, Nature.MODEST, Nature.MILD, Nature.QUIET, Nature.BASHFUL, Nature.CALM, Nature.GENTLE, Nature.CAREFUL ].indexOf(p.nature) > -1)),
new SpeciesEvolutionCondition(p => [ Nature.LONELY, Nature.BOLD, Nature.RELAXED, Nature.TIMID, Nature.SERIOUS, Nature.MODEST, Nature.MILD, Nature.QUIET, Nature.BASHFUL, Nature.CALM, Nature.GENTLE, Nature.CAREFUL ].indexOf(p.getNature()) > -1)),
new SpeciesFormEvolution(Species.TOXTRICITY, '', 'amped', 30, null, null)
],
[Species.SIZZLIPEDE]: [

View File

@ -293,7 +293,7 @@ export class SpeciesDefaultFormMatchTrigger extends SpeciesFormChangeTrigger {
}
canChange(pokemon: Pokemon): boolean {
return this.formKey === pokemon.species.forms[pokemon.scene.getSpeciesFormIndex(pokemon.species, pokemon.gender, pokemon.nature, true)].formKey;
return this.formKey === pokemon.species.forms[pokemon.scene.getSpeciesFormIndex(pokemon.species, pokemon.gender, pokemon.getNature(), true)].formKey;
}
}

View File

@ -64,6 +64,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
public stats: integer[];
public ivs: integer[];
public nature: Nature;
public natureOverride: Nature | -1;
public moveset: PokemonMove[];
public status: Status;
public friendship: integer;
@ -125,6 +126,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.stats = dataSource.stats;
this.ivs = dataSource.ivs;
this.nature = dataSource.nature || 0 as Nature;
this.natureOverride = dataSource.natureOverride !== undefined ? dataSource.natureOverride : -1;
this.moveset = dataSource.moveset;
this.status = dataSource.status;
this.friendship = dataSource.friendship !== undefined ? dataSource.friendship : this.species.baseFriendship;
@ -153,17 +155,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}
}
if (this.formIndex === undefined)
this.formIndex = this.scene.getSpeciesFormIndex(species, this.gender, this.nature, this.isPlayer());
if (this.shiny === undefined)
this.trySetShiny();
if (nature !== undefined)
this.setNature(nature);
else
this.generateNature();
if (this.formIndex === undefined)
this.formIndex = this.scene.getSpeciesFormIndex(species, this.gender, this.getNature(), this.isPlayer());
if (this.shiny === undefined)
this.trySetShiny();
this.friendship = species.baseFriendship;
this.metLevel = level;
this.metBiome = scene.currentBattle ? scene.arena.biomeType : -1;
@ -560,6 +562,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}
}
getNature(): Nature {
return this.natureOverride !== -1 ? this.natureOverride : this.nature;
}
setNature(nature: Nature): void {
this.nature = nature;
this.calculateStats();
@ -887,7 +893,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.fusionGender = Gender.FEMALE;
}
this.fusionFormIndex = this.scene.getSpeciesFormIndex(this.fusionSpecies, this.fusionGender, this.nature, true);
this.fusionFormIndex = this.scene.getSpeciesFormIndex(this.fusionSpecies, this.fusionGender, this.getNature(), true);
this.generateName();
}
@ -2119,6 +2125,7 @@ export class PlayerPokemon extends Pokemon {
const newEvolution = pokemonEvolutions[this.species.speciesId][1];
if (newEvolution.condition.predicate(this)) {
const newPokemon = this.scene.addPlayerPokemon(this.species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.ivs, this.nature);
newPokemon.natureOverride = this.natureOverride;
this.scene.getParty().push(newPokemon);
newPokemon.evolve(newEvolution);
const modifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier

View File

@ -271,7 +271,7 @@ export class PokemonNatureChangeModifierType extends PokemonModifierType {
constructor(nature: Nature) {
super(`${getNatureName(nature)} Mint`, `Changes a Pokémon\'s nature to ${getNatureName(nature, true, true, true)}`, ((_type, args) => new Modifiers.PokemonNatureChangeModifier(this, (args[0] as PlayerPokemon).id, this.nature)),
((pokemon: PlayerPokemon) => {
if (pokemon.nature === this.nature)
if (pokemon.getNature() === this.nature)
return PartyUiHandler.NoEffectMessage;
return null;
}), `mint_${Utils.getEnumKeys(Stat).find(s => getNatureStatMultiplier(nature, Stat[s]) > 1)?.toLowerCase() || 'neutral' }`, 'mint');

View File

@ -1105,7 +1105,7 @@ export class PokemonNatureChangeModifier extends ConsumablePokemonModifier {
apply(args: any[]): boolean {
const pokemon = args[0] as Pokemon;
pokemon.nature = this.nature;
pokemon.natureOverride = this.nature;
return true;
}

View File

@ -27,6 +27,7 @@ export default class PokemonData {
public stats: integer[];
public ivs: integer[];
public nature: Nature;
public natureOverride: Nature | -1;
public moveset: PokemonMove[];
public status: Status;
public friendship: integer;
@ -64,6 +65,7 @@ export default class PokemonData {
this.stats = source.stats;
this.ivs = source.ivs;
this.nature = source.nature !== undefined ? source.nature : 0 as Nature;
this.natureOverride = source.natureOverride !== undefined ? source.natureOverride : -1;
this.friendship = source.friendship !== undefined ? source.friendship : getPokemonSpecies(this.species).baseFriendship;
this.metLevel = source.metLevel || 5;
this.metBiome = source.metBiome !== undefined ? source.metBiome : -1;

View File

@ -121,7 +121,7 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container {
this.pokemonGenderText.setVisible(false);
this.pokemonAbilityText.setText(pokemon.getAbility(true).name);
this.pokemonNatureText.setText(getNatureName(pokemon.nature, true));
this.pokemonNatureText.setText(getNatureName(pokemon.getNature(), true));
const originalIvs: integer[] = this.scene.gameData.dexData[pokemon.species.speciesId].caughtAttr
? this.scene.gameData.dexData[pokemon.species.speciesId].ivs

View File

@ -574,7 +574,7 @@ export default class SummaryUiHandler extends UiHandler {
});
}
let memoString = `${getBBCodeFrag(Utils.toReadableString(Nature[this.pokemon.nature]), TextStyle.SUMMARY_RED)}${getBBCodeFrag(' nature,', TextStyle.WINDOW_ALT)}\n${getBBCodeFrag(`${this.pokemon.metBiome === -1 ? 'apparently ' : ''}met at Lv`, TextStyle.WINDOW_ALT)}${getBBCodeFrag(this.pokemon.metLevel.toString(), TextStyle.SUMMARY_RED)}${getBBCodeFrag(',', TextStyle.WINDOW_ALT)}\n${getBBCodeFrag(getBiomeName(this.pokemon.metBiome), TextStyle.SUMMARY_RED)}${getBBCodeFrag('.', TextStyle.WINDOW_ALT)}`;
let memoString = `${getBBCodeFrag(Utils.toReadableString(Nature[this.pokemon.getNature()]), TextStyle.SUMMARY_RED)}${getBBCodeFrag(' nature,', TextStyle.WINDOW_ALT)}\n${getBBCodeFrag(`${this.pokemon.metBiome === -1 ? 'apparently ' : ''}met at Lv`, TextStyle.WINDOW_ALT)}${getBBCodeFrag(this.pokemon.metLevel.toString(), TextStyle.SUMMARY_RED)}${getBBCodeFrag(',', TextStyle.WINDOW_ALT)}\n${getBBCodeFrag(getBiomeName(this.pokemon.metBiome), TextStyle.SUMMARY_RED)}${getBBCodeFrag('.', TextStyle.WINDOW_ALT)}`;
const memoText = addBBCodeTextObject(this.scene, 7, 113, memoString, TextStyle.WINDOW_ALT);
memoText.setOrigin(0, 0);
@ -593,7 +593,7 @@ export default class SummaryUiHandler extends UiHandler {
const rowIndex = s % 3;
const colIndex = Math.floor(s / 3);
const natureStatMultiplier = getNatureStatMultiplier(this.pokemon.nature, s);
const natureStatMultiplier = getNatureStatMultiplier(this.pokemon.getNature(), s);
const statLabel = addTextObject(this.scene, 27 + 115 * colIndex, 56 + 16 * rowIndex, statName, natureStatMultiplier === 1 ? TextStyle.SUMMARY : natureStatMultiplier > 1 ? TextStyle.SUMMARY_PINK : TextStyle.SUMMARY_BLUE);
statLabel.setOrigin(0.5, 0);