abilities: fix rattled not giving the attack drop still

This commit is contained in:
Madi Simpson 2024-05-03 22:50:39 -07:00
parent 708020402e
commit 5b8418c60d

View File

@ -1332,13 +1332,15 @@ export class PostSummonStatChangeAbAttr extends PostSummonAbAttr {
statChangePhases.push(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.levels)); statChangePhases.push(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.levels));
else { else {
for (let opponent of pokemon.getOpponents()) { for (let opponent of pokemon.getOpponents()) {
const hasIntimidateImmunity: boolean = (this.intimidate && (opponent.hasAbilityWithAttr(IntimidateImmunityAbAttr))) const cancelled = new Utils.BooleanHolder(false)
const overwritesIntimidate: boolean = (this.intimidate && (opponent.hasAbilityWithAttr(OverwriteIntimidateStatChangeAbAttr))) if (this.intimidate) {
if (hasIntimidateImmunity) if (opponent.hasAbilityWithAttr(IntimidateImmunityAbAttr)) {
intimidateImmune.push(opponent); cancelled.value = true;
else if (overwritesIntimidate) intimidateImmune.push(opponent);
applyAbAttrs(OverwriteIntimidateStatChangeAbAttr, opponent, null); }
else applyAbAttrs(PostIntimidateStatChangeAbAttr, opponent, cancelled)
}
if (!cancelled.value)
statChangePhases.push(new StatChangePhase(pokemon.scene, opponent.getBattlerIndex(), false, this.stats, this.levels)); statChangePhases.push(new StatChangePhase(pokemon.scene, opponent.getBattlerIndex(), false, this.stats, this.levels));
} }
} }
@ -1380,18 +1382,21 @@ export class PostSummonAllyHealAbAttr extends PostSummonAbAttr {
} }
} }
export class OverwriteIntimidateStatChangeAbAttr extends AbAttr { export class PostIntimidateStatChangeAbAttr extends AbAttr {
private stats: BattleStat[]; private stats: BattleStat[];
private levels: integer; private levels: integer;
private overwrites: boolean;
constructor(stats: BattleStat[], levels: integer) { constructor(stats: BattleStat[], levels: integer, overwrites?: boolean) {
super() super(true)
this.stats = stats this.stats = stats
this.levels = levels this.levels = levels
this.overwrites = !!overwrites
} }
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
pokemon.scene.pushPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), false, this.stats, this.levels)); pokemon.scene.pushPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), false, this.stats, this.levels));
cancelled.value = this.overwrites;
return true; return true;
} }
} }
@ -3024,7 +3029,7 @@ export function initAbilities() {
new Ability(Abilities.RATTLED, 5) new Ability(Abilities.RATTLED, 5)
.attr(PostDefendStatChangeAbAttr, (target, user, move) => move.category !== MoveCategory.STATUS && (move.type === Type.DARK || move.type === Type.BUG || .attr(PostDefendStatChangeAbAttr, (target, user, move) => move.category !== MoveCategory.STATUS && (move.type === Type.DARK || move.type === Type.BUG ||
move.type === Type.GHOST), BattleStat.SPD, 1) move.type === Type.GHOST), BattleStat.SPD, 1)
.attr(OverwriteIntimidateStatChangeAbAttr, [BattleStat.SPD], 1), .attr(PostIntimidateStatChangeAbAttr, [BattleStat.SPD], 1),
new Ability(Abilities.MAGIC_BOUNCE, 5) new Ability(Abilities.MAGIC_BOUNCE, 5)
.ignorable() .ignorable()
.unimplemented(), .unimplemented(),
@ -3409,7 +3414,7 @@ export function initAbilities() {
.ignorable() .ignorable()
.partial(), .partial(),
new Ability(Abilities.GUARD_DOG, 9) new Ability(Abilities.GUARD_DOG, 9)
.attr(OverwriteIntimidateStatChangeAbAttr, [BattleStat.ATK], 1) .attr(PostIntimidateStatChangeAbAttr, [BattleStat.ATK], 1, true)
.attr(ForceSwitchOutImmunityAbAttr) .attr(ForceSwitchOutImmunityAbAttr)
.ignorable(), .ignorable(),
new Ability(Abilities.ROCKY_PAYLOAD, 9) new Ability(Abilities.ROCKY_PAYLOAD, 9)