From d4c265443fa122b952d46786992b1d4c5dc0088e Mon Sep 17 00:00:00 2001 From: InfernoVulpix Date: Thu, 25 Apr 2024 20:51:04 -0400 Subject: [PATCH] Assurance effect implementation Theoretically implemented for all use cases but only tested for regular damage so far. --- src/data/ability.ts | 3 +++ src/data/arena-tag.ts | 2 ++ src/data/move.ts | 6 +++++- src/field/pokemon.ts | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index bae2744ae..e75649a42 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -453,6 +453,7 @@ export class PostDefendDisguiseAbAttr extends PostDefendAbAttr { if (!recoilDamage) return false; pokemon.damageAndUpdate(recoilDamage, HitResult.OTHER); + pokemon.turnData.damageTaken += recoilDamage; pokemon.scene.queueMessage(getPokemonMessage(pokemon, '\'s disguise was busted!')); return true; } @@ -733,6 +734,7 @@ export class PostDefendContactDamageAbAttr extends PostDefendAbAttr { applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { if (move.getMove().checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) { attacker.damageAndUpdate(Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)), HitResult.OTHER); + attacker.turnData.damageTaken += Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)); return true; } @@ -2070,6 +2072,7 @@ export class PostFaintContactDamageAbAttr extends PostFaintAbAttr { return false; } attacker.damageAndUpdate(Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)), HitResult.OTHER); + attacker.turnData.damageTaken += Math.ceil(attacker.getMaxHp() * (1 / this.damageRatio)); return true; } diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index c2430db95..669971da3 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -252,6 +252,7 @@ class SpikesTag extends ArenaTrapTag { pokemon.scene.queueMessage(getPokemonMessage(pokemon, ' is hurt\nby the spikes!')); pokemon.damageAndUpdate(damage, HitResult.OTHER); + pokemon.turnData.damageTaken += damage; return true; } } @@ -382,6 +383,7 @@ class StealthRockTag extends ArenaTrapTag { const damage = Math.ceil(pokemon.getMaxHp() * damageHpRatio); pokemon.scene.queueMessage(`Pointed stones dug into\n${pokemon.name}!`); pokemon.damageAndUpdate(damage, HitResult.OTHER); + pokemon.turnData.damageTaken += damage; } return false; diff --git a/src/data/move.ts b/src/data/move.ts index b4604f7fc..02b627ca9 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -695,6 +695,7 @@ export class RecoilAttr extends MoveEffectAttr { user.damageAndUpdate(recoilDamage, HitResult.OTHER, false, true, true); user.scene.queueMessage(getPokemonMessage(user, ' is hit\nwith recoil!')); + user.turnData.damageTaken += recoilDamage; return true; } @@ -714,6 +715,7 @@ export class SacrificialAttr extends MoveEffectAttr { return false; user.damageAndUpdate(user.hp, HitResult.OTHER, false, true, true); + user.turnData.damageTaken += user.hp; return true; } @@ -884,6 +886,7 @@ export class HitHealAttr extends MoveEffectAttr { !reverseDrain ? healAmount : healAmount * -1, !reverseDrain ? getPokemonMessage(target, ` had its\nenergy drained!`) : undefined, false, true)); + if (reverseDrain) user.turnData.damageTaken += healAmount; return true; } @@ -2392,6 +2395,7 @@ const crashDamageFunc = (user: Pokemon, move: Move) => { user.damageAndUpdate(Math.floor(user.getMaxHp() / 2), HitResult.OTHER, false, true); user.scene.queueMessage(getPokemonMessage(user, ' kept going\nand crashed!')); + user.turnData.damageTaken += Math.floor(user.getMaxHp() / 2); return true; }; @@ -4741,7 +4745,7 @@ export function initMoves() { new AttackMove(Moves.PAYBACK, Type.DARK, MoveCategory.PHYSICAL, 50, 100, 10, -1, 0, 4) .attr(MovePowerMultiplierAttr, (user, target, move) => target.getLastXMoves(1).find(m => m.turn === target.scene.currentBattle.turn) || user.scene.currentBattle.turnCommands[target.getBattlerIndex()].command === Command.BALL ? 2 : 1), new AttackMove(Moves.ASSURANCE, Type.DARK, MoveCategory.PHYSICAL, 60, 100, 10, -1, 0, 4) - .partial(), + .attr(MovePowerMultiplierAttr, (user, target, move) => target.turnData.damageTaken > 0 ? 2 : 1), new StatusMove(Moves.EMBARGO, Type.DARK, 100, 15, -1, 0, 4) .unimplemented(), new AttackMove(Moves.FLING, Type.DARK, MoveCategory.PHYSICAL, -1, 100, 10, -1, 0, 4) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index fae667a71..e4db82f3d 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1390,6 +1390,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const oneHitKo = result === HitResult.ONE_HIT_KO; damage.value = this.damageAndUpdate(damage.value, result as DamageResult, isCritical, oneHitKo, oneHitKo); + this.turnData.damageTaken += damage.value; if (isCritical) this.scene.queueMessage('A critical hit!'); this.scene.setPhaseQueueSplice(); @@ -2976,6 +2977,7 @@ export class PokemonTurnData { public hitCount: integer; public hitsLeft: integer; public damageDealt: integer = 0; + public damageTaken: integer = 0; public attacksReceived: AttackMoveResult[] = []; }