From 844613072814f8ee2a819550b7d33bebaea0d4ee Mon Sep 17 00:00:00 2001 From: Madmadness65 Date: Sat, 6 Apr 2024 21:50:17 -0500 Subject: [PATCH] Fully implement Spiky Shield move --- src/data/ability.ts | 4 ++-- src/data/battler-tags.ts | 26 ++++++++++++++++++++++++++ src/data/enums/battler-tag-type.ts | 1 + src/data/move.ts | 4 ++-- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 41b1dade6..7be9f5365 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -2498,11 +2498,11 @@ export function initAbilities() { new Ability(Abilities.DELTA_STREAM, "Delta Stream", "The Pokémon changes the weather to eliminate all of the Flying type's weaknesses.", 6) .attr(PostSummonWeatherChangeAbAttr, WeatherType.STRONG_WINDS), new Ability(Abilities.STAMINA, "Stamina", "Boosts the Defense stat when hit by an attack.", 7) - .attr(PostDefendStatChangeAbAttr, (target, user, move) => move.category != MoveCategory.STATUS, BattleStat.DEF, 1), + .attr(PostDefendStatChangeAbAttr, (target, user, move) => move.category !== MoveCategory.STATUS, BattleStat.DEF, 1), new Ability(Abilities.WIMP_OUT, "Wimp Out (N)", "The Pokémon cowardly switches out when its HP becomes half or less.", 7), new Ability(Abilities.EMERGENCY_EXIT, "Emergency Exit (N)", "The Pokémon, sensing danger, switches out when its HP becomes half or less.", 7), new Ability(Abilities.WATER_COMPACTION, "Water Compaction", "Boosts the Pokémon's Defense stat sharply when hit by a Water-type move.", 7) - .attr(PostDefendStatChangeAbAttr, (target, user, move) => move.type === Type.WATER , BattleStat.DEF, 2), + .attr(PostDefendStatChangeAbAttr, (target, user, move) => move.type === Type.WATER, BattleStat.DEF, 2), new Ability(Abilities.MERCILESS, "Merciless (N)", "The Pokémon's attacks become critical hits if the target is poisoned.", 7), new Ability(Abilities.SHIELDS_DOWN, "Shields Down (N)", "When its HP becomes half or less, the Pokémon's shell breaks and it becomes aggressive.", 7) .attr(ProtectAbilityAbAttr), diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 81ea80938..6c3c12dc2 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -634,6 +634,30 @@ export class ProtectedTag extends BattlerTag { } } +export class ContactDamageProtectedTag extends ProtectedTag { + private damageRatio: integer; + + constructor(sourceMove: Moves, damageRatio: integer) { + super(sourceMove, BattlerTagType.SPIKY_SHIELD); + + this.damageRatio = damageRatio; + } + + lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { + const ret = super.lapse(pokemon, lapseType); + + if (lapseType === BattlerTagLapseType.CUSTOM) { + const effectPhase = pokemon.scene.getCurrentPhase(); + if (effectPhase instanceof MoveEffectPhase && effectPhase.move.getMove().hasFlag(MoveFlags.MAKES_CONTACT)) { + const attacker = effectPhase.getPokemon(); + attacker.damageAndUpdate(Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)), HitResult.OTHER); + } + } + + return ret; + } +} + export class ContactStatChangeProtectedTag extends ProtectedTag { private stat: BattleStat; private levels: integer; @@ -1016,6 +1040,8 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: integer, sourc return new ThunderCageTag(turnCount, sourceId); case BattlerTagType.PROTECTED: return new ProtectedTag(sourceMove); + case BattlerTagType.SPIKY_SHIELD: + return new ContactDamageProtectedTag(sourceMove, 8); case BattlerTagType.KINGS_SHIELD: return new ContactStatChangeProtectedTag(sourceMove, tagType, BattleStat.ATK, -1); case BattlerTagType.OBSTRUCT: diff --git a/src/data/enums/battler-tag-type.ts b/src/data/enums/battler-tag-type.ts index 0ce106187..4aecd5195 100644 --- a/src/data/enums/battler-tag-type.ts +++ b/src/data/enums/battler-tag-type.ts @@ -23,6 +23,7 @@ export enum BattlerTagType { MAGMA_STORM = "MAGMA_STORM", THUNDER_CAGE = "THUNDER_CAGE", PROTECTED = "PROTECTED", + SPIKY_SHIELD = "SPIKY_SHIELD", KINGS_SHIELD = "KINGS_SHIELD", OBSTRUCT = "OBSTRUCT", SILK_TRAP = "SILK_TRAP", diff --git a/src/data/move.ts b/src/data/move.ts index f552e6017..b7363fa8c 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -4255,8 +4255,8 @@ export function initMoves() { .attr(MultiHitAttr), new AttackMove(Moves.MYSTICAL_FIRE, "Mystical Fire", Type.FIRE, MoveCategory.SPECIAL, 75, 100, 10, "The user attacks by breathing a special, hot fire. This also lowers the target's Sp. Atk stat.", 100, 0, 6) .attr(StatChangeAttr, BattleStat.SPATK, -1), - new SelfStatusMove(Moves.SPIKY_SHIELD, "Spiky Shield (P)", Type.GRASS, -1, 10, "In addition to protecting the user from attacks, this move also damages any attacker that makes direct contact.", -1, 4, 6) - .attr(ProtectAttr), + new SelfStatusMove(Moves.SPIKY_SHIELD, "Spiky Shield", Type.GRASS, -1, 10, "In addition to protecting the user from attacks, this move also damages any attacker that makes direct contact.", -1, 4, 6) + .attr(ProtectAttr, BattlerTagType.SPIKY_SHIELD), new StatusMove(Moves.AROMATIC_MIST, "Aromatic Mist", Type.FAIRY, -1, 20, "The user raises the Sp. Def stat of an ally Pokémon by using a mysterious aroma.", -1, 0, 6) .attr(StatChangeAttr, BattleStat.SPDEF, 1) .target(MoveTarget.NEAR_ALLY),