Class Attack
java.lang.Object
com.pixelmonmod.pixelmon.battles.attacks.Attack
A Pokémon's attack.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
attack categories.static final int
attack categories.static final int
attack categories.boolean
Whether the attack can never miss the targetfloat
The amount of damage dealt by the attack.boolean
Whether the move critically hit or not.static final float
Type effectiveness multipliers.static final float
Type effectiveness multipliers.static final float
Type effectiveness multipliers.static final float
Type effectiveness multipliers.static final float
Type effectiveness multipliers.static final float
Type effectiveness multipliers.boolean
boolean
static final int
Special accuracy cases.boolean
boolean
int
The accuracy of the attack.int
The base power of the attack.The result of the attack.static final int
Special accuracy cases.int
Overridden base power of the attack.int
The attack's PP.int
The number of PP UP's that have been used, always 3 for a PP maxint
The original accuracy of the attack before modifications.The original attack before modifications.int
The original power of the attack before modifications. -
Constructor Summary
ConstructorDescriptionAttack
(RegistryValue<ImmutableAttack> move) Makes a deep copy of the Attack objectAttack
(ImmutableAttack base) Initializes an attack with its base attack stats.Initializes an attack with its base attack stats. -
Method Summary
Modifier and TypeMethodDescriptionapplyAttackEffect
(PixelmonWrapper user, PixelmonWrapper target) Applies status and stat modifiers.static void
applyContact
(PixelmonWrapper user, PixelmonWrapper target) Triggered when a Pokémon makes contact.static void
applyContactLate
(PixelmonWrapper user, PixelmonWrapper target) Triggered when a Pokémon makes contact.void
applySelfStatusMove
(PixelmonWrapper user, MoveResults moveResults) Triggered when a Pokémon uses a status move that targets itself.static double
calcCriticalHit
(EffectBase e, PixelmonWrapper user, PixelmonWrapper target) Calculates whether the attack will land a critical hit.double
calculateMoveAccuracy
(PixelmonWrapper user, PixelmonWrapper target, Ability userAbility) Make the calculations on how accurate a move will be.boolean
canHit
(PixelmonWrapper pixelmon1, PixelmonWrapper pixelmon2) Determines whether or not the attack can occur due to fainting.boolean
Checks if the move succeeds even if there is no target.boolean
canReachTarget
(PixelmonWrapper user, PixelmonWrapper target) Determines whether or not the attack can reach the target based on targeting infoboolean
Checks if the move is an offensive move that can remove a held Berry.boolean
cantMiss
(PixelmonWrapper user) Determines whether the move will never miss.boolean
boolean
Checks if the move can be used if the battle is a Sky Battle.copy()
Makes a copy of the move object.Creates a list containing the attack.createMoveChoices
(PixelmonWrapper pw, boolean includeAllies) Creates a list of move choices for an attack.void
createMoveChoices
(PixelmonWrapper pw, List<MoveChoice> choices, boolean includeAllies) Creates move choices out of an attack and adds them to a list.static boolean
dealsDamage
(Attack attack) Determines whether the attack deals direct damage.deepCopy()
Makes a copy of the move object.int
doDamageCalc
(PixelmonWrapper userWrapper, PixelmonWrapper targetWrapper, double crit) Calculates the attack's damage.boolean
Determines whether the attack continues between turns.boolean
The unmodified attack details.The attack's category, Physical/Special/Status.static ImmutableAttack[]
getAttacks
(String[] nameList) Gets move details for an array of moves.static float
getChanceToCrit
(EffectBase e, PixelmonWrapper user, PixelmonWrapper target) boolean
Returns whether the move is disabled.int
getMaxPP()
The attack's maximum PP with PP Ups.getMove()
The current attack.int
int
getPP()
The attack's current PP.int
The amount of PP Ups that have been used to upgrade the maximum PP of the move.getType()
double
getTypeEffectiveness
(PixelmonWrapper user, PixelmonWrapper target) Gets the type effectiveness of the move on its target.static boolean
Checks if there is a move with a certain name.static boolean
hasAttack
(List<Attack> attackList, RegistryValue<ImmutableAttack>... attacks) Checks if a list of attacks has certain attacks in it.static boolean
hasAttack
(List<Attack> attackList, Optional<ImmutableAttack>... attacks) Checks if a list of attacks has certain attacks in it.int
hashCode()
static boolean
hasMoreEffects
(Attack attack, EffectBase effect) Determines whether the attack has more possible effects to try.boolean
hasNoEffect
(PixelmonWrapper user, PixelmonWrapper target) Checks if the move has no effect on the target Pokémon.static boolean
hasOffensiveAttackType
(List<Attack> attackList, Element type) Checks if a list of attacks has an offensive attack of a certain type.boolean
hasSTAB
(PixelmonWrapper user) Determines whether the attack has STAB.boolean
Whether the move has any effect that makes it ignore the weather.void
Initializes the attack's stats and PP.final boolean
isAttack
(RegistryValue<ImmutableAttack>... attacks) boolean
isAttack
(ImmutableAttack... attacks) Determines whether the attack is one of the specified attacks.final boolean
isAttack
(List<Supplier<ImmutableAttack>> attacks) final boolean
isAttack
(Optional<ImmutableAttack>... attacks) boolean
static void
modifyMoveEffects
(PixelmonWrapper user, PixelmonWrapper target, List<EffectBase> effects) 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.void
onMiss
(PixelmonWrapper user, PixelmonWrapper target, MoveResults results, Object cause) Handles procedures when the attack misses.void
overrideAttackCategory
(AttackCategory category) void
overridePPMax
(int pp) Replaces the maximum PP of a move, overriding any PP Up/PP Max used.void
overrideType
(Element type) void
playAnimation
(PixelmonWrapper user, PixelmonWrapper target) Does animation for the attack.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.void
Restores the base attack's details if they are modified during the attack.void
void
Restores the base attack's details if they are modified during the attack.void
Saves the base attack's details.void
sendEffectiveChat
(PixelmonWrapper user, PixelmonWrapper target) Sends a battle message about the type effectiveness of an attack.void
setDisabled
(boolean value, PixelmonWrapper pixelmon) Disables or enables a move.void
setDisabled
(boolean value, PixelmonWrapper pixelmon, boolean switching) Disables or enables a move.void
setMoveAccuracy
(int moveAccuracy) void
setOverridePower
(int overridePower) void
setPP
(int pp) Sets this attack's current PP.void
setPPLevel
(int ppLevel) Sets how many PP Ups have been used on the Pokémon to increase the maximum PP for this move.toString()
boolean
use
(PixelmonWrapper user, PixelmonWrapper target, MoveResults moveResults) boolean
use
(PixelmonWrapper user, PixelmonWrapper target, MoveResults moveResults, ZMove zMove) Executes the attack.
-
Field Details
-
EFFECTIVE_NORMAL
public static final float EFFECTIVE_NORMALType effectiveness multipliers.- See Also:
-
EFFECTIVE_SUPER
public static final float EFFECTIVE_SUPERType effectiveness multipliers.- See Also:
-
EFFECTIVE_MAX
public static final float EFFECTIVE_MAXType effectiveness multipliers.- See Also:
-
EFFECTIVE_NOT
public static final float EFFECTIVE_NOTType effectiveness multipliers.- See Also:
-
EFFECTIVE_BARELY
public static final float EFFECTIVE_BARELYType effectiveness multipliers.- See Also:
-
EFFECTIVE_NONE
public static final float EFFECTIVE_NONEType effectiveness multipliers.- See Also:
-
ATTACK_PHYSICAL
public static final int ATTACK_PHYSICALattack categories.- See Also:
-
ATTACK_SPECIAL
public static final int ATTACK_SPECIALattack categories.- See Also:
-
ATTACK_STATUS
public static final int ATTACK_STATUSattack categories.- See Also:
-
NEVER_MISS
public static final int NEVER_MISSSpecial accuracy cases.- See Also:
-
IGNORE_SEMIINVULNERABLE
public static final int IGNORE_SEMIINVULNERABLESpecial accuracy cases.- See Also:
-
pp
public int ppThe attack's PP. -
ppLevel
public int ppLevelThe number of PP UP's that have been used, always 3 for a PP max -
movePower
public int movePowerThe base power of the attack. -
overridePower
public int overridePowerOverridden base power of the attack. -
moveAccuracy
public int moveAccuracyThe accuracy of the attack. -
cantMiss
public boolean cantMissWhether the attack can never miss the target -
moveResult
The result of the attack. -
damageResult
public float damageResultThe amount of damage dealt by the attack. -
didCrit
public boolean didCritWhether the move critically hit or not. -
savedAttack
The original attack before modifications. -
savedPower
public int savedPowerThe original power of the attack before modifications. -
savedAccuracy
public int savedAccuracyThe original accuracy of the attack before modifications. -
hasPlayedAnimationOnce
public transient boolean hasPlayedAnimationOnce -
isZ
public transient boolean isZ -
isMax
public transient boolean isMax -
originalMove
-
fromDancer
public transient boolean fromDancer
-
-
Constructor Details
-
Attack
Initializes an attack with its base attack stats.- Parameters:
base
- The base attack stats of this attack.
-
Attack
Initializes an attack with its base attack stats.- Parameters:
moveName
- The name of the attack.
-
Attack
-
Attack
Makes a deep copy of the Attack object- Parameters:
attack
- The attack we are assigning
-
-
Method Details
-
initializeAttack
Initializes the attack's stats and PP.- Parameters:
base
- The base attack to initialize the attack from.
-
getMove
The current attack. -
getActualMove
The unmodified attack details. -
getPP
public int getPP()The attack's current PP. -
setPP
public void setPP(int pp) Sets this attack's current PP.- Parameters:
pp
- A non-negative number.
-
getPPLevel
public int getPPLevel()The amount of PP Ups that have been used to upgrade the maximum PP of the move.This should have a minimum value of 0 and a maximum value of 3.
-
setPPLevel
public void setPPLevel(int ppLevel) Sets how many PP Ups have been used on the Pokémon to increase the maximum PP for this move.- Parameters:
ppLevel
- An integer between 0 and 3.
-
getMaxPP
public int getMaxPP()The attack's maximum PP with PP Ups. -
overridePPMax
public void overridePPMax(int pp) Replaces the maximum PP of a move, overriding any PP Up/PP Max used.Typically used for transforming into another Pokemon or into another form, such as during Dynamaxing.
- Parameters:
pp
- The number that the move's maximum PP will be set to.
-
getOverriddenPPMax
- Returns:
- the overriddenPPMax. used for updating the client that there is a override.
-
getEffects
- Returns:
- The effects for the move, whether modified by the field or base.
-
getAttackCategory
The attack's category, Physical/Special/Status. -
overrideAttackCategory
-
getType
-
getActualType
-
overrideType
-
resetMove
public void resetMove()Restores the base attack's details if they are modified during the attack. -
resetOverridePower
public void resetOverridePower() -
use
-
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
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
Does animation for the attack.- Parameters:
user
- The attack's user.target
- The attack's target.
-
doDamageCalc
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
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
Applies status and stat modifiers.- Parameters:
user
- The attack's user.target
- The attack's target.- Returns:
- The attack's result.
-
applyContact
Triggered when a Pokémon makes contact.- Parameters:
user
- The attack's user.target
- The attack's target.
-
applyContactLate
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
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
Determines whether the attack has STAB.- Parameters:
user
- The attack's user.- Returns:
- Whether the attack has STAB.
-
setDisabled
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
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
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.
-
getChanceToCrit
-
canHit
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
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
Determines whether the attack continues between turns.- Parameters:
pw
- The attack's user.- Returns:
- Whether the attack continues between turns.
-
cantMiss
Determines whether the move will never miss.- Parameters:
user
- The move's user.- Returns:
- Whether the move will never miss.
-
sendEffectiveChat
Sends a battle message about the type effectiveness of an attack.- Parameters:
user
- The attack's user.target
- The attack's target.
-
dealsDamage
Determines whether the attack deals direct damage.- Parameters:
attack
- The attack to check.- Returns:
- Whether the attack deals direct damage.
-
hasMoreEffects
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
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
-
isAttack
-
isAttack
-
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
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
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
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
Creates a list containing the attack.- Returns:
- A list containing the attack.
-
equals
-
hashCode
public int hashCode() -
getTypeEffectiveness
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
Makes a copy of the move object.- Returns:
- A copy of the move object.
-
deepCopy
Makes a copy of the move object.- Returns:
- A copy of the move object.
-
checkSkyBattle
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
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
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
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
-