Assurance effect implementation

Theoretically implemented for all use cases but only tested for regular damage so far.
This commit is contained in:
InfernoVulpix 2024-04-25 20:51:04 -04:00 committed by Samuel H
parent 0eabfd56e3
commit d4c265443f
4 changed files with 12 additions and 1 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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)

View File

@ -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[] = [];
}