mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-27 02:32:21 +02:00
Ensure that passives are not (re)applied when main abilities change
This commit is contained in:
parent
0e9af6c9cf
commit
220d8260c8
@ -4867,9 +4867,10 @@ async function applyAbAttrsInternal<TAttr extends AbAttr>(
|
||||
showAbilityInstant: boolean = false,
|
||||
simulated: boolean = false,
|
||||
messages: string[] = [],
|
||||
considerPassive: boolean = true
|
||||
) {
|
||||
for (const passive of [ false, true ]) {
|
||||
if (!pokemon?.canApplyAbility(passive) || (passive && pokemon.getPassiveAbility().id === pokemon.getAbility().id)) {
|
||||
if (!pokemon?.canApplyAbility(passive) || (passive && (pokemon.getPassiveAbility().id === pokemon.getAbility().id || !considerPassive))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -5295,6 +5296,21 @@ export function applyPostItemLostAbAttrs(attrType: Constructor<PostItemLostAbAtt
|
||||
return applyAbAttrsInternal<PostItemLostAbAttr>(attrType, pokemon, (attr, passive) => attr.applyPostItemLost(pokemon, simulated, args), args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies abilities when they become active mid-turn (ability switch)
|
||||
*
|
||||
* Ignores passives as they don't change and shouldn't be reapplied when main abilities change
|
||||
*/
|
||||
export function applyMidTurnAbAttrs(pokemon: Pokemon, simulated: boolean = false, ...args: any[]): Promise<void> {
|
||||
return applyAbAttrsInternal<PostSummonAbAttr>(PostSummonAbAttr, pokemon, (attr, passive) => attr.applyPostSummon(pokemon, passive, simulated, args), args, false, simulated, [], false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears primal weather during the turn if {@linkcode pokemon}'s ability corresponds to one
|
||||
*/
|
||||
export function applyMidTurnClearWeatherAbAttrs(pokemon: Pokemon, simulated: boolean = false, ...args: any[]): Promise<void> {
|
||||
return applyAbAttrsInternal<PreSwitchOutAbAttr>(PreSwitchOutClearWeatherAbAttr, pokemon, (attr, passive) => attr.applyPreSwitchOut(pokemon, passive, simulated, args), args, true, simulated, [], false);
|
||||
}
|
||||
function queueShowAbility(pokemon: Pokemon, passive: boolean): void {
|
||||
globalScene.unshiftPhase(new ShowAbilityPhase(pokemon.id, passive));
|
||||
globalScene.clearPhaseQueueSplice();
|
||||
|
@ -32,7 +32,7 @@ import { BattlerTag, BattlerTagLapseType, EncoreTag, GroundedTag, HighestStatBoo
|
||||
import { WeatherType } from "#enums/weather-type";
|
||||
import { ArenaTagSide, NoCritTag, WeakenMoveScreenTag } from "#app/data/arena-tag";
|
||||
import type { Ability, AbAttr } from "#app/data/ability";
|
||||
import { StatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatStagesAbAttr, MoveImmunityAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, FieldMultiplyStatAbAttr, AddSecondStrikeAbAttr, UserFieldStatusEffectImmunityAbAttr, UserFieldBattlerTagImmunityAbAttr, BattlerTagImmunityAbAttr, MoveTypeChangeAbAttr, FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, CheckTrappedAbAttr, PostSetStatusAbAttr, applyPostSetStatusAbAttrs, InfiltratorAbAttr, AlliedFieldDamageReductionAbAttr, PostDamageAbAttr, applyPostDamageAbAttrs, CommanderAbAttr, applyPostItemLostAbAttrs, PostItemLostAbAttr, applyPostSummonAbAttrs, PostSummonAbAttr, PreSwitchOutAbAttr, applyPreSwitchOutAbAttrs } from "#app/data/ability";
|
||||
import { StatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatStagesAbAttr, MoveImmunityAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, FieldMultiplyStatAbAttr, AddSecondStrikeAbAttr, UserFieldStatusEffectImmunityAbAttr, UserFieldBattlerTagImmunityAbAttr, BattlerTagImmunityAbAttr, MoveTypeChangeAbAttr, FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, CheckTrappedAbAttr, PostSetStatusAbAttr, applyPostSetStatusAbAttrs, InfiltratorAbAttr, AlliedFieldDamageReductionAbAttr, PostDamageAbAttr, applyPostDamageAbAttrs, CommanderAbAttr, applyPostItemLostAbAttrs, PostItemLostAbAttr, applyMidTurnAbAttrs, applyMidTurnClearWeatherAbAttrs } from "#app/data/ability";
|
||||
import type PokemonData from "#app/system/pokemon-data";
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
@ -1432,23 +1432,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
|
||||
/**
|
||||
* Sets the {@linkcode Pokemon}'s ability and activates it if it normally activates on summon
|
||||
* Clears
|
||||
*
|
||||
* Also clears primal weather if it is from the ability being changed
|
||||
* @param ability New Ability
|
||||
*/
|
||||
public setTempAbility(ability: Ability): void {
|
||||
const legendaryWeather = [ Abilities.DESOLATE_LAND, Abilities.PRIMORDIAL_SEA, Abilities.DELTA_STREAM ];
|
||||
// If the ability to set is also a legendary weather, no need to clear old weather
|
||||
if (legendaryWeather.includes(this.getAbility().id) && !legendaryWeather.includes(ability.id)) {
|
||||
applyPreSwitchOutAbAttrs(PreSwitchOutAbAttr, this);
|
||||
}
|
||||
applyMidTurnClearWeatherAbAttrs(this);
|
||||
this.summonData.ability = ability.id;
|
||||
|
||||
applyPostSummonAbAttrs(PostSummonAbAttr, this)
|
||||
.then(() => {
|
||||
const field = this.isPlayer() ? globalScene.getPlayerField() : globalScene.getEnemyField();
|
||||
field.forEach((p) => applyAbAttrs(CommanderAbAttr, p, null, false));
|
||||
});
|
||||
|
||||
applyMidTurnAbAttrs(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user