[Refactor] Move base shiny/HA chance to constants outside functions (#4407)
This commit is contained in:
parent
82111bc62d
commit
d620b5c7fa
|
@ -63,6 +63,12 @@ import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
|
|||
import { MysteryEncounterPokemonData } from "#app/data/mystery-encounters/mystery-encounter-pokemon-data";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
|
||||
/** `64/65536 -> 1/1024` */
|
||||
const BASE_SHINY_CHANCE = 64;
|
||||
|
||||
/** `1/256` */
|
||||
const BASE_HIDDEN_ABILITY_CHANCE = 256;
|
||||
|
||||
export enum FieldPosition {
|
||||
CENTER,
|
||||
LEFT,
|
||||
|
@ -139,7 +145,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
throw `Cannot create a player Pokemon for species '${species.getName(formIndex)}'`;
|
||||
}
|
||||
|
||||
const hiddenAbilityChance = new Utils.IntegerHolder(256);
|
||||
const hiddenAbilityChance = new Utils.IntegerHolder(BASE_HIDDEN_ABILITY_CHANCE);
|
||||
if (!this.hasTrainer()) {
|
||||
this.scene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance);
|
||||
}
|
||||
|
@ -1822,7 +1828,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
* The exact mechanic is that it calculates E as the XOR of the player's trainer ID and secret ID.
|
||||
* F is calculated as the XOR of the first 16 bits of the Pokemon's ID with the last 16 bits.
|
||||
* The XOR of E and F are then compared to the {@linkcode shinyThreshold} (or {@linkcode thresholdOverride} if set) to see whether or not to generate a shiny.
|
||||
* The base shiny odds are {@linkcode baseShinyChance} / 65536
|
||||
* The base shiny odds are {@linkcode BASE_SHINY_CHANCE} / 65536
|
||||
* @param thresholdOverride number that is divided by 2^16 (65536) to get the shiny chance, overrides {@linkcode shinyThreshold} if set (bypassing shiny rate modifiers such as Shiny Charm)
|
||||
* @returns true if the Pokemon has been set as a shiny, false otherwise
|
||||
*/
|
||||
|
@ -1838,9 +1844,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
const E = this.scene.gameData.trainerId ^ this.scene.gameData.secretId;
|
||||
const F = rand1 ^ rand2;
|
||||
|
||||
/** `64/65536 -> 1/1024` */
|
||||
const baseShinyChance = 64;
|
||||
const shinyThreshold = new Utils.IntegerHolder(baseShinyChance);
|
||||
const shinyThreshold = new Utils.IntegerHolder(BASE_SHINY_CHANCE);
|
||||
if (thresholdOverride === undefined) {
|
||||
if (this.scene.eventManager.isEventActive()) {
|
||||
shinyThreshold.value *= this.scene.eventManager.getShinyMultiplier();
|
||||
|
@ -1865,15 +1869,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
* Function that tries to set a Pokemon shiny based on seed.
|
||||
* For manual use only, usually to roll a Pokemon's shiny chance a second time.
|
||||
*
|
||||
* The base shiny odds are {@linkcode baseShinyChance} / 65536
|
||||
* The base shiny odds are {@linkcode BASE_SHINY_CHANCE} / 65536
|
||||
* @param thresholdOverride number that is divided by 2^16 (65536) to get the shiny chance, overrides {@linkcode shinyThreshold} if set (bypassing shiny rate modifiers such as Shiny Charm)
|
||||
* @param applyModifiersToOverride If {@linkcode thresholdOverride} is set and this is true, will apply Shiny Charm and event modifiers to {@linkcode thresholdOverride}
|
||||
* @returns true if the Pokemon has been set as a shiny, false otherwise
|
||||
*/
|
||||
trySetShinySeed(thresholdOverride?: integer, applyModifiersToOverride?: boolean): boolean {
|
||||
/** `64/65536 -> 1/1024` */
|
||||
const baseShinyChance = 64;
|
||||
const shinyThreshold = new Utils.IntegerHolder(baseShinyChance);
|
||||
const shinyThreshold = new Utils.IntegerHolder(BASE_SHINY_CHANCE);
|
||||
if (thresholdOverride === undefined || applyModifiersToOverride) {
|
||||
if (thresholdOverride !== undefined && applyModifiersToOverride) {
|
||||
shinyThreshold.value = thresholdOverride;
|
||||
|
@ -1931,7 +1933,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
}
|
||||
|
||||
generateFusionSpecies(forStarter?: boolean): void {
|
||||
const hiddenAbilityChance = new Utils.IntegerHolder(256);
|
||||
const hiddenAbilityChance = new Utils.IntegerHolder(BASE_HIDDEN_ABILITY_CHANCE);
|
||||
if (!this.hasTrainer()) {
|
||||
this.scene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue