mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-21 07:42:25 +02:00
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
|
* @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 {
|
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);
|
const damagePhase = new DamageAnimPhase(this.getBattlerIndex(), damage, result as DamageResult, critical);
|
||||||
globalScene.unshiftPhase(damagePhase);
|
globalScene.unshiftPhase(damagePhase);
|
||||||
if (this.switchOutStatus && source) {
|
if (this.switchOutStatus && source) {
|
||||||
@ -5365,6 +5369,10 @@ export class PokemonTurnData {
|
|||||||
* forced to act again in the same turn
|
* forced to act again in the same turn
|
||||||
*/
|
*/
|
||||||
public extraTurns: number = 0;
|
public extraTurns: number = 0;
|
||||||
|
/**
|
||||||
|
* Used to track damage sources from HitResult.OTHER
|
||||||
|
*/
|
||||||
|
public damageSources: DamageResult[] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum AiType {
|
export enum AiType {
|
||||||
|
@ -5,7 +5,7 @@ import { allMoves } from "#app/data/move";
|
|||||||
import { MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball";
|
import { MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball";
|
||||||
import { type FormChangeItem, SpeciesFormChangeItemTrigger, SpeciesFormChangeLapseTeraTrigger, SpeciesFormChangeTeraTrigger } from "#app/data/pokemon-forms";
|
import { type FormChangeItem, SpeciesFormChangeItemTrigger, SpeciesFormChangeLapseTeraTrigger, SpeciesFormChangeTeraTrigger } from "#app/data/pokemon-forms";
|
||||||
import { getStatusEffectHealText } from "#app/data/status-effect";
|
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 { getPokemonNameWithAffix } from "#app/messages";
|
||||||
import Overrides from "#app/overrides";
|
import Overrides from "#app/overrides";
|
||||||
import { EvolutionPhase } from "#app/phases/evolution-phase";
|
import { EvolutionPhase } from "#app/phases/evolution-phase";
|
||||||
@ -1927,6 +1927,10 @@ export class PokemonInstantReviveModifier extends PokemonHeldItemModifier {
|
|||||||
* @returns always `true`
|
* @returns always `true`
|
||||||
*/
|
*/
|
||||||
override apply(pokemon: Pokemon): boolean {
|
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
|
// Restore the Pokemon to half HP
|
||||||
globalScene.unshiftPhase(new PokemonHealPhase(pokemon.getBattlerIndex(),
|
globalScene.unshiftPhase(new PokemonHealPhase(pokemon.getBattlerIndex(),
|
||||||
toDmgValue(pokemon.getMaxHp() / 2), i18next.t("modifier:pokemonInstantReviveApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), false, false, true));
|
toDmgValue(pokemon.getMaxHp() / 2), i18next.t("modifier:pokemonInstantReviveApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), false, false, true));
|
||||||
|
Loading…
Reference in New Issue
Block a user