From 032e26728b6582cc1311bf523c511ac0da1fde4c Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Sun, 23 Apr 2023 01:03:09 -0400 Subject: [PATCH] Fix some bugs --- src/arena.ts | 2 +- src/battle-phases.ts | 9 +++++++-- src/battle-scene.ts | 4 ++-- src/modifier/modifier-type.ts | 2 +- src/pokemon.ts | 14 ++++++++------ 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/arena.ts b/src/arena.ts index b16986601e1..b62e3ed0d5d 100644 --- a/src/arena.ts +++ b/src/arena.ts @@ -29,7 +29,7 @@ export class Arena { } randomSpecies(waveIndex: integer, level: integer, attempt?: integer): PokemonSpecies { - const isBoss = (waveIndex >= 100 || waveIndex % 10 === 0) && !!this.pokemonPool[BiomePoolTier.BOSS].length; + const isBoss = (level >= 100 || waveIndex % 10 === 0) && !!this.pokemonPool[BiomePoolTier.BOSS].length; const tierValue = Utils.randInt(!isBoss ? 512 : 64); let tier = !isBoss ? tierValue >= 156 ? BiomePoolTier.COMMON : tierValue >= 32 ? BiomePoolTier.UNCOMMON : tierValue >= 6 ? BiomePoolTier.RARE : tierValue >= 1 ? BiomePoolTier.SUPER_RARE : BiomePoolTier.ULTRA_RARE diff --git a/src/battle-phases.ts b/src/battle-phases.ts index 2fe2113b674..a05e89f1367 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -42,7 +42,7 @@ export class SelectStarterPhase extends BattlePhase { const starterGender = starter.species.malePercent !== null ? !starter.female ? Gender.MALE : Gender.FEMALE : Gender.GENDERLESS; - const starterPokemon = new PlayerPokemon(this.scene, starter.species, startingLevel, starter.formIndex, starterGender, starter.shiny); + const starterPokemon = new PlayerPokemon(this.scene, starter.species, startingLevel, 0, starter.formIndex, starterGender, starter.shiny); starterPokemon.setVisible(false); party.push(starterPokemon); loadPokemonAssets.push(starterPokemon.loadAssets()); @@ -1642,7 +1642,7 @@ export class PokemonHealPhase extends CommonAnimPhase { } start() { - if (!this.skipAnim && this.getPokemon().getHpRatio() < 1) + if (!this.skipAnim && this.getPokemon().hp && this.getPokemon().getHpRatio() < 1) super.start(); else this.end(); @@ -1650,6 +1650,11 @@ export class PokemonHealPhase extends CommonAnimPhase { end() { const pokemon = this.getPokemon(); + + if (!this.getPokemon().hp) { + super.end(); + return; + } const fullHp = pokemon.getHpRatio() >= 1; diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 78c12e27d7f..c7f25a365b1 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -334,7 +334,7 @@ export default class BattleScene extends Phaser.Scene { if (this.quickStart) { for (let s = 0; s < 3; s++) { const playerSpecies = getPokemonSpecies((getPokemonSpecies(s === 0 ? Species.TORCHIC : s === 1 ? Species.TREECKO : Species.MUDKIP)).getSpeciesForLevel(startingLevel, true)); - const playerPokemon = new PlayerPokemon(this, playerSpecies, startingLevel, 0); + const playerPokemon = new PlayerPokemon(this, playerSpecies, startingLevel, 0, 0); playerPokemon.setVisible(false); loadPokemonAssets.push(playerPokemon.loadAssets()); @@ -744,7 +744,7 @@ export default class BattleScene extends Phaser.Scene { return new Promise(resolve => { const waveIndex = this.currentBattle.waveIndex; const chances = Math.ceil(waveIndex / 10); - const isBoss = waveIndex >= 100 || !(waveIndex % 10); + const isBoss = this.getEnemyPokemon().level >= 100 || !(waveIndex % 10); let count = 0; for (let c = 0; c < chances; c++) { if (!Utils.randInt(!isBoss ? 12 : 4)) diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 130f933b4bd..ac37053d170 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -630,7 +630,7 @@ const enemyModifierPool = { new WeightedModifierType(modifierTypes.LUCKY_EGG, 2), ].map(m => { m.setTier(ModifierTier.ULTRA); return m; }), [ModifierTier.MASTER]: [ - modifierTypes.SHELL_BELL + new WeightedModifierType(modifierTypes.SHELL_BELL, 1) ].map(m => { m.setTier(ModifierTier.MASTER); return m; }) }; diff --git a/src/pokemon.ts b/src/pokemon.ts index 2f42bff377b..c2566ee0f89 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -28,6 +28,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { public name: string; public species: PokemonSpecies; public formIndex: integer; + public abilityIndex: integer; public shiny: boolean; public pokeball: PokeballType; protected battleInfo: BattleInfo; @@ -51,7 +52,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { private shinySparkle: Phaser.GameObjects.Sprite; - constructor(scene: BattleScene, x: number, y: number, species: PokemonSpecies, level: integer, formIndex?: integer, gender?: Gender, shiny?: boolean, dataSource?: Pokemon) { + constructor(scene: BattleScene, x: number, y: number, species: PokemonSpecies, level: integer, abilityIndex?: integer, formIndex?: integer, gender?: Gender, shiny?: boolean, dataSource?: Pokemon) { super(scene, x, y); this.name = Utils.toPokemonUpperCase(species.name); this.species = species; @@ -60,6 +61,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { : new EnemyBattleInfo(scene); this.pokeball = dataSource?.pokeball || PokeballType.POKEBALL; this.level = level; + this.abilityIndex = abilityIndex || (species.ability2 ? Utils.randInt(2) : 0); this.formIndex = formIndex || 0; if (gender !== undefined) this.gender = gender; @@ -110,7 +112,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (this.shiny === undefined) { let shinyThreshold = new Utils.IntegerHolder(32); - this.scene.applyModifiers(ShinyRateBoosterModifier, this.isPlayer(), shinyThreshold); + this.scene.applyModifiers(ShinyRateBoosterModifier, true, shinyThreshold); console.log(shinyThreshold.value); this.shiny = (E ^ F) < shinyThreshold.value; @@ -829,8 +831,8 @@ export default interface Pokemon { export class PlayerPokemon extends Pokemon { public compatibleTms: Moves[]; - constructor(scene: BattleScene, species: PokemonSpecies, level: integer, formIndex: integer, gender?: Gender, shiny?: boolean, dataSource?: Pokemon) { - super(scene, 106, 148, species, level, formIndex, gender, shiny, dataSource); + constructor(scene: BattleScene, species: PokemonSpecies, level: integer, abilityIndex: integer, formIndex: integer, gender?: Gender, shiny?: boolean, dataSource?: Pokemon) { + super(scene, 106, 148, species, level, abilityIndex, formIndex, gender, shiny, dataSource); this.generateCompatibleTms(); } @@ -880,7 +882,7 @@ export class PlayerPokemon extends Pokemon { if (this.species.speciesId === Species.NINCADA && evolution.speciesId === Species.NINJASK) { const newEvolution = pokemonEvolutions[this.species.speciesId][1]; if (newEvolution.condition.predicate(this)) { - const newPokemon = new PlayerPokemon(this.scene, this.species, this.level, this.formIndex, this.gender, this.shiny); + const newPokemon = new PlayerPokemon(this.scene, this.species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny); this.scene.getParty().push(newPokemon); newPokemon.evolve(newEvolution); } @@ -1004,7 +1006,7 @@ export class EnemyPokemon extends Pokemon { let ret: PlayerPokemon = null; if (party.length < 6) { - const newPokemon = new PlayerPokemon(this.scene, this.species, this.level, this.formIndex, this.gender, this.shiny, this); + const newPokemon = new PlayerPokemon(this.scene, this.species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this); party.push(newPokemon); ret = newPokemon; }