Don't boost enemy trainer shiny odds with shiny charm

pull/2/head
Flashfyre 2023-10-28 10:51:34 -04:00
parent 1a488d421c
commit ae6d4d0ea0
6 changed files with 44 additions and 25 deletions

View File

@ -246,7 +246,7 @@ export class EncounterPhase extends BattlePhase {
battle.enemyParty[e] = battle.trainer.genPartyMember(e);
else {
const enemySpecies = this.scene.randomSpecies(battle.waveIndex, level, null, true);
battle.enemyParty[e] = new EnemyPokemon(this.scene, enemySpecies, level);
battle.enemyParty[e] = new EnemyPokemon(this.scene, enemySpecies, level, false);
}
}
const enemyPokemon = this.scene.getEnemyParty()[e];

View File

@ -521,7 +521,7 @@ function getGymLeaderPartyTemplate(scene: BattleScene) {
function getRandomPartyMemberFunc(speciesPool: Species[], postProcess?: (enemyPokemon: EnemyPokemon) => void): PartyMemberFunc {
return (scene: BattleScene, level: integer) => {
const species = getPokemonSpecies(Phaser.Math.RND.pick(speciesPool)).getSpeciesForLevel(level, true);
const ret = new EnemyPokemon(scene, getPokemonSpecies(species), level);
const ret = new EnemyPokemon(scene, getPokemonSpecies(species), level, true);
if (postProcess)
postProcess(ret);
return ret;
@ -532,7 +532,7 @@ function getSpeciesFilterRandomPartyMemberFunc(speciesFilter: PokemonSpeciesFilt
const originalSpeciesFilter = speciesFilter;
speciesFilter = (species: PokemonSpecies) => allowLegendaries || (!species.legendary && !species.pseudoLegendary && !species.mythical) && originalSpeciesFilter(species);
return (scene: BattleScene, level: integer) => {
const ret = new EnemyPokemon(scene, scene.randomSpecies(scene.currentBattle.waveIndex, level, speciesFilter), level);
const ret = new EnemyPokemon(scene, scene.randomSpecies(scene.currentBattle.waveIndex, level, speciesFilter), level, true);
if (postProcess)
postProcess(ret);
return ret;

View File

@ -125,23 +125,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}
}
const rand1 = Utils.binToDec(Utils.decToBin(this.id).substring(0, 16));
const rand2 = Utils.binToDec(Utils.decToBin(this.id).substring(16, 32));
const E = this.scene.gameData.trainerId ^ this.scene.gameData.secretId;
const F = rand1 ^ rand2;
if (this.shiny === undefined) {
let shinyThreshold = new Utils.IntegerHolder(32);
this.scene.applyModifiers(ShinyRateBoosterModifier, true, shinyThreshold);
console.log(shinyThreshold.value);
this.shiny = (E ^ F) < shinyThreshold.value;
if ((E ^ F) < 32)
console.log('REAL SHINY!!');
if (this.shiny)
console.log((E ^ F), shinyThreshold.value);
}
if (this.shiny === undefined)
this.trySetShiny();
this.winCount = 0;
this.pokerus = false;
@ -207,6 +192,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
abstract isPlayer(): boolean;
abstract hasTrainer(): boolean;
abstract getFieldIndex(): integer;
abstract getBattlerIndex(): BattlerIndex;
@ -507,6 +494,26 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.summonData.moveset[moveIndex] = move;
}
trySetShiny(): boolean {
const rand1 = Utils.binToDec(Utils.decToBin(this.id).substring(0, 16));
const rand2 = Utils.binToDec(Utils.decToBin(this.id).substring(16, 32));
const E = this.scene.gameData.trainerId ^ this.scene.gameData.secretId;
const F = rand1 ^ rand2;
let shinyThreshold = new Utils.IntegerHolder(32);
if (!this.hasTrainer()) {
this.scene.applyModifiers(ShinyRateBoosterModifier, true, shinyThreshold);
console.log(shinyThreshold.value);
}
this.shiny = (E ^ F) < shinyThreshold.value;
if ((E ^ F) < 32)
console.log('REAL SHINY!!');
return this.shiny;
}
generateAndPopulateMoveset(): void {
this.moveset = [];
const movePool = [];
@ -1097,6 +1104,10 @@ export class PlayerPokemon extends Pokemon {
return true;
}
hasTrainer(): boolean {
return true;
}
getFieldIndex(): integer {
return this.scene.getPlayerField().indexOf(this);
}
@ -1165,12 +1176,15 @@ export class PlayerPokemon extends Pokemon {
}
export class EnemyPokemon extends Pokemon {
public trainer: boolean;
public aiType: AiType;
constructor(scene: BattleScene, species: PokemonSpecies, level: integer, dataSource?: PokemonData) {
constructor(scene: BattleScene, species: PokemonSpecies, level: integer, trainer: boolean, dataSource?: PokemonData) {
super(scene, 236, 84, species, level, dataSource?.abilityIndex, dataSource ? dataSource.formIndex : scene.arena.getFormIndex(species),
dataSource?.gender, dataSource?.shiny, dataSource);
this.trainer = trainer;
if (!dataSource) {
let prevolution: Species;
let speciesId = species.speciesId;
@ -1323,6 +1337,10 @@ export class EnemyPokemon extends Pokemon {
return false;
}
hasTrainer(): boolean {
return this.trainer;
}
getFieldIndex(): integer {
return this.scene.getEnemyField().indexOf(this);
}

View File

@ -253,7 +253,7 @@ export class GameData {
scene.newArena(sessionData.arena.biome, true);
sessionData.enemyParty.forEach((enemyData, e) => {
const enemyPokemon = enemyData.toPokemon(scene) as EnemyPokemon;
const enemyPokemon = enemyData.toPokemon(scene, battleType) as EnemyPokemon;
battle.enemyParty[e] = enemyPokemon;
if (battleType === BattleType.WILD)
battle.seenEnemyPartyMemberIds.add(enemyPokemon.id);

View File

@ -1,3 +1,4 @@
import { BattleType } from "../battle";
import BattleScene from "../battle-scene";
import { Gender } from "../data/gender";
import { PokeballType } from "../data/pokeball";
@ -69,10 +70,10 @@ export default class PokemonData {
}
}
toPokemon(scene: BattleScene): Pokemon {
toPokemon(scene: BattleScene, battleType?: BattleType): Pokemon {
const species = getPokemonSpecies(this.species);
if (this.player)
return new PlayerPokemon(scene, species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this);
return new EnemyPokemon(scene, species, this.level, this);
return new EnemyPokemon(scene, species, this.level, battleType === BattleType.TRAINER, this);
}
}

View File

@ -131,7 +131,7 @@ export default class Trainer extends Phaser.GameObjects.Container {
? getPokemonSpecies(battle.enemyParty[offset].species.getSpeciesForLevel(level))
: this.genNewPartyMemberSpecies(level);
ret = new EnemyPokemon(this.scene, species, level);
ret = new EnemyPokemon(this.scene, species, level, true);
}, this.config.hasStaticParty ? this.config.getDerivedType() + ((index + 1) << 8) : this.scene.currentBattle.waveIndex + (this.config.getDerivedType() << 10) + ((index + 1) << 8));
return ret;