From b5bf9766aab5bbebaaffe6461911cc8e538b568b Mon Sep 17 00:00:00 2001 From: Christopher Schmidt Date: Thu, 27 Feb 2025 22:17:46 -0500 Subject: [PATCH] Removes unnecessary check, makes DamageResult default to EFFECTIVE, updates remaining damageAndUpdate calls to use INDIRECT --- src/data/arena-tag.ts | 2 +- src/data/battler-tags.ts | 10 +++++----- src/field/pokemon.ts | 11 ++--------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index aaa1f704169..74dbe629698 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -1148,7 +1148,7 @@ class FireGrassPledgeTag extends ArenaTag { globalScene.queueMessage(i18next.t("arenaTag:fireGrassPledgeLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); // TODO: Replace this with a proper animation globalScene.unshiftPhase(new CommonAnimPhase(pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.MAGMA_STORM)); - pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 8)); + pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 8), HitResult.INDIRECT); }); return super.lapse(arena); diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 08b662faff9..36ec3460c02 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -841,7 +841,7 @@ export class SeedTag extends BattlerTag { if (!cancelled.value) { globalScene.unshiftPhase(new CommonAnimPhase(source.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.LEECH_SEED)); - const damage = pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 8)); + const damage = pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 8), HitResult.INDIRECT); const reverseDrain = pokemon.hasAbilityWithAttr(ReverseDrainAbAttr, false); globalScene.unshiftPhase(new PokemonHealPhase(source.getBattlerIndex(), !reverseDrain ? damage : damage * -1, @@ -940,7 +940,7 @@ export class NightmareTag extends BattlerTag { applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); if (!cancelled.value) { - pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 4)); + pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 4), HitResult.INDIRECT); } } @@ -1268,7 +1268,7 @@ export abstract class DamagingTrapTag extends TrappedTag { applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); if (!cancelled.value) { - pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 8)); + pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 8), HitResult.INDIRECT); } } @@ -1981,7 +1981,7 @@ export class SaltCuredTag extends BattlerTag { if (!cancelled.value) { const pokemonSteelOrWater = pokemon.isOfType(Type.STEEL) || pokemon.isOfType(Type.WATER); - pokemon.damageAndUpdate(toDmgValue(pokemonSteelOrWater ? pokemon.getMaxHp() / 4 : pokemon.getMaxHp() / 8)); + pokemon.damageAndUpdate(toDmgValue(pokemonSteelOrWater ? pokemon.getMaxHp() / 4 : pokemon.getMaxHp() / 8), HitResult.INDIRECT); globalScene.queueMessage( i18next.t("battlerTags:saltCuredLapse", { @@ -2027,7 +2027,7 @@ export class CursedTag extends BattlerTag { applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); if (!cancelled.value) { - pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 4)); + pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 4), HitResult.INDIRECT); globalScene.queueMessage(i18next.t("battlerTags:cursedLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); } } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index aaf8da78766..0e473c970ed 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3168,15 +3168,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param ignoreFaintPhase boolean to ignore adding a FaintPhase, passsed to damage() * @returns integer of damage done */ - damageAndUpdate(damage: number, result?: DamageResult, critical: boolean = false, ignoreSegments: boolean = false, ignoreFaintPhase: boolean = false, source?: Pokemon): number { - let isIndirectDamage: boolean = true; - if (result !== undefined) { - if (result === HitResult.INDIRECT || result === HitResult.INDIRECT_KO) { - isIndirectDamage = true; - } else { - isIndirectDamage = false; - } - } + damageAndUpdate(damage: number, result: DamageResult = HitResult.EFFECTIVE, critical: boolean = false, ignoreSegments: boolean = false, ignoreFaintPhase: boolean = false, source?: Pokemon): number { + const isIndirectDamage = [ HitResult.INDIRECT, HitResult.INDIRECT_KO ].includes(result); const damagePhase = new DamageAnimPhase(this.getBattlerIndex(), damage, result as DamageResult, critical); globalScene.unshiftPhase(damagePhase); if (this.switchOutStatus && source) {