mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 16:02:20 +02:00
implements anticipation
This commit is contained in:
parent
0ecc46ab97
commit
2ebc060fa3
@ -1569,6 +1569,43 @@ function getWeatherCondition(...weatherTypes: WeatherType[]): AbAttrCondition {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAnticipationCondition(): AbAttrCondition {
|
||||||
|
return (pokemon: Pokemon) => {
|
||||||
|
for (let opponent of pokemon.getOpponents()) {
|
||||||
|
for (let move of opponent.moveset) {
|
||||||
|
// move is super effective
|
||||||
|
if (move.getMove() instanceof AttackMove && pokemon.getAttackTypeEffectiveness(move.getMove().type) >= 2) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// move is a OHKO
|
||||||
|
if ([Moves.FISSURE, Moves.SHEER_COLD, Moves.GUILLOTINE, Moves.HORN_DRILL].includes(move.getMove().id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// edge case for hidden power, type is computed
|
||||||
|
if (move.getMove().id === Moves.HIDDEN_POWER) {
|
||||||
|
const iv_val = Math.floor(((opponent.ivs[Stat.HP] & 1)
|
||||||
|
+(opponent.ivs[Stat.ATK] & 1) * 2
|
||||||
|
+(opponent.ivs[Stat.DEF] & 1) * 4
|
||||||
|
+(opponent.ivs[Stat.SPD] & 1) * 8
|
||||||
|
+(opponent.ivs[Stat.SPATK] & 1) * 16
|
||||||
|
+(opponent.ivs[Stat.SPDEF] & 1) * 32) * 15/63);
|
||||||
|
|
||||||
|
const type = [
|
||||||
|
Type.FIGHTING, Type.FLYING, Type.POISON, Type.GROUND,
|
||||||
|
Type.ROCK, Type.BUG, Type.GHOST, Type.STEEL,
|
||||||
|
Type.FIRE, Type.WATER, Type.GRASS, Type.ELECTRIC,
|
||||||
|
Type.PSYCHIC, Type.ICE, Type.DRAGON, Type.DARK][iv_val];
|
||||||
|
|
||||||
|
if (pokemon.getAttackTypeEffectiveness(type) >= 2) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export class PostWeatherChangeAbAttr extends AbAttr {
|
export class PostWeatherChangeAbAttr extends AbAttr {
|
||||||
applyPostWeatherChange(pokemon: Pokemon, passive: boolean, weather: WeatherType, args: any[]): boolean {
|
applyPostWeatherChange(pokemon: Pokemon, passive: boolean, weather: WeatherType, args: any[]): boolean {
|
||||||
return false;
|
return false;
|
||||||
@ -2589,7 +2626,8 @@ export function initAbilities() {
|
|||||||
new Ability(Abilities.AFTERMATH, "Aftermath", "Damages the attacker if it contacts the Pokémon with a finishing hit.", 4)
|
new Ability(Abilities.AFTERMATH, "Aftermath", "Damages the attacker if it contacts the Pokémon with a finishing hit.", 4)
|
||||||
.attr(PostFaintContactDamageAbAttr,4)
|
.attr(PostFaintContactDamageAbAttr,4)
|
||||||
.bypassFaint(),
|
.bypassFaint(),
|
||||||
new Ability(Abilities.ANTICIPATION, "Anticipation (N)", "The Pokémon can sense an opposing Pokémon's dangerous moves.", 4),
|
new Ability(Abilities.ANTICIPATION, "Anticipation", "The Pokémon can sense an opposing Pokémon's dangerous moves.", 4)
|
||||||
|
.conditionalAttr(getAnticipationCondition(), PostSummonMessageAbAttr, (pokemon: Pokemon) => getPokemonMessage(pokemon, ' shuddered!')),
|
||||||
new Ability(Abilities.FOREWARN, "Forewarn (N)", "When it enters a battle, the Pokémon can tell one of the moves an opposing Pokémon has.", 4),
|
new Ability(Abilities.FOREWARN, "Forewarn (N)", "When it enters a battle, the Pokémon can tell one of the moves an opposing Pokémon has.", 4),
|
||||||
new Ability(Abilities.UNAWARE, "Unaware", "When attacking, the Pokémon ignores the target Pokémon's stat changes.", 4)
|
new Ability(Abilities.UNAWARE, "Unaware", "When attacking, the Pokémon ignores the target Pokémon's stat changes.", 4)
|
||||||
.attr(IgnoreOpponentStatChangesAbAttr)
|
.attr(IgnoreOpponentStatChangesAbAttr)
|
||||||
|
Loading…
Reference in New Issue
Block a user