Fixes recoil damage calculation (#1063)

Recoil damage previously used the total damage dealt by the user instead of using the damage dealt in the current turn.
This commit is contained in:
rayanzmn 2024-05-20 00:54:17 +02:00 committed by GitHub
parent f649179e24
commit f1394307f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -782,8 +782,8 @@ export class RecoilAttr extends MoveEffectAttr {
if (cancelled.value)
return false;
const recoilDamage = Math.max(Math.floor((!this.useHp ? user.turnData.damageDealt : user.getMaxHp()) * this.damageRatio),
user.turnData.damageDealt ? 1 : 0);
const recoilDamage = Math.max(Math.floor((!this.useHp ? user.turnData.currDamageDealt : user.getMaxHp()) * this.damageRatio),
user.turnData.currDamageDealt ? 1 : 0);
if (!recoilDamage)
return false;

View File

@ -1659,6 +1659,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.scene.gameData.gameStats.highestDamage = damage.value;
}
source.turnData.damageDealt += damage.value;
source.turnData.currDamageDealt = damage.value;
this.battleData.hitCount++;
const attackResult = { move: move.id, result: result as DamageResult, damage: damage.value, critical: isCritical, sourceId: source.id };
this.turnData.attacksReceived.unshift(attackResult);
@ -3381,6 +3382,7 @@ export class PokemonTurnData {
public hitCount: integer;
public hitsLeft: integer;
public damageDealt: integer = 0;
public currDamageDealt: integer = 0;
public damageTaken: integer = 0;
public attacksReceived: AttackMoveResult[] = [];
}