Update PreDefendAbAttrs

This commit is contained in:
Dean 2025-02-01 02:16:26 -08:00
parent 79bc8f9d0f
commit cb6ceed997

View File

@ -290,20 +290,25 @@ export class PostBattleInitStatStageChangeAbAttr extends PostBattleInitAbAttr {
type PreDefendAbAttrCondition = (pokemon: Pokemon, attacker: Pokemon, move: Move) => boolean; type PreDefendAbAttrCondition = (pokemon: Pokemon, attacker: Pokemon, move: Move) => boolean;
export class PreDefendAbAttr extends AbAttr { export class PreDefendAbAttr extends AbAttr {
willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
return true;
}
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, args: any[]): boolean | Promise<boolean> { applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, args: any[]): boolean | Promise<boolean> {
return false; return false;
} }
} }
export class PreDefendFullHpEndureAbAttr extends PreDefendAbAttr { export class PreDefendFullHpEndureAbAttr extends PreDefendAbAttr {
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
if (pokemon.isFullHp() return pokemon.isFullHp()
&& pokemon.getMaxHp() > 1 //Checks if pokemon has wonder_guard (which forces 1hp) && pokemon.getMaxHp() > 1 //Checks if pokemon has wonder_guard (which forces 1hp)
&& (args[0] as Utils.NumberHolder).value >= pokemon.hp) { //Damage >= hp && (args[0] as Utils.NumberHolder).value >= pokemon.hp; //Damage >= hp
return simulated || pokemon.addTag(BattlerTagType.STURDY, 1);
} }
return false; applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
return simulated || pokemon.addTag(BattlerTagType.STURDY, 1);
} }
} }
@ -345,14 +350,13 @@ export class ReceivedMoveDamageMultiplierAbAttr extends PreDefendAbAttr {
this.damageMultiplier = damageMultiplier; this.damageMultiplier = damageMultiplier;
} }
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
if (this.condition(pokemon, attacker, move)) { return this.condition(pokemon, attacker, move);
(args[0] as Utils.NumberHolder).value = Utils.toDmgValue((args[0] as Utils.NumberHolder).value * this.damageMultiplier);
return true;
} }
return false; applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
(args[0] as Utils.NumberHolder).value = Utils.toDmgValue((args[0] as Utils.NumberHolder).value * this.damageMultiplier);
return true;
} }
} }
@ -403,6 +407,10 @@ export class TypeImmunityAbAttr extends PreDefendAbAttr {
this.condition = condition ?? null; this.condition = condition ?? null;
} }
willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
return ![ MoveTarget.BOTH_SIDES, MoveTarget.ENEMY_SIDE, MoveTarget.USER_SIDE ].includes(move.moveTarget) && attacker !== pokemon && attacker.getMoveType(move) === this.immuneType;
}
/** /**
* Applies immunity if this ability grants immunity to the type of the given move. * Applies immunity if this ability grants immunity to the type of the given move.
* @param pokemon {@linkcode Pokemon} The defending Pokemon. * @param pokemon {@linkcode Pokemon} The defending Pokemon.
@ -414,16 +422,9 @@ export class TypeImmunityAbAttr extends PreDefendAbAttr {
* @param args [1] - Whether the move is simulated. * @param args [1] - Whether the move is simulated.
*/ */
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
// Field moves should ignore immunity
if ([ MoveTarget.BOTH_SIDES, MoveTarget.ENEMY_SIDE, MoveTarget.USER_SIDE ].includes(move.moveTarget)) {
return false;
}
if (attacker !== pokemon && attacker.getMoveType(move) === this.immuneType) {
(args[0] as Utils.NumberHolder).value = 0; (args[0] as Utils.NumberHolder).value = 0;
return true; return true;
} }
return false;
}
getImmuneType(): Type | null { getImmuneType(): Type | null {
return this.immuneType; return this.immuneType;
@ -439,6 +440,11 @@ export class AttackTypeImmunityAbAttr extends TypeImmunityAbAttr {
super(immuneType, condition); super(immuneType, condition);
} }
willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
return move.category !== MoveCategory.STATUS && !move.hasAttr(NeutralDamageAgainstFlyingTypeMultiplierAttr)
&& super.willSucceedPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args);
}
/** /**
* Applies immunity if the move used is not a status move. * Applies immunity if the move used is not a status move.
* Type immunity abilities that do not give additional benefits (HP recovery, stat boosts, etc) are not immune to status moves of the type * Type immunity abilities that do not give additional benefits (HP recovery, stat boosts, etc) are not immune to status moves of the type
@ -446,10 +452,7 @@ export class AttackTypeImmunityAbAttr extends TypeImmunityAbAttr {
*/ */
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
// this is a hacky way to fix the Levitate/Thousand Arrows interaction, but it works for now... // this is a hacky way to fix the Levitate/Thousand Arrows interaction, but it works for now...
if (move.category !== MoveCategory.STATUS && !move.hasAttr(NeutralDamageAgainstFlyingTypeMultiplierAttr)) { super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args);
return super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args);
}
return false;
} }
} }
@ -458,10 +461,12 @@ export class TypeImmunityHealAbAttr extends TypeImmunityAbAttr {
super(immuneType); super(immuneType);
} }
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
const ret = super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args); return super.willSucceedPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args);
}
if (ret) { applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args);
if (!pokemon.isFullHp() && !simulated) { if (!pokemon.isFullHp() && !simulated) {
const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name;
globalScene.unshiftPhase(new PokemonHealPhase(pokemon.getBattlerIndex(), globalScene.unshiftPhase(new PokemonHealPhase(pokemon.getBattlerIndex(),
@ -470,9 +475,6 @@ export class TypeImmunityHealAbAttr extends TypeImmunityAbAttr {
} }
return true; return true;
} }
return false;
}
} }
class TypeImmunityStatStageChangeAbAttr extends TypeImmunityAbAttr { class TypeImmunityStatStageChangeAbAttr extends TypeImmunityAbAttr {
@ -486,17 +488,17 @@ class TypeImmunityStatStageChangeAbAttr extends TypeImmunityAbAttr {
this.stages = stages; this.stages = stages;
} }
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
const ret = super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args); return super.willSucceedPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args);
}
if (ret) { applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args);
cancelled.value = true; // Suppresses "No Effect" message cancelled.value = true; // Suppresses "No Effect" message
if (!simulated) { if (!simulated) {
globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ this.stat ], this.stages)); globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ this.stat ], this.stages));
} }
} return true;
return ret;
} }
} }
@ -511,17 +513,18 @@ class TypeImmunityAddBattlerTagAbAttr extends TypeImmunityAbAttr {
this.turnCount = turnCount; this.turnCount = turnCount;
} }
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
const ret = super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args); return super.willSucceedPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args);
}
if (ret) { applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args);
cancelled.value = true; // Suppresses "No Effect" message cancelled.value = true; // Suppresses "No Effect" message
if (!simulated) { if (!simulated) {
pokemon.addTag(this.tagType, this.turnCount, undefined, pokemon.id); pokemon.addTag(this.tagType, this.turnCount, undefined, pokemon.id);
} }
}
return ret; return true;
} }
} }
@ -530,20 +533,19 @@ export class NonSuperEffectiveImmunityAbAttr extends TypeImmunityAbAttr {
super(null, condition); super(null, condition);
} }
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
const modifierValue = args.length > 0 const modifierValue = args.length > 0
? (args[0] as Utils.NumberHolder).value ? (args[0] as Utils.NumberHolder).value
: pokemon.getAttackTypeEffectiveness(attacker.getMoveType(move), attacker, undefined, undefined, move); : pokemon.getAttackTypeEffectiveness(attacker.getMoveType(move), attacker, undefined, undefined, move);
return move instanceof AttackMove && modifierValue < 2;
}
if (move instanceof AttackMove && modifierValue < 2) { applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
cancelled.value = true; // Suppresses "No Effect" message cancelled.value = true; // Suppresses "No Effect" message
(args[0] as Utils.NumberHolder).value = 0; (args[0] as Utils.NumberHolder).value = 0;
return true; return true;
} }
return false;
}
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:nonSuperEffectiveImmunity", { return i18next.t("abilityTriggers:nonSuperEffectiveImmunity", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
@ -558,6 +560,12 @@ export class NonSuperEffectiveImmunityAbAttr extends TypeImmunityAbAttr {
* @extends PreDefendAbAttr * @extends PreDefendAbAttr
*/ */
export class FullHpResistTypeAbAttr extends PreDefendAbAttr { export class FullHpResistTypeAbAttr extends PreDefendAbAttr {
willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
const typeMultiplier = args[0];
return (typeMultiplier && typeMultiplier instanceof Utils.NumberHolder) && !(move && move.hasAttr(FixedDamageAttr)) && pokemon.isFullHp() && typeMultiplier.value > 0.5;
}
/** /**
* Reduces a type multiplier to 0.5 if the source is at full HP. * Reduces a type multiplier to 0.5 if the source is at full HP.
* @param pokemon {@linkcode Pokemon} the Pokemon with this ability * @param pokemon {@linkcode Pokemon} the Pokemon with this ability
@ -571,21 +579,10 @@ export class FullHpResistTypeAbAttr extends PreDefendAbAttr {
*/ */
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, args: any[]): boolean | Promise<boolean> { applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, args: any[]): boolean | Promise<boolean> {
const typeMultiplier = args[0]; const typeMultiplier = args[0];
if (!(typeMultiplier && typeMultiplier instanceof Utils.NumberHolder)) {
return false;
}
if (move && move.hasAttr(FixedDamageAttr)) {
return false;
}
if (pokemon.isFullHp() && typeMultiplier.value > 0.5) {
typeMultiplier.value = 0.5; typeMultiplier.value = 0.5;
pokemon.turnData.moveEffectiveness = 0.5; pokemon.turnData.moveEffectiveness = 0.5;
return true; return true;
} }
return false;
}
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:fullHpResistType", { return i18next.t("abilityTriggers:fullHpResistType", {
@ -601,18 +598,15 @@ export class PostDefendAbAttr extends AbAttr {
} }
export class FieldPriorityMoveImmunityAbAttr extends PreDefendAbAttr { export class FieldPriorityMoveImmunityAbAttr extends PreDefendAbAttr {
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
if (move.moveTarget === MoveTarget.USER || move.moveTarget === MoveTarget.NEAR_ALLY) { willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
return false; return !(move.moveTarget === MoveTarget.USER || move.moveTarget === MoveTarget.NEAR_ALLY) && move.getPriority(attacker) > 0 && !move.isMultiTarget();
} }
if (move.getPriority(attacker) > 0 && !move.isMultiTarget()) { applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
cancelled.value = true; cancelled.value = true;
return true; return true;
} }
return false;
}
} }
export class PostStatStageChangeAbAttr extends AbAttr { export class PostStatStageChangeAbAttr extends AbAttr {
@ -630,13 +624,13 @@ export class MoveImmunityAbAttr extends PreDefendAbAttr {
this.immuneCondition = immuneCondition; this.immuneCondition = immuneCondition;
} }
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
if (this.immuneCondition(pokemon, attacker, move)) { return this.immuneCondition(pokemon, attacker, move);
cancelled.value = true;
return true;
} }
return false; applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
cancelled.value = true;
return true;
} }
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
@ -651,14 +645,16 @@ export class MoveImmunityAbAttr extends PreDefendAbAttr {
* @extends PreDefendAbAttr * @extends PreDefendAbAttr
*/ */
export class WonderSkinAbAttr extends PreDefendAbAttr { export class WonderSkinAbAttr extends PreDefendAbAttr {
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
const moveAccuracy = args[0] as Utils.NumberHolder; const moveAccuracy = args[0] as Utils.NumberHolder;
if (move.category === MoveCategory.STATUS && moveAccuracy.value >= 50) { return move.category === MoveCategory.STATUS && moveAccuracy.value >= 50;
moveAccuracy.value = 50;
return true;
} }
return false; applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
const moveAccuracy = args[0] as Utils.NumberHolder;
moveAccuracy.value = 50;
return true;
} }
} }
@ -672,13 +668,15 @@ export class MoveImmunityStatStageChangeAbAttr extends MoveImmunityAbAttr {
this.stages = stages; this.stages = stages;
} }
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
const ret = super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args); return !simulated && super.willSucceedPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args);
if (ret && !simulated) {
globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ this.stat ], this.stages));
} }
return ret; applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
super.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args);
globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ this.stat ], this.stages));
return true;
} }
} }
/** /**
@ -1209,18 +1207,17 @@ export class MoveEffectChanceMultiplierAbAttr extends AbAttr {
* @see {@linkcode applyPreDefend} * @see {@linkcode applyPreDefend}
*/ */
export class IgnoreMoveEffectsAbAttr extends PreDefendAbAttr { export class IgnoreMoveEffectsAbAttr extends PreDefendAbAttr {
willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
return (args[0] as Utils.NumberHolder).value > 0;
}
/** /**
* @param args [0]: {@linkcode Utils.NumberHolder} Move additional effect chance. * @param args [0]: {@linkcode Utils.NumberHolder} Move additional effect chance.
*/ */
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
if ((args[0] as Utils.NumberHolder).value <= 0) {
return false;
}
(args[0] as Utils.NumberHolder).value = 0; (args[0] as Utils.NumberHolder).value = 0;
return true; return true;
} }
} }
@ -4697,6 +4694,10 @@ export class FormBlockDamageAbAttr extends ReceivedMoveDamageMultiplierAbAttr {
this.triggerMessageFunc = triggerMessageFunc; this.triggerMessageFunc = triggerMessageFunc;
} }
willSucceedPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder | null, args: any[]): boolean {
return this.condition(pokemon, attacker, move) && !move.hitsSubstitute(attacker, pokemon);
}
/** /**
* Applies the pre-defense ability to the Pokémon. * Applies the pre-defense ability to the Pokémon.
* Removes the appropriate `BattlerTagType` when hit by an attack and is in its defense form. * Removes the appropriate `BattlerTagType` when hit by an attack and is in its defense form.
@ -4710,7 +4711,6 @@ export class FormBlockDamageAbAttr extends ReceivedMoveDamageMultiplierAbAttr {
* @returns `true` if the immunity was applied. * @returns `true` if the immunity was applied.
*/ */
override applyPreDefend(pokemon: Pokemon, _passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, _cancelled: Utils.BooleanHolder, args: any[]): boolean { override applyPreDefend(pokemon: Pokemon, _passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, _cancelled: Utils.BooleanHolder, args: any[]): boolean {
if (this.condition(pokemon, attacker, move) && !move.hitsSubstitute(attacker, pokemon)) {
if (!simulated) { if (!simulated) {
(args[0] as Utils.NumberHolder).value = this.multiplier; (args[0] as Utils.NumberHolder).value = this.multiplier;
pokemon.removeTag(this.tagType); pokemon.removeTag(this.tagType);
@ -4721,9 +4721,6 @@ export class FormBlockDamageAbAttr extends ReceivedMoveDamageMultiplierAbAttr {
return true; return true;
} }
return false;
}
/** /**
* Gets the message triggered when the Pokémon avoids damage using the form-changing ability. * Gets the message triggered when the Pokémon avoids damage using the form-changing ability.
* @param pokemon The Pokémon with the ability. * @param pokemon The Pokémon with the ability.
@ -5193,7 +5190,7 @@ export function applyPostBattleInitAbAttrs(attrType: Constructor<PostBattleInitA
export function applyPreDefendAbAttrs(attrType: Constructor<PreDefendAbAttr>, export function applyPreDefendAbAttrs(attrType: Constructor<PreDefendAbAttr>,
pokemon: Pokemon, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, simulated: boolean = false, ...args: any[]): Promise<void> { pokemon: Pokemon, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, simulated: boolean = false, ...args: any[]): Promise<void> {
return applyAbAttrsInternal<PreDefendAbAttr>(attrType, pokemon, (attr, passive) => attr.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args), args, false, simulated); return applyAbAttrsInternal<PreDefendAbAttr>(attrType, pokemon, (attr, passive) => attr.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args), (attr, passive) => attr.willSucceedPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args), args, false, simulated);
} }
export function applyPostDefendAbAttrs(attrType: Constructor<PostDefendAbAttr>, export function applyPostDefendAbAttrs(attrType: Constructor<PostDefendAbAttr>,