More tweaks from the Rubocop overlord

This commit is contained in:
Maruno17
2021-12-19 17:28:59 +00:00
parent 33781493f4
commit 65b1a8d6c3
161 changed files with 2839 additions and 2967 deletions

View File

@@ -64,11 +64,11 @@ class Battle::Scene
# Shift depending on index (no shifting needed for sideSize of 1)
case sideSize
when 2
ret[0] += [-48, 48, 32, -32][2 * index + side]
ret[1] += [ 0, 0, 0, -16][2 * index + side]
ret[0] += [-48, 48, 32, -32][(2 * index) + side]
ret[1] += [ 0, 0, 0, -16][(2 * index) + side]
when 3
ret[0] += [-80, 80, 0, 0, 80, -80][2 * index + side]
ret[1] += [ 0, 0, 0, -8, 0, -16][2 * index + side]
ret[0] += [-80, 80, 0, 0, 80, -80][(2 * index) + side]
ret[1] += [ 0, 0, 0, -8, 0, -16][(2 * index) + side]
end
return ret
end

View File

@@ -83,7 +83,7 @@ class Battle::Scene
# Wild battle, so set up the Pokémon sprite(s) accordingly
if @battle.wildBattle?
@battle.pbParty(1).each_with_index do |pkmn, i|
index = i * 2 + 1
index = (i * 2) + 1
pbChangePokemon(index, pkmn)
pkmnSprite = @sprites["pokemon_#{index}"]
pkmnSprite.tone = Tone.new(-80, -80, -80)

View File

@@ -6,11 +6,11 @@ class Battle::Scene
def pbCommandMenu(idxBattler, firstAction)
shadowTrainer = (GameData::Type.exists?(:SHADOW) && @battle.trainerBattle?)
cmds = [
_INTL("What will\n{1} do?", @battle.battlers[idxBattler].name),
_INTL("Fight"),
_INTL("Bag"),
_INTL("Pokémon"),
(shadowTrainer) ? _INTL("Call") : (firstAction) ? _INTL("Run") : _INTL("Cancel")
_INTL("What will\n{1} do?", @battle.battlers[idxBattler].name),
_INTL("Fight"),
_INTL("Bag"),
_INTL("Pokémon"),
(shadowTrainer) ? _INTL("Call") : (firstAction) ? _INTL("Run") : _INTL("Cancel")
]
ret = pbCommandMenuEx(idxBattler, cmds, (shadowTrainer) ? 2 : (firstAction) ? 0 : 1)
ret = 4 if ret == 3 && shadowTrainer # Convert "Run" to "Call"

View File

@@ -28,7 +28,7 @@ class Battle::Scene
# shiny animation(s)
# Set up data box animation
for i in 0...@battle.sideSizes[1]
idxBattler = 2 * i + 1
idxBattler = (2 * i) + 1
next if !@battle.battlers[idxBattler]
dataBoxAnim = Animation::DataBoxAppear.new(@sprites, @viewport, idxBattler)
@animations.push(dataBoxAnim)
@@ -43,7 +43,7 @@ class Battle::Scene
# Show shiny animation for wild Pokémon
if @battle.showAnims
for i in 0...@battle.sideSizes[1]
idxBattler = 2 * i + 1
idxBattler = (2 * i) + 1
next if !@battle.battlers[idxBattler] || !@battle.battlers[idxBattler].shiny?
if Settings::SUPER_SHINY && @battle.battlers[idxBattler].super_shiny?
pbCommonAnimation("SuperShiny", @battle.battlers[idxBattler])
@@ -58,13 +58,14 @@ class Battle::Scene
# Animates a party lineup appearing for the given side
#=============================================================================
def pbShowPartyLineup(side, fullAnim = false)
@animations.push(Animation::LineupAppear.new(
@sprites, @viewport, side, @battle.pbParty(side), @battle.pbPartyStarts(side), fullAnim
))
if !fullAnim
while inPartyAnimation?
pbUpdate
end
@animations.push(
Animation::LineupAppear.new(@sprites, @viewport, side,
@battle.pbParty(side), @battle.pbPartyStarts(side),
fullAnim)
)
return if fullAnim
while inPartyAnimation?
pbUpdate
end
end
@@ -298,13 +299,13 @@ class Battle::Scene
#=============================================================================
def pbLevelUp(pkmn, _battler, oldTotalHP, oldAttack, oldDefense, oldSpAtk, oldSpDef, oldSpeed)
pbTopRightWindow(
_INTL("Max. HP<r>+{1}\r\nAttack<r>+{2}\r\nDefense<r>+{3}\r\nSp. Atk<r>+{4}\r\nSp. Def<r>+{5}\r\nSpeed<r>+{6}",
pkmn.totalhp - oldTotalHP, pkmn.attack - oldAttack, pkmn.defense - oldDefense,
pkmn.spatk - oldSpAtk, pkmn.spdef - oldSpDef, pkmn.speed - oldSpeed)
_INTL("Max. HP<r>+{1}\r\nAttack<r>+{2}\r\nDefense<r>+{3}\r\nSp. Atk<r>+{4}\r\nSp. Def<r>+{5}\r\nSpeed<r>+{6}",
pkmn.totalhp - oldTotalHP, pkmn.attack - oldAttack, pkmn.defense - oldDefense,
pkmn.spatk - oldSpAtk, pkmn.spdef - oldSpDef, pkmn.speed - oldSpeed)
)
pbTopRightWindow(
_INTL("Max. HP<r>{1}\r\nAttack<r>{2}\r\nDefense<r>{3}\r\nSp. Atk<r>{4}\r\nSp. Def<r>{5}\r\nSpeed<r>{6}",
pkmn.totalhp, pkmn.attack, pkmn.defense, pkmn.spatk, pkmn.spdef, pkmn.speed)
_INTL("Max. HP<r>{1}\r\nAttack<r>{2}\r\nDefense<r>{3}\r\nSp. Atk<r>{4}\r\nSp. Def<r>{5}\r\nSpeed<r>{6}",
pkmn.totalhp, pkmn.attack, pkmn.defense, pkmn.spatk, pkmn.spdef, pkmn.speed)
)
end
@@ -541,7 +542,7 @@ class Battle::Scene
end
animPlayer.setLineTransform(
FOCUSUSER_X, FOCUSUSER_Y, FOCUSTARGET_X, FOCUSTARGET_Y,
oldUserX, oldUserY - userHeight / 2, oldTargetX, oldTargetY - targetHeight / 2
oldUserX, oldUserY - (userHeight / 2), oldTargetX, oldTargetY - (targetHeight / 2)
)
# Play the animation
animPlayer.start

View File

@@ -106,11 +106,11 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
USE_GRAPHICS = true
# Lists of which button graphics to use in different situations/types of battle.
MODES = [
[0, 2, 1, 3], # 0 = Regular battle
[0, 2, 1, 9], # 1 = Regular battle with "Cancel" instead of "Run"
[0, 2, 1, 4], # 2 = Regular battle with "Call" instead of "Run"
[5, 7, 6, 3], # 3 = Safari Zone
[0, 8, 1, 3] # 4 = Bug Catching Contest
[0, 2, 1, 3], # 0 = Regular battle
[0, 2, 1, 9], # 1 = Regular battle with "Cancel" instead of "Run"
[0, 2, 1, 4], # 2 = Regular battle with "Call" instead of "Run"
[5, 7, 6, 3], # 3 = Safari Zone
[0, 8, 1, 3] # 4 = Bug Catching Contest
]
def initialize(viewport, z)
@@ -137,7 +137,7 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
button = SpriteWrapper.new(viewport)
button.bitmap = @buttonBitmap.bitmap
button.x = self.x + Graphics.width - 260
button.x += (i.even? ? 0 : @buttonBitmap.width / 2 - 4)
button.x += (i.even? ? 0 : (@buttonBitmap.width / 2) - 4)
button.y = self.y + 6
button.y += (((i / 2) == 0) ? 0 : BUTTON_HEIGHT - 4)
button.src_rect.width = @buttonBitmap.width / 2
@@ -218,10 +218,10 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
TYPE_ICON_HEIGHT = 28
# Text colours of PP of selected move
PP_COLORS = [
Color.new(248, 72, 72), Color.new(136, 48, 48), # Red, zero PP
Color.new(248, 136, 32), Color.new(144, 72, 24), # Orange, 1/4 of total PP or less
Color.new(248, 192, 0), Color.new(144, 104, 0), # Yellow, 1/2 of total PP or less
TEXT_BASE_COLOR, TEXT_SHADOW_COLOR # Black, more than 1/2 of total PP
Color.new(248, 72, 72), Color.new(136, 48, 48), # Red, zero PP
Color.new(248, 136, 32), Color.new(144, 72, 24), # Orange, 1/4 of total PP or less
Color.new(248, 192, 0), Color.new(144, 104, 0), # Yellow, 1/2 of total PP or less
TEXT_BASE_COLOR, TEXT_SHADOW_COLOR # Black, more than 1/2 of total PP
]
def initialize(viewport, z)
@@ -247,7 +247,7 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
button = SpriteWrapper.new(viewport)
button.bitmap = @buttonBitmap.bitmap
button.x = self.x + 4
button.x += (i.even? ? 0 : @buttonBitmap.width / 2 - 4)
button.x += (i.even? ? 0 : (@buttonBitmap.width / 2) - 4)
button.y = self.y + 6
button.y += (((i / 2) == 0) ? 0 : BUTTON_HEIGHT - 4)
button.src_rect.width = @buttonBitmap.width / 2
@@ -278,7 +278,7 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
@megaButton = SpriteWrapper.new(viewport)
@megaButton.bitmap = @megaEvoBitmap.bitmap
@megaButton.x = self.x + 120
@megaButton.y = self.y - @megaEvoBitmap.height / 2
@megaButton.y = self.y - (@megaEvoBitmap.height / 2)
@megaButton.src_rect.height = @megaEvoBitmap.height / 2
addSprite("megaButton", @megaButton)
# Create Shift button
@@ -354,7 +354,7 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
textPos = []
@buttons.each_with_index do |button, i|
next if !@visibility["button_#{i}"]
x = button.x - self.x + button.src_rect.width / 2
x = button.x - self.x + (button.src_rect.width / 2)
y = button.y - self.y + 2
moveNameBase = TEXT_BASE_COLOR
if GET_MOVE_TEXT_COLOR_FROM_MOVE_BUTTON && moves[i].display_type(@battler)
@@ -414,7 +414,7 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
ppFraction = [(4.0 * move.pp / move.total_pp).ceil, 3].min
textPos = []
textPos.push([_INTL("PP: {1}/{2}", move.pp, move.total_pp),
448, 44, 2, PP_COLORS[ppFraction * 2], PP_COLORS[ppFraction * 2 + 1]])
448, 44, 2, PP_COLORS[ppFraction * 2], PP_COLORS[(ppFraction * 2) + 1]])
pbDrawTextPositions(@infoOverlay.bitmap, textPos)
end
end
@@ -454,11 +454,11 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
# Lists of which button graphics to use in different situations/types of battle.
MODES = [
[0, 2, 1, 3], # 0 = Regular battle
[0, 2, 1, 9], # 1 = Regular battle with "Cancel" instead of "Run"
[0, 2, 1, 4], # 2 = Regular battle with "Call" instead of "Run"
[5, 7, 6, 3], # 3 = Safari Zone
[0, 8, 1, 3] # 4 = Bug Catching Contest
[0, 2, 1, 3], # 0 = Regular battle
[0, 2, 1, 9], # 1 = Regular battle with "Cancel" instead of "Run"
[0, 2, 1, 4], # 2 = Regular battle with "Call" instead of "Run"
[5, 7, 6, 3], # 3 = Safari Zone
[0, 8, 1, 3] # 4 = Bug Catching Contest
]
CMD_BUTTON_WIDTH_SMALL = 170
TEXT_BASE_COLOR = Color.new(240, 248, 224)
@@ -467,7 +467,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
def initialize(viewport, z, sideSizes)
super(viewport)
@sideSizes = sideSizes
maxIndex = (@sideSizes[0] > @sideSizes[1]) ? (@sideSizes[0] - 1) * 2 : @sideSizes[1] * 2 - 1
maxIndex = (@sideSizes[0] > @sideSizes[1]) ? (@sideSizes[0] - 1) * 2 : (@sideSizes[1] * 2) - 1
@smallButtons = (@sideSizes.max > 2)
self.x = 0
self.y = Graphics.height - 96
@@ -483,7 +483,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
# NOTE: Battler indexes go from left to right from the perspective of
# that side's trainer, so inc is different for each side for the
# same value of i/2.
inc = (i.even?) ? i / 2 : numButtons - 1 - i / 2
inc = (i.even?) ? i / 2 : numButtons - 1 - (i / 2)
button = SpriteWrapper.new(viewport)
button.bitmap = @buttonBitmap.bitmap
button.src_rect.width = (@smallButtons) ? CMD_BUTTON_WIDTH_SMALL : @buttonBitmap.width / 2
@@ -536,7 +536,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
sel ||= (@mode == 1)
buttonType = (i.even?) ? 1 : 2
end
buttonType = 2 * buttonType + ((@smallButtons) ? 1 : 0)
buttonType = (2 * buttonType) + ((@smallButtons) ? 1 : 0)
button.src_rect.x = (sel) ? @buttonBitmap.width / 2 : 0
button.src_rect.y = buttonType * BUTTON_HEIGHT
button.z = self.z + ((sel) ? 3 : 2)
@@ -546,7 +546,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
textpos = []
@buttons.each_with_index do |button, i|
next if !button || nil_or_empty?(@texts[i])
x = button.x - self.x + button.src_rect.width / 2
x = button.x - self.x + (button.src_rect.width / 2)
y = button.y - self.y + 2
textpos.push([@texts[i], x, y, 2, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR])
end

View File

@@ -96,7 +96,7 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
@contents = BitmapWrapper.new(@databoxBitmap.width, @databoxBitmap.height)
self.bitmap = @contents
self.visible = false
self.z = 150 + ((@battler.index) / 2) * 5
self.z = 150 + ((@battler.index / 2) * 5)
pbSetSystemFont(self.bitmap)
end
@@ -538,9 +538,9 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
return if !@_iconBitmap
pbSetOrigin
if @index.even?
self.z = 50 + 5 * @index / 2
self.z = 50 + (5 * @index / 2)
else
self.z = 50 - 5 * (@index + 1) / 2
self.z = 50 - (5 * (@index + 1) / 2)
end
# Set original position
p = Battle::Scene.pbBattlerPosition(@index, @sideSize)

View File

@@ -102,7 +102,7 @@ module Battle::Scene::Animation::BallAnimationMixin
ball.setVisible(7, true)
ballStartX = traSprite.x
ballStartX -= ball.totalDuration * (Graphics.width / (2 * 16)) if !safariThrow
ballStartY = traSprite.y - traSprite.bitmap.height / 2
ballStartY = traSprite.y - (traSprite.bitmap.height / 2)
return ballStartX, ballStartY
end
# Back sprite is animated, make the Poké Ball track the trainer's hand
@@ -166,13 +166,13 @@ module Battle::Scene::Animation::BallAnimationMixin
# throw). Instead, that throw animation and initialDelay are designed
# to make sure the Ball's trajectory starts at the same position.
ball.setVisible(delay, true)
a = 2 * startY - 4 * midY + 2 * endY
b = 4 * midY - 3 * startY - endY
a = (2 * startY) - (4 * midY) + (2 * endY)
b = (4 * midY) - (3 * startY) - endY
c = startY
for i in 1..duration
t = i.to_f / duration # t ranges from 0 to 1
x = startX + (endX - startX) * t # Linear in t
y = a * t**2 + b * t + c # Quadratic in t
t = i.to_f / duration # t ranges from 0 to 1
x = startX + ((endX - startX) * t) # Linear in t
y = (a * (t**2)) + (b * t) + c # Quadratic in t
ball.moveXY(delay + i - 1, 1, x, y)
end
createBallTumbling(ball, delay, duration)

View File

@@ -28,7 +28,7 @@ class Battle::Scene::Animation::Intro < Battle::Scene::Animation
end
else # Wild battle
@battle.pbParty(1).each_with_index do |_pkmn, i|
idxBattler = 2 * i + 1
idxBattler = (2 * i) + 1
makeSlideSprite("pokemon_#{idxBattler}", -1, appearTime, PictureOrigin::Bottom)
end
end
@@ -71,7 +71,7 @@ class Battle::Scene::Animation::Intro2 < Battle::Scene::Animation
def createProcesses
for i in 0...@sideSize
idxBattler = 2 * i + 1
idxBattler = (2 * i) + 1
next if !@sprites["pokemon_#{idxBattler}"]
battler = addSprite(@sprites["pokemon_#{idxBattler}"], PictureOrigin::Bottom)
battler.moveTone(0, 4, Tone.new(0, 0, 0, 0))
@@ -112,7 +112,7 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation
ballY = barY - 30
barX -= bar.bitmap.width
end
ballXdiff = 32 * (1 - 2 * @side)
ballXdiff = 32 * (1 - (2 * @side))
bar.x = barX
bar.y = barY
bar.opacity = 255
@@ -155,7 +155,7 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation
bar.moveDelta(0, 8, -dir * Graphics.width / 2, 0)
delay = bar.totalDuration
for i in 0...Battle::Scene::NUM_BALLS
createBall(i, (@fullAnim) ? delay + i * 2 : 0, dir)
createBall(i, (@fullAnim) ? delay + (i * 2) : 0, dir)
end
end
@@ -287,7 +287,7 @@ class Battle::Scene::Animation::TrainerAppear < Battle::Scene::Animation
# Make new trainer sprite move on-screen
if @sprites["trainer_#{@idxTrainer + 1}"]
trainerX, trainerY = Battle::Scene.pbTrainerPosition(1)
trainerX += 64 + Graphics.width / 4
trainerX += 64 + (Graphics.width / 4)
newTrainer = addSprite(@sprites["trainer_#{@idxTrainer + 1}"], PictureOrigin::Bottom)
newTrainer.setVisible(delay, true)
newTrainer.setXY(delay, trainerX, trainerY)
@@ -342,7 +342,7 @@ class Battle::Scene::Animation::PlayerFade < Battle::Scene::Animation
for i in 0...Battle::Scene::NUM_BALLS
next if !@sprites["partyBall_0_#{i}"] || !@sprites["partyBall_0_#{i}"].visible
partyBall = addSprite(@sprites["partyBall_0_#{i}"])
partyBall.moveDelta(delay + 2 * i, 16, -Graphics.width, 0) if @fullAnim
partyBall.moveDelta(delay + (2 * i), 16, -Graphics.width, 0) if @fullAnim
partyBall.moveOpacity(delay, 12, 0)
partyBall.setVisible(delay + 12, false)
partyBall.setOpacity(delay + 12, 255)
@@ -387,7 +387,7 @@ class Battle::Scene::Animation::TrainerFade < Battle::Scene::Animation
for i in 0...Battle::Scene::NUM_BALLS
next if !@sprites["partyBall_1_#{i}"] || !@sprites["partyBall_1_#{i}"].visible
partyBall = addSprite(@sprites["partyBall_1_#{i}"])
partyBall.moveDelta(delay + 2 * i, 16, Graphics.width, 0) if @fullAnim
partyBall.moveDelta(delay + (2 * i), 16, Graphics.width, 0) if @fullAnim
partyBall.moveOpacity(delay, 12, 0)
partyBall.setVisible(delay + 12, false)
partyBall.setOpacity(delay + 12, 255)
@@ -782,12 +782,12 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation
d = [1, 2, 4, 8][i] # Fraction of the starting height each bounce rises to
delay -= t if i == 0
if i > 0
ball.setZoomXY(delay, 100 + 5 * (5 - i), 100 - 5 * (5 - i)) # Squish
ball.setZoomXY(delay, 100 + (5 * (5 - i)), 100 - (5 * (5 - i))) # Squish
ball.moveZoom(delay, 2, 100) # Unsquish
ball.moveXY(delay, t, ballEndX, ballGroundY - (ballGroundY - ballEndY) / d)
ball.moveXY(delay, t, ballEndX, ballGroundY - ((ballGroundY - ballEndY) / d))
end
ball.moveXY(delay + t, t, ballEndX, ballGroundY)
ball.setSE(delay + 2 * t, "Battle ball drop", 100 - i * 7)
ball.setSE(delay + (2 * t), "Battle ball drop", 100 - (i * 7))
delay = ball.totalDuration
end
battler.setXY(ball.totalDuration, ballEndX, ballGroundY)
@@ -795,9 +795,9 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation
delay = ball.totalDuration + 12
for i in 0...[@numShakes, 3].min
ball.setSE(delay, "Battle ball shake")
ball.moveXY(delay, 2, ballEndX - 2 * (4 - i), ballGroundY)
ball.moveXY(delay, 2, ballEndX - (2 * (4 - i)), ballGroundY)
ball.moveAngle(delay, 2, 5 * (4 - i)) # positive means counterclockwise
ball.moveXY(delay + 2, 4, ballEndX + 2 * (4 - i), ballGroundY)
ball.moveXY(delay + 2, 4, ballEndX + (2 * (4 - i)), ballGroundY)
ball.moveAngle(delay + 2, 4, -5 * (4 - i)) # negative means clockwise
ball.moveXY(delay + 6, 2, ballEndX, ballGroundY)
ball.moveAngle(delay + 6, 2, 0)