From 9f433bcecb0326a78fca340c22fb178cf1bfb89c Mon Sep 17 00:00:00 2001 From: Benjamin Date: Wed, 30 Oct 2024 01:12:32 -0400 Subject: [PATCH] fix: if pokemon died to any move, now pass the source to faintPhase --- src/data/ability.ts | 1 - src/data/move.ts | 1 - src/field/pokemon.ts | 8 +++++--- src/phases/faint-phase.ts | 4 ++-- src/phases/post-turn-status-effect-phase.ts | 3 --- src/phases/weather-effect-phase.ts | 3 --- 6 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 45563fb4045..d761657f5cd 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -3351,7 +3351,6 @@ export class PostWeatherLapseDamageAbAttr extends PostWeatherLapseAbAttr { const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; scene.queueMessage(i18next.t("abilityTriggers:postWeatherLapseDamage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName })); pokemon.damageAndUpdate(Utils.toDmgValue(pokemon.getMaxHp() / (16 / this.damageFactor)), HitResult.OTHER); - pokemon.turnData.lastDmgSrc = WeatherType.HARSH_SUN; } return true; diff --git a/src/data/move.ts b/src/data/move.ts index d174d168bce..efdd4568927 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1434,7 +1434,6 @@ export class RecoilAttr extends MoveEffectAttr { user.damageAndUpdate(recoilDamage, HitResult.OTHER, false, true, true); user.scene.queueMessage(i18next.t("moveTriggers:hitWithRecoil", { pokemonName: getPokemonNameWithAffix(user) })); user.turnData.damageTaken += recoilDamage; - user.turnData.lastDmgSrc = user.id; return true; } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 9844a69a474..b418950ac38 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3,7 +3,7 @@ import BattleScene, { AnySound } from "#app/battle-scene"; import { Variant, VariantSet, variantColorCache } from "#app/data/variant"; import { variantData } from "#app/data/variant"; import BattleInfo, { PlayerBattleInfo, EnemyBattleInfo } from "#app/ui/battle-info"; -import Move, { HighCritAttr, HitsTagAttr, applyMoveAttrs, FixedDamageAttr, VariableAtkAttr, allMoves, MoveCategory, TypelessAttr, CritOnlyAttr, getMoveTargets, OneHitKOAttr, VariableMoveTypeAttr, VariableDefAttr, AttackMove, ModifiedDamageAttr, VariableMoveTypeMultiplierAttr, IgnoreOpponentStatStagesAttr, SacrificialAttr, VariableMoveCategoryAttr, CounterDamageAttr, StatStageChangeAttr, RechargeAttr, IgnoreWeatherTypeDebuffAttr, BypassBurnDamageReductionAttr, SacrificialAttrOnHit, OneHitKOAccuracyAttr, RespectAttackTypeImmunityAttr, MoveTarget, CombinedPledgeStabBoostAttr } from "#app/data/move"; +import Move, { HighCritAttr, HitsTagAttr, applyMoveAttrs, FixedDamageAttr, VariableAtkAttr, allMoves, MoveCategory, TypelessAttr, CritOnlyAttr, getMoveTargets, OneHitKOAttr, VariableMoveTypeAttr, VariableDefAttr, AttackMove, ModifiedDamageAttr, VariableMoveTypeMultiplierAttr, IgnoreOpponentStatStagesAttr, SacrificialAttr, VariableMoveCategoryAttr, CounterDamageAttr, StatStageChangeAttr, RechargeAttr, IgnoreWeatherTypeDebuffAttr, BypassBurnDamageReductionAttr, SacrificialAttrOnHit, OneHitKOAccuracyAttr, RespectAttackTypeImmunityAttr, MoveTarget, CombinedPledgeStabBoostAttr, PostVictoryStatStageChangeAttr } from "#app/data/move"; import { default as PokemonSpecies, PokemonSpeciesForm, getFusedSpeciesName, getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species"; import { CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER, getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters"; import { starterPassiveAbilities } from "#app/data/balance/passives"; @@ -2795,7 +2795,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.battleData.hitCount++; const attackResult = { move: move.id, result: result as DamageResult, damage: damage, critical: isCritical, sourceId: source.id, sourceBattlerIndex: source.getBattlerIndex() }; this.turnData.attacksReceived.unshift(attackResult); - this.turnData.lastDmgSrc = source; if (source.isPlayer() && !this.isPlayer()) { this.scene.applyModifiers(DamageMoneyRewardModifier, true, source, new Utils.NumberHolder(damage)); } @@ -2827,6 +2826,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (!isNullOrUndefined(destinyTag) && dmg) { // Destiny Bond will activate during FaintPhase this.scene.unshiftPhase(new FaintPhase(this.scene, this.getBattlerIndex(), isOneHitKo, destinyTag, source)); + } + if (move.getAttrs(PostVictoryStatStageChangeAttr)) { + + this.scene.unshiftPhase(new FaintPhase(this.scene, this.getBattlerIndex(), isOneHitKo, undefined, source)); } else { this.scene.unshiftPhase(new FaintPhase(this.scene, this.getBattlerIndex(), isOneHitKo)); } @@ -5124,7 +5127,6 @@ export class PokemonTurnData { public statStagesDecreased: boolean = false; public moveEffectiveness: TypeDamageMultiplier | null = null; public combiningPledge?: Moves; - public lastDmgSrc: Pokemon | WeatherType | StatusEffect; } export enum AiType { diff --git a/src/phases/faint-phase.ts b/src/phases/faint-phase.ts index fb19ca7179f..f2b43d1a611 100644 --- a/src/phases/faint-phase.ts +++ b/src/phases/faint-phase.ts @@ -96,9 +96,9 @@ export class FaintPhase extends PokemonPhase { const alivePlayField = this.scene.getField(true); alivePlayField.forEach(p => applyPostKnockOutAbAttrs(PostKnockOutAbAttr, p, pokemon)); if (pokemon.turnData?.attacksReceived?.length) { - const defeatSource = pokemon.turnData.lastDmgSrc; + const defeatSource = this.source; - if (defeatSource instanceof Pokemon && defeatSource?.isOnField()) { + if (defeatSource instanceof Pokemon && defeatSource.isOnField()) { applyPostVictoryAbAttrs(PostVictoryAbAttr, defeatSource); const pvmove = allMoves[pokemon.turnData.attacksReceived[0].move]; const pvattrs = pvmove.getAttrs(PostVictoryStatStageChangeAttr); diff --git a/src/phases/post-turn-status-effect-phase.ts b/src/phases/post-turn-status-effect-phase.ts index efbe019e3de..2efd992a2b5 100644 --- a/src/phases/post-turn-status-effect-phase.ts +++ b/src/phases/post-turn-status-effect-phase.ts @@ -28,16 +28,13 @@ export class PostTurnStatusEffectPhase extends PokemonPhase { switch (pokemon.status.effect) { case StatusEffect.POISON: damage.value = Math.max(pokemon.getMaxHp() >> 3, 1); - pokemon.turnData.lastDmgSrc = StatusEffect.POISON; break; case StatusEffect.TOXIC: damage.value = Math.max(Math.floor((pokemon.getMaxHp() / 16) * pokemon.status.toxicTurnCount), 1); - pokemon.turnData.lastDmgSrc = StatusEffect.TOXIC; break; case StatusEffect.BURN: damage.value = Math.max(pokemon.getMaxHp() >> 4, 1); applyAbAttrs(ReduceBurnDamageAbAttr, pokemon, null, false, damage); - pokemon.turnData.lastDmgSrc = StatusEffect.BURN; break; } if (damage.value) { diff --git a/src/phases/weather-effect-phase.ts b/src/phases/weather-effect-phase.ts index 1a5865faf55..b48ee342780 100644 --- a/src/phases/weather-effect-phase.ts +++ b/src/phases/weather-effect-phase.ts @@ -54,9 +54,6 @@ export class WeatherEffectPhase extends CommonAnimPhase { const immune = !pokemon || !!pokemon.getTypes(true, true).filter(t => this.weather?.isTypeDamageImmune(t)).length; if (!immune) { inflictDamage(pokemon); - if (this.weather?.weatherType) { - pokemon.turnData.lastDmgSrc = this.weather.weatherType; - } } }); }