java.lang.Object
com.pixelmonmod.pixelmon.battles.attacks.Attack

public class Attack extends Object
A Pokémon's attack.
  • Field Details

    • EFFECTIVE_NORMAL

      public static final float EFFECTIVE_NORMAL
      Type effectiveness multipliers.
      See Also:
    • EFFECTIVE_SUPER

      public static final float EFFECTIVE_SUPER
      Type effectiveness multipliers.
      See Also:
    • EFFECTIVE_MAX

      public static final float EFFECTIVE_MAX
      Type effectiveness multipliers.
      See Also:
    • EFFECTIVE_NOT

      public static final float EFFECTIVE_NOT
      Type effectiveness multipliers.
      See Also:
    • EFFECTIVE_BARELY

      public static final float EFFECTIVE_BARELY
      Type effectiveness multipliers.
      See Also:
    • EFFECTIVE_NONE

      public static final float EFFECTIVE_NONE
      Type effectiveness multipliers.
      See Also:
    • ATTACK_PHYSICAL

      public static final int ATTACK_PHYSICAL
      attack categories.
      See Also:
    • ATTACK_SPECIAL

      public static final int ATTACK_SPECIAL
      attack categories.
      See Also:
    • ATTACK_STATUS

      public static final int ATTACK_STATUS
      attack categories.
      See Also:
    • NEVER_MISS

      public static final int NEVER_MISS
      Special accuracy cases.
      See Also:
    • IGNORE_SEMIINVULNERABLE

      public static final int IGNORE_SEMIINVULNERABLE
      Special accuracy cases.
      See Also:
    • pp

      public int pp
      The attack's PP.
    • ppLevel

      public int ppLevel
      The number of PP UP's that have been used, always 3 for a PP max
    • movePower

      public int movePower
      The base power of the attack.
    • overridePower

      public int overridePower
      Overridden base power of the attack.
    • moveAccuracy

      public int moveAccuracy
      The accuracy of the attack.
    • cantMiss

      public boolean cantMiss
      Whether the attack can never miss the target
    • moveResult

      public MoveResults moveResult
      The result of the attack.
    • damageResult

      public float damageResult
      The amount of damage dealt by the attack.
    • didCrit

      public boolean didCrit
      Whether the move critically hit or not.
    • savedAttack

      public ImmutableAttack savedAttack
      The original attack before modifications.
    • savedPower

      public int savedPower
      The original power of the attack before modifications.
    • savedAccuracy

      public int savedAccuracy
      The original accuracy of the attack before modifications.
    • hasPlayedAnimationOnce

      public transient boolean hasPlayedAnimationOnce
    • isZ

      public transient boolean isZ
    • isMax

      public transient boolean isMax
    • originalMove

      public transient Attack originalMove
    • fromDancer

      public transient boolean fromDancer
  • Constructor Details

    • Attack

      public Attack(ImmutableAttack base)
      Initializes an attack with its base attack stats.
      Parameters:
      base - The base attack stats of this attack.
    • Attack

      public Attack(String moveName)
      Initializes an attack with its base attack stats.
      Parameters:
      moveName - The name of the attack.
    • Attack

      public Attack(RegistryValue<ImmutableAttack> move)
    • Attack

      public Attack(Attack attack)
      Makes a deep copy of the Attack object
      Parameters:
      attack - The attack we are assigning
  • Method Details

    • initializeAttack

      public void initializeAttack(ImmutableAttack base)
      Initializes the attack's stats and PP.
      Parameters:
      base - The base attack to initialize the attack from.
    • getMove

      public ImmutableAttack getMove()
      The current attack.
    • getActualMove

      public ImmutableAttack getActualMove()
      The unmodified attack details.
    • getMaxPP

      public int getMaxPP()
      The attack's maximum PP with PP Ups.
    • overridePPMax

      public void overridePPMax(int pp)
    • getOverriddenPPMax

      public Integer getOverriddenPPMax()
      Returns:
      the overriddenPPMax. used for updating the client that there is a override.
    • getEffects

      public List<EffectBase> getEffects()
      Returns:
      The effects for the move, whether modified by the field or base.
    • getAttackCategory

      public AttackCategory getAttackCategory()
      The attack's category, Physical/Special/Status.
    • overrideAttackCategory

      public void overrideAttackCategory(AttackCategory category)
    • getType

      public Element getType()
    • getActualType

      public Element getActualType()
    • overrideType

      public void overrideType(Element type)
    • resetMove

      public void resetMove()
      Restores the base attack's details if they are modified during the attack.
    • resetOverridePower

      public void resetOverridePower()
    • use

      public boolean use(PixelmonWrapper user, PixelmonWrapper target, MoveResults moveResults)
    • use

      public boolean use(PixelmonWrapper user, PixelmonWrapper target, MoveResults moveResults, ZMove zMove)
      Executes the attack.
      Returns:
      boolean Whether the attack's PP will be lowered.
    • modifyMoveEffects

      public static void modifyMoveEffects(PixelmonWrapper user, PixelmonWrapper target, List<EffectBase> effects)
    • modifyMoveStats

      public int[] modifyMoveStats(PixelmonWrapper user, PixelmonWrapper target, Ability userAbility, Ability targetAbility, int livePower)
      Modify the attacker's power and accuracy based on abilities, items, and statuses.
      Parameters:
      user - The Pokémon using the move.
      target - The Pokémon being attacked.
      userAbility - The attacking Pokémon's ability.
      livePower - The move power and move accuracy that are modified.
      Returns:
      Whether a Pokémon self-targeted themselves with a move.
    • calculateMoveAccuracy

      public double calculateMoveAccuracy(PixelmonWrapper user, PixelmonWrapper target, Ability userAbility)
      Make the calculations on how accurate a move will be.
      Parameters:
      user - The Pokémon using the move.
      target - The Pokémon being attacked.
      userAbility - The user's ability.
      Returns:
      Whether a Pokémon self-targeted themselves with a move.
    • hasNoEffect

      public boolean hasNoEffect(PixelmonWrapper user, PixelmonWrapper target)
      Checks if the move has no effect on the target Pokémon.
      Parameters:
      user - The Pokémon using the move.
      target - The Pokémon being targeted by the move.
      Returns:
      Whether the move has no effect on the target Pokémon.
    • playAnimation

      public void playAnimation(PixelmonWrapper user, PixelmonWrapper target)
      Does animation for the attack.
      Parameters:
      user - The attack's user.
      target - The attack's target.
    • doDamageCalc

      public int doDamageCalc(PixelmonWrapper userWrapper, PixelmonWrapper targetWrapper, double crit)
      Calculates the attack's damage.
      Parameters:
      userWrapper - The attack's user.
      targetWrapper - The attack's target.
      crit - The critical hit modifier.
      Returns:
      The calculated damage.
    • applySelfStatusMove

      public void applySelfStatusMove(PixelmonWrapper user, MoveResults moveResults)
      Triggered when a Pokémon uses a status move that targets itself.
      Parameters:
      user - The attack's user.
      moveResults - The results of the attack.
    • applyAttackEffect

      public AttackResult applyAttackEffect(PixelmonWrapper user, PixelmonWrapper target)
      Applies status and stat modifiers.
      Parameters:
      user - The attack's user.
      target - The attack's target.
      Returns:
      The attack's result.
    • applyContact

      public static void applyContact(PixelmonWrapper user, PixelmonWrapper target)
      Triggered when a Pokémon makes contact.
      Parameters:
      user - The attack's user.
      target - The attack's target.
    • applyContactLate

      public static void applyContactLate(PixelmonWrapper user, PixelmonWrapper target)
      Triggered when a Pokémon makes contact. Occurs after other end-of-move effects.
      Parameters:
      user - The move's user.
      target - The move's target.
    • postProcessAttackAllHits

      public static void postProcessAttackAllHits(PixelmonWrapper user, PixelmonWrapper target, Attack attack, float power, DamageTypeEnum damageType, boolean onSubstitute)
      Applies any post-damage effects after all hits of a move.
      Parameters:
      user - The attack's user.
      target - The attack's target.
      attack - The attack.
      power - The damage dealt by the attack.
      damageType - The type of damage dealt.
      onSubstitute - Whether the damage was done on a substitute.
    • onMiss

      public void onMiss(PixelmonWrapper user, PixelmonWrapper target, MoveResults results, Object cause)
      Handles procedures when the attack misses.
      Parameters:
      user - The attack's user.
      target - The attack's target.
      results - The results of the move.
      cause - The cause of the attack missing.
    • hasSTAB

      public boolean hasSTAB(PixelmonWrapper user)
      Determines whether the attack has STAB.
      Parameters:
      user - The attack's user.
      Returns:
      Whether the attack has STAB.
    • setDisabled

      public void setDisabled(boolean value, PixelmonWrapper pixelmon)
      Disables or enables a move.
      Parameters:
      value - Whether the move is to be disabled (true) or enabled (false).
      pixelmon - The Pokémon with the move.
    • setDisabled

      public void setDisabled(boolean value, PixelmonWrapper pixelmon, boolean switching)
      Disables or enables a move.
      Parameters:
      value - Whether the move is to be disabled (true) or enabled (false).
      pixelmon - The Pokémon with the move.
      switching - Whether the Pokémon is switching out.
    • getDisabled

      public boolean getDisabled()
      Returns whether the move is disabled.
      Returns:
      Whether the move is disabled.
    • canUseMove

      public boolean canUseMove()
    • calcCriticalHit

      public static double calcCriticalHit(EffectBase e, PixelmonWrapper user, PixelmonWrapper target)
      Calculates whether the attack will land a critical hit.
      Parameters:
      e - An attack effect that influences critical hit calculation, if applicable.
      user - The attack's user.
      target - The attack's target.
      Returns:
      The critical hit modifier.
    • canHit

      public boolean canHit(PixelmonWrapper pixelmon1, PixelmonWrapper pixelmon2)
      Determines whether or not the attack can occur due to fainting.
      Parameters:
      pixelmon1 - The attack's user.
      pixelmon2 - The attack's target.
      Returns:
      Whether the attack can occur.
    • canReachTarget

      public boolean canReachTarget(PixelmonWrapper user, PixelmonWrapper target)
      Determines whether or not the attack can reach the target based on targeting info
      Parameters:
      user - The attack's user.
      target - The attack's target.
      Returns:
      Whether the attack can reach the opponent.
    • doesPersist

      public boolean doesPersist(PixelmonWrapper pw)
      Determines whether the attack continues between turns.
      Parameters:
      pw - The attack's user.
      Returns:
      Whether the attack continues between turns.
    • cantMiss

      public boolean cantMiss(PixelmonWrapper user)
      Determines whether the move will never miss.
      Parameters:
      user - The move's user.
      Returns:
      Whether the move will never miss.
    • sendEffectiveChat

      public void sendEffectiveChat(PixelmonWrapper user, PixelmonWrapper target)
      Sends a battle message about the type effectiveness of an attack.
      Parameters:
      user - The attack's user.
      target - The attack's target.
    • dealsDamage

      public static boolean dealsDamage(Attack attack)
      Determines whether the attack deals direct damage.
      Parameters:
      attack - The attack to check.
      Returns:
      Whether the attack deals direct damage.
    • hasMoreEffects

      public static boolean hasMoreEffects(Attack attack, EffectBase effect)
      Determines whether the attack has more possible effects to try.
      Parameters:
      attack - The attack to check.
      effect - The current effect.
      Returns:
      Whether the attack deals direct damage.
    • saveAttack

      public void saveAttack()
      Saves the base attack's details.
    • restoreAttack

      public void restoreAttack()
      Restores the base attack's details if they are modified during the attack.
    • isAttack

      public boolean isAttack(ImmutableAttack... attacks)
      Determines whether the attack is one of the specified attacks.
      Parameters:
      attacks - The attacks to compare this attack to.
      Returns:
      Whether the attack is one of the specified attacks.
    • isAttack

      @SafeVarargs public final boolean isAttack(Optional<ImmutableAttack>... attacks)
    • isAttack

      @SafeVarargs public final boolean isAttack(RegistryValue<ImmutableAttack>... attacks)
    • isAttack

      public final boolean isAttack(List<Supplier<ImmutableAttack>> attacks)
    • hasAttack

      @SafeVarargs public static boolean hasAttack(List<Attack> attackList, Optional<ImmutableAttack>... attacks)
      Checks if a list of attacks has certain attacks in it.
      Parameters:
      attackList - The list of attacks to search.
      attacks - The attacks to look for.
      Returns:
      Whether the attack list has at least one of the specified attacks.
    • hasAttack

      @SafeVarargs public static boolean hasAttack(List<Attack> attackList, RegistryValue<ImmutableAttack>... attacks)
      Checks if a list of attacks has certain attacks in it.
      Parameters:
      attackList - The list of attacks to search.
      attacks - The attacks to look for.
      Returns:
      Whether the attack list has at least one of the specified attacks.
    • hasOffensiveAttackType

      public static boolean hasOffensiveAttackType(List<Attack> attackList, Element type)
      Checks if a list of attacks has an offensive attack of a certain type.
      Parameters:
      attackList - The list of attacks to search.
      type - The type to look for.
      Returns:
      Whether the list of attacks has an offensive attack of the specified type.
    • createMoveChoices

      public void createMoveChoices(PixelmonWrapper pw, List<MoveChoice> choices, boolean includeAllies)
      Creates move choices out of an attack and adds them to a list.
      Parameters:
      pw - The Pokémon using the attack.
      choices - The list of choices to add the new choices to.
      includeAllies - Whether to include choices that only target teammates.
    • createMoveChoices

      public ArrayList<MoveChoice> createMoveChoices(PixelmonWrapper pw, boolean includeAllies)
      Creates a list of move choices for an attack.
      Parameters:
      pw - The Pokémon using the attack.
      includeAllies - Whether to include choices that only target teammates.
      Returns:
      A list of the move choices for an attack.
    • createList

      public ArrayList<Attack> createList()
      Creates a list containing the attack.
      Returns:
      A list containing the attack.
    • equals

      public boolean equals(Object compare)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getTypeEffectiveness

      public double getTypeEffectiveness(PixelmonWrapper user, PixelmonWrapper target)
      Gets the type effectiveness of the move on its target.
      Parameters:
      user - The user of the move.
      target - The target of the move.
      Returns:
      The type effectiveness multiplier of the move on its target.
    • canRemoveBerry

      public boolean canRemoveBerry()
      Checks if the move is an offensive move that can remove a held Berry. Used to delay the potential activation of Berries for these moves.
      Returns:
      Whether the move is an offensive move that can remove a held Berry.
    • copy

      public Attack copy()
      Makes a copy of the move object.
      Returns:
      A copy of the move object.
    • deepCopy

      public Attack deepCopy()
      Makes a copy of the move object.
      Returns:
      A copy of the move object.
    • checkSkyBattle

      public boolean checkSkyBattle(BattleController bc)
      Checks if the move can be used if the battle is a Sky Battle.
      Parameters:
      bc - The battle that the move is to be used in.
      Returns:
      Whether the move can be used if the battle is a Sky Battle.
    • canHitNoTarget

      public boolean canHitNoTarget()
      Checks if the move succeeds even if there is no target.
      Returns:
      Whether the move succeeds even if there is no target.
    • isSoundBased

      public boolean isSoundBased()
    • hasAttack

      public static boolean hasAttack(String moveName)
      Checks if there is a move with a certain name.
      Parameters:
      moveName - The name of the move to look for.
      Returns:
      Whether there is a move with the specified name.
    • getAttacks

      public static ImmutableAttack[] getAttacks(String[] nameList)
      Gets move details for an array of moves.
      Parameters:
      nameList - The names of the moves to get details for.
      Returns:
      An array of move details corresponding to the specified moves.
    • setOverridePower

      public void setOverridePower(int overridePower)
    • getOverridePower

      public int getOverridePower()
    • setMoveAccuracy

      public void setMoveAccuracy(int moveAccuracy)
    • ignoresWeather

      public boolean ignoresWeather(PixelmonWrapper pw)
      Whether the move has any effect that makes it ignore the weather.
      Parameters:
      pw - The user of the move.
      Returns:
      True if the move ignores the weather.
    • toString

      public String toString()
      Overrides:
      toString in class Object