From 55f2a32d9f21958da3973b2128c1a7961a642b72 Mon Sep 17 00:00:00 2001 From: chaosgrimmon <31082757+chaosgrimmon@users.noreply.github.com> Date: Thu, 11 Jul 2024 10:21:38 -0400 Subject: [PATCH] [Bug] Grounded on Terrain fixes (#2969) * [Help] [Move/Bug] Patches Psychic Terrain applicability edge cases Was cancelling moves even if targeted mons weren't on the terrain. * [Bug `]Pokemon.isGrounded` does not exist Replaced with `Pokemon.isGrounded()`, which does. * [Bug] Psychic Terrain priority move cancel ignoring ungrounded * [Bug] Semi-invulnerable should not be grounded --- src/data/move.ts | 2 +- src/data/terrain.ts | 3 ++- src/field/pokemon.ts | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 321fbc6d097..2e0f39278bc 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -3617,7 +3617,7 @@ export class TerrainPulseTypeAttr extends VariableMoveTypeAttr { * @returns true if the function succeeds */ apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - if (!user.isGrounded) { + if (!user.isGrounded()) { return false; } diff --git a/src/data/terrain.ts b/src/data/terrain.ts index f7324c28b93..507557eaf9f 100644 --- a/src/data/terrain.ts +++ b/src/data/terrain.ts @@ -60,7 +60,8 @@ export class Terrain { if (!move.hasAttr(ProtectAttr)) { const priority = new Utils.IntegerHolder(move.priority); applyAbAttrs(IncrementMovePriorityAbAttr, user, null, move, priority); - return priority.value > 0 && user.getOpponents().filter(o => targets.includes(o.getBattlerIndex())).length > 0; + // Cancels move if the move has positive priority and targets a Pokemon grounded on the Psychic Terrain + return priority.value > 0 && user.getOpponents().filter(o => targets.includes(o.getBattlerIndex()) && o.isGrounded()).length > 0; } } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 086614f0190..dd75951dc56 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -19,7 +19,7 @@ import { pokemonEvolutions, pokemonPrevolutions, SpeciesFormEvolution, SpeciesEv import { reverseCompatibleTms, tmSpecies, tmPoolTiers } from "../data/tms"; import { DamagePhase, FaintPhase, LearnMovePhase, MoveEffectPhase, ObtainStatusEffectPhase, StatChangePhase, SwitchSummonPhase, ToggleDoublePositionPhase } from "../phases"; import { BattleStat } from "../data/battle-stat"; -import { BattlerTag, BattlerTagLapseType, EncoreTag, GroundedTag, HelpingHandTag, HighestStatBoostTag, TypeBoostTag, TypeImmuneTag, getBattlerTag } from "../data/battler-tags"; +import { BattlerTag, BattlerTagLapseType, EncoreTag, GroundedTag, HelpingHandTag, HighestStatBoostTag, TypeBoostTag, TypeImmuneTag, getBattlerTag, SemiInvulnerableTag } from "../data/battler-tags"; import { WeatherType } from "../data/weather"; import { TempBattleStat } from "../data/temp-battle-stat"; import { ArenaTagSide, WeakenMoveScreenTag, WeakenMoveTypeTag } from "../data/arena-tag"; @@ -1125,7 +1125,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } isGrounded(): boolean { - return !!this.getTag(GroundedTag) || (!this.isOfType(Type.FLYING, true, true) && !this.hasAbility(Abilities.LEVITATE) && !this.getTag(BattlerTagType.MAGNET_RISEN)); + return !!this.getTag(GroundedTag) || (!this.isOfType(Type.FLYING, true, true) && !this.hasAbility(Abilities.LEVITATE) && !this.getTag(BattlerTagType.MAGNET_RISEN) && !this.getTag(SemiInvulnerableTag)); } /**