using arena tags source id variable

This commit is contained in:
PrabbyDD 2024-12-09 19:37:17 -08:00
parent 88e05756c4
commit 07cea3f09f
3 changed files with 12 additions and 16 deletions

View File

@ -86,9 +86,6 @@ export default class Battle {
/** Primarily for double battles, keeps track of last enemy and player pokemon that triggered its ability or used a move */ /** Primarily for double battles, keeps track of last enemy and player pokemon that triggered its ability or used a move */
public lastEnemyInvolved: number; public lastEnemyInvolved: number;
public lastPlayerInvolved: number; public lastPlayerInvolved: number;
/* Specifically for mirror armor, keeps track of last enemy/player pokemon to sucessfully use sticky web */
public lastEnemyIDUsingStickyWeb: integer;
public lastPlayerIDUsingStickyWeb: integer;
public lastUsedPokeball: PokeballType | null = null; public lastUsedPokeball: PokeballType | null = null;
/** The number of times a Pokemon on the player's side has fainted this battle */ /** The number of times a Pokemon on the player's side has fainted this battle */
public playerFaints: number = 0; public playerFaints: number = 0;

View File

@ -58,7 +58,6 @@ import { BooleanHolder, executeIf, NumberHolder } from "#app/utils";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import i18next from "i18next"; import i18next from "i18next";
import { ArenaTagType } from "#app/enums/arena-tag-type";
export class MoveEffectPhase extends PokemonPhase { export class MoveEffectPhase extends PokemonPhase {
public move: PokemonMove; public move: PokemonMove;
@ -90,15 +89,8 @@ export class MoveEffectPhase extends PokemonPhase {
/** If an enemy used this move, set this as last enemy that used move or ability */ /** If an enemy used this move, set this as last enemy that used move or ability */
if (!user?.isPlayer()) { if (!user?.isPlayer()) {
/** If the move used was sticky web AND sticky web not already active, save the id of pokemon that used it */
if (this.move.moveId === 564 && user !== null && !this.scene.arena.hasTag(ArenaTagType.STICKY_WEB)) {
this.scene.currentBattle.lastEnemyIDUsingStickyWeb = user.id;
}
this.scene.currentBattle.lastEnemyInvolved = this.fieldIndex; this.scene.currentBattle.lastEnemyInvolved = this.fieldIndex;
} else { } else {
if (this.move.moveId === 564 && user !== null && !this.scene.arena.hasTag(ArenaTagType.STICKY_WEB)) {
this.scene.currentBattle.lastPlayerIDUsingStickyWeb = user.id;
}
this.scene.currentBattle.lastPlayerInvolved = this.fieldIndex; this.scene.currentBattle.lastPlayerInvolved = this.fieldIndex;
} }

View File

@ -1,7 +1,7 @@
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import BattleScene from "#app/battle-scene"; import BattleScene from "#app/battle-scene";
import { applyAbAttrs, applyPostStatStageChangeAbAttrs, applyPreStatStageChangeAbAttrs, PostStatStageChangeAbAttr, ProtectStatAbAttr, ReflectStatStageChangeAbAttr, StatStageChangeCopyAbAttr, StatStageChangeMultiplierAbAttr } from "#app/data/ability"; import { applyAbAttrs, applyPostStatStageChangeAbAttrs, applyPreStatStageChangeAbAttrs, PostStatStageChangeAbAttr, ProtectStatAbAttr, ReflectStatStageChangeAbAttr, StatStageChangeCopyAbAttr, StatStageChangeMultiplierAbAttr } from "#app/data/ability";
import { ArenaTagSide, MistTag } from "#app/data/arena-tag"; import { ArenaTag, ArenaTagSide, MistTag } from "#app/data/arena-tag";
import Pokemon from "#app/field/pokemon"; import Pokemon from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages"; import { getPokemonNameWithAffix } from "#app/messages";
import { ResetNegativeStatStageModifier } from "#app/modifier/modifier"; import { ResetNegativeStatStageModifier } from "#app/modifier/modifier";
@ -11,6 +11,7 @@ import i18next from "i18next";
import { PokemonPhase } from "./pokemon-phase"; import { PokemonPhase } from "./pokemon-phase";
import { Stat, type BattleStat, getStatKey, getStatStageChangeDescriptionKey } from "#enums/stat"; import { Stat, type BattleStat, getStatKey, getStatStageChangeDescriptionKey } from "#enums/stat";
import { OctolockTag } from "#app/data/battler-tags"; import { OctolockTag } from "#app/data/battler-tags";
import { ArenaTagType } from "#app/enums/arena-tag-type";
export type StatStageChangeCallback = (target: Pokemon | null, changed: BattleStat[], relativeChanges: number[]) => void; export type StatStageChangeCallback = (target: Pokemon | null, changed: BattleStat[], relativeChanges: number[]) => void;
@ -61,8 +62,11 @@ export class StatStageChangePhase extends PokemonPhase {
opponentPokemon = this.scene.getEnemyField()[this.scene.currentBattle.lastEnemyInvolved]; opponentPokemon = this.scene.getEnemyField()[this.scene.currentBattle.lastEnemyInvolved];
} else { } else {
/** If this SSCP is from sticky web, then check if pokemon that last sucessfully used sticky web is on field */ /** If this SSCP is from sticky web, then check if pokemon that last sucessfully used sticky web is on field */
const stickyTagID = this.scene.arena.findTagsOnSide(
(t: ArenaTag) => t.tagType === ArenaTagType.STICKY_WEB,
ArenaTagSide.PLAYER)[0].sourceId;
this.scene.getEnemyField().forEach((e) => { this.scene.getEnemyField().forEach((e) => {
if (e.id === this.scene.currentBattle.lastEnemyIDUsingStickyWeb) { if (e.id === stickyTagID) {
opponentPokemon = e; opponentPokemon = e;
} }
}); });
@ -71,9 +75,12 @@ export class StatStageChangePhase extends PokemonPhase {
if (!this.comingFromStickyWeb) { if (!this.comingFromStickyWeb) {
opponentPokemon = this.scene.getPlayerField()[this.scene.currentBattle.lastPlayerInvolved]; opponentPokemon = this.scene.getPlayerField()[this.scene.currentBattle.lastPlayerInvolved];
} else { } else {
this.scene.getPlayerField().forEach((p) => { const stickyTagID = this.scene.arena.findTagsOnSide(
if (p.id === this.scene.currentBattle.lastPlayerIDUsingStickyWeb) { (t: ArenaTag) => t.tagType === ArenaTagType.STICKY_WEB,
opponentPokemon = p; ArenaTagSide.ENEMY)[0].sourceId;
this.scene.getPlayerField().forEach((e) => {
if (e.id === stickyTagID) {
opponentPokemon = e;
} }
}); });
} }