add flee var to turndata, prevent battle skip with EE

This commit is contained in:
muscode13 2024-11-21 14:53:58 -06:00
parent 6442b8345f
commit 6b62ec49cc
5 changed files with 19 additions and 7 deletions

View File

@ -4959,7 +4959,7 @@ class ForceSwitchOutHelper {
} }
if (switchOutTarget.hp > 0) { if (switchOutTarget.hp > 0) {
switchOutTarget.leaveField(false); switchOutTarget.leaveField(false, true, true);
pokemon.scene.queueMessage(i18next.t("moveTriggers:fled", { pokemonName: getPokemonNameWithAffix(switchOutTarget) }), null, true, 500); pokemon.scene.queueMessage(i18next.t("moveTriggers:fled", { pokemonName: getPokemonNameWithAffix(switchOutTarget) }), null, true, 500);
if (switchOutTarget.scene.currentBattle.double) { if (switchOutTarget.scene.currentBattle.double) {

View File

@ -2954,7 +2954,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* @returns integer representing damage * @returns integer representing damage
*/ */
damage(damage: integer, ignoreSegments: boolean = false, preventEndure: boolean = false, ignoreFaintPhase: boolean = false): integer { damage(damage: integer, ignoreSegments: boolean = false, preventEndure: boolean = false, ignoreFaintPhase: boolean = false): integer {
if (this.isFainted()) { if (this.isFainted() || this.turnData?.flee) {
return 0; return 0;
} }
const surviveDamage = new Utils.BooleanHolder(false); const surviveDamage = new Utils.BooleanHolder(false);
@ -4075,7 +4075,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* @param hideInfo Indicates if this should also play the animation to hide the Pokemon's * @param hideInfo Indicates if this should also play the animation to hide the Pokemon's
* info container. * info container.
*/ */
leaveField(clearEffects: boolean = true, hideInfo: boolean = true) { leaveField(clearEffects: boolean = true, hideInfo: boolean = true, flee?: boolean) {
this.resetSprite(); this.resetSprite();
this.resetTurnData(); this.resetTurnData();
if (clearEffects) { if (clearEffects) {
@ -4085,6 +4085,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if (hideInfo) { if (hideInfo) {
this.hideInfo(); this.hideInfo();
} }
if (flee) {
this.turnData.flee = true;
console.log("FLEE SET TO", this.turnData.flee);
}
this.scene.field.remove(this); this.scene.field.remove(this);
this.setSwitchOutStatus(true); this.setSwitchOutStatus(true);
this.scene.triggerPokemonFormChange(this, SpeciesFormChangeActiveTrigger, true); this.scene.triggerPokemonFormChange(this, SpeciesFormChangeActiveTrigger, true);
@ -5279,6 +5283,7 @@ export class PokemonTurnData {
public switchedInThisTurn: boolean = false; public switchedInThisTurn: boolean = false;
public failedRunAway: boolean = false; public failedRunAway: boolean = false;
public joinedRound: boolean = false; public joinedRound: boolean = false;
public flee: boolean = false;
} }
export enum AiType { export enum AiType {

View File

@ -31,7 +31,12 @@ import { WeatherType } from "#enums/weather-type";
* } * }
* ``` * ```
*/ */
const overrides = {} satisfies Partial<InstanceType<typeof DefaultOverrides>>; const overrides = {
BATTLE_TYPE_OVERRIDE: "odd-doubles",
OPP_SPECIES_OVERRIDE: Species.WIMPOD,
OPP_MOVESET_OVERRIDE: Moves.SPLASH,
MOVESET_OVERRIDE: [ Moves.MATCHA_GOTCHA, Moves.QUICK_ATTACK ]
} satisfies Partial<InstanceType<typeof DefaultOverrides>>;
/** /**
* If you need to add Overrides values for local testing do that inside {@linkcode overrides} * If you need to add Overrides values for local testing do that inside {@linkcode overrides}

View File

@ -228,9 +228,11 @@ export class MoveEffectPhase extends PokemonPhase {
* If the move missed a target, stop all future hits against that target * If the move missed a target, stop all future hits against that target
* and move on to the next target (if there is one). * and move on to the next target (if there is one).
*/ */
if (isCommanding || (!isImmune && !isProtected && !targetHitChecks[target.getBattlerIndex()])) { if (target.turnData.flee || isCommanding || (!isImmune && !isProtected && !targetHitChecks[target.getBattlerIndex()])) {
this.stopMultiHit(target); this.stopMultiHit(target);
this.scene.queueMessage(i18next.t("battle:attackMissed", { pokemonNameWithAffix: getPokemonNameWithAffix(target) })); if (!target.turnData.flee) {
this.scene.queueMessage(i18next.t("battle:attackMissed", { pokemonNameWithAffix: getPokemonNameWithAffix(target) }));
}
if (moveHistoryEntry.result === MoveResult.PENDING) { if (moveHistoryEntry.result === MoveResult.PENDING) {
moveHistoryEntry.result = MoveResult.MISS; moveHistoryEntry.result = MoveResult.MISS;
} }

View File

@ -16,7 +16,7 @@ export class PostTurnStatusEffectPhase extends PokemonPhase {
start() { start() {
const pokemon = this.getPokemon(); const pokemon = this.getPokemon();
if (pokemon?.isActive(true) && pokemon.status && pokemon.status.isPostTurn()) { if (pokemon?.isActive(true) && pokemon.status && pokemon.status.isPostTurn() && !pokemon.turnData.flee) {
pokemon.status.incrementTurn(); pokemon.status.incrementTurn();
const cancelled = new Utils.BooleanHolder(false); const cancelled = new Utils.BooleanHolder(false);
applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled);