From 46525c1bac523d59073308137b91608384d2a6c6 Mon Sep 17 00:00:00 2001 From: Zedarflight Date: Fri, 10 May 2024 18:39:49 -0700 Subject: [PATCH] implemented Tera Shell --- src/data/ability.ts | 25 +++++++++++++++++++++++-- src/field/pokemon.ts | 3 ++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 8a244b85b..f99099f7e 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -300,6 +300,27 @@ export class ReceivedMoveDamageMultiplierAbAttr extends PreDefendAbAttr { } } +export class ReceivedMoveEffectivenessAbAttr extends PreDefendAbAttr { + protected condition: PokemonDefendCondition; + private newType: number; + + constructor(condition: PokemonDefendCondition, newType: number) { + super(); + + this.condition = condition; + this.newType = newType; + } + + applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean { + if (this.condition(pokemon, attacker, move.getMove())) { + (args[0] as Utils.NumberHolder).value = this.newType; // Set new effectiveness value. + return true; + } + + return false; + } +} + export class ReceivedTypeDamageMultiplierAbAttr extends ReceivedMoveDamageMultiplierAbAttr { constructor(moveType: Type, powerMultiplier: number) { super((user, target, move) => move.type === moveType, powerMultiplier); @@ -3705,8 +3726,8 @@ export function initAbilities() { new Ability(Abilities.TERA_SHELL, 9) .attr(UncopiableAbilityAbAttr) .attr(UnswappableAbilityAbAttr) - .ignorable() - .unimplemented(), + .attr(ReceivedMoveEffectivenessAbAttr,(target, user, move) => target.getHpRatio() === 1 && target.getAttackTypeEffectiveness(move.type, user) > 0, 0.5) + .ignorable(), new Ability(Abilities.TERAFORM_ZERO, 9) .attr(UncopiableAbilityAbAttr) .attr(UnswappableAbilityAbAttr) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 8afff1b27..028b7dd3e 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -27,7 +27,7 @@ import { TempBattleStat } from '../data/temp-battle-stat'; import { ArenaTagSide, WeakenMoveScreenTag, WeakenMoveTypeTag } from '../data/arena-tag'; import { ArenaTagType } from "../data/enums/arena-tag-type"; import { Biome } from "../data/enums/biome"; -import { Ability, AbAttr, BattleStatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, FieldVariableMovePowerAbAttr, IgnoreOpponentStatChangesAbAttr, MoveImmunityAbAttr, MoveTypeChangeAttr, NonSuperEffectiveImmunityAbAttr, PreApplyBattlerTagAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, ReduceStatusEffectDurationAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, VariableMoveTypeAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyBattleStatMultiplierAbAttrs, applyPostDefendAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr } from '../data/ability'; +import { Ability, AbAttr, BattleStatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, FieldVariableMovePowerAbAttr, IgnoreOpponentStatChangesAbAttr, MoveImmunityAbAttr, MoveTypeChangeAttr, NonSuperEffectiveImmunityAbAttr, PreApplyBattlerTagAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, ReceivedMoveEffectivenessAbAttr, ReduceStatusEffectDurationAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, VariableMoveTypeAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyBattleStatMultiplierAbAttrs, applyPostDefendAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr } from '../data/ability'; import { Abilities } from "#app/data/enums/abilities"; import PokemonData from '../system/pokemon-data'; import Battle, { BattlerIndex } from '../battle'; @@ -1318,6 +1318,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.scene.getField(true).map(p => applyPreAttackAbAttrs(FieldVariableMovePowerAbAttr, this, source, battlerMove, power)); applyPreDefendAbAttrs(ReceivedMoveDamageMultiplierAbAttr, this, source, battlerMove, cancelled, power); + applyPreDefendAbAttrs(ReceivedMoveEffectivenessAbAttr, this, source, battlerMove, cancelled, typeMultiplier); power.value *= typeChangeMovePowerMultiplier.value;