[Beta][P1-3] Fix Commander implementation bugs (#4826)

This commit is contained in:
innerthunder 2024-11-09 10:14:11 -08:00 committed by GitHub
parent 329e43ad48
commit a763cd173d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 20 deletions

View File

@ -774,7 +774,7 @@ export default class BattleScene extends SceneBase {
/**
* @returns An array of {@linkcode PlayerPokemon} filtered from the player's party
* that are {@linkcode PlayerPokemon.isAllowedInBattle | allowed in battle}.
* that are {@linkcode Pokemon.isAllowedInBattle | allowed in battle}.
*/
public getPokemonAllowedInBattle(): PlayerPokemon[] {
return this.getPlayerParty().filter(p => p.isAllowedInBattle());
@ -1243,23 +1243,27 @@ export default class BattleScene extends SceneBase {
const lastBattle = this.currentBattle;
if (lastBattle?.double && !newDouble) {
this.tryRemovePhase(p => p instanceof SwitchPhase);
}
const maxExpLevel = this.getMaxExpLevel();
this.lastEnemyTrainer = lastBattle?.trainer ?? null;
this.lastMysteryEncounter = lastBattle?.mysteryEncounter;
if (newBattleType === BattleType.MYSTERY_ENCOUNTER) {
// Disable double battle on mystery encounters (it may be re-enabled as part of encounter)
newDouble = false;
}
if (lastBattle?.double && !newDouble) {
this.tryRemovePhase(p => p instanceof SwitchPhase);
this.getPlayerField().forEach(p => p.lapseTag(BattlerTagType.COMMANDED));
}
this.executeWithSeedOffset(() => {
this.currentBattle = new Battle(this.gameMode, newWaveIndex, newBattleType, newTrainer, newDouble);
}, newWaveIndex << 3, this.waveSeed);
this.currentBattle.incrementTurn(this);
if (newBattleType === BattleType.MYSTERY_ENCOUNTER) {
// Disable double battle on mystery encounters (it may be re-enabled as part of encounter)
this.currentBattle.double = false;
// Will generate the actual Mystery Encounter during NextEncounterPhase, to ensure it uses proper biome
this.currentBattle.mysteryEncounterType = mysteryEncounterType;
}

View File

@ -23,7 +23,7 @@ import { reverseCompatibleTms, tmSpecies, tmPoolTiers } from "#app/data/balance/
import { BattlerTag, BattlerTagLapseType, EncoreTag, GroundedTag, HighestStatBoostTag, SubstituteTag, TypeImmuneTag, getBattlerTag, SemiInvulnerableTag, TypeBoostTag, MoveRestrictionBattlerTag, ExposedTag, DragonCheerTag, CritBoostTag, TrappedTag, TarShotTag, AutotomizedTag, PowerTrickTag } from "../data/battler-tags";
import { WeatherType } from "#enums/weather-type";
import { ArenaTagSide, NoCritTag, WeakenMoveScreenTag } from "#app/data/arena-tag";
import { Ability, AbAttr, StatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatStagesAbAttr, MoveImmunityAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, FieldMultiplyStatAbAttr, AddSecondStrikeAbAttr, UserFieldStatusEffectImmunityAbAttr, UserFieldBattlerTagImmunityAbAttr, BattlerTagImmunityAbAttr, MoveTypeChangeAbAttr, FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, CheckTrappedAbAttr, PostSetStatusAbAttr, applyPostSetStatusAbAttrs, InfiltratorAbAttr, AlliedFieldDamageReductionAbAttr, PostDamageAbAttr, applyPostDamageAbAttrs, PostDamageForceSwitchAbAttr } from "#app/data/ability";
import { Ability, AbAttr, StatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatStagesAbAttr, MoveImmunityAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, FieldMultiplyStatAbAttr, AddSecondStrikeAbAttr, UserFieldStatusEffectImmunityAbAttr, UserFieldBattlerTagImmunityAbAttr, BattlerTagImmunityAbAttr, MoveTypeChangeAbAttr, FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, CheckTrappedAbAttr, PostSetStatusAbAttr, applyPostSetStatusAbAttrs, InfiltratorAbAttr, AlliedFieldDamageReductionAbAttr, PostDamageAbAttr, applyPostDamageAbAttrs, PostDamageForceSwitchAbAttr, CommanderAbAttr } from "#app/data/ability";
import PokemonData from "#app/system/pokemon-data";
import { BattlerIndex } from "#app/battle";
import { Mode } from "#app/ui/ui";
@ -3081,7 +3081,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}
lapseTag(tagType: BattlerTagType): boolean {
const tags = this.summonData.tags;
const tags = this.summonData?.tags;
if (isNullOrUndefined(tags)) {
return false;
}
const tag = tags.find(t => t.tagType === tagType);
if (tag && !(tag.lapse(this, BattlerTagLapseType.CUSTOM))) {
tag.onRemove(this);
@ -3646,6 +3649,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.scene.triggerPokemonBattleAnim(this, PokemonAnimType.SUBSTITUTE_ADD);
this.getTag(SubstituteTag)!.sourceInFocus = false;
}
// If this Pokemon has Commander and Dondozo as an active ally, hide this Pokemon's sprite.
if (this.hasAbilityWithAttr(CommanderAbAttr)
&& this.scene.currentBattle.double
&& this.getAlly()?.species.speciesId === Species.DONDOZO) {
this.setVisible(false);
}
this.summonDataPrimer = null;
}
this.updateInfo();

View File

@ -26,25 +26,29 @@ export class CheckSwitchPhase extends BattlePhase {
const pokemon = this.scene.getPlayerField()[this.fieldIndex];
// End this phase early...
// ...if the user is playing in Set Mode
if (this.scene.battleStyle === BattleStyle.SET) {
super.end();
return;
return super.end();
}
// ...if the checked Pokemon is somehow not on the field
if (this.scene.field.getAll().indexOf(pokemon) === -1) {
this.scene.unshiftPhase(new SummonMissingPhase(this.scene, this.fieldIndex));
super.end();
return;
return super.end();
}
// ...if there are no other allowed Pokemon in the player's party to switch with
if (!this.scene.getPlayerParty().slice(1).filter(p => p.isActive()).length) {
super.end();
return;
return super.end();
}
if (pokemon.getTag(BattlerTagType.FRENZY)) {
super.end();
return;
// ...or if any player Pokemon has an effect that prevents the checked Pokemon from switching
if (pokemon.getTag(BattlerTagType.FRENZY)
|| pokemon.isTrapped()
|| this.scene.getPlayerField().some(p => p.getTag(BattlerTagType.COMMANDED))) {
return super.end();
}
this.scene.ui.showText(i18next.t("battle:switchQuestion", { pokemonName: this.useName ? getPokemonNameWithAffix(pokemon) : i18next.t("battle:pokemon") }), null, () => {

View File

@ -36,7 +36,6 @@ import { PlayerGender } from "#enums/player-gender";
import { Species } from "#enums/species";
import i18next from "i18next";
import { WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/data/mystery-encounters/mystery-encounters";
import { BattlerTagType } from "#enums/battler-tag-type";
export class EncounterPhase extends BattlePhase {
private loaded: boolean;
@ -483,7 +482,6 @@ export class EncounterPhase extends BattlePhase {
}
} else {
if (availablePartyMembers.length > 1 && availablePartyMembers[1].isOnField()) {
this.scene.getPlayerField().forEach((pokemon) => pokemon.lapseTag(BattlerTagType.COMMANDED));
this.scene.pushPhase(new ReturnPhase(this.scene, 1));
}
this.scene.pushPhase(new ToggleDoublePositionPhase(this.scene, false));