Fix #5085 Moves dont play a No Effect Message Against Immune Type
When using non-volatile status move like: Will-O-Wisp, Thunder Wave, Toxic, or Poison Gas against a Pokémon whose type is immune to that Status condition, no "It doesn't affect" message plays. My proposed fixes: In move.ts: Removed the queue of the message ""XXXX is protected by Safeguard!" in the class: "StatusEffectAttr" due to the Pokemon being safeguarded when a status move is used and added a call to the function canSetStatus(). In pokemon.ts: Added the function "messageIsImmune(quiet: boolean)" which displays the message "It doesn't affect XXXX" if the quiet parameter is set to false. Updated the "canSetStatus()" function so that when it returns false (meaning the status couldn't be applied) it calls the "messageIsImmune()" function to display the message correctly. Also included the queue of the message removed from the move.ts file allowing the centralization of the messages associated with status moves.
This commit is contained in:
parent
8bca0bcb32
commit
f4d0d56cfd
|
@ -2431,29 +2431,11 @@ export class StatusEffectAttr extends MoveEffectAttr {
|
|||
}
|
||||
}
|
||||
|
||||
if (user !== target && target.isSafeguarded(user)) {
|
||||
if (move.category === MoveCategory.STATUS) {
|
||||
globalScene.queueMessage(i18next.t("moveTriggers:safeguard", { targetName: getPokemonNameWithAffix(target) }));
|
||||
}
|
||||
if (user !== target && move.category === MoveCategory.STATUS && !target.canSetStatus(this.effect, false, false, user, true)) {
|
||||
return false;
|
||||
}
|
||||
if (!pokemon.status || (pokemon.status.effect === this.effect && moveChance < 0)){
|
||||
const statusApplied = pokemon.trySetStatus(this.effect, true, user, this.turnsRemaining);
|
||||
if (!statusApplied) {
|
||||
const isImmune =
|
||||
(this.effect === StatusEffect.POISON || this.effect === StatusEffect.TOXIC)
|
||||
&& (pokemon.isOfType(PokemonType.POISON) || pokemon.isOfType(PokemonType.STEEL) || pokemon.hasAbility(Abilities.IMMUNITY))
|
||||
|| (this.effect === StatusEffect.PARALYSIS
|
||||
&& (pokemon.isOfType(PokemonType.ELECTRIC) || pokemon.hasAbility(Abilities.LIMBER)))
|
||||
|| (this.effect === StatusEffect.BURN
|
||||
&& (pokemon.isOfType(PokemonType.FIRE) || pokemon.hasAbility(Abilities.WATER_VEIL)))
|
||||
|| (this.effect === StatusEffect.FREEZE
|
||||
&& (pokemon.isOfType(PokemonType.ICE) || pokemon.hasAbility(Abilities.MAGMA_ARMOR)));
|
||||
if (isImmune) {
|
||||
globalScene.queueMessage(i18next.t("abilityTriggers:moveImmunity", { pokemonNameWithAffix: getPokemonNameWithAffix(target) }));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if ((!pokemon.status || (pokemon.status.effect === this.effect && moveChance < 0))
|
||||
&& pokemon.trySetStatus(this.effect, true, user, this.turnsRemaining)) {
|
||||
applyPostAttackAbAttrs(ConfusionOnStatusEffectAbAttr, user, target, move, null, false, this.effect);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -5300,6 +5300,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
);
|
||||
}
|
||||
|
||||
messageIsImmune(quiet: boolean): boolean {
|
||||
if(!quiet){
|
||||
globalScene.queueMessage(
|
||||
i18next.t("abilityTriggers:moveImmunity", {pokemonNameWithAffix: getPokemonNameWithAffix(this),})
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a status effect can be applied to the Pokemon.
|
||||
*
|
||||
|
@ -5318,24 +5327,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
): boolean {
|
||||
if (effect !== StatusEffect.FAINT) {
|
||||
if (overrideStatus ? this.status?.effect === effect : this.status) {
|
||||
return false;
|
||||
return this.messageIsImmune(quiet);
|
||||
}
|
||||
if (
|
||||
this.isGrounded() &&
|
||||
!ignoreField &&
|
||||
globalScene.arena.terrain?.terrainType === TerrainType.MISTY
|
||||
) {
|
||||
return false;
|
||||
return this.messageIsImmune(quiet);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
sourcePokemon &&
|
||||
sourcePokemon !== this &&
|
||||
this.isSafeguarded(sourcePokemon)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const types = this.getTypes(true, true);
|
||||
|
||||
|
@ -5361,22 +5363,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
defType,
|
||||
);
|
||||
if (cancelImmunity.value) {
|
||||
return false;
|
||||
return this.messageIsImmune(quiet);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
});
|
||||
|
||||
if (this.isOfType(PokemonType.POISON) || this.isOfType(PokemonType.STEEL)) {
|
||||
if (poisonImmunity.includes(true)) {
|
||||
return false;
|
||||
return this.messageIsImmune(quiet);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case StatusEffect.PARALYSIS:
|
||||
if (this.isOfType(PokemonType.ELECTRIC)) {
|
||||
return false;
|
||||
return this.messageIsImmune(quiet);
|
||||
}
|
||||
break;
|
||||
case StatusEffect.SLEEP:
|
||||
|
@ -5384,7 +5386,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
this.isGrounded() &&
|
||||
globalScene.arena.terrain?.terrainType === TerrainType.ELECTRIC
|
||||
) {
|
||||
return false;
|
||||
return this.messageIsImmune(quiet);
|
||||
}
|
||||
break;
|
||||
case StatusEffect.FREEZE:
|
||||
|
@ -5396,12 +5398,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
globalScene.arena.weather.weatherType,
|
||||
))
|
||||
) {
|
||||
return false;
|
||||
return this.messageIsImmune(quiet);
|
||||
}
|
||||
break;
|
||||
case StatusEffect.BURN:
|
||||
if (this.isOfType(PokemonType.FIRE)) {
|
||||
return false;
|
||||
return this.messageIsImmune(quiet);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -5427,6 +5429,16 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
);
|
||||
|
||||
if (cancelled.value) {
|
||||
return this.messageIsImmune(quiet);
|
||||
}
|
||||
|
||||
if (
|
||||
sourcePokemon &&
|
||||
sourcePokemon !== this &&
|
||||
this.isSafeguarded(sourcePokemon)
|
||||
) {
|
||||
if(!quiet){
|
||||
globalScene.queueMessage(i18next.t("moveTriggers:safeguard", { targetName: getPokemonNameWithAffix(this) }));}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5440,7 +5452,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
turnsRemaining = 0,
|
||||
sourceText: string | null = null,
|
||||
): boolean {
|
||||
if (!this.canSetStatus(effect, asPhase, false, sourcePokemon)) {
|
||||
if (!this.canSetStatus(effect, false, false, sourcePokemon)) {
|
||||
return false;
|
||||
}
|
||||
if (this.isFainted() && effect !== StatusEffect.FAINT) {
|
||||
|
|
Loading…
Reference in New Issue