Create new turnData field for tracking damageResults, check for HitResult in Reviver Seed modifier
This commit is contained in:
parent
996ce5d986
commit
b0d29eb232
|
@ -3060,6 +3060,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
* @returns integer of damage done
|
||||
*/
|
||||
damageAndUpdate(damage: number, result?: DamageResult, critical: boolean = false, ignoreSegments: boolean = false, preventEndure: boolean = false, ignoreFaintPhase: boolean = false, source?: Pokemon): number {
|
||||
// When damage is done from any source (Move or Indirect damage, e.g. weather), store latest occurrence in damageSources[0]
|
||||
if (result !== undefined) {
|
||||
this.turnData.damageSources.unshift(result);
|
||||
}
|
||||
const damagePhase = new DamageAnimPhase(this.getBattlerIndex(), damage, result as DamageResult, critical);
|
||||
globalScene.unshiftPhase(damagePhase);
|
||||
if (this.switchOutStatus && source) {
|
||||
|
@ -5365,6 +5369,10 @@ export class PokemonTurnData {
|
|||
* forced to act again in the same turn
|
||||
*/
|
||||
public extraTurns: number = 0;
|
||||
/**
|
||||
* Used to track damage sources from HitResult.OTHER
|
||||
*/
|
||||
public damageSources: DamageResult[] = [];
|
||||
}
|
||||
|
||||
export enum AiType {
|
||||
|
|
|
@ -5,7 +5,7 @@ import { allMoves } from "#app/data/move";
|
|||
import { MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball";
|
||||
import { type FormChangeItem, SpeciesFormChangeItemTrigger, SpeciesFormChangeLapseTeraTrigger, SpeciesFormChangeTeraTrigger } from "#app/data/pokemon-forms";
|
||||
import { getStatusEffectHealText } from "#app/data/status-effect";
|
||||
import Pokemon, { type PlayerPokemon } from "#app/field/pokemon";
|
||||
import Pokemon, { HitResult, type PlayerPokemon } from "#app/field/pokemon";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import Overrides from "#app/overrides";
|
||||
import { EvolutionPhase } from "#app/phases/evolution-phase";
|
||||
|
@ -1927,6 +1927,10 @@ export class PokemonInstantReviveModifier extends PokemonHeldItemModifier {
|
|||
* @returns always `true`
|
||||
*/
|
||||
override apply(pokemon: Pokemon): boolean {
|
||||
// Do not revive if damage is indirect
|
||||
if (pokemon.turnData?.damageSources?.at(0) === HitResult.OTHER) {
|
||||
return false;
|
||||
}
|
||||
// Restore the Pokemon to half HP
|
||||
globalScene.unshiftPhase(new PokemonHealPhase(pokemon.getBattlerIndex(),
|
||||
toDmgValue(pokemon.getMaxHp() / 2), i18next.t("modifier:pokemonInstantReviveApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), false, false, true));
|
||||
|
|
Loading…
Reference in New Issue