mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-27 09:16:03 +00:00
Fix logic to prevent healing tokens from healing to full
This commit is contained in:
parent
91ab0b4b32
commit
68f0692849
@ -1915,7 +1915,7 @@ export class EnemyTurnHealModifier extends EnemyPersistentModifier {
|
|||||||
if (pokemon.getHpRatio() < 1) {
|
if (pokemon.getHpRatio() < 1) {
|
||||||
const scene = pokemon.scene;
|
const scene = pokemon.scene;
|
||||||
scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(),
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1843,16 +1843,16 @@ export class TurnEndPhase extends FieldPhase {
|
|||||||
|
|
||||||
this.scene.applyModifiers(TurnHealModifier, pokemon.isPlayer(), pokemon);
|
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()) {
|
if (this.scene.arena.terrain?.terrainType === TerrainType.GRASSY && pokemon.isGrounded()) {
|
||||||
this.scene.unshiftPhase(new PokemonHealPhase(this.scene, pokemon.getBattlerIndex(),
|
this.scene.unshiftPhase(new PokemonHealPhase(this.scene, pokemon.getBattlerIndex(),
|
||||||
Math.max(pokemon.getMaxHp() >> 4, 1), getPokemonMessage(pokemon, '\'s HP was restored.'), true));
|
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);
|
applyPostTurnAbAttrs(PostTurnAbAttr, pokemon);
|
||||||
|
|
||||||
this.scene.applyModifiers(TurnHeldItemTransferModifier, pokemon.isPlayer(), pokemon);
|
this.scene.applyModifiers(TurnHeldItemTransferModifier, pokemon.isPlayer(), pokemon);
|
||||||
@ -3499,8 +3499,9 @@ export class PokemonHealPhase extends CommonAnimPhase {
|
|||||||
private skipAnim: boolean;
|
private skipAnim: boolean;
|
||||||
private revive: boolean;
|
private revive: boolean;
|
||||||
private healStatus: 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);
|
super(scene, battlerIndex, undefined, CommonAnim.HEALTH_UP);
|
||||||
|
|
||||||
this.hpHealed = hpHealed;
|
this.hpHealed = hpHealed;
|
||||||
@ -3509,6 +3510,7 @@ export class PokemonHealPhase extends CommonAnimPhase {
|
|||||||
this.skipAnim = skipAnim;
|
this.skipAnim = skipAnim;
|
||||||
this.revive = revive;
|
this.revive = revive;
|
||||||
this.healStatus = healStatus;
|
this.healStatus = healStatus;
|
||||||
|
this.preventFullHeal = preventFullHeal;
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
@ -3536,6 +3538,9 @@ export class PokemonHealPhase extends CommonAnimPhase {
|
|||||||
if (!this.revive)
|
if (!this.revive)
|
||||||
this.scene.applyModifiers(HealingBoosterModifier, this.player, hpRestoreMultiplier);
|
this.scene.applyModifiers(HealingBoosterModifier, this.player, hpRestoreMultiplier);
|
||||||
const healAmount = new Utils.NumberHolder(Math.floor(this.hpHealed * hpRestoreMultiplier.value));
|
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);
|
healAmount.value = pokemon.heal(healAmount.value);
|
||||||
if (healAmount.value)
|
if (healAmount.value)
|
||||||
this.scene.damageNumberHandler.add(pokemon, healAmount.value, HitResult.HEAL);
|
this.scene.damageNumberHandler.add(pokemon, healAmount.value, HitResult.HEAL);
|
||||||
|
Loading…
Reference in New Issue
Block a user