diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 3468b40db0c..01bc8d252ec 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -1915,7 +1915,7 @@ export class EnemyTurnHealModifier extends EnemyPersistentModifier { if (pokemon.getHpRatio() < 1) { const scene = pokemon.scene; scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), - Math.max(Math.min(Math.floor(pokemon.getMaxHp() / (100 / this.healPercent)) * this.stackCount, (pokemon.getMaxHp() - pokemon.hp) - 1), 1), getPokemonMessage(pokemon, `\nrestored some HP!`), true)); + Math.max(Math.floor(pokemon.getMaxHp() / (100 / this.healPercent)) * this.stackCount, 1), getPokemonMessage(pokemon, `\nrestored some HP!`), true, false, false, false, true)); return true; } diff --git a/src/phases.ts b/src/phases.ts index 34b995ab306..77958335aaa 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1843,16 +1843,16 @@ export class TurnEndPhase extends FieldPhase { this.scene.applyModifiers(TurnHealModifier, pokemon.isPlayer(), pokemon); - if (!pokemon.isPlayer()) { - this.scene.applyModifiers(EnemyTurnHealModifier, false, pokemon); - this.scene.applyModifier(EnemyStatusEffectHealChanceModifier, false, pokemon); - } - if (this.scene.arena.terrain?.terrainType === TerrainType.GRASSY && pokemon.isGrounded()) { this.scene.unshiftPhase(new PokemonHealPhase(this.scene, pokemon.getBattlerIndex(), Math.max(pokemon.getMaxHp() >> 4, 1), getPokemonMessage(pokemon, '\'s HP was restored.'), true)); } + if (!pokemon.isPlayer()) { + this.scene.applyModifiers(EnemyTurnHealModifier, false, pokemon); + this.scene.applyModifier(EnemyStatusEffectHealChanceModifier, false, pokemon); + } + applyPostTurnAbAttrs(PostTurnAbAttr, pokemon); this.scene.applyModifiers(TurnHeldItemTransferModifier, pokemon.isPlayer(), pokemon); @@ -3499,8 +3499,9 @@ export class PokemonHealPhase extends CommonAnimPhase { private skipAnim: boolean; private revive: boolean; private healStatus: boolean; + private preventFullHeal: boolean; - constructor(scene: BattleScene, battlerIndex: BattlerIndex, hpHealed: integer, message: string, showFullHpMessage: boolean, skipAnim: boolean = false, revive: boolean = false, healStatus: boolean = false) { + constructor(scene: BattleScene, battlerIndex: BattlerIndex, hpHealed: integer, message: string, showFullHpMessage: boolean, skipAnim: boolean = false, revive: boolean = false, healStatus: boolean = false, preventFullHeal: boolean = false) { super(scene, battlerIndex, undefined, CommonAnim.HEALTH_UP); this.hpHealed = hpHealed; @@ -3509,6 +3510,7 @@ export class PokemonHealPhase extends CommonAnimPhase { this.skipAnim = skipAnim; this.revive = revive; this.healStatus = healStatus; + this.preventFullHeal = preventFullHeal; } start() { @@ -3536,6 +3538,9 @@ export class PokemonHealPhase extends CommonAnimPhase { if (!this.revive) this.scene.applyModifiers(HealingBoosterModifier, this.player, hpRestoreMultiplier); const healAmount = new Utils.NumberHolder(Math.floor(this.hpHealed * hpRestoreMultiplier.value)); + // Prevent healing to full if specified (in case of healing tokens so Sturdy doesn't cause a softlock) + if (this.preventFullHeal && pokemon.hp + healAmount.value >= pokemon.getMaxHp()) + healAmount.value = (pokemon.getMaxHp() - pokemon.hp) - 1; healAmount.value = pokemon.heal(healAmount.value); if (healAmount.value) this.scene.damageNumberHandler.add(pokemon, healAmount.value, HitResult.HEAL);