mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-08 17:32:18 +02:00
abilities: make ability bars pop in to some success
This commit is contained in:
parent
5b8418c60d
commit
53a709822d
@ -1269,6 +1269,36 @@ export class IgnoreOpponentStatChangesAbAttr extends AbAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class IntimidateImmunityAbAttr extends AbAttr {
|
||||||
|
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||||
|
cancelled.value = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
|
||||||
|
return getPokemonMessage(pokemon, `'s Attack was not lowered!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PostIntimidateStatChangeAbAttr extends AbAttr {
|
||||||
|
private stats: BattleStat[];
|
||||||
|
private levels: integer;
|
||||||
|
private overwrites: boolean;
|
||||||
|
|
||||||
|
constructor(stats: BattleStat[], levels: integer, overwrites?: boolean) {
|
||||||
|
super(true)
|
||||||
|
this.stats = stats
|
||||||
|
this.levels = levels
|
||||||
|
this.overwrites = !!overwrites
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
cancelled.value = this.overwrites;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class PostSummonAbAttr extends AbAttr {
|
export class PostSummonAbAttr extends AbAttr {
|
||||||
applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise<boolean> {
|
applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise<boolean> {
|
||||||
return false;
|
return false;
|
||||||
@ -1321,40 +1351,28 @@ export class PostSummonStatChangeAbAttr extends PostSummonAbAttr {
|
|||||||
: stats as BattleStat[];
|
: stats as BattleStat[];
|
||||||
this.levels = levels;
|
this.levels = levels;
|
||||||
this.selfTarget = !!selfTarget;
|
this.selfTarget = !!selfTarget;
|
||||||
this.intimidate = intimidate
|
this.intimidate = !!intimidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean {
|
applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean {
|
||||||
const statChangePhases: StatChangePhase[] = [];
|
if (this.selfTarget) {
|
||||||
const intimidateImmune: Pokemon[] = []
|
pokemon.scene.pushPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.levels));
|
||||||
|
return true;
|
||||||
if (this.selfTarget)
|
}
|
||||||
statChangePhases.push(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.levels));
|
for (let opponent of pokemon.getOpponents()) {
|
||||||
else {
|
const cancelled = new Utils.BooleanHolder(false)
|
||||||
for (let opponent of pokemon.getOpponents()) {
|
if (this.intimidate) {
|
||||||
const cancelled = new Utils.BooleanHolder(false)
|
applyAbAttrs(IntimidateImmunityAbAttr, opponent, cancelled);
|
||||||
if (this.intimidate) {
|
applyAbAttrs(PostIntimidateStatChangeAbAttr, opponent, cancelled);
|
||||||
if (opponent.hasAbilityWithAttr(IntimidateImmunityAbAttr)) {
|
}
|
||||||
cancelled.value = true;
|
if (!cancelled.value) {
|
||||||
intimidateImmune.push(opponent);
|
const statChangePhase = new StatChangePhase(pokemon.scene, opponent.getBattlerIndex(), false, this.stats, this.levels);
|
||||||
}
|
if (!statChangePhase.getPokemon().summonData)
|
||||||
applyAbAttrs(PostIntimidateStatChangeAbAttr, opponent, cancelled)
|
pokemon.scene.pushPhase(statChangePhase); // TODO: This causes the ability bar to be shown at the wrong time
|
||||||
}
|
else
|
||||||
if (!cancelled.value)
|
pokemon.scene.unshiftPhase(statChangePhase);
|
||||||
statChangePhases.push(new StatChangePhase(pokemon.scene, opponent.getBattlerIndex(), false, this.stats, this.levels));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let statChangePhase of statChangePhases) {
|
|
||||||
if (!this.selfTarget && !statChangePhase.getPokemon().summonData)
|
|
||||||
pokemon.scene.pushPhase(statChangePhase); // TODO: This causes the ability bar to be shown at the wrong time
|
|
||||||
else
|
|
||||||
pokemon.scene.unshiftPhase(statChangePhase);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let opponent of intimidateImmune)
|
|
||||||
pokemon.scene.queueMessage(getPokemonMessage(opponent, ` can't be Intimidated!`));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1382,25 +1400,6 @@ export class PostSummonAllyHealAbAttr extends PostSummonAbAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PostIntimidateStatChangeAbAttr extends AbAttr {
|
|
||||||
private stats: BattleStat[];
|
|
||||||
private levels: integer;
|
|
||||||
private overwrites: boolean;
|
|
||||||
|
|
||||||
constructor(stats: BattleStat[], levels: integer, overwrites?: boolean) {
|
|
||||||
super(true)
|
|
||||||
this.stats = stats
|
|
||||||
this.levels = levels
|
|
||||||
this.overwrites = !!overwrites
|
|
||||||
}
|
|
||||||
|
|
||||||
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));
|
|
||||||
cancelled.value = this.overwrites;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class DownloadAbAttr extends PostSummonAbAttr {
|
export class DownloadAbAttr extends PostSummonAbAttr {
|
||||||
private enemyDef: integer;
|
private enemyDef: integer;
|
||||||
private enemySpDef: integer;
|
private enemySpDef: integer;
|
||||||
@ -2289,9 +2288,16 @@ export class FlinchStatChangeAbAttr extends FlinchEffectAbAttr {
|
|||||||
|
|
||||||
export class IncreasePpAbAttr extends AbAttr { }
|
export class IncreasePpAbAttr extends AbAttr { }
|
||||||
|
|
||||||
export class IntimidateImmunityAbAttr extends AbAttr { }
|
export class ForceSwitchOutImmunityAbAttr extends AbAttr {
|
||||||
|
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||||
|
cancelled.value = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
export class ForceSwitchOutImmunityAbAttr extends AbAttr { }
|
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
|
||||||
|
return getPokemonMessage(pokemon, `'s ${abilityName} prevents it from being switched out!`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class ReduceBerryUseThresholdAbAttr extends AbAttr {
|
export class ReduceBerryUseThresholdAbAttr extends AbAttr {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -2887,8 +2887,13 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
if (!this.user && (target.isMax()))
|
|
||||||
return resolve(false);
|
const cancelled = new Utils.BooleanHolder(false);
|
||||||
|
if (!this.user)
|
||||||
|
applyAbAttrs(ForceSwitchOutImmunityAbAttr, target, cancelled)
|
||||||
|
|
||||||
|
if ((!this.user && target.isMax()) || cancelled.value)
|
||||||
|
return resolve(false);
|
||||||
|
|
||||||
// Check if the move category is not STATUS or if the switch out condition is not met
|
// Check if the move category is not STATUS or if the switch out condition is not met
|
||||||
if (move.category !== MoveCategory.STATUS && !this.getSwitchOutCondition()(user, target, move)) {
|
if (move.category !== MoveCategory.STATUS && !this.getSwitchOutCondition()(user, target, move)) {
|
||||||
@ -2943,9 +2948,9 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
resolve(true);
|
resolve(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getCondition(): MoveConditionFunc {
|
getCondition(): MoveConditionFunc {
|
||||||
return (user, target, move) => move.category !== MoveCategory.STATUS || this.getSwitchOutCondition()(user, target, move);
|
return (user, target, move) => (move.category !== MoveCategory.STATUS || this.getSwitchOutCondition()(user, target, move));
|
||||||
}
|
}
|
||||||
|
|
||||||
getSwitchOutCondition(): MoveConditionFunc {
|
getSwitchOutCondition(): MoveConditionFunc {
|
||||||
@ -2953,9 +2958,6 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
const switchOutTarget = (this.user ? user : target);
|
const switchOutTarget = (this.user ? user : target);
|
||||||
const player = switchOutTarget instanceof PlayerPokemon;
|
const player = switchOutTarget instanceof PlayerPokemon;
|
||||||
|
|
||||||
if (!this.user && target.hasAbilityWithAttr(ForceSwitchOutImmunityAbAttr))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!player && !user.scene.currentBattle.battleType) {
|
if (!player && !user.scene.currentBattle.battleType) {
|
||||||
if (this.batonPass)
|
if (this.batonPass)
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user