Fix damage display issues with battle info
parent
1f6a6f4621
commit
6f54fa7741
|
@ -905,8 +905,7 @@ export class PostWeatherLapseDamageAbAttr extends PostWeatherLapseAbAttr {
|
|||
if (pokemon.getHpRatio() < 1) {
|
||||
const scene = pokemon.scene;
|
||||
scene.queueMessage(getPokemonMessage(pokemon, ` is hurt\nby its ${pokemon.getAbility()}!`));
|
||||
const damage = pokemon.damage(Math.ceil(pokemon.getMaxHp() / (16 / this.damageFactor)));
|
||||
scene.unshiftPhase(new DamagePhase(pokemon.scene, pokemon.getBattlerIndex(), damage, HitResult.OTHER));
|
||||
pokemon.damageAndUpdate(Math.ceil(pokemon.getMaxHp() / (16 / this.damageFactor)), HitResult.OTHER);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ class SpikesTag extends ArenaTrapTag {
|
|||
const damage = Math.ceil(pokemon.getMaxHp() * damageHpRatio);
|
||||
|
||||
pokemon.scene.queueMessage(getPokemonMessage(pokemon, ' is hurt\nby the spikes!'));
|
||||
pokemon.scene.unshiftPhase(new DamagePhase(pokemon.scene, pokemon.getBattlerIndex(), pokemon.damage(damage), HitResult.OTHER));
|
||||
pokemon.damageAndUpdate(damage, HitResult.OTHER);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ class StealthRockTag extends ArenaTrapTag {
|
|||
if (damageHpRatio) {
|
||||
const damage = Math.ceil(pokemon.getMaxHp() * damageHpRatio);
|
||||
pokemon.scene.queueMessage(`Pointed stones dug into\n${pokemon.name}!`);
|
||||
pokemon.scene.unshiftPhase(new DamagePhase(pokemon.scene, pokemon.getBattlerIndex(), pokemon.damage(damage), HitResult.OTHER));
|
||||
pokemon.damageAndUpdate(damage, HitResult.OTHER);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -179,7 +179,7 @@ export class ConfusedTag extends BattlerTag {
|
|||
const def = pokemon.getBattleStat(Stat.DEF);
|
||||
const damage = Math.ceil(((((2 * pokemon.level / 5 + 2) * 40 * atk / def) / 50) + 2) * (pokemon.randSeedInt(15, 85) / 100));
|
||||
pokemon.scene.queueMessage('It hurt itself in its\nconfusion!');
|
||||
pokemon.scene.unshiftPhase(new DamagePhase(pokemon.scene, pokemon.getBattlerIndex(), pokemon.damage(damage)));
|
||||
pokemon.damageAndUpdate(damage);
|
||||
pokemon.battleData.hitCount++;
|
||||
(pokemon.scene.getCurrentPhase() as MovePhase).cancel();
|
||||
}
|
||||
|
@ -263,9 +263,7 @@ export class SeedTag extends BattlerTag {
|
|||
if (source) {
|
||||
pokemon.scene.unshiftPhase(new CommonAnimPhase(pokemon.scene, source.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.LEECH_SEED));
|
||||
|
||||
const damage = pokemon.damage(Math.max(Math.floor(pokemon.getMaxHp() / 8), 1));
|
||||
|
||||
pokemon.scene.unshiftPhase(new DamagePhase(pokemon.scene, pokemon.getBattlerIndex(), damage));
|
||||
const damage = pokemon.damageAndUpdate(Math.max(Math.floor(pokemon.getMaxHp() / 8), 1));
|
||||
pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, source.getBattlerIndex(), damage, getPokemonMessage(pokemon, '\'s health is\nsapped by Leech Seed!'), false, true));
|
||||
}
|
||||
}
|
||||
|
@ -302,8 +300,7 @@ export class NightmareTag extends BattlerTag {
|
|||
pokemon.scene.queueMessage(getPokemonMessage(pokemon, ' is locked\nin a Nightmare!'));
|
||||
pokemon.scene.unshiftPhase(new CommonAnimPhase(pokemon.scene, pokemon.getBattlerIndex(), undefined, CommonAnim.CURSE)); // TODO: Update animation type
|
||||
|
||||
const damage = Math.ceil(pokemon.getMaxHp() / 4);
|
||||
pokemon.scene.unshiftPhase(new DamagePhase(pokemon.scene, pokemon.getBattlerIndex(), pokemon.damage(damage)));
|
||||
pokemon.damageAndUpdate(Math.ceil(pokemon.getMaxHp() / 4));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -470,8 +467,7 @@ export abstract class DamagingTrapTag extends TrappedTag {
|
|||
pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` is hurt\nby ${this.getMoveName()}!`));
|
||||
pokemon.scene.unshiftPhase(new CommonAnimPhase(pokemon.scene, pokemon.getBattlerIndex(), undefined, this.commonAnim));
|
||||
|
||||
const damage = Math.ceil(pokemon.getMaxHp() / 8);
|
||||
pokemon.scene.unshiftPhase(new DamagePhase(pokemon.scene, pokemon.getBattlerIndex(), pokemon.damage(damage)));
|
||||
pokemon.damageAndUpdate(Math.ceil(pokemon.getMaxHp() / 8))
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -615,7 +611,7 @@ export class PerishSongTag extends BattlerTag {
|
|||
if (ret)
|
||||
pokemon.scene.queueMessage(getPokemonMessage(pokemon, `\'s perish count fell to ${this.turnCount}.`));
|
||||
else
|
||||
pokemon.scene.unshiftPhase(new DamagePhase(pokemon.scene, pokemon.getBattlerIndex(), pokemon.damage(pokemon.hp, true, true), HitResult.ONE_HIT_KO));
|
||||
pokemon.damageAndUpdate(pokemon.hp, HitResult.ONE_HIT_KO, false, true, true);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -532,7 +532,7 @@ export class RecoilAttr extends MoveEffectAttr {
|
|||
if (!recoilDamage)
|
||||
return false;
|
||||
|
||||
user.scene.unshiftPhase(new DamagePhase(user.scene, user.getBattlerIndex(), user.damage(recoilDamage, true), HitResult.OTHER));
|
||||
user.damageAndUpdate(recoilDamage, HitResult.OTHER, false, true);
|
||||
user.scene.queueMessage(getPokemonMessage(user, ' is hit\nwith recoil!'));
|
||||
|
||||
return true;
|
||||
|
@ -552,7 +552,7 @@ export class SacrificialAttr extends MoveEffectAttr {
|
|||
if (!super.apply(user, target, move, args))
|
||||
return false;
|
||||
|
||||
user.scene.unshiftPhase(new DamagePhase(user.scene, user.getBattlerIndex(), user.damage(user.hp, true, true), HitResult.OTHER));
|
||||
user.damageAndUpdate(user.hp, HitResult.OTHER, false, true, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1123,8 +1123,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
this.scene.applyModifiers(EnemyDamageReducerModifier, false, damage);
|
||||
|
||||
if (damage) {
|
||||
damage.value = this.damage(damage.value);
|
||||
this.scene.unshiftPhase(new DamagePhase(this.scene, this.getBattlerIndex(), damage.value, result as DamageResult, isCritical));
|
||||
damage.value = this.damageAndUpdate(damage.value, result as DamageResult, isCritical);
|
||||
if (isCritical)
|
||||
this.scene.queueMessage('A critical hit!');
|
||||
this.scene.setPhaseQueueSplice();
|
||||
|
@ -1201,6 +1200,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
return damage;
|
||||
}
|
||||
|
||||
damageAndUpdate(damage: integer, result?: DamageResult, critical: boolean = false, ignoreSegments: boolean = false, preventEndure: boolean = false): integer {
|
||||
const damagePhase = new DamagePhase(this.scene, this.getBattlerIndex(), damage, result as DamageResult, critical);
|
||||
this.scene.unshiftPhase(damagePhase);
|
||||
damage = this.damage(damage, ignoreSegments, preventEndure);
|
||||
// Damage amount may have changed, but needed to be queued before calling damage function
|
||||
damagePhase.updateAmount(damage);
|
||||
return damage;
|
||||
}
|
||||
|
||||
heal(amount: integer): integer {
|
||||
const healAmount = Math.min(amount, this.getMaxHp() - this.hp);
|
||||
this.hp += healAmount;
|
||||
|
|
|
@ -2397,7 +2397,7 @@ export class WeatherEffectPhase extends CommonAnimPhase {
|
|||
const damage = Math.ceil(pokemon.getMaxHp() / 16);
|
||||
|
||||
this.scene.queueMessage(getWeatherDamageMessage(this.weather.weatherType, pokemon));
|
||||
this.scene.unshiftPhase(new DamagePhase(this.scene, pokemon.getBattlerIndex(), pokemon.damage(damage)));
|
||||
pokemon.damageAndUpdate(damage);
|
||||
};
|
||||
|
||||
this.executeForAll((pokemon: Pokemon) => {
|
||||
|
@ -2543,6 +2543,10 @@ export class DamagePhase extends PokemonPhase {
|
|||
this.applyDamage();
|
||||
}
|
||||
|
||||
updateAmount(amount: integer): void {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
applyDamage() {
|
||||
switch (this.damageResult) {
|
||||
case HitResult.EFFECTIVE:
|
||||
|
|
Loading…
Reference in New Issue