Added decent spacing to all scripts thanks to Rubocop

This commit is contained in:
Maruno17
2021-12-18 15:25:40 +00:00
parent f7b76ae62e
commit d17fc40a47
207 changed files with 18577 additions and 18587 deletions

View File

@@ -7,35 +7,35 @@ class Battle::Battler
# earlier in the same round (after choosing the command but before using the
# move) or an unusable move may be called by another move such as Metronome.
#=============================================================================
def pbCanChooseMove?(move,commandPhase,showMessages = true,specialUsage = false)
def pbCanChooseMove?(move, commandPhase, showMessages = true, specialUsage = false)
# Disable
if @effects[PBEffects::DisableMove]==move.id && !specialUsage
if @effects[PBEffects::DisableMove] == move.id && !specialUsage
if showMessages
msg = _INTL("{1}'s {2} is disabled!",pbThis,move.name)
msg = _INTL("{1}'s {2} is disabled!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
end
# Heal Block
if @effects[PBEffects::HealBlock]>0 && move.healingMove?
if @effects[PBEffects::HealBlock] > 0 && move.healingMove?
if showMessages
msg = _INTL("{1} can't use {2} because of Heal Block!",pbThis,move.name)
msg = _INTL("{1} can't use {2} because of Heal Block!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
end
# Gravity
if @battle.field.effects[PBEffects::Gravity]>0 && move.unusableInGravity?
if @battle.field.effects[PBEffects::Gravity] > 0 && move.unusableInGravity?
if showMessages
msg = _INTL("{1} can't use {2} because of gravity!",pbThis,move.name)
msg = _INTL("{1} can't use {2} because of gravity!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
end
# Throat Chop
if @effects[PBEffects::ThroatChop]>0 && move.soundMove?
if @effects[PBEffects::ThroatChop] > 0 && move.soundMove?
if showMessages
msg = _INTL("{1} can't use {2} because of Throat Chop!",pbThis,move.name)
msg = _INTL("{1} can't use {2} because of Throat Chop!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
@@ -46,7 +46,7 @@ class Battle::Battler
choiced_move_name = GameData::Move.get(@effects[PBEffects::ChoiceBand]).name
if hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF])
if showMessages
msg = _INTL("The {1} only allows the use of {2}!",itemName, choiced_move_name)
msg = _INTL("The {1} only allows the use of {2}!", itemName, choiced_move_name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
@@ -59,18 +59,18 @@ class Battle::Battler
end
end
# Taunt
if @effects[PBEffects::Taunt]>0 && move.statusMove?
if @effects[PBEffects::Taunt] > 0 && move.statusMove?
if showMessages
msg = _INTL("{1} can't use {2} after the taunt!",pbThis,move.name)
msg = _INTL("{1} can't use {2} after the taunt!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
end
# Torment
if @effects[PBEffects::Torment] && !@effects[PBEffects::Instructed] &&
@lastMoveUsed && move.id==@lastMoveUsed && move.id!=@battle.struggle.id
@lastMoveUsed && move.id == @lastMoveUsed && move.id != @battle.struggle.id
if showMessages
msg = _INTL("{1} can't use the same move twice in a row due to the torment!",pbThis)
msg = _INTL("{1} can't use the same move twice in a row due to the torment!", pbThis)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
@@ -78,7 +78,7 @@ class Battle::Battler
# Imprison
if @battle.allOtherSideBattlers(@index).any? { |b| b.effects[PBEffects::Imprison] && b.pbHasMove?(move.id) }
if showMessages
msg = _INTL("{1} can't use its sealed {2}!",pbThis,move.name)
msg = _INTL("{1} can't use its sealed {2}!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
@@ -94,7 +94,7 @@ class Battle::Battler
return false
end
# Belch
return false if !move.pbCanChooseMove?(self,commandPhase,showMessages)
return false if !move.pbCanChooseMove?(self, commandPhase, showMessages)
return true
end
@@ -105,7 +105,7 @@ class Battle::Battler
# use a different move in disobedience), or false if attack stops.
def pbObedienceCheck?(choice)
return true if usingMultiTurnAttack?
return true if choice[0]!=:UseMove
return true if choice[0] != :UseMove
return true if !@battle.internalBattle
return true if !@battle.pbOwnedByPlayer?(@index)
disobedient = false
@@ -115,61 +115,61 @@ class Battle::Battler
badgeLevel = 10 * (@battle.pbPlayer.badge_count + 1)
badgeLevel = GameData::GrowthRate.max_level if @battle.pbPlayer.badge_count >= 8
if @level > badgeLevel
a = ((@level+badgeLevel)*@battle.pbRandom(256)/256).floor
disobedient |= (a>=badgeLevel)
a = ((@level + badgeLevel) * @battle.pbRandom(256) / 256).floor
disobedient |= (a >= badgeLevel)
end
end
disobedient |= !pbHyperModeObedience(choice[2])
return true if !disobedient
# Pokémon is disobedient; make it do something else
return pbDisobey(choice,badgeLevel)
return pbDisobey(choice, badgeLevel)
end
def pbDisobey(choice,badgeLevel)
def pbDisobey(choice, badgeLevel)
move = choice[2]
PBDebug.log("[Disobedience] #{pbThis} disobeyed")
@effects[PBEffects::Rage] = false
# Do nothing if using Snore/Sleep Talk
if @status == :SLEEP && move.usableWhenAsleep?
@battle.pbDisplay(_INTL("{1} ignored orders and kept sleeping!",pbThis))
@battle.pbDisplay(_INTL("{1} ignored orders and kept sleeping!", pbThis))
return false
end
b = ((@level+badgeLevel)*@battle.pbRandom(256)/256).floor
b = ((@level + badgeLevel) * @battle.pbRandom(256) / 256).floor
# Use another move
if b<badgeLevel
@battle.pbDisplay(_INTL("{1} ignored orders!",pbThis))
if b < badgeLevel
@battle.pbDisplay(_INTL("{1} ignored orders!", pbThis))
return false if !@battle.pbCanShowFightMenu?(@index)
otherMoves = []
eachMoveWithIndex do |_m,i|
next if i==choice[1]
otherMoves.push(i) if @battle.pbCanChooseMove?(@index,i,false)
eachMoveWithIndex do |_m, i|
next if i == choice[1]
otherMoves.push(i) if @battle.pbCanChooseMove?(@index, i, false)
end
return false if otherMoves.length==0 # No other move to use; do nothing
return false if otherMoves.length == 0 # No other move to use; do nothing
newChoice = otherMoves[@battle.pbRandom(otherMoves.length)]
choice[1] = newChoice
choice[2] = @moves[newChoice]
choice[3] = -1
return true
end
c = @level-badgeLevel
c = @level - badgeLevel
r = @battle.pbRandom(256)
# Fall asleep
if r<c && pbCanSleep?(self,false)
pbSleepSelf(_INTL("{1} began to nap!",pbThis))
if r < c && pbCanSleep?(self, false)
pbSleepSelf(_INTL("{1} began to nap!", pbThis))
return false
end
# Hurt self in confusion
r -= c
if r < c && @status != :SLEEP
pbConfusionDamage(_INTL("{1} won't obey! It hurt itself in its confusion!",pbThis))
pbConfusionDamage(_INTL("{1} won't obey! It hurt itself in its confusion!", pbThis))
return false
end
# Show refusal message and do nothing
case @battle.pbRandom(4)
when 0 then @battle.pbDisplay(_INTL("{1} won't obey!",pbThis))
when 1 then @battle.pbDisplay(_INTL("{1} turned away!",pbThis))
when 2 then @battle.pbDisplay(_INTL("{1} is loafing around!",pbThis))
when 3 then @battle.pbDisplay(_INTL("{1} pretended not to notice!",pbThis))
when 0 then @battle.pbDisplay(_INTL("{1} won't obey!", pbThis))
when 1 then @battle.pbDisplay(_INTL("{1} turned away!", pbThis))
when 2 then @battle.pbDisplay(_INTL("{1} is loafing around!", pbThis))
when 3 then @battle.pbDisplay(_INTL("{1} pretended not to notice!", pbThis))
end
return false
end
@@ -179,25 +179,25 @@ class Battle::Battler
# If this returns true, and if PP isn't a problem, the move will be considered
# to have been used (even if it then fails for whatever reason).
#=============================================================================
def pbTryUseMove(choice,move,specialUsage,skipAccuracyCheck)
def pbTryUseMove(choice, move, specialUsage, skipAccuracyCheck)
# Check whether it's possible for self to use the given move
# NOTE: Encore has already changed the move being used, no need to have a
# check for it here.
if !pbCanChooseMove?(move,false,true,specialUsage)
if !pbCanChooseMove?(move, false, true, specialUsage)
@lastMoveFailed = true
return false
end
# Check whether it's possible for self to do anything at all
if @effects[PBEffects::SkyDrop]>=0 # Intentionally no message here
if @effects[PBEffects::SkyDrop] >= 0 # Intentionally no message here
PBDebug.log("[Move failed] #{pbThis} can't use #{move.name} because of being Sky Dropped")
return false
end
if @effects[PBEffects::HyperBeam]>0 # Intentionally before Truant
@battle.pbDisplay(_INTL("{1} must recharge!",pbThis))
if @effects[PBEffects::HyperBeam] > 0 # Intentionally before Truant
@battle.pbDisplay(_INTL("{1} must recharge!", pbThis))
return false
end
if choice[1]==-2 # Battle Palace
@battle.pbDisplay(_INTL("{1} appears incapable of using its power!",pbThis))
if choice[1] == -2 # Battle Palace
@battle.pbDisplay(_INTL("{1} appears incapable of using its power!", pbThis))
return false
end
# Skip checking all applied effects that could make self fail doing something
@@ -206,7 +206,7 @@ class Battle::Battler
case @status
when :SLEEP
self.statusCount -= 1
if @statusCount<=0
if @statusCount <= 0
pbCureStatus
else
pbContinueStatus
@@ -217,7 +217,7 @@ class Battle::Battler
end
when :FROZEN
if !move.thawsUser?
if @battle.pbRandom(100)<20
if @battle.pbRandom(100) < 20
pbCureStatus
else
pbContinueStatus
@@ -233,7 +233,7 @@ class Battle::Battler
@effects[PBEffects::Truant] = !@effects[PBEffects::Truant]
if !@effects[PBEffects::Truant] # True means loafing, but was just inverted
@battle.pbShowAbilitySplash(self)
@battle.pbDisplay(_INTL("{1} is loafing around!",pbThis))
@battle.pbDisplay(_INTL("{1} is loafing around!", pbThis))
@lastMoveFailed = true
@battle.pbHideAbilitySplash(self)
return false
@@ -241,7 +241,7 @@ class Battle::Battler
end
# Flinching
if @effects[PBEffects::Flinch]
@battle.pbDisplay(_INTL("{1} flinched and couldn't move!",pbThis))
@battle.pbDisplay(_INTL("{1} flinched and couldn't move!", pbThis))
if abilityActive?
Battle::AbilityEffects.triggerOnFlinch(self.ability, self, @battle)
end
@@ -249,16 +249,16 @@ class Battle::Battler
return false
end
# Confusion
if @effects[PBEffects::Confusion]>0
if @effects[PBEffects::Confusion] > 0
@effects[PBEffects::Confusion] -= 1
if @effects[PBEffects::Confusion]<=0
if @effects[PBEffects::Confusion] <= 0
pbCureConfusion
@battle.pbDisplay(_INTL("{1} snapped out of its confusion.",pbThis))
@battle.pbDisplay(_INTL("{1} snapped out of its confusion.", pbThis))
else
@battle.pbCommonAnimation("Confusion",self)
@battle.pbDisplay(_INTL("{1} is confused!",pbThis))
@battle.pbCommonAnimation("Confusion", self)
@battle.pbDisplay(_INTL("{1} is confused!", pbThis))
threshold = (Settings::MECHANICS_GENERATION >= 7) ? 33 : 50 # % chance
if @battle.pbRandom(100)<threshold
if @battle.pbRandom(100) < threshold
pbConfusionDamage(_INTL("It hurt itself in its confusion!"))
@lastMoveFailed = true
return false
@@ -267,19 +267,19 @@ class Battle::Battler
end
# Paralysis
if @status == :PARALYSIS
if @battle.pbRandom(100)<25
if @battle.pbRandom(100) < 25
pbContinueStatus
@lastMoveFailed = true
return false
end
end
# Infatuation
if @effects[PBEffects::Attract]>=0
@battle.pbCommonAnimation("Attract",self)
@battle.pbDisplay(_INTL("{1} is in love with {2}!",pbThis,
if @effects[PBEffects::Attract] >= 0
@battle.pbCommonAnimation("Attract", self)
@battle.pbDisplay(_INTL("{1} is in love with {2}!", pbThis,
@battle.battlers[@effects[PBEffects::Attract]].pbThis(true)))
if @battle.pbRandom(100)<50
@battle.pbDisplay(_INTL("{1} is immobilized by love!",pbThis))
if @battle.pbRandom(100) < 50
@battle.pbDisplay(_INTL("{1} is immobilized by love!", pbThis))
@lastMoveFailed = true
return false
end
@@ -293,7 +293,7 @@ class Battle::Battler
#=============================================================================
def pbSuccessCheckAgainstTarget(move, user, target, targets)
show_message = move.pbShowFailMessages?(targets)
typeMod = move.pbCalcTypeMod(move.calcType,user,target)
typeMod = move.pbCalcTypeMod(move.calcType, user, target)
target.damageState.typeMod = typeMod
# Two-turn attacks can't fail here in the charging turn
return true if user.effects[PBEffects::TwoTurnAttack]
@@ -301,12 +301,12 @@ class Battle::Battler
return false if move.pbFailsAgainstTarget?(user, target, show_message)
# Immunity to priority moves because of Psychic Terrain
if @battle.field.terrain == :Psychic && target.affectedByTerrain? && target.opposes?(user) &&
@battle.choices[user.index][4]>0 # Move priority saved from pbCalculatePriority
@battle.choices[user.index][4] > 0 # Move priority saved from pbCalculatePriority
@battle.pbDisplay(_INTL("{1} surrounds itself with psychic terrain!", target.pbThis)) if show_message
return false
end
# Crafty Shield
if target.pbOwnSide.effects[PBEffects::CraftyShield] && user.index!=target.index &&
if target.pbOwnSide.effects[PBEffects::CraftyShield] && user.index != target.index &&
move.statusMove? && !move.pbTarget(user).targets_all
if show_message
@battle.pbCommonAnimation("CraftyShield", target)
@@ -318,7 +318,7 @@ class Battle::Battler
end
if !(user.hasActiveAbility?(:UNSEENFIST) && move.contactMove?)
# Wide Guard
if target.pbOwnSide.effects[PBEffects::WideGuard] && user.index!=target.index &&
if target.pbOwnSide.effects[PBEffects::WideGuard] && user.index != target.index &&
move.pbTarget(user).num_targets > 1 &&
(Settings::MECHANICS_GENERATION >= 7 || move.damagingMove?)
if show_message
@@ -332,7 +332,7 @@ class Battle::Battler
if move.canProtectAgainst?
# Quick Guard
if target.pbOwnSide.effects[PBEffects::QuickGuard] &&
@battle.choices[user.index][4]>0 # Move priority saved from pbCalculatePriority
@battle.choices[user.index][4] > 0 # Move priority saved from pbCalculatePriority
if show_message
@battle.pbCommonAnimation("QuickGuard", target)
@battle.pbDisplay(_INTL("Quick Guard protected {1}!", target.pbThis(true)))
@@ -376,8 +376,8 @@ class Battle::Battler
@battle.successStates[user.index].protected = true
if move.pbContactMove?(user) && user.affectedByContactEffect?
@battle.scene.pbDamageAnimation(user)
user.pbReduceHP(user.totalhp/8,false)
@battle.pbDisplay(_INTL("{1} was hurt!",user.pbThis))
user.pbReduceHP(user.totalhp / 8, false)
@battle.pbDisplay(_INTL("{1} was hurt!", user.pbThis))
user.pbItemHPHealCheck
end
return false
@@ -391,14 +391,14 @@ class Battle::Battler
target.damageState.protected = true
@battle.successStates[user.index].protected = true
if move.pbContactMove?(user) && user.affectedByContactEffect?
user.pbPoison(target) if user.pbCanPoison?(target,false)
user.pbPoison(target) if user.pbCanPoison?(target, false)
end
return false
end
# Obstruct
if target.effects[PBEffects::Obstruct] && move.damagingMove?
if show_message
@battle.pbCommonAnimation("Obstruct",target)
@battle.pbCommonAnimation("Obstruct", target)
@battle.pbDisplay(_INTL("{1} protected itself!", target.pbThis))
end
target.damageState.protected = true
@@ -468,11 +468,11 @@ class Battle::Battler
@battle.pbDisplay(_INTL("{1}'s {2} makes Ground moves miss!", target.pbThis, target.itemName)) if show_message
return false
end
if target.effects[PBEffects::MagnetRise]>0
if target.effects[PBEffects::MagnetRise] > 0
@battle.pbDisplay(_INTL("{1} makes Ground moves miss with Magnet Rise!", target.pbThis)) if show_message
return false
end
if target.effects[PBEffects::Telekinesis]>0
if target.effects[PBEffects::Telekinesis] > 0
@battle.pbDisplay(_INTL("{1} makes Ground moves miss with Telekinesis!", target.pbThis)) if show_message
return false
end
@@ -505,8 +505,8 @@ class Battle::Battler
end
end
# Substitute
if target.effects[PBEffects::Substitute]>0 && move.statusMove? &&
!move.ignoresSubstitute?(user) && user.index!=target.index
if target.effects[PBEffects::Substitute] > 0 && move.statusMove? &&
!move.ignoresSubstitute?(user) && user.index != target.index
PBDebug.log("[Target immune] #{target.pbThis} is protected by its Substitute")
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis(true))) if show_message
return false
@@ -518,14 +518,14 @@ class Battle::Battler
# Per-hit success check against the target.
# Includes semi-invulnerable move use and accuracy calculation.
#=============================================================================
def pbSuccessCheckPerHit(move,user,target,skipAccuracyCheck)
def pbSuccessCheckPerHit(move, user, target, skipAccuracyCheck)
# Two-turn attacks can't fail here in the charging turn
return true if user.effects[PBEffects::TwoTurnAttack]
# Lock-On
return true if user.effects[PBEffects::LockOn]>0 &&
user.effects[PBEffects::LockOnPos]==target.index
return true if user.effects[PBEffects::LockOn] > 0 &&
user.effects[PBEffects::LockOnPos] == target.index
# Toxic
return true if move.pbOverrideSuccessCheckPerHit(user,target)
return true if move.pbOverrideSuccessCheckPerHit(user, target)
miss = false
hitsInvul = false
# No Guard
@@ -534,7 +534,7 @@ class Battle::Battler
# Future Sight
hitsInvul = true if @battle.futureSight
# Helping Hand
hitsInvul = true if move.function=="PowerUpAllyMove"
hitsInvul = true if move.function == "PowerUpAllyMove"
if !hitsInvul
# Semi-invulnerable moves
if target.effects[PBEffects::TwoTurnAttack]
@@ -550,8 +550,8 @@ class Battle::Battler
miss = true
end
end
if target.effects[PBEffects::SkyDrop]>=0 &&
target.effects[PBEffects::SkyDrop]!=user.index
if target.effects[PBEffects::SkyDrop] >= 0 &&
target.effects[PBEffects::SkyDrop] != user.index
miss = true if !move.hitsFlyingTargets?
end
end
@@ -560,7 +560,7 @@ class Battle::Battler
# Called by another move
return true if skipAccuracyCheck
# Accuracy check
return true if move.pbAccuracyCheck(user,target) # Includes Counter/Mirror Coat
return true if move.pbAccuracyCheck(user, target) # Includes Counter/Mirror Coat
end
# Missed
PBDebug.log("[Move failed] Failed pbAccuracyCheck or target is semi-invulnerable")
@@ -570,15 +570,15 @@ class Battle::Battler
#=============================================================================
# Message shown when a move fails the per-hit success check above.
#=============================================================================
def pbMissMessage(move,user,target)
def pbMissMessage(move, user, target)
if target.damageState.affection_missed
@battle.pbDisplay(_INTL("{1} avoided the move in time with your shout!", target.pbThis))
elsif move.pbTarget(user).num_targets > 1
@battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis))
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis))
elsif target.effects[PBEffects::TwoTurnAttack]
@battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis))
elsif !move.pbMissMessage(user,target)
@battle.pbDisplay(_INTL("{1}'s attack missed!",user.pbThis))
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis))
elsif !move.pbMissMessage(user, target)
@battle.pbDisplay(_INTL("{1}'s attack missed!", user.pbThis))
end
end
end