diff --git a/src/data/move.ts b/src/data/move.ts index f313516fd37..18605985e6d 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -747,16 +747,26 @@ export class SacrificialAttr extends MoveEffectAttr { super(true, MoveEffectTrigger.PRE_APPLY); } + /** + * Applies the sacrificial effect to the user + * @param user Pokemon that used the move + * @param target The target of the move + * @param move Move with this attribute + * @param args N/A + */ apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - - - user.damageAndUpdate(user.hp, HitResult.OTHER, false, true, true); user.turnData.damageTaken += user.hp; return true; } + /** + * + * @param user Pokemon that used the move + * @param target The target of the move + * @param move Move with this attribute + */ getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { if (user.isBoss()) return -20; @@ -766,15 +776,23 @@ export class SacrificialAttr extends MoveEffectAttr { /** - * Attribute used for moves which self KO the user but only if the move hits a target + * * Attribute used for moves which self KO the user but only if the move hits a target */ export class SacrificialAttrOnHit extends MoveEffectAttr { constructor() { super(true, MoveEffectTrigger.PRE_APPLY); } + /** + * Applies the sacrificial effect to the user + * @param user Pokemon that used the move + * @param target The target of the move + * @param move Move with this attribute + * @param args N/A + */ apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + // If the move hits a target, the user will self KO if (!super.apply(user, target, move, args)) return false; @@ -784,6 +802,12 @@ export class SacrificialAttrOnHit extends MoveEffectAttr { return true; } + /** + * + * @param user Pokemon that used the move + * @param target The target of the move + * @param move Move with this attribute + */ getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { if (user.isBoss()) return -20; diff --git a/src/phases.ts b/src/phases.ts index 5df00f6f82e..f93401bbd19 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2295,13 +2295,12 @@ export class MovePhase extends BattlePhase { return this.end(); } + // Check if the move has no valid targets (because they are flying, etc.) - if the used move is sacrificial it does not need a target so we add the user as a target so the move does not fail if (targets.length === 0 && this.move.getMove().getAttrs(SacrificialAttr).length) { // Add the user as a target if the move is sacrificial targets.push(this.pokemon); } - - if (!moveQueue.length || !moveQueue.shift().ignorePP) // using .shift here clears out two turn moves once they've been used this.move.usePp(ppUsed); @@ -2465,13 +2464,14 @@ export class MoveEffectPhase extends PokemonPhase { // Move animation only needs one target new MoveAnim(this.move.getMove().id as Moves, user, this.getTarget()?.getBattlerIndex()).play(this.scene, () => { - // Check if the user is in the targets list for sacrificial moves + // Check if the user is in the targets list for sacrificial moves, if not add them if (this.move.getMove().getAttrs(SacrificialAttr).length && !targets.includes(user)) { targets.push(user); targetHitChecks[user.getBattlerIndex()] = true; } for (let target of targets) { if (!targetHitChecks[target.getBattlerIndex()]) { + // If we have a sacrifical move, and the target isnt the user - it should not "miss". So we skip the miss check if (this.move.getMove().getAttrs(SacrificialAttr).length && target !== user) { continue; }