More Rubocop

This commit is contained in:
Maruno17
2021-12-27 00:26:45 +00:00
parent 4a6324389b
commit aa643a6049
51 changed files with 346 additions and 323 deletions

View File

@@ -93,6 +93,11 @@ Style/Documentation:
Style/FormatString:
EnforcedStyle: sprintf
# String literals are not frozen by default, which makes this comment a
# pointless bit of boilerplate that we neither need nor want.
Style/FrozenStringLiteralComment:
Enabled: false
# RMXP and Essentials use lots of global variables.
Style/GlobalVars:
Enabled: false

View File

@@ -43,8 +43,8 @@ class Module
delimiter = class_method ? '.' : '#'
target.define_method(name) do |*args, **kvargs|
alias_name = format('%s%s%s', class_name, delimiter, name)
aliased_method_name = format('%s%s%s', class_name, delimiter, aliased_method)
alias_name = sprintf('%s%s%s', class_name, delimiter, name)
aliased_method_name = sprintf('%s%s%s', class_name, delimiter, aliased_method)
Deprecation.warn_method(alias_name, removal_in, aliased_method_name)
method(aliased_method).call(*args, **kvargs)
end

View File

@@ -413,12 +413,12 @@ module PluginManager
# -1 if v1 is lower than v2
#-----------------------------------------------------------------------------
def self.compare_versions(v1, v2)
d1 = v1.split("")
d1 = v1.chars
d1.insert(0, "0") if d1[0] == "." # Turn ".123" into "0.123"
while d1[-1] == "." # Turn "123." into "123"
d1 = d1[0..-2]
end
d2 = v2.split("")
d2 = v2.chars
d2.insert(0, "0") if d2[0] == "." # Turn ".123" into "0.123"
while d2[-1] == "." # Turn "123." into "123"
d2 = d2[0..-2]

View File

@@ -9,9 +9,9 @@ class SpriteAnimation
["x", "y", "ox", "oy", "viewport", "flash", "src_rect", "opacity", "tone"].each do |def_name|
eval <<-__END__
def #{def_name}(*arg)
@sprite.#{def_name}(*arg)
end
def #{def_name}(*arg) # def x(*arg)
@sprite.#{def_name}(*arg) # @sprite.x(*arg)
end # end
__END__
end

View File

@@ -10,7 +10,7 @@ module Game
$data_system = load_data('Data/System.rxdata')
pbLoadBattleAnimations
GameData.load_all
map_file = format('Data/Map%03d.rxdata', $data_system.start_map_id)
map_file = sprintf('Data/Map%03d.rxdata', $data_system.start_map_id)
if $data_system.start_map_id == 0 || !pbRgssExists?(map_file)
raise _INTL('No starting position was set in the map editor.')
end

View File

@@ -22,7 +22,7 @@ class Interpreter
def inspect
str = super.chop
str << format(' @event_id: %d>', @event_id)
str << sprintf(' @event_id: %d>', @event_id)
return str
end

View File

@@ -16,7 +16,7 @@ class Game_SelfSwitches
# key : key
#-----------------------------------------------------------------------------
def [](key)
return (@data[key] == true) ? true : false
return @data[key] == true
end
#-----------------------------------------------------------------------------
# * Set Self Switch

View File

@@ -8,7 +8,7 @@ class Sprite_Reflection
@event = event
@height = 0
@fixedheight = false
if @event != $game_player && @event&.name[/reflection\((\d+)\)/i]
if @event && @event != $game_player && @event.name[/reflection\((\d+)\)/i]
@height = $~[1].to_i || 0
@fixedheight = true
end

View File

@@ -1,38 +1,38 @@
class PictureOrigin
TopLeft = 0
Center = 1
TopRight = 2
BottomLeft = 3
LowerLeft = 3
BottomRight = 4
LowerRight = 4
Top = 5
Bottom = 6
Left = 7
Right = 8
TOP_LEFT = 0
CENTER = 1
TOP_RIGHT = 2
BOTTOM_LEFT = 3
LOWER_LEFT = 3
BOTTOM_RIGHT = 4
LOWER_RIGHT = 4
TOP = 5
BOTTOM = 6
LEFT = 7
RIGHT = 8
end
class Processes
XY = 0
DeltaXY = 1
DELTA_XY = 1
Z = 2
Curve = 3
Zoom = 4
Angle = 5
Tone = 6
Color = 7
Hue = 8
Opacity = 9
Visible = 10
BlendType = 11
CURVE = 3
ZOOM = 4
ANGLE = 5
TONE = 6
COLOR = 7
HUE = 8
OPACITY = 9
VISIBLE = 10
BLEND_TYPE = 11
SE = 12
Name = 13
Origin = 14
Src = 15
SrcSize = 16
CropBottom = 17
NAME = 13
ORIGIN = 14
SRC = 15
SRC_SIZE = 16
CROP_BOTTOM = 17
end
@@ -114,7 +114,7 @@ class PictureEx
@visible = true
@blend_type = 0
@name = ""
@origin = PictureOrigin::TopLeft
@origin = PictureOrigin::TOP_LEFT
@src_rect = Rect.new(0, 0, -1, -1)
@cropBottom = -1
@frameUpdates = []
@@ -213,12 +213,12 @@ class PictureEx
def moveCurve(delay, duration, x1, y1, x2, y2, x3, y3, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Curve, delay, duration, 0, cb, [@x, @y, x1, y1, x2, y2, x3, y3]])
@processes.push([Processes::CURVE, delay, duration, 0, cb, [@x, @y, x1, y1, x2, y2, x3, y3]])
end
def moveDelta(delay, duration, x, y, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::DeltaXY, delay, duration, 0, cb, @x, @y, x, y])
@processes.push([Processes::DELTA_XY, delay, duration, 0, cb, @x, @y, x, y])
end
def setDelta(delay, x, y, cb = nil)
@@ -236,7 +236,7 @@ class PictureEx
def moveZoomXY(delay, duration, zoom_x, zoom_y, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Zoom, delay, duration, 0, cb, @zoom_x, @zoom_y, zoom_x, zoom_y])
@processes.push([Processes::ZOOM, delay, duration, 0, cb, @zoom_x, @zoom_y, zoom_x, zoom_y])
end
def setZoomXY(delay, zoom_x, zoom_y, cb = nil)
@@ -253,7 +253,7 @@ class PictureEx
def moveAngle(delay, duration, angle, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Angle, delay, duration, 0, cb, @angle, angle])
@processes.push([Processes::ANGLE, delay, duration, 0, cb, @angle, angle])
end
def setAngle(delay, angle, cb = nil)
@@ -263,7 +263,7 @@ class PictureEx
def moveTone(delay, duration, tone, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
target = (tone) ? tone.clone : Tone.new(0, 0, 0, 0)
@processes.push([Processes::Tone, delay, duration, 0, cb, @tone.clone, target])
@processes.push([Processes::TONE, delay, duration, 0, cb, @tone.clone, target])
end
def setTone(delay, tone, cb = nil)
@@ -273,7 +273,7 @@ class PictureEx
def moveColor(delay, duration, color, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
target = (color) ? color.clone : Color.new(0, 0, 0, 0)
@processes.push([Processes::Color, delay, duration, 0, cb, @color.clone, target])
@processes.push([Processes::COLOR, delay, duration, 0, cb, @color.clone, target])
end
def setColor(delay, color, cb = nil)
@@ -283,7 +283,7 @@ class PictureEx
# Hue changes don't actually work.
def moveHue(delay, duration, hue, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Hue, delay, duration, 0, cb, @hue, hue])
@processes.push([Processes::HUE, delay, duration, 0, cb, @hue, hue])
end
# Hue changes don't actually work.
@@ -293,7 +293,7 @@ class PictureEx
def moveOpacity(delay, duration, opacity, cb = nil)
delay, duration = ensureDelayAndDuration(delay, duration)
@processes.push([Processes::Opacity, delay, duration, 0, cb, @opacity, opacity])
@processes.push([Processes::OPACITY, delay, duration, 0, cb, @opacity, opacity])
end
def setOpacity(delay, opacity, cb = nil)
@@ -302,13 +302,13 @@ class PictureEx
def setVisible(delay, visible, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::Visible, delay, 0, 0, cb, visible])
@processes.push([Processes::VISIBLE, delay, 0, 0, cb, visible])
end
# Only values of 0 (normal), 1 (additive) and 2 (subtractive) are allowed.
def setBlendType(delay, blend, cb = nil)
delay = ensureDelayAndDuration(delay)
@processes.push([Processes::BlendType, delay, 0, 0, cb, blend])
@processes.push([Processes::BLEND_TYPE, delay, 0, 0, cb, blend])
end
def setSE(delay, seFile, volume = nil, pitch = nil, cb = nil)
@@ -318,28 +318,28 @@ class PictureEx
def setName(delay, name, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::Name, delay, 0, 0, cb, name])
@processes.push([Processes::NAME, delay, 0, 0, cb, name])
end
def setOrigin(delay, origin, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::Origin, delay, 0, 0, cb, origin])
@processes.push([Processes::ORIGIN, delay, 0, 0, cb, origin])
end
def setSrc(delay, srcX, srcY, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::Src, delay, 0, 0, cb, srcX, srcY])
@processes.push([Processes::SRC, delay, 0, 0, cb, srcX, srcY])
end
def setSrcSize(delay, srcWidth, srcHeight, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::SrcSize, delay, 0, 0, cb, srcWidth, srcHeight])
@processes.push([Processes::SRC_SIZE, delay, 0, 0, cb, srcWidth, srcHeight])
end
# Used to cut Pokémon sprites off when they faint and sink into the ground.
def setCropBottom(delay, y, cb = nil)
delay = ensureDelay(delay)
@processes.push([Processes::CropBottom, delay, 0, 0, cb, y])
@processes.push([Processes::CROP_BOTTOM, delay, 0, 0, cb, y])
end
def update
@@ -354,28 +354,28 @@ class PictureEx
when Processes::XY
process[5] = @x
process[6] = @y
when Processes::DeltaXY
when Processes::DELTA_XY
process[5] = @x
process[6] = @y
process[7] += @x
process[8] += @y
when Processes::Curve
when Processes::CURVE
process[5][0] = @x
process[5][1] = @y
when Processes::Z
process[5] = @z
when Processes::Zoom
when Processes::ZOOM
process[5] = @zoom_x
process[6] = @zoom_y
when Processes::Angle
when Processes::ANGLE
process[5] = @angle
when Processes::Tone
when Processes::TONE
process[5] = @tone.clone
when Processes::Color
when Processes::COLOR
process[5] = @color.clone
when Processes::Hue
when Processes::HUE
process[5] = @hue
when Processes::Opacity
when Processes::OPACITY
process[5] = @opacity
end
end
@@ -389,49 +389,49 @@ class PictureEx
fra = (process[2] == 0) ? 1 : process[3] # Frame counter
dur = (process[2] == 0) ? 1 : process[2] # Total duration of process
case process[0]
when Processes::XY, Processes::DeltaXY
when Processes::XY, Processes::DELTA_XY
@x = process[5] + (fra * (process[7] - process[5]) / dur)
@y = process[6] + (fra * (process[8] - process[6]) / dur)
when Processes::Curve
when Processes::CURVE
@x, @y = getCubicPoint2(process[5], fra.to_f / dur)
when Processes::Z
@z = process[5] + (fra * (process[6] - process[5]) / dur)
when Processes::Zoom
when Processes::ZOOM
@zoom_x = process[5] + (fra * (process[7] - process[5]) / dur)
@zoom_y = process[6] + (fra * (process[8] - process[6]) / dur)
when Processes::Angle
when Processes::ANGLE
@angle = process[5] + (fra * (process[6] - process[5]) / dur)
when Processes::Tone
when Processes::TONE
@tone.red = process[5].red + (fra * (process[6].red - process[5].red) / dur)
@tone.green = process[5].green + (fra * (process[6].green - process[5].green) / dur)
@tone.blue = process[5].blue + (fra * (process[6].blue - process[5].blue) / dur)
@tone.gray = process[5].gray + (fra * (process[6].gray - process[5].gray) / dur)
when Processes::Color
when Processes::COLOR
@color.red = process[5].red + (fra * (process[6].red - process[5].red) / dur)
@color.green = process[5].green + (fra * (process[6].green - process[5].green) / dur)
@color.blue = process[5].blue + (fra * (process[6].blue - process[5].blue) / dur)
@color.alpha = process[5].alpha + (fra * (process[6].alpha - process[5].alpha) / dur)
when Processes::Hue
when Processes::HUE
@hue = (process[6] - process[5]).to_f / dur
when Processes::Opacity
when Processes::OPACITY
@opacity = process[5] + (fra * (process[6] - process[5]) / dur)
when Processes::Visible
when Processes::VISIBLE
@visible = process[5]
when Processes::BlendType
when Processes::BLEND_TYPE
@blend_type = process[5]
when Processes::SE
pbSEPlay(process[5], process[6], process[7])
when Processes::Name
when Processes::NAME
@name = process[5]
when Processes::Origin
when Processes::ORIGIN
@origin = process[5]
when Processes::Src
when Processes::SRC
@src_rect.x = process[5]
@src_rect.y = process[6]
when Processes::SrcSize
when Processes::SRC_SIZE
@src_rect.width = process[5]
@src_rect.height = process[6]
when Processes::CropBottom
when Processes::CROP_BOTTOM
@cropBottom = process[5]
end
# Increase frame counter
@@ -447,7 +447,7 @@ class PictureEx
@processes.compact! if procEnded
# Add the constant rotation speed
if @rotate_speed != 0
@frameUpdates.push(Processes::Angle) if !@frameUpdates.include?(Processes::Angle)
@frameUpdates.push(Processes::ANGLE) if !@frameUpdates.include?(Processes::ANGLE)
@angle += @rotate_speed
while @angle < 0
@angle += 360
@@ -466,52 +466,52 @@ def setPictureSprite(sprite, picture, iconSprite = false)
return if picture.frameUpdates.length == 0
picture.frameUpdates.each do |type|
case type
when Processes::XY, Processes::DeltaXY
when Processes::XY, Processes::DELTA_XY
sprite.x = picture.x.round
sprite.y = picture.y.round
when Processes::Z
sprite.z = picture.z
when Processes::Zoom
when Processes::ZOOM
sprite.zoom_x = picture.zoom_x / 100.0
sprite.zoom_y = picture.zoom_y / 100.0
when Processes::Angle
when Processes::ANGLE
sprite.angle = picture.angle
when Processes::Tone
when Processes::TONE
sprite.tone = picture.tone
when Processes::Color
when Processes::COLOR
sprite.color = picture.color
when Processes::Hue
when Processes::HUE
# This doesn't do anything.
when Processes::BlendType
when Processes::BLEND_TYPE
sprite.blend_type = picture.blend_type
when Processes::Opacity
when Processes::OPACITY
sprite.opacity = picture.opacity
when Processes::Visible
when Processes::VISIBLE
sprite.visible = picture.visible
when Processes::Name
when Processes::NAME
sprite.name = picture.name if iconSprite && sprite.name != picture.name
when Processes::Origin
when Processes::ORIGIN
case picture.origin
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
when PictureOrigin::TOP_LEFT, PictureOrigin::LEFT, PictureOrigin::BOTTOM_LEFT
sprite.ox = 0
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
when PictureOrigin::TOP, PictureOrigin::CENTER, PictureOrigin::BOTTOM
sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width / 2 : 0
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
when PictureOrigin::TOP_RIGHT, PictureOrigin::RIGHT, PictureOrigin::BOTTOM_RIGHT
sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width : 0
end
case picture.origin
when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight
when PictureOrigin::TOP_LEFT, PictureOrigin::TOP, PictureOrigin::TOP_RIGHT
sprite.oy = 0
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
when PictureOrigin::LEFT, PictureOrigin::CENTER, PictureOrigin::RIGHT
sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height / 2 : 0
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
when PictureOrigin::BOTTOM_LEFT, PictureOrigin::BOTTOM, PictureOrigin::BOTTOM_RIGHT
sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height : 0
end
when Processes::Src
when Processes::SRC
next unless iconSprite && sprite.src_rect
sprite.src_rect.x = picture.src_rect.x
sprite.src_rect.y = picture.src_rect.y
when Processes::SrcSize
when Processes::SRC_SIZE
next unless iconSprite && sprite.src_rect
sprite.src_rect.width = picture.src_rect.width
sprite.src_rect.height = picture.src_rect.height

View File

@@ -396,7 +396,7 @@ def pbDoEnsureBitmap(bitmap, dwidth, dheight)
bitmap&.dispose
bitmap = Bitmap.new([1, dwidth].max, [1, dheight].max)
(oldfont) ? bitmap.font = oldfont : pbSetSystemFont(bitmap)
bitmap.font.shadow = false if bitmap.font&.respond_to?("shadow")
bitmap.font.shadow = false if bitmap.font.respond_to?("shadow")
end
return bitmap
end

View File

@@ -512,7 +512,6 @@ class Window_MultilineTextEntry < SpriteWindow_Base
startY = getLineY(@firstline)
textchars.each do |text|
thisline = text[5]
thiscolumn = text[7]
thislength = text[8]
textY = text[2] - startY
# Don't draw lines before the first or zero-length segments

View File

@@ -115,14 +115,14 @@ def getPlayTime2(filename)
return -1 if wave != 0x45564157 # "WAVE"
fmt = fgetdw.call(file)
return -1 if fmt != 0x20746d66 # "fmt "
fmtsize = fgetdw.call(file)
format = fgetw.call(file)
channels = fgetw.call(file)
rate = fgetdw.call(file)
fgetdw.call(file) # fmtsize
fgetw.call(file) # format
fgetw.call(file) # channels
fgetdw.call(file) # rate
bytessec = fgetdw.call(file)
return -1 if bytessec == 0
bytessample = fgetw.call(file)
bitssample = fgetw.call(file)
fgetw.call(file) # bytessample
fgetw.call(file) # bitssample
data = fgetdw.call(file)
return -1 if data != 0x61746164 # "data"
datasize = fgetdw.call(file)

View File

@@ -58,7 +58,7 @@ def pbBGMPlay(param, volume = nil, pitch = nil)
return
elsif (RPG.const_defined?(:BGM) rescue false)
b = RPG::BGM.new(param.name, param.volume, param.pitch)
if b&.respond_to?("play")
if b.respond_to?("play")
b.play
return
end
@@ -108,7 +108,7 @@ def pbMEPlay(param, volume = nil, pitch = nil)
return
elsif (RPG.const_defined?(:ME) rescue false)
b = RPG::ME.new(param.name, param.volume, param.pitch)
if b&.respond_to?("play")
if b.respond_to?("play")
b.play
return
end
@@ -125,7 +125,7 @@ def pbMEStop(timeInSeconds = 0.0)
if $game_system && timeInSeconds > 0.0 && $game_system.respond_to?("me_fade")
$game_system.me_fade(timeInSeconds)
return
elsif $game_system&.respond_to?("me_stop")
elsif $game_system.respond_to?("me_stop")
$game_system.me_stop(nil)
return
elsif (RPG.const_defined?(:ME) rescue false)
@@ -158,7 +158,7 @@ def pbBGSPlay(param, volume = nil, pitch = nil)
return
elsif (RPG.const_defined?(:BGS) rescue false)
b = RPG::BGS.new(param.name, param.volume, param.pitch)
if b&.respond_to?("play")
if b.respond_to?("play")
b.play
return
end
@@ -209,7 +209,7 @@ def pbSEPlay(param, volume = nil, pitch = nil)
end
if (RPG.const_defined?(:SE) rescue false)
b = RPG::SE.new(param.name, param.volume, param.pitch)
if b&.respond_to?("play")
if b.respond_to?("play")
b.play
return
end

View File

@@ -60,10 +60,13 @@ class Battle
end
sideCounts.each_with_index do |_count, i|
if !requireds[i] || requireds[i] == 0
if side == 0
raise _INTL("Player-side trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)",
i + 1, @sideSizes[0], @sideSizes[1]) if side == 0
i + 1, @sideSizes[0], @sideSizes[1])
elsif side == 1
raise _INTL("Opposing trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)",
i + 1, @sideSizes[0], @sideSizes[1]) if side == 1
i + 1, @sideSizes[0], @sideSizes[1])
end
end
next if requireds[i] <= sideCounts[i] # Trainer has enough Pokémon to fill their positions
if requireds[i] == 1

View File

@@ -9,8 +9,10 @@ class Battle
end
# Embargo
if battler && battler.effects[PBEffects::Embargo] > 0
if showMessages
scene.pbDisplay(_INTL("Embargo's effect prevents the item's use on {1}!",
battler.pbThis(true))) if showMessages
battler.pbThis(true)))
end
return false
end
return true

View File

@@ -61,8 +61,9 @@ class Battle::Battler
case @battle.field.terrain
when :Electric
if newStatus == :SLEEP
@battle.pbDisplay(_INTL("{1} surrounds itself with electrified terrain!",
pbThis(true))) if showMessages
if showMessages
@battle.pbDisplay(_INTL("{1} surrounds itself with electrified terrain!", pbThis(true)))
end
return false
end
when :Misty

View File

@@ -14,8 +14,10 @@ class Battle::Battler
end
# Check the stat stage
if statStageAtMax?(stat)
if showFailMsg
@battle.pbDisplay(_INTL("{1}'s {2} won't go any higher!",
pbThis, GameData::Stat.get(stat).name)) if showFailMsg
pbThis, GameData::Stat.get(stat).name))
end
return false
end
return true
@@ -162,8 +164,10 @@ class Battle::Battler
end
# Check the stat stage
if statStageAtMin?(stat)
if showFailMsg
@battle.pbDisplay(_INTL("{1}'s {2} won't go any lower!",
pbThis, GameData::Stat.get(stat).name)) if showFailMsg
pbThis, GameData::Stat.get(stat).name))
end
return false
end
return true

View File

@@ -1358,8 +1358,9 @@ class Battle::Move::StartGravity < Battle::Move
b.effects[PBEffects::SkyDrop] = -1
showMessage = true
end
@battle.pbDisplay(_INTL("{1} couldn't stay airborne because of gravity!",
b.pbThis)) if showMessage
if showMessage
@battle.pbDisplay(_INTL("{1} couldn't stay airborne because of gravity!", b.pbThis))
end
end
end
end

View File

@@ -607,9 +607,11 @@ class Battle::Move::HealUserDependingOnUserStockpile < Battle::Move
@battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!", user.pbThis))
showAnim = true
if user.effects[PBEffects::StockpileDef] > 0 &&
user.pbCanLowerStatStage?(:DEFENSE, user, self) && user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim)
user.pbCanLowerStatStage?(:DEFENSE, user, self)
if user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim)
showAnim = false
end
end
if user.effects[PBEffects::StockpileSpDef] > 0 &&
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user, self)
user.pbLowerStatStage(:SPECIAL_DEFENSE, user.effects[PBEffects::StockpileSpDef], user, showAnim)

View File

@@ -255,8 +255,10 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
else
s = GameData::Status.get(@battler.status).icon_position
end
if s >= 0
imagePos.push(["Graphics/Pictures/Battle/icon_statuses", @spriteBaseX + 24, 36,
0, s * STATUS_ICON_HEIGHT, -1, STATUS_ICON_HEIGHT]) if s >= 0
0, s * STATUS_ICON_HEIGHT, -1, STATUS_ICON_HEIGHT])
end
end
pbDrawImagePositions(self.bitmap, imagePos)
refreshHP

View File

@@ -17,7 +17,7 @@ class Battle::Scene::Animation
def empty?; return @pictureEx.length == 0; end
def animDone?; return @animDone; end
def addSprite(s, origin = PictureOrigin::TopLeft)
def addSprite(s, origin = PictureOrigin::TOP_LEFT)
num = @pictureEx.length
picture = PictureEx.new(s.z)
picture.x = s.x
@@ -31,7 +31,7 @@ class Battle::Scene::Animation
return picture
end
def addNewSprite(x, y, name, origin = PictureOrigin::TopLeft)
def addNewSprite(x, y, name, origin = PictureOrigin::TOP_LEFT)
num = @pictureEx.length
picture = PictureEx.new(num)
picture.setXY(0, x, y)
@@ -87,7 +87,7 @@ module Battle::Scene::Animation::BallAnimationMixin
def addBallSprite(ballX, ballY, poke_ball)
file_path = sprintf("Graphics/Battle animations/ball_%s", poke_ball)
ball = addNewSprite(ballX, ballY, file_path, PictureOrigin::Center)
ball = addNewSprite(ballX, ballY, file_path, PictureOrigin::CENTER)
@ballSprite = @pictureSprites.last
if @ballSprite.bitmap.width >= @ballSprite.bitmap.height
@ballSprite.src_rect.width = @ballSprite.bitmap.height / 2

View File

@@ -15,26 +15,26 @@ class Battle::Scene::Animation::Intro < Battle::Scene::Animation
makeSlideSprite("battle_bg2", 0.5, appearTime)
end
# Bases
makeSlideSprite("base_0", 1, appearTime, PictureOrigin::Bottom)
makeSlideSprite("base_1", -1, appearTime, PictureOrigin::Center)
makeSlideSprite("base_0", 1, appearTime, PictureOrigin::BOTTOM)
makeSlideSprite("base_1", -1, appearTime, PictureOrigin::CENTER)
# Player sprite, partner trainer sprite
@battle.player.each_with_index do |_p, i|
makeSlideSprite("player_#{i + 1}", 1, appearTime, PictureOrigin::Bottom)
makeSlideSprite("player_#{i + 1}", 1, appearTime, PictureOrigin::BOTTOM)
end
# Opposing trainer sprite(s) or wild Pokémon sprite(s)
if @battle.trainerBattle?
@battle.opponent.each_with_index do |_p, i|
makeSlideSprite("trainer_#{i + 1}", -1, appearTime, PictureOrigin::Bottom)
makeSlideSprite("trainer_#{i + 1}", -1, appearTime, PictureOrigin::BOTTOM)
end
else # Wild battle
@battle.pbParty(1).each_with_index do |_pkmn, i|
idxBattler = (2 * i) + 1
makeSlideSprite("pokemon_#{idxBattler}", -1, appearTime, PictureOrigin::Bottom)
makeSlideSprite("pokemon_#{idxBattler}", -1, appearTime, PictureOrigin::BOTTOM)
end
end
# Shadows
@battle.battlers.length.times do |i|
makeSlideSprite("shadow_#{i}", (i.even?) ? 1 : -1, appearTime, PictureOrigin::Center)
makeSlideSprite("shadow_#{i}", (i.even?) ? 1 : -1, appearTime, PictureOrigin::CENTER)
end
# Fading blackness over whole screen
blackScreen = addNewSprite(0, 0, "Graphics/Battle animations/black_screen")
@@ -73,7 +73,7 @@ class Battle::Scene::Animation::Intro2 < Battle::Scene::Animation
@sideSize.times do |i|
idxBattler = (2 * i) + 1
next if !@sprites["pokemon_#{idxBattler}"]
battler = addSprite(@sprites["pokemon_#{idxBattler}"], PictureOrigin::Bottom)
battler = addSprite(@sprites["pokemon_#{idxBattler}"], PictureOrigin::BOTTOM)
battler.moveTone(0, 4, Tone.new(0, 0, 0, 0))
battler.setCallback(10 * i, [@sprites["pokemon_#{idxBattler}"], :pbPlayIntroAnimation])
end
@@ -279,7 +279,7 @@ class Battle::Scene::Animation::TrainerAppear < Battle::Scene::Animation
delay = 0
# Make old trainer sprite move off-screen first if necessary
if @idxTrainer > 0 && @sprites["trainer_#{@idxTrainer}"].visible
oldTrainer = addSprite(@sprites["trainer_#{@idxTrainer}"], PictureOrigin::Bottom)
oldTrainer = addSprite(@sprites["trainer_#{@idxTrainer}"], PictureOrigin::BOTTOM)
oldTrainer.moveDelta(delay, 8, Graphics.width / 4, 0)
oldTrainer.setVisible(delay + 8, false)
delay = oldTrainer.totalDuration
@@ -288,7 +288,7 @@ class Battle::Scene::Animation::TrainerAppear < Battle::Scene::Animation
if @sprites["trainer_#{@idxTrainer + 1}"]
trainerX, trainerY = Battle::Scene.pbTrainerPosition(1)
trainerX += 64 + (Graphics.width / 4)
newTrainer = addSprite(@sprites["trainer_#{@idxTrainer + 1}"], PictureOrigin::Bottom)
newTrainer = addSprite(@sprites["trainer_#{@idxTrainer + 1}"], PictureOrigin::BOTTOM)
newTrainer.setVisible(delay, true)
newTrainer.setXY(delay, trainerX, trainerY)
newTrainer.moveDelta(delay, 8, -Graphics.width / 4, 0)
@@ -318,7 +318,7 @@ class Battle::Scene::Animation::PlayerFade < Battle::Scene::Animation
pl = @sprites[spriteNameBase + "_#{i}"]
i += 1
next if !pl.visible || pl.x < 0
trainer = addSprite(pl, PictureOrigin::Bottom)
trainer = addSprite(pl, PictureOrigin::BOTTOM)
trainer.moveDelta(0, 16, -Graphics.width / 2, 0)
# Animate trainer sprite(s) if they have multiple frames
if pl.bitmap && !pl.bitmap.disposed? && pl.bitmap.width >= pl.bitmap.height * 2
@@ -371,7 +371,7 @@ class Battle::Scene::Animation::TrainerFade < Battle::Scene::Animation
trSprite = @sprites[spriteNameBase + "_#{i}"]
i += 1
next if !trSprite.visible || trSprite.x > Graphics.width
trainer = addSprite(trSprite, PictureOrigin::Bottom)
trainer = addSprite(trSprite, PictureOrigin::BOTTOM)
trainer.moveDelta(0, 16, Graphics.width / 2, 0)
trainer.setVisible(16, false)
end
@@ -456,7 +456,7 @@ class Battle::Scene::Animation::PokeballPlayerSendOut < Battle::Scene::Animation
ballBurst(delay, battlerStartX, battlerStartY - 18, poke_ball)
ball.moveOpacity(delay + 2, 2, 0)
# Set up battler sprite
battler = addSprite(batSprite, PictureOrigin::Bottom)
battler = addSprite(batSprite, PictureOrigin::BOTTOM)
battler.setXY(0, battlerStartX, battlerStartY)
battler.setZoom(0, 0)
battler.setColor(0, col)
@@ -464,7 +464,7 @@ class Battle::Scene::Animation::PokeballPlayerSendOut < Battle::Scene::Animation
battlerAppear(battler, delay, battlerEndX, battlerEndY, batSprite, col)
if @shadowVisible
# Set up shadow sprite
shadow = addSprite(shaSprite, PictureOrigin::Center)
shadow = addSprite(shaSprite, PictureOrigin::CENTER)
shadow.setOpacity(0, 0)
# Shadow animation
shadow.setVisible(delay, @shadowVisible)
@@ -520,7 +520,7 @@ class Battle::Scene::Animation::PokeballTrainerSendOut < Battle::Scene::Animatio
ballBurst(delay, battlerStartX, battlerStartY - 18, poke_ball)
ball.moveOpacity(delay + 2, 2, 0)
# Set up battler sprite
battler = addSprite(batSprite, PictureOrigin::Bottom)
battler = addSprite(batSprite, PictureOrigin::BOTTOM)
battler.setXY(0, battlerStartX, battlerStartY)
battler.setZoom(0, 0)
battler.setColor(0, col)
@@ -528,7 +528,7 @@ class Battle::Scene::Animation::PokeballTrainerSendOut < Battle::Scene::Animatio
battlerAppear(battler, delay, battlerEndX, battlerEndY, batSprite, col)
if @shadowVisible
# Set up shadow sprite
shadow = addSprite(shaSprite, PictureOrigin::Center)
shadow = addSprite(shaSprite, PictureOrigin::CENTER)
shadow.setOpacity(0, 0)
# Shadow animation
shadow.setVisible(delay, @shadowVisible)
@@ -570,7 +570,7 @@ class Battle::Scene::Animation::BattlerRecall < Battle::Scene::Animation
battlerEndX = ballPos[0]
battlerEndY = ballPos[1]
# Set up battler sprite
battler = addSprite(batSprite, PictureOrigin::Bottom)
battler = addSprite(batSprite, PictureOrigin::BOTTOM)
battler.setVisible(0, true)
battler.setColor(0, col)
# Set up Poké Ball sprite
@@ -585,7 +585,7 @@ class Battle::Scene::Animation::BattlerRecall < Battle::Scene::Animation
battlerAbsorb(battler, delay, battlerEndX, battlerEndY, col)
if shaSprite.visible
# Set up shadow sprite
shadow = addSprite(shaSprite, PictureOrigin::Center)
shadow = addSprite(shaSprite, PictureOrigin::CENTER)
# Shadow animation
shadow.moveOpacity(0, 10, 0)
shadow.setVisible(delay, false)
@@ -609,8 +609,8 @@ class Battle::Scene::Animation::BattlerDamage < Battle::Scene::Animation
batSprite = @sprites["pokemon_#{@idxBattler}"]
shaSprite = @sprites["shadow_#{@idxBattler}"]
# Set up battler/shadow sprite
battler = addSprite(batSprite, PictureOrigin::Bottom)
shadow = addSprite(shaSprite, PictureOrigin::Center)
battler = addSprite(batSprite, PictureOrigin::BOTTOM)
shadow = addSprite(shaSprite, PictureOrigin::CENTER)
# Animation
delay = 0
case @effectiveness
@@ -647,8 +647,8 @@ class Battle::Scene::Animation::BattlerFaint < Battle::Scene::Animation
batSprite = @sprites["pokemon_#{@idxBattler}"]
shaSprite = @sprites["shadow_#{@idxBattler}"]
# Set up battler/shadow sprite
battler = addSprite(batSprite, PictureOrigin::Bottom)
shadow = addSprite(shaSprite, PictureOrigin::Center)
battler = addSprite(batSprite, PictureOrigin::BOTTOM)
shadow = addSprite(shaSprite, PictureOrigin::CENTER)
# Get approx duration depending on sprite's position/size. Min 20 frames.
battlerTop = batSprite.y - batSprite.height
cropY = Battle::Scene.pbBattlerPosition(@idxBattler, @battle.pbSideSize(@idxBattler))[1]
@@ -723,7 +723,7 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation
@ballSpriteIndex = (@success) ? @tempSprites.length - 1 : -1
# Set up trainer sprite (only visible in Safari Zone battles)
if @showingTrainer && traSprite && traSprite.bitmap.width >= traSprite.bitmap.height * 2
trainer = addSprite(traSprite, PictureOrigin::Bottom)
trainer = addSprite(traSprite, PictureOrigin::BOTTOM)
# Trainer animation
ballStartX, ballStartY = trainerThrowingFrames(ball, trainer, traSprite)
end
@@ -738,7 +738,7 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation
delay = ball.totalDuration + 6
ballOpenUp(ball, delay, @poke_ball, true, false)
# Set up battler sprite
battler = addSprite(batSprite, PictureOrigin::Bottom)
battler = addSprite(batSprite, PictureOrigin::BOTTOM)
# Poké Ball absorbs battler
delay = ball.totalDuration
ballBurstCapture(delay, ballEndX, ballEndY, @poke_ball)
@@ -751,7 +751,7 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation
battler.setVisible(delay + 5, false)
if @shadowVisible
# Set up shadow sprite
shadow = addSprite(shaSprite, PictureOrigin::Center)
shadow = addSprite(shaSprite, PictureOrigin::CENTER)
# Shadow animation
shadow.moveOpacity(delay, 5, 0)
shadow.moveZoom(delay, 5, 0)

View File

@@ -391,13 +391,15 @@ class Battle::AI
)
end
end
if skill >= PBTrainerAI.bestSkill && target.itemActive? && (target.item && !target.item.is_berry?)
if skill >= PBTrainerAI.bestSkill &&
target.itemActive? && target.item && !target.item.is_berry?
Battle::ItemEffects.triggerDamageCalcFromTarget(
target.item, user, target, move, multipliers, baseDmg, type
)
end
# Global abilities
if skill >= PBTrainerAI.mediumSkill && ((@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||
if skill >= PBTrainerAI.mediumSkill &&
((@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY))
if @battle.pbCheckGlobalAbility(:AURABREAK)
multipliers[:base_damage_multiplier] *= 2 / 3.0
@@ -413,7 +415,8 @@ class Battle::AI
# TODO
# Helping Hand - n/a
# Charge
if skill >= PBTrainerAI.mediumSkill && (user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC)
if skill >= PBTrainerAI.mediumSkill &&
user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC
multipliers[:base_damage_multiplier] *= 2
end
# Mud Sport and Water Sport
@@ -487,7 +490,7 @@ class Battle::AI
# Critical hits - n/a
# Random variance - n/a
# STAB
if skill >= PBTrainerAI.mediumSkill && (type && user.pbHasType?(type))
if skill >= PBTrainerAI.mediumSkill && type && user.pbHasType?(type)
if user.hasActiveAbility?(:ADAPTABILITY)
multipliers[:final_damage_multiplier] *= 2
else
@@ -500,13 +503,14 @@ class Battle::AI
multipliers[:final_damage_multiplier] *= typemod.to_f / Effectiveness::NORMAL_EFFECTIVE
end
# Burn
if skill >= PBTrainerAI.highSkill && (user.status == :BURN && move.physicalMove?(type) &&
!user.hasActiveAbility?(:GUTS) &&
!(Settings::MECHANICS_GENERATION >= 6 && move.function == "DoublePowerIfUserPoisonedBurnedParalyzed")) # Facade
if skill >= PBTrainerAI.highSkill && move.physicalMove?(type) &&
user.status == :BURN && !user.hasActiveAbility?(:GUTS) &&
!(Settings::MECHANICS_GENERATION >= 6 &&
move.function == "DoublePowerIfUserPoisonedBurnedParalyzed") # Facade
multipliers[:final_damage_multiplier] /= 2
end
# Aurora Veil, Reflect, Light Screen
if skill >= PBTrainerAI.highSkill && (!move.ignoresReflect? && !user.hasActiveAbility?(:INFILTRATOR))
if skill >= PBTrainerAI.highSkill && !move.ignoresReflect? && !user.hasActiveAbility?(:INFILTRATOR)
if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0
if @battle.pbSideBattlerCount(target) > 1
multipliers[:final_damage_multiplier] *= 2 / 3.0
@@ -549,14 +553,14 @@ class Battle::AI
if c >= 0 && user.abilityActive?
c = Battle::AbilityEffects.triggerCriticalCalcFromUser(user.ability, user, target, c)
end
if skill >= PBTrainerAI.bestSkill && (c >= 0 && !moldBreaker && target.abilityActive?)
if skill >= PBTrainerAI.bestSkill && c >= 0 && !moldBreaker && target.abilityActive?
c = Battle::AbilityEffects.triggerCriticalCalcFromTarget(target.ability, user, target, c)
end
# Item effects that alter critical hit rate
if c >= 0 && user.itemActive?
c = Battle::ItemEffects.triggerCriticalCalcFromUser(user.item, user, target, c)
end
if skill >= PBTrainerAI.bestSkill && (c >= 0 && target.itemActive?)
if skill >= PBTrainerAI.bestSkill && c >= 0 && target.itemActive?
c = Battle::ItemEffects.triggerCriticalCalcFromTarget(target.item, user, target, c)
end
# Other efffects
@@ -632,7 +636,7 @@ class Battle::AI
)
end
end
if skill >= PBTrainerAI.bestSkill && (target.abilityActive? && !moldBreaker)
if skill >= PBTrainerAI.bestSkill && target.abilityActive? && !moldBreaker
Battle::AbilityEffects.triggerAccuracyCalcFromTarget(
target.ability, modifiers, user, target, move, type
)
@@ -666,8 +670,8 @@ class Battle::AI
user.effects[PBEffects::LockOnPos] == target.index
end
if skill >= PBTrainerAI.highSkill
if move.function == "BadPoisonTarget" && (Settings::MORE_TYPE_EFFECTS && move.statusMove? &&
user.pbHasType?(:POISON)) # Toxic
if move.function == "BadPoisonTarget" && # Toxic
Settings::MORE_TYPE_EFFECTS && move.statusMove? && user.pbHasType?(:POISON)
modifiers[:base_accuracy] = 0
end
if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(move.function)

View File

@@ -119,10 +119,10 @@ class Battle::Scene::Animation::ThrowBait < Battle::Scene::Animation
ballEndX = ballPos[0] - 40
ballEndY = ballPos[1] - 4
# Set up trainer sprite
trainer = addSprite(traSprite, PictureOrigin::Bottom)
trainer = addSprite(traSprite, PictureOrigin::BOTTOM)
# Set up bait sprite
ball = addNewSprite(ballStartX, ballStartY,
"Graphics/Battle animations/safari_bait", PictureOrigin::Center)
"Graphics/Battle animations/safari_bait", PictureOrigin::CENTER)
ball.setZ(0, batSprite.z + 1)
# Trainer animation
if traSprite.bitmap.width >= traSprite.bitmap.height * 2
@@ -138,7 +138,7 @@ class Battle::Scene::Animation::ThrowBait < Battle::Scene::Animation
ball.moveOpacity(delay + 8, 2, 0)
ball.setVisible(delay + 10, false)
# Set up battler sprite
battler = addSprite(batSprite, PictureOrigin::Bottom)
battler = addSprite(batSprite, PictureOrigin::BOTTOM)
# Show Pokémon jumping before eating the bait
delay = ball.totalDuration + 3
2.times do
@@ -184,10 +184,10 @@ class Battle::Scene::Animation::ThrowRock < Battle::Scene::Animation
ballEndX = batSprite.x
ballEndY = batSprite.y - (batSprite.bitmap.height / 2)
# Set up trainer sprite
trainer = addSprite(traSprite, PictureOrigin::Bottom)
trainer = addSprite(traSprite, PictureOrigin::BOTTOM)
# Set up bait sprite
ball = addNewSprite(ballStartX, ballStartY,
"Graphics/Battle animations/safari_rock", PictureOrigin::Center)
"Graphics/Battle animations/safari_rock", PictureOrigin::CENTER)
ball.setZ(0, batSprite.z + 1)
# Trainer animation
if traSprite.bitmap.width >= traSprite.bitmap.height * 2
@@ -205,7 +205,7 @@ class Battle::Scene::Animation::ThrowRock < Battle::Scene::Animation
ball.setVisible(delay + 4, false)
# Set up anger sprite
anger = addNewSprite(ballEndX - 42, ballEndY - 36,
"Graphics/Battle animations/safari_anger", PictureOrigin::Center)
"Graphics/Battle animations/safari_anger", PictureOrigin::CENTER)
anger.setVisible(0, false)
anger.setZ(0, batSprite.z + 1)
# Show anger appearing

View File

@@ -74,7 +74,7 @@ def pbHiddenMoveAnimation(pokemon)
bg = Sprite.new(viewport)
bg.bitmap = RPG::Cache.picture("hiddenMovebg")
sprite = PokemonSprite.new(viewport)
sprite.setOffset(PictureOrigin::Center)
sprite.setOffset(PictureOrigin::CENTER)
sprite.setPokemonBitmap(pokemon)
sprite.z = 1
sprite.visible = false

View File

@@ -42,27 +42,27 @@ class ItemIconSprite < SpriteWrapper
@forceitemchange = false
end
def setOffset(offset = PictureOrigin::Center)
def setOffset(offset = PictureOrigin::CENTER)
@offset = offset
changeOrigin
end
def changeOrigin
@offset = PictureOrigin::Center if !@offset
@offset = PictureOrigin::CENTER if !@offset
case @offset
when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight
when PictureOrigin::TOP_LEFT, PictureOrigin::TOP, PictureOrigin::TOP_RIGHT
self.oy = 0
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
when PictureOrigin::LEFT, PictureOrigin::CENTER, PictureOrigin::RIGHT
self.oy = self.height / 2
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
when PictureOrigin::BOTTOM_LEFT, PictureOrigin::BOTTOM, PictureOrigin::BOTTOM_RIGHT
self.oy = self.height
end
case @offset
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
when PictureOrigin::TOP_LEFT, PictureOrigin::LEFT, PictureOrigin::BOTTOM_LEFT
self.ox = 0
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
when PictureOrigin::TOP, PictureOrigin::CENTER, PictureOrigin::BOTTOM
self.ox = self.width / 2
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
when PictureOrigin::TOP_RIGHT, PictureOrigin::RIGHT, PictureOrigin::BOTTOM_RIGHT
self.ox = self.width
end
end

View File

@@ -20,28 +20,28 @@ class PokemonSprite < SpriteWrapper
self.bitmap = nil
end
def setOffset(offset = PictureOrigin::Center)
def setOffset(offset = PictureOrigin::CENTER)
@offset = offset
changeOrigin
end
def changeOrigin
return if !self.bitmap
@offset = PictureOrigin::Center if !@offset
@offset = PictureOrigin::CENTER if !@offset
case @offset
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
when PictureOrigin::TOP_LEFT, PictureOrigin::LEFT, PictureOrigin::BOTTOM_LEFT
self.ox = 0
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
when PictureOrigin::TOP, PictureOrigin::CENTER, PictureOrigin::BOTTOM
self.ox = self.bitmap.width / 2
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
when PictureOrigin::TOP_RIGHT, PictureOrigin::RIGHT, PictureOrigin::BOTTOM_RIGHT
self.ox = self.bitmap.width
end
case @offset
when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight
when PictureOrigin::TOP_LEFT, PictureOrigin::TOP, PictureOrigin::TOP_RIGHT
self.oy = 0
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
when PictureOrigin::LEFT, PictureOrigin::CENTER, PictureOrigin::RIGHT
self.oy = self.bitmap.height / 2
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
when PictureOrigin::BOTTOM_LEFT, PictureOrigin::BOTTOM, PictureOrigin::BOTTOM_RIGHT
self.oy = self.bitmap.height
end
end
@@ -138,30 +138,30 @@ class PokemonIconSprite < SpriteWrapper
changeOrigin
end
def setOffset(offset = PictureOrigin::Center)
def setOffset(offset = PictureOrigin::CENTER)
@offset = offset
changeOrigin
end
def changeOrigin
return if !self.bitmap
@offset = PictureOrigin::TopLeft if !@offset
@offset = PictureOrigin::TOP_LEFT if !@offset
case @offset
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
when PictureOrigin::TOP_LEFT, PictureOrigin::LEFT, PictureOrigin::BOTTOM_LEFT
self.ox = 0
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
when PictureOrigin::TOP, PictureOrigin::CENTER, PictureOrigin::BOTTOM
self.ox = self.src_rect.width / 2
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
when PictureOrigin::TOP_RIGHT, PictureOrigin::RIGHT, PictureOrigin::BOTTOM_RIGHT
self.ox = self.src_rect.width
end
case @offset
when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight
when PictureOrigin::TOP_LEFT, PictureOrigin::TOP, PictureOrigin::TOP_RIGHT
self.oy = 0
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
when PictureOrigin::LEFT, PictureOrigin::CENTER, PictureOrigin::RIGHT
# NOTE: This assumes the top quarter of the icon is blank, so oy is placed
# in the middle of the lower three quarters of the image.
self.oy = self.src_rect.height * 5 / 8
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
when PictureOrigin::BOTTOM_LEFT, PictureOrigin::BOTTOM, PictureOrigin::BOTTOM_RIGHT
self.oy = self.src_rect.height
end
end
@@ -268,30 +268,30 @@ class PokemonSpeciesIconSprite < SpriteWrapper
refresh
end
def setOffset(offset = PictureOrigin::Center)
def setOffset(offset = PictureOrigin::CENTER)
@offset = offset
changeOrigin
end
def changeOrigin
return if !self.bitmap
@offset = PictureOrigin::TopLeft if !@offset
@offset = PictureOrigin::TOP_LEFT if !@offset
case @offset
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
when PictureOrigin::TOP_LEFT, PictureOrigin::LEFT, PictureOrigin::BOTTOM_LEFT
self.ox = 0
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
when PictureOrigin::TOP, PictureOrigin::CENTER, PictureOrigin::BOTTOM
self.ox = self.src_rect.width / 2
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
when PictureOrigin::TOP_RIGHT, PictureOrigin::RIGHT, PictureOrigin::BOTTOM_RIGHT
self.ox = self.src_rect.width
end
case @offset
when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight
when PictureOrigin::TOP_LEFT, PictureOrigin::TOP, PictureOrigin::TOP_RIGHT
self.oy = 0
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
when PictureOrigin::LEFT, PictureOrigin::CENTER, PictureOrigin::RIGHT
# NOTE: This assumes the top quarter of the icon is blank, so oy is placed
# in the middle of the lower three quarters of the image.
self.oy = self.src_rect.height * 5 / 8
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
when PictureOrigin::BOTTOM_LEFT, PictureOrigin::BOTTOM, PictureOrigin::BOTTOM_RIGHT
self.oy = self.src_rect.height
end
end

View File

@@ -106,7 +106,7 @@ class Pokemon
def inspect
str = super.chop
str << format(' %s Lv.%s>', @species, @level.to_s || '???')
str << sprintf(' %s Lv.%s>', @species, @level.to_s || '???')
return str
end

View File

@@ -11,7 +11,7 @@ class Trainer
def inspect
str = super.chop
party_str = @party.map { |p| p.species_data.species }.inspect
str << format(' %s @party=%s>', self.full_name, party_str)
str << sprintf(' %s @party=%s>', self.full_name, party_str)
return str
end

View File

@@ -7,7 +7,7 @@ class Player < Trainer
def inspect
str = super.chop
str << format(' seen: %d, owned: %d>', self.seen_count, self.owned_count)
str << sprintf(' seen: %d, owned: %d>', self.seen_count, self.owned_count)
return str
end

View File

@@ -21,7 +21,7 @@ class PokemonEggHatch_Scene
Color.new(248, 248, 248), @viewport)
# Create egg sprite/Pokémon sprite
@sprites["pokemon"] = PokemonSprite.new(@viewport)
@sprites["pokemon"].setOffset(PictureOrigin::Bottom)
@sprites["pokemon"].setOffset(PictureOrigin::BOTTOM)
@sprites["pokemon"].x = Graphics.width / 2
@sprites["pokemon"].y = 264 + 56 # 56 to offset the egg sprite
@sprites["pokemon"].setSpeciesBitmap(@pokemon.species, @pokemon.gender,

View File

@@ -498,12 +498,12 @@ class PokemonEvolutionScene
addBackgroundOrColoredPlane(@sprites, "background", "evolutionbg",
Color.new(248, 248, 248), @bgviewport)
rsprite1 = PokemonSprite.new(@viewport)
rsprite1.setOffset(PictureOrigin::Center)
rsprite1.setOffset(PictureOrigin::CENTER)
rsprite1.setPokemonBitmap(@pokemon, false)
rsprite1.x = Graphics.width / 2
rsprite1.y = (Graphics.height - 64) / 2
rsprite2 = PokemonSprite.new(@viewport)
rsprite2.setOffset(PictureOrigin::Center)
rsprite2.setOffset(PictureOrigin::CENTER)
rsprite2.setPokemonBitmapSpecies(@pokemon, @newspecies, false)
rsprite2.x = rsprite1.x
rsprite2.y = rsprite1.y

View File

@@ -36,14 +36,14 @@ class PokemonTrade_Scene
Color.new(248, 248, 248), @viewport)
@sprites["rsprite1"] = PokemonSprite.new(@viewport)
@sprites["rsprite1"].setPokemonBitmap(@pokemon, false)
@sprites["rsprite1"].setOffset(PictureOrigin::Bottom)
@sprites["rsprite1"].setOffset(PictureOrigin::BOTTOM)
@sprites["rsprite1"].x = Graphics.width / 2
@sprites["rsprite1"].y = 264
@sprites["rsprite1"].z = 10
@pokemon.species_data.apply_metrics_to_sprite(@sprites["rsprite1"], 1)
@sprites["rsprite2"] = PokemonSprite.new(@viewport)
@sprites["rsprite2"].setPokemonBitmap(@pokemon2, false)
@sprites["rsprite2"].setOffset(PictureOrigin::Bottom)
@sprites["rsprite2"].setOffset(PictureOrigin::BOTTOM)
@sprites["rsprite2"].x = Graphics.width / 2
@sprites["rsprite2"].y = 264
@sprites["rsprite2"].z = 10
@@ -63,11 +63,11 @@ class PokemonTrade_Scene
pictureBall.setXY(0, Graphics.width / 2, 48)
pictureBall.setName(0, ballimage)
pictureBall.setSrcSize(0, 32, 64)
pictureBall.setOrigin(0, PictureOrigin::Center)
pictureBall.setOrigin(0, PictureOrigin::CENTER)
pictureBall.setVisible(0, true)
# Starting position of sprite
picturePoke.setXY(0, @sprites["rsprite1"].x, @sprites["rsprite1"].y)
picturePoke.setOrigin(0, PictureOrigin::Bottom)
picturePoke.setOrigin(0, PictureOrigin::BOTTOM)
picturePoke.setVisible(0, true)
# Change Pokémon color
picturePoke.moveColor(2, 5, Color.new(31 * 8, 22 * 8, 30 * 8, 255))
@@ -105,10 +105,10 @@ class PokemonTrade_Scene
pictureBall.setXY(0, Graphics.width / 2, -32)
pictureBall.setName(0, ballimage)
pictureBall.setSrcSize(0, 32, 64)
pictureBall.setOrigin(0, PictureOrigin::Center)
pictureBall.setOrigin(0, PictureOrigin::CENTER)
pictureBall.setVisible(0, true)
# Starting position of sprite
picturePoke.setOrigin(0, PictureOrigin::Bottom)
picturePoke.setOrigin(0, PictureOrigin::BOTTOM)
picturePoke.setZoom(0, 0)
picturePoke.setColor(0, Color.new(31 * 8, 22 * 8, 30 * 8, 255))
picturePoke.setVisible(0, false)

View File

@@ -210,7 +210,7 @@ class HallOfFame_Scene
ypoint = ypointformula(i)
pok = @hallEntry[i]
@sprites["pokemon#{i}"] = PokemonSprite.new(@viewport)
@sprites["pokemon#{i}"].setOffset(PictureOrigin::TopLeft)
@sprites["pokemon#{i}"].setOffset(PictureOrigin::TOP_LEFT)
@sprites["pokemon#{i}"].setPokemonBitmap(pok)
# This method doesn't put the exact coordinates
@sprites["pokemon#{i}"].x = xpoint

View File

@@ -281,7 +281,7 @@ class PokemonPokedex_Scene
@sprites["searchbg"].visible = false
@sprites["pokedex"] = Window_Pokedex.new(206, 30, 276, 364, @viewport)
@sprites["icon"] = PokemonSprite.new(@viewport)
@sprites["icon"].setOffset(PictureOrigin::Center)
@sprites["icon"].setOffset(PictureOrigin::CENTER)
@sprites["icon"].x = 112
@sprites["icon"].y = 196
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)

View File

@@ -14,7 +14,7 @@ class PokemonPokedexInfo_Scene
@sprites = {}
@sprites["background"] = IconSprite.new(0, 0, @viewport)
@sprites["infosprite"] = PokemonSprite.new(@viewport)
@sprites["infosprite"].setOffset(PictureOrigin::Center)
@sprites["infosprite"].setOffset(PictureOrigin::CENTER)
@sprites["infosprite"].x = 104
@sprites["infosprite"].y = 136
@mapdata = pbLoadTownMapData
@@ -40,14 +40,14 @@ class PokemonPokedexInfo_Scene
@sprites["areaoverlay"] = IconSprite.new(0, 0, @viewport)
@sprites["areaoverlay"].setBitmap("Graphics/Pictures/Pokedex/overlay_area")
@sprites["formfront"] = PokemonSprite.new(@viewport)
@sprites["formfront"].setOffset(PictureOrigin::Center)
@sprites["formfront"].setOffset(PictureOrigin::CENTER)
@sprites["formfront"].x = 130
@sprites["formfront"].y = 158
@sprites["formback"] = PokemonSprite.new(@viewport)
@sprites["formback"].setOffset(PictureOrigin::Bottom)
@sprites["formback"].setOffset(PictureOrigin::BOTTOM)
@sprites["formback"].x = 382 # y is set below as it depends on metrics
@sprites["formicon"] = PokemonSpeciesIconSprite.new(nil, @viewport)
@sprites["formicon"].setOffset(PictureOrigin::Center)
@sprites["formicon"].setOffset(PictureOrigin::CENTER)
@sprites["formicon"].x = 82
@sprites["formicon"].y = 328
@sprites["uparrow"] = AnimatedSprite.new("Graphics/Pictures/uparrow", 8, 28, 40, 2, @viewport)
@@ -99,7 +99,7 @@ class PokemonPokedexInfo_Scene
@sprites = {}
@sprites["background"] = IconSprite.new(0, 0, @viewport)
@sprites["infosprite"] = PokemonSprite.new(@viewport)
@sprites["infosprite"].setOffset(PictureOrigin::Center)
@sprites["infosprite"].setOffset(PictureOrigin::CENTER)
@sprites["infosprite"].x = 104
@sprites["infosprite"].y = 136
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)

View File

@@ -207,7 +207,7 @@ class PokemonPartyPanel < SpriteWrapper
@ballsprite.addBitmap("desel", "Graphics/Pictures/Party/icon_ball")
@ballsprite.addBitmap("sel", "Graphics/Pictures/Party/icon_ball_sel")
@pkmnsprite = PokemonIconSprite.new(pokemon, viewport)
@pkmnsprite.setOffset(PictureOrigin::Center)
@pkmnsprite.setOffset(PictureOrigin::CENTER)
@pkmnsprite.active = @active
@pkmnsprite.z = self.z + 2
@helditemsprite = HeldItemIconSprite.new(0, 0, @pokemon, viewport)

View File

@@ -122,12 +122,12 @@ class PokemonSummary_Scene
@sprites = {}
@sprites["background"] = IconSprite.new(0, 0, @viewport)
@sprites["pokemon"] = PokemonSprite.new(@viewport)
@sprites["pokemon"].setOffset(PictureOrigin::Center)
@sprites["pokemon"].setOffset(PictureOrigin::CENTER)
@sprites["pokemon"].x = 104
@sprites["pokemon"].y = 206
@sprites["pokemon"].setPokemonBitmap(@pokemon)
@sprites["pokeicon"] = PokemonIconSprite.new(@pokemon, @viewport)
@sprites["pokeicon"].setOffset(PictureOrigin::Center)
@sprites["pokeicon"].setOffset(PictureOrigin::CENTER)
@sprites["pokeicon"].x = 46
@sprites["pokeicon"].y = 92
@sprites["pokeicon"].visible = false
@@ -189,7 +189,7 @@ class PokemonSummary_Scene
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
pbSetSystemFont(@sprites["overlay"].bitmap)
@sprites["pokeicon"] = PokemonIconSprite.new(@pokemon, @viewport)
@sprites["pokeicon"].setOffset(PictureOrigin::Center)
@sprites["pokeicon"].setOffset(PictureOrigin::CENTER)
@sprites["pokeicon"].x = 46
@sprites["pokeicon"].y = 92
@sprites["movesel"] = MoveSelectionSprite.new(@viewport, !move_to_learn.nil?)

View File

@@ -177,7 +177,7 @@ class PokemonLoad_Scene
end
trainer.party.each_with_index do |pkmn, i|
@sprites["party#{i}"] = PokemonIconSprite.new(pkmn, @viewport)
@sprites["party#{i}"].setOffset(PictureOrigin::Center)
@sprites["party#{i}"].setOffset(PictureOrigin::CENTER)
@sprites["party#{i}"].x = (167 + (33 * (i % 2))) * 2
@sprites["party#{i}"].y = (56 + (25 * (i / 2))) * 2
@sprites["party#{i}"].z = 99999

View File

@@ -22,7 +22,7 @@ class ReadyMenuButton < SpriteWrapper
pbSetSystemFont(self.bitmap)
if @command[2]
@icon = PokemonIconSprite.new($player.party[@command[3]], viewport)
@icon.setOffset(PictureOrigin::Center)
@icon.setOffset(PictureOrigin::CENTER)
else
@icon = ItemIconSprite.new(0, 0, @command[0], viewport)
end

View File

@@ -598,7 +598,7 @@ class PokemonStorageScene
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @boxsidesviewport)
pbSetSystemFont(@sprites["overlay"].bitmap)
@sprites["pokemon"] = AutoMosaicPokemonSprite.new(@boxsidesviewport)
@sprites["pokemon"].setOffset(PictureOrigin::Center)
@sprites["pokemon"].setOffset(PictureOrigin::CENTER)
@sprites["pokemon"].x = 90
@sprites["pokemon"].y = 134
@sprites["boxparty"] = PokemonBoxPartySprite.new(@storage.party, @boxsidesviewport)

View File

@@ -27,7 +27,7 @@ class MoveRelearner_Scene
@sprites = {}
addBackgroundPlane(@sprites, "bg", "reminderbg", @viewport)
@sprites["pokeicon"] = PokemonIconSprite.new(@pokemon, @viewport)
@sprites["pokeicon"].setOffset(PictureOrigin::Center)
@sprites["pokeicon"].setOffset(PictureOrigin::CENTER)
@sprites["pokeicon"].x = 320
@sprites["pokeicon"].y = 84
@sprites["background"] = IconSprite.new(0, 0, @viewport)

View File

@@ -860,7 +860,7 @@ class PurifyChamberSetView < SpriteWrapper
@directflow.setFlowStrength(1)
@__sprites = []
@__sprites[0] = PokemonIconSprite.new(nil, viewport)
PurifyChamber::SETSIZE * 2.times do |i|
(PurifyChamber::SETSIZE * 2).times do |i|
@__sprites[i + 1] = PokemonIconSprite.new(nil, viewport)
end
@__sprites[1 + (PurifyChamber::SETSIZE * 2)] = PokemonIconSprite.new(nil, viewport)

View File

@@ -277,7 +277,7 @@ def pbDownloadMysteryGift(trainer)
sprites["msgwindow"].visible = false
if gift[1] == 0
sprite = PokemonSprite.new(viewport)
sprite.setOffset(PictureOrigin::Center)
sprite.setOffset(PictureOrigin::CENTER)
sprite.setPokemonBitmap(gift[2])
sprite.x = Graphics.width / 2
sprite.y = -sprite.bitmap.height / 2

View File

@@ -141,7 +141,7 @@ class PokemonEntryScene
@sprites["shadow"].x = 33 * 2
@sprites["shadow"].y = 32 * 2
@sprites["subject"] = PokemonIconSprite.new(pokemon, @viewport)
@sprites["subject"].setOffset(PictureOrigin::Center)
@sprites["subject"].setOffset(PictureOrigin::CENTER)
@sprites["subject"].x = 88
@sprites["subject"].y = 54
@sprites["gender"] = BitmapSprite.new(32, 32, @viewport)
@@ -426,7 +426,7 @@ class PokemonEntryScene2
@sprites["shadow"].x = 66
@sprites["shadow"].y = 64
@sprites["subject"] = PokemonIconSprite.new(pokemon, @viewport)
@sprites["subject"].setOffset(PictureOrigin::Center)
@sprites["subject"].setOffset(PictureOrigin::CENTER)
@sprites["subject"].x = 88
@sprites["subject"].y = 54
@sprites["gender"] = BitmapSprite.new(32, 32, @viewport)

View File

@@ -435,7 +435,7 @@ class VoltorbFlip
numText += "0"
end
numText += num.to_s
numImages = numText.split(//)[0...2]
numImages = numText.chars[0...2]
2.times do |j|
@numbers[j] = [@directory + "numbersSmall", 472 + (j * 16), (i * 64) + 8, numImages[j].to_i * 16, 0, 16, 16]
end
@@ -453,7 +453,7 @@ class VoltorbFlip
numText += "0"
end
numText += num.to_s
numImages = numText.split(//)[0...2]
numImages = numText.chars[0...2]
2.times do |j|
@numbers[j] = [@directory + "numbersSmall", (i * 64) + 152 + (j * 16), 328, numImages[j].to_i * 16, 0, 16, 16]
end
@@ -470,7 +470,7 @@ class VoltorbFlip
coinText += "0"
end
coinText += source.to_s
coinImages = coinText.split(//)[0...5]
coinImages = coinText.chars[0...5]
5.times do |i|
@coins[i] = [@directory + "numbersScore", 6 + (i * 24), y, coinImages[i].to_i * 24, 0, 24, 38]
end

View File

@@ -72,10 +72,10 @@ class SpritePositioner
@sprites["shadow_1"] = IconSprite.new(0, 0, @viewport)
@sprites["shadow_1"].z = 3
@sprites["pokemon_0"] = PokemonSprite.new(@viewport)
@sprites["pokemon_0"].setOffset(PictureOrigin::Bottom)
@sprites["pokemon_0"].setOffset(PictureOrigin::BOTTOM)
@sprites["pokemon_0"].z = 4
@sprites["pokemon_1"] = PokemonSprite.new(@viewport)
@sprites["pokemon_1"].setOffset(PictureOrigin::Bottom)
@sprites["pokemon_1"].setOffset(PictureOrigin::BOTTOM)
@sprites["pokemon_1"].z = 4
@sprites["info"] = Window_UnformattedTextPokemon.new("")
@sprites["info"].viewport = @viewport

View File

@@ -802,7 +802,7 @@ class AnimationCanvas < Sprite
if Input.trigger?(Input::MOUSELEFT) && mousepos &&
pbSpriteHitTest(self, mousepos[0], mousepos[1], false, true)
selectedcel = -1
usealpha = (Input.press?(Input::ALT)) ? true : false
usealpha = Input.press?(Input::ALT)
PBAnimation::MAX_SPRITES.times do |j|
if pbSpriteHitTest(@celsprites[j], mousepos[0], mousepos[1], usealpha, false)
selectedcel = j