Fix bug with fainting on force switch out

Fix bug with fainting on force switch out; move overrides in Pokemon to BattleScene
pull/24/head
Flashfyre 2024-04-01 21:02:48 -04:00
parent 72dc263552
commit 96288d29ce
4 changed files with 15 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 679 B

After

Width:  |  Height:  |  Size: 703 B

View File

@ -19,7 +19,7 @@ import { } from "./data/move";
import { initMoves } from './data/move';
import { ModifierPoolType, getDefaultModifierTypeForTier, getEnemyModifierTypesForWave } from './modifier/modifier-type';
import AbilityBar from './ui/ability-bar';
import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, IncrementMovePriorityAbAttr, applyAbAttrs, initAbilities } from './data/ability';
import { Abilities, BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, IncrementMovePriorityAbAttr, applyAbAttrs, initAbilities } from './data/ability';
import Battle, { BattleType, FixedBattleConfig, fixedBattles } from './battle';
import { GameMode, GameModes, gameModes } from './game-mode';
import FieldSpritePipeline from './pipelines/field-sprite';
@ -68,7 +68,13 @@ export const STARTING_LEVEL_OVERRIDE = 0;
export const STARTING_WAVE_OVERRIDE = 0;
export const STARTING_BIOME_OVERRIDE = Biome.TOWN;
export const STARTING_MONEY_OVERRIDE = 0;
export const ENEMY_SPECIES_OVERRIDE = 0;
export const ABILITY_OVERRIDE = Abilities.NONE;
export const MOVE_OVERRIDE = Moves.NONE;
export const OPP_SPECIES_OVERRIDE = 0;
export const OPP_ABILITY_OVERRIDE = Abilities.NONE;
export const OPP_MOVE_OVERRIDE = Moves.NONE;
const DEBUG_RNG = false;
export const startingWave = STARTING_WAVE_OVERRIDE || 1;
@ -552,8 +558,8 @@ export default class BattleScene extends SceneBase {
}
addEnemyPokemon(species: PokemonSpecies, level: integer, trainerSlot: TrainerSlot, boss: boolean = false, dataSource?: PokemonData, postProcess?: (enemyPokemon: EnemyPokemon) => void): EnemyPokemon {
if (ENEMY_SPECIES_OVERRIDE)
species = getPokemonSpecies(ENEMY_SPECIES_OVERRIDE);
if (OPP_SPECIES_OVERRIDE)
species = getPokemonSpecies(OPP_SPECIES_OVERRIDE);
const pokemon = new EnemyPokemon(this, species, level, trainerSlot, boss, dataSource);
if (boss) {
const secondaryIvs = Utils.getIvsFromId(Utils.randSeedInt(4294967295));

View File

@ -2189,7 +2189,10 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
return resolve(false);
const switchOutTarget = this.user ? user : target;
if (switchOutTarget instanceof PlayerPokemon) {
if (switchOutTarget.hp)
(switchOutTarget as PlayerPokemon).switchOut(this.batonPass, true).then(() => resolve(true));
else
resolve(false);
return;
} else if (user.scene.currentBattle.battleType) {
switchOutTarget.resetTurnData();

View File

@ -1,5 +1,5 @@
import Phaser from 'phaser';
import BattleScene, { AnySound } from '../battle-scene';
import BattleScene, { ABILITY_OVERRIDE, AnySound, MOVE_OVERRIDE, OPP_ABILITY_OVERRIDE, OPP_MOVE_OVERRIDE } from '../battle-scene';
import BattleInfo, { PlayerBattleInfo, EnemyBattleInfo } from '../ui/battle-info';
import { Moves } from "../data/enums/moves";
import Move, { HighCritAttr, HitsTagAttr, applyMoveAttrs, FixedDamageAttr, VariableAtkAttr, VariablePowerAttr, allMoves, MoveCategory, TypelessAttr, CritOnlyAttr, getMoveTargets, OneHitKOAttr, MultiHitAttr, StatusMoveTypeImmunityAttr, MoveTarget, VariableDefAttr, AttackMove, ModifiedDamageAttr, VariableMoveTypeMultiplierAttr } from "../data/move";
@ -47,12 +47,6 @@ export enum FieldPosition {
RIGHT
}
const ABILITY_OVERRIDE = Abilities.NONE;
const MOVE_OVERRIDE = Moves.NONE;
const OPP_ABILITY_OVERRIDE = Abilities.NONE;
const OPP_MOVE_OVERRIDE = Moves.NONE;
export default abstract class Pokemon extends Phaser.GameObjects.Container {
public id: integer;
public name: string;