From be3dd0edc13e85d671c51299a5620d5d0487f68a Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 30 Mar 2024 15:34:00 -0400 Subject: [PATCH] Salt Cure Full Implementation --- src/battle-scene.ts | 1 + src/data/battler-tags.ts | 33 +++++++++++++++++++++++++ src/data/enums/battler-tag-type.ts | 3 ++- src/data/move.ts | 39 ++++++++++++------------------ src/ui/command-ui-handler.ts | 4 +++ 5 files changed, 55 insertions(+), 25 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 16bd9a792..a1136699d 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1520,6 +1520,7 @@ export default class BattleScene extends Phaser.Scene { this.cameras.main.removePostPipeline('InvertPostFX'); } + /* Phase Functions */ getCurrentPhase(): Phase { return this.currentPhase; } diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 1d8583b55..3943674e1 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -877,6 +877,37 @@ export class IgnoreAccuracyTag extends BattlerTag { } } +export class SaltCuredTag extends BattlerTag { + private sourceIndex: integer; + + constructor(sourceId: integer) { + super(BattlerTagType.SALT_CURED, BattlerTagLapseType.AFTER_MOVE, 1, Moves.SALT_CURE, sourceId); + } + + onAdd(pokemon: Pokemon): void { + super.onAdd(pokemon); + + pokemon.scene.queueMessage(getPokemonMessage(pokemon, ' is being salt cured!')); + this.sourceIndex = pokemon.scene.getPokemonById(this.sourceId).getBattlerIndex(); + } + + lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { + const ret = lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType); + + if (ret) { + const source = pokemon.getOpponents().find(o => o.getBattlerIndex() === this.sourceIndex); + pokemon.scene.unshiftPhase(new CommonAnimPhase(pokemon.scene, source.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.SALT_CURE)); + + const pokemonSteelOrWater = pokemon.isOfType(Type.STEEL) || pokemon.isOfType(Type.WATER); + pokemon.damageAndUpdate(Math.max(Math.floor(pokemonSteelOrWater ? pokemon.getMaxHp() / 4 : pokemon.getMaxHp() / 8), 1)); + + pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` is hurt by ${this.getMoveName()}!`)); + } + + return ret; + } +} + export function getBattlerTag(tagType: BattlerTagType, turnCount: integer, sourceMove: Moves, sourceId: integer): BattlerTag { switch (tagType) { case BattlerTagType.RECHARGING: @@ -955,6 +986,8 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: integer, sourc return new BattlerTag(BattlerTagType.BYPASS_SLEEP, BattlerTagLapseType.TURN_END, turnCount, sourceMove); case BattlerTagType.IGNORE_FLYING: return new BattlerTag(tagType, BattlerTagLapseType.TURN_END, turnCount, sourceMove); + case BattlerTagType.SALT_CURED: + return new SaltCuredTag(sourceId); case BattlerTagType.NONE: default: return new BattlerTag(tagType, BattlerTagLapseType.CUSTOM, turnCount, sourceMove, sourceId); diff --git a/src/data/enums/battler-tag-type.ts b/src/data/enums/battler-tag-type.ts index c517d4c15..90e1e5404 100644 --- a/src/data/enums/battler-tag-type.ts +++ b/src/data/enums/battler-tag-type.ts @@ -39,5 +39,6 @@ export enum BattlerTagType { NO_CRIT = "NO_CRIT", IGNORE_ACCURACY = "IGNORE_ACCURACY", BYPASS_SLEEP = "BYPASS_SLEEP", - IGNORE_FLYING = "IGNORE_FLYING" + IGNORE_FLYING = "IGNORE_FLYING", + SALT_CURED = "SALT_CURED" } diff --git a/src/data/move.ts b/src/data/move.ts index 99c291411..15090f833 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1888,27 +1888,18 @@ export class AddBattlerTagAttr extends MoveEffectAttr { getTagTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { switch (this.tagType) { case BattlerTagType.RECHARGING: + case BattlerTagType.PERISH_SONG: return -16; case BattlerTagType.FLINCHED: - return -5; case BattlerTagType.CONFUSED: - return -5; case BattlerTagType.INFATUATED: - return -5; - case BattlerTagType.SEEDED: - return -3; case BattlerTagType.NIGHTMARE: - return -5; - case BattlerTagType.FRENZY: - return -3; - case BattlerTagType.ENCORE: - return -2; - case BattlerTagType.INGRAIN: - return 3; - case BattlerTagType.AQUA_RING: - return 3; case BattlerTagType.DROWSY: - return -5; + case BattlerTagType.NO_CRIT: + return -5; + case BattlerTagType.SEEDED: + case BattlerTagType.SALT_CURED: + case BattlerTagType.FRENZY: case BattlerTagType.TRAPPED: case BattlerTagType.BIND: case BattlerTagType.WRAP: @@ -1919,18 +1910,16 @@ export class AddBattlerTagAttr extends MoveEffectAttr { case BattlerTagType.MAGMA_STORM: case BattlerTagType.THUNDER_CAGE: return -3; + case BattlerTagType.ENCORE: + return -2; + case BattlerTagType.INGRAIN: + case BattlerTagType.IGNORE_ACCURACY: + case BattlerTagType.AQUA_RING: + return 3; case BattlerTagType.PROTECTED: - return 5; - case BattlerTagType.PERISH_SONG: - return -16; case BattlerTagType.FLYING: - return 5; case BattlerTagType.CRIT_BOOST: return 5; - case BattlerTagType.NO_CRIT: - return -5; - case BattlerTagType.IGNORE_ACCURACY: - return 3; } } @@ -4686,7 +4675,9 @@ export function initMoves() { .attr(ClearTerrainAttr), new AttackMove(Moves.GLAIVE_RUSH, "Glaive Rush (P)", Type.DRAGON, MoveCategory.PHYSICAL, 120, 100, 5, "The user throws its entire body into a reckless charge. After this move is used, attacks on the user cannot miss and will inflict double damage until the user's next turn.", -1, 0, 9), new StatusMove(Moves.REVIVAL_BLESSING, "Revival Blessing (N)", Type.NORMAL, -1, 1, "The user bestows a loving blessing, reviving a party Pokémon that has fainted and restoring half that Pokémon's max HP.", -1, 0, 9), - new AttackMove(Moves.SALT_CURE, "Salt Cure (P)", Type.ROCK, MoveCategory.PHYSICAL, 40, 100, 15, "The user salt cures the target, inflicting damage every turn. Steel and Water types are more strongly affected by this move.", -1, 0, 9), + new AttackMove(Moves.SALT_CURE, "Salt Cure", Type.ROCK, MoveCategory.PHYSICAL, 40, 100, 15, "The user salt cures the target, inflicting damage every turn. Steel and Water types are more strongly affected by this move.", -1, 0, 9) + .attr(AddBattlerTagAttr, BattlerTagType.SALT_CURED) + .condition((user, target, move) => !target.getTag(BattlerTagType.SALT_CURED)), new AttackMove(Moves.TRIPLE_DIVE, "Triple Dive", Type.WATER, MoveCategory.PHYSICAL, 30, 95, 10, "The user performs a perfectly timed triple dive, hitting the target with splashes of water three times in a row.", -1, 0, 9) .attr(MultiHitAttr, MultiHitType._3), new AttackMove(Moves.MORTAL_SPIN, "Mortal Spin", Type.POISON, MoveCategory.PHYSICAL, 30, 100, 15, "The user performs a spin attack that can also eliminate the effects of such moves as Bind, Wrap, and Leech Seed. This also poisons opposing Pokémon.", 100, 0, 9) diff --git a/src/ui/command-ui-handler.ts b/src/ui/command-ui-handler.ts index 9831d006a..c0fdd43fa 100644 --- a/src/ui/command-ui-handler.ts +++ b/src/ui/command-ui-handler.ts @@ -72,20 +72,24 @@ export default class CommandUiHandler extends UiHandler { if (button === Button.ACTION) { switch (cursor) { + // Fight case 0: if ((this.scene.getCurrentPhase() as CommandPhase).checkFightOverride()) return true; ui.setMode(Mode.FIGHT, (this.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); success = true; break; + // Ball case 1: ui.setModeWithoutClear(Mode.BALL); success = true; break; + // Pokemon case 2: ui.setMode(Mode.PARTY, PartyUiMode.SWITCH, (this.scene.getCurrentPhase() as CommandPhase).getPokemon().getFieldIndex(), null, PartyUiHandler.FilterNonFainted); success = true; break; + // Run case 3: (this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.RUN, 0); success = true;