Fixed damage tracking issues

This commit is contained in:
Bertie690 2025-05-14 19:12:25 -04:00
parent 1f7c67423b
commit 09bdfa395b
5 changed files with 8 additions and 26 deletions

View File

@ -5540,24 +5540,6 @@ function applySingleAbAttrs<TAttr extends AbAttr>(
}
}
/**
* Calculates the amount of recovery from the Shell Bell item.
*
* If the Pokémon is holding a Shell Bell, this function computes the amount of health
* recovered based on the damage dealt in the current turn. The recovery is multiplied by the
* Shell Bell's modifier (if any).
*
* @param pokemon - The Pokémon whose Shell Bell recovery is being calculated.
* @returns The amount of health recovered by Shell Bell, or `0` if none are present.
*/
function calculateShellBellRecovery(pokemon: Pokemon): number {
const shellBellModifier = pokemon.getHeldItems().find(m => m instanceof HitHealModifier);
if (shellBellModifier) {
return toDmgValue(pokemon.turnData.lastMoveDamageDealt / 8) * shellBellModifier.stackCount;
}
return 0;
}
/**
* Triggers after the Pokemon takes any damage
* @extends AbAttr
@ -5645,7 +5627,7 @@ export class PostDamageForceSwitchAbAttr extends ForceSwitch(PostDamageAbAttr) {
return false;
}
return this.canSwitchOut(pokemon, oppponent)
return this.canSwitchOut(pokemon, undefined)
}
/**

View File

@ -34,7 +34,7 @@ export function ForceSwitch<TBase extends SubMoveOrAbAttr>(Base: TBase) {
* @param switchOutTarget - The {@linkcode Pokemon} attempting to switch out.
* @param opponent - The {@linkcode Pokemon} opposing the currently switched out Pokemon.
* Unused if {@linkcode selfSwitch} is `true`, in which case it should conventionally be set to `undefined`.
* Unused if {@linkcode selfSwitch} is `true`, as it is only used to check Suction Cups.
* @returns Whether {@linkcode switchOutTarget} can be switched out by the current Move or Ability.
*/
protected canSwitchOut(switchOutTarget: Pokemon, opponent: Pokemon | undefined): boolean {

View File

@ -1633,6 +1633,7 @@ export class CelebrateAttr extends MoveEffectAttr {
}
export class RecoilAttr extends MoveEffectAttr {
/** Whether the recoil damage should use the user's max HP (`true`) or damage dealt `false`. */
private useHp: boolean;
private damageRatio: number;
private unblockable: boolean;
@ -1665,8 +1666,8 @@ export class RecoilAttr extends MoveEffectAttr {
return false;
}
const damageValue = (!this.useHp ? user.turnData.lastMoveDamageDealt : user.getMaxHp()) * this.damageRatio;
const minValue = user.turnData.lastMoveDamageDealt ? 1 : 0;
const damageValue = (!this.useHp ? user.turnData.singleHitDamageDealt : user.getMaxHp()) * this.damageRatio;
const minValue = user.turnData.singleHitDamageDealt ? 1 : 0;
const recoilDamage = toDmgValue(damageValue, minValue);
if (!recoilDamage) {
return false;

View File

@ -10,6 +10,7 @@ import {
IgnoreMoveEffectsAbAttr,
MaxMultiHitAbAttr,
PostAttackAbAttr,
PostDamageAbAttr,
PostDefendAbAttr,
ReflectStatusMoveAbAttr,
} from "#app/data/abilities/ability";
@ -100,9 +101,6 @@ export class MoveEffectPhase extends PokemonPhase {
/** Phases queued during moves */
private queuedPhases: Phase[] = [];
/** The amount of direct attack damage taken by each of this Phase's targets. */
private targetDamageTaken: number[] = [];
/**
* @param reflected Indicates that the move was reflected by the user due to magic coat or magic bounce
* @param virtual Indicates that the move is a virtual move (i.e. called by metronome)
@ -125,7 +123,6 @@ export class MoveEffectPhase extends PokemonPhase {
this.targets = targets;
this.hitChecks = Array(this.targets.length).fill([HitCheckResult.PENDING, 0]);
this.targetDamageTaken = Array(this.targets.length).fill(0);
}
/**
@ -788,6 +785,7 @@ export class MoveEffectPhase extends PokemonPhase {
}
if (this.lastHit) {
globalScene.triggerPokemonFormChange(user, SpeciesFormChangePostMoveTrigger);
applyPostDamageAbAttrs(PostDamageAbAttr, target, target.turnData.lastMoveDamageDealt);
}
}

View File

@ -160,6 +160,7 @@ export class MovePhase extends BattlePhase {
}
this.pokemon.turnData.acted = true;
this.pokemon.turnData.lastMoveDamageDealt = 0;
// Reset hit-related turn data when starting follow-up moves (e.g. Metronomed moves, Dancer repeats)
if (this.followUp) {