Made AI function code-specific MoveFailureCheck handlers

This commit is contained in:
Maruno17
2022-08-27 20:11:01 +01:00
parent b6c84fa278
commit 265897f9e1
24 changed files with 1653 additions and 924 deletions

View File

@@ -85,6 +85,8 @@ end
# Raise one of user's stats.
#===============================================================================
class Battle::Move::StatUpMove < Battle::Move
attr_reader :statUp
def canSnatch?; return true; end
def pbMoveFailed?(user, targets)
@@ -108,6 +110,8 @@ end
# Raise multiple of user's stats.
#===============================================================================
class Battle::Move::MultiStatUpMove < Battle::Move
attr_reader :statUp
def canSnatch?; return true; end
def pbMoveFailed?(user, targets)
@@ -167,6 +171,8 @@ end
# Lower one of target's stats.
#===============================================================================
class Battle::Move::TargetStatDownMove < Battle::Move
attr_reader :statDown
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
@@ -190,6 +196,8 @@ end
# Lower multiple of target's stats.
#===============================================================================
class Battle::Move::TargetMultiStatDownMove < Battle::Move
attr_reader :statDown
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
@@ -479,6 +487,8 @@ end
# Weather-inducing move.
#===============================================================================
class Battle::Move::WeatherMove < Battle::Move
attr_reader :weatherType
def initialize(battle, move)
super
@weatherType = :None

View File

@@ -459,6 +459,8 @@ end
# side. (Court Change)
#===============================================================================
class Battle::Move::SwapSideEffects < Battle::Move
attr_reader :number_effects, :boolean_effects
def initialize(battle, move)
super
@number_effects = [

View File

@@ -407,6 +407,8 @@ end
# (Shell Smash)
#===============================================================================
class Battle::Move::LowerUserDefSpDef1RaiseUserAtkSpAtkSpd2 < Battle::Move
attr_reader :statUp, :statDown
def canSnatch?; return true; end
def initialize(battle, move)
@@ -1397,7 +1399,7 @@ end
# Raises the Attack and Defense of all user's allies by 1 stage each. Bypasses
# protections, including Crafty Shield. Fails if there is no ally. (Coaching)
#===============================================================================
class Battle::Move::RaiseUserAndAlliesAtkDef1 < Battle::Move
class Battle::Move::RaiseAlliesAtkDef1 < Battle::Move
def ignoresSubstitute?(user); return true; end
def canSnatch?; return true; end

View File

@@ -957,7 +957,7 @@ class Battle::Move::SetTargetAbilityToSimple < Battle::Move
end
def pbFailsAgainstTarget?(user, target, show_message)
if target.unstoppableAbility? || [:TRUANT, :SIMPLE].include?(target.ability)
if target.unstoppableAbility? || [:TRUANT, :SIMPLE].include?(target.ability_id)
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -1165,7 +1165,7 @@ class Battle::Move::NegateTargetAbility < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.unstoppableAbility?
if target.unstoppableAbility? || target.effects[PBEffects::GastroAcid]
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end

View File

@@ -453,8 +453,6 @@ class Battle::Move::DoublePowerIfTargetPoisoned < Battle::Move
end
end
#===============================================================================
# Power is doubled if the target is paralyzed. Cures the target of paralysis.
# (Smelling Salts)

View File

@@ -137,7 +137,7 @@ class Battle::Move::RestoreUserConsumedItem < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user, targets)
if !user.recycleItem
if !user.recycleItem || user.item
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -317,6 +317,7 @@ class Battle::Move::UserConsumeBerryRaiseDefense2 < Battle::Move::StatUpMove
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
# TODO: Should this return super? It can consume the berry at this point.
return super
end

View File

@@ -668,6 +668,8 @@ end
# Uses the last move that was used. (Copycat)
#===============================================================================
class Battle::Move::UseLastMoveUsed < Battle::Move
attr_reader :moveBlacklist
def callsAnotherMove?; return true; end
def initialize(battle, move)
@@ -983,6 +985,8 @@ end
# Uses a random move known by any non-user Pokémon in the user's party. (Assist)
#===============================================================================
class Battle::Move::UseRandomMoveFromUserParty < Battle::Move
attr_reader :moveBlacklist
def callsAnotherMove?; return true; end
def initialize(battle, move)
@@ -1098,6 +1102,8 @@ end
# Uses a random move the user knows. Fails if user is not asleep. (Sleep Talk)
#===============================================================================
class Battle::Move::UseRandomUserMoveIfAsleep < Battle::Move
attr_reader :moveBlacklist
def usableWhenAsleep?; return true; end
def callsAnotherMove?; return true; end
@@ -1192,6 +1198,8 @@ end
# out. (Mimic)
#===============================================================================
class Battle::Move::ReplaceMoveThisBattleWithTargetLastMoveUsed < Battle::Move
attr_reader :moveBlacklist
def ignoresSubstitute?(user); return true; end
def initialize(battle, move)
@@ -1243,6 +1251,8 @@ end
# This move permanently turns into the last move used by the target. (Sketch)
#===============================================================================
class Battle::Move::ReplaceMoveWithTargetLastMoveUsed < Battle::Move
attr_reader :moveBlacklist
def ignoresSubstitute?(user); return true; end
def initialize(battle, move)

View File

@@ -540,6 +540,8 @@ end
# The target uses its most recent move again. (Instruct)
#===============================================================================
class Battle::Move::TargetUsesItsLastUsedMoveAgain < Battle::Move
attr_reader :moveBlacklist
def ignoresSubstitute?(user); return true; end
def initialize(battle, move)
@@ -757,6 +759,8 @@ end
# For 4 rounds, the target must use the same move each round. (Encore)
#===============================================================================
class Battle::Move::DisableTargetUsingDifferentMove < Battle::Move
attr_reader :moveBlacklist
def ignoresSubstitute?(user); return true; end
def canMagicCoat?; return true; end