From 96288d29ce22a9e8d285b78038cadb3e4b5d42b4 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Mon, 1 Apr 2024 21:02:48 -0400 Subject: [PATCH] Fix bug with fainting on force switch out Fix bug with fainting on force switch out; move overrides in Pokemon to BattleScene --- public/images/arenas/plains_bg.png | Bin 679 -> 703 bytes src/battle-scene.ts | 14 ++++++++++---- src/data/move.ts | 5 ++++- src/field/pokemon.ts | 8 +------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/public/images/arenas/plains_bg.png b/public/images/arenas/plains_bg.png index 0ab30c7ee418f89ac781a904dd4f17f4c5aae7f8..9455b22331894311da6a851773d71215e5eb7677 100644 GIT binary patch literal 703 zcmeAS@N?(olHy`uVBq!ia0y~yU~~Yow{Wll$)``g3NkP-wRyTYhE&{odv~MP;Q)r# zhuiKrYL*FTW&NGe}@$;!ton6`jz3kU>nr;TBVg zFbhl`n_&pCu<%{y?`Z-xH83!#>|w2|t}WtfVC4|l%5ay3Q3uHx4Q*2{AHN7v>2QVV z&#o#y0sIzZ9RK|(bp5BA5BY|T`(I3Z|JCdW6HC(1;s^&FZUF&@h8^1v;|CKAeV4l*z)Pqj&i6=^dCPEVc^CRCaWGTE&w@pJ43AqAJ924BPMKPh-GF02GthU z7g7q~zyTQwHd(>puMG!pL<2)1_l4#QF#8}<2t`D(_G?ZrT=9whzJK)kIOjGaYnE&L z3qBP3uU{>&DT{%Xb^im8r&0=JnGAC)+!;`}!})kk{j*v+&f22lgWmINz=X-*>FVdQ I&MBb@0F}SD4gdfE literal 679 zcmeAS@N?(olHy`uVBq!ia0y~yU~~YoTR7N&5jgR z3=A9lx&I`xGB7Zid%8G=RK&f#yU~+5k)iG3@1y5D@0`$?pfp!_N4M}2-jv=3;Tsw1 zVoi#Q1;R@>V(vX}6sUgq^zpylr+@shoTt{Xp#7(`f;&T_4kODZ7J(B&4hr6AoHZXm zetjNjp>UFkWz!xW#uJ<1@wy%=QP`c0;vsF@^Yfp6veHpF z4e|sZH_Q_1w26hU4Fn}8Y@me$+a?rUA(ve ztZFA42RK-=f!+sdf^mVNgc1^YEo@+2y%+GAjiQA}4ltDTKeb<+|L^!8@$V15Uwr?$ zxVk&KVfu&8`+q;yKmE4sC6Dg 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)); diff --git a/src/data/move.ts b/src/data/move.ts index 517c29ebf7f..65ff679b56b 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -2189,7 +2189,10 @@ export class ForceSwitchOutAttr extends MoveEffectAttr { return resolve(false); const switchOutTarget = this.user ? user : target; if (switchOutTarget instanceof PlayerPokemon) { - (switchOutTarget as PlayerPokemon).switchOut(this.batonPass, true).then(() => resolve(true)); + 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(); diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index d5983a3b50a..280228bfd79 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -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;