From 930c14fa62b0362736a70cdb05c1a76889f93358 Mon Sep 17 00:00:00 2001 From: EmoUsedHM01 <131687820+EmoUsedHM01@users.noreply.github.com> Date: Fri, 12 Apr 2024 21:05:32 +0100 Subject: [PATCH] Laser Focus support, with the added BattlerTagTypes to support it (#103) * Added a new BattlerTagType and support for Laser Focus BattlerTagType.ALWAYS_CRIT * Updated battler-tags to support ALWAYS_CRIT * Added ALWAYS_CRIT = "ALWAYS_CRIT", for the updated battler-tag-type * Updated the crit formula to include the new critAlways * Updated crit logic to include critAlways, fixed indents --- src/data/battler-tags.ts | 8 ++++++++ src/data/enums/battler-tag-type.ts | 1 + src/data/move.ts | 19 ++++++++++++++++++- src/field/pokemon.ts | 5 +++-- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 1244d8697..d182a4c45 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -956,6 +956,12 @@ export class CritBoostTag extends BattlerTag { } } +export class AlwaysCritTag extends BattlerTag { + constructor(sourceMove: Moves) { + super(BattlerTagType.ALWAYS_CRIT, BattlerTagLapseType.TURN_END, 2, sourceMove); + } +} + export class IgnoreAccuracyTag extends BattlerTag { constructor(sourceMove: Moves) { super(BattlerTagType.IGNORE_ACCURACY, BattlerTagLapseType.TURN_END, 2, sourceMove); @@ -1077,6 +1083,8 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: integer, sourc return new TypeBoostTag(tagType, sourceMove, Type.FIRE); case BattlerTagType.CRIT_BOOST: return new CritBoostTag(tagType, sourceMove); + case BattlerTagType.ALWAYS_CRIT: + return new AlwaysCritTag(tagType, sourceMove); case BattlerTagType.NO_CRIT: return new BattlerTag(tagType, BattlerTagLapseType.AFTER_MOVE, turnCount, sourceMove); case BattlerTagType.IGNORE_ACCURACY: diff --git a/src/data/enums/battler-tag-type.ts b/src/data/enums/battler-tag-type.ts index 4aecd5195..85f007534 100644 --- a/src/data/enums/battler-tag-type.ts +++ b/src/data/enums/battler-tag-type.ts @@ -41,6 +41,7 @@ export enum BattlerTagType { HIDDEN = "HIDDEN", FIRE_BOOST = "FIRE_BOOST", CRIT_BOOST = "CRIT_BOOST", + ALWAYS_CRIT = "ALWAYS_CRIT", NO_CRIT = "NO_CRIT", IGNORE_ACCURACY = "IGNORE_ACCURACY", BYPASS_SLEEP = "BYPASS_SLEEP", diff --git a/src/data/move.ts b/src/data/move.ts index a0f1a9311..e0535ed67 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -2300,6 +2300,7 @@ export class AddBattlerTagAttr extends MoveEffectAttr { case BattlerTagType.PROTECTED: case BattlerTagType.FLYING: case BattlerTagType.CRIT_BOOST: + case BattlerTagType.ALWAYS_CRIT: return 5; } } @@ -2421,6 +2422,21 @@ export class IgnoreAccuracyAttr extends AddBattlerTagAttr { } } +export class AlwaysCritsAttr extends AddBattlerTagAttr { + constructor() { + super(BattlerTagType.ALWAYS_CRIT, true, false, 2); + } + + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + if (!super.apply(user, target, move, args)) + return false; + + user.scene.queueMessage(getPokemonMessage(user, ` took aim\nat ${target.name}!`)); + + return true; + } +} + export class FaintCountdownAttr extends AddBattlerTagAttr { constructor() { super(BattlerTagType.PERISH_SONG, false, true, 4); @@ -4678,7 +4694,8 @@ export function initMoves() { new StatusMove(Moves.TOXIC_THREAD, "Toxic Thread", Type.POISON, 100, 20, "The user shoots poisonous threads to poison the target and lower the target's Speed stat.", 100, 0, 7) .attr(StatusEffectAttr, StatusEffect.POISON) .attr(StatChangeAttr, BattleStat.SPD, -1), - new SelfStatusMove(Moves.LASER_FOCUS, "Laser Focus (N)", Type.NORMAL, -1, 30, "The user concentrates intensely. The attack on the next turn always results in a critical hit.", -1, 0, 7), + new SelfStatusMove(Moves.LASER_FOCUS, "Laser Focus", Type.NORMAL, -1, 30, "The user concentrates intensely. The attack on the next turn always results in a critical hit.", -1, 0, 7) + .attr(AddBattlerTagAttr, BattlerTagType.ALWAYS_CRIT, true, false), new StatusMove(Moves.GEAR_UP, "Gear Up", Type.STEEL, -1, 20, "The user engages its gears to raise the Attack and Sp. Atk stats of ally Pokémon with the Plus or Minus Ability.", -1, 0, 7) .attr(StatChangeAttr, [ BattleStat.ATK, BattleStat.SPATK ], 1, false, (user, target, move) => [ Abilities.PLUS, Abilities.MINUS ].includes(target.getAbility().id) || (target.canApplyPassive() && [ Abilities.PLUS, Abilities.MINUS ].includes(target.getPassiveAbility().id))) .target(MoveTarget.USER_AND_ALLIES) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 9dc560d80..5631a39fe 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1174,8 +1174,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { power.value *= 1.5; let isCritical: boolean; const critOnly = new Utils.BooleanHolder(false); + const critAlways = source.getTag(BattlerTagType.ALWAYS_CRIT); applyMoveAttrs(CritOnlyAttr, source, this, move, critOnly); - if (critOnly.value) + if (critOnly.value || critAlways) isCritical = true; else { const critLevel = new Utils.IntegerHolder(0); @@ -2879,4 +2880,4 @@ export class PokemonMove { getName(): string { return this.getMove().name; } -} \ No newline at end of file +}