Code tidying with Rubocop

This commit is contained in:
Maruno17
2023-07-18 22:42:10 +01:00
parent 6053363715
commit a5734eaf46
68 changed files with 276 additions and 232 deletions

View File

@@ -128,6 +128,12 @@ Style/EndlessMethod:
Style/FormatString: Style/FormatString:
EnforcedStyle: sprintf EnforcedStyle: sprintf
# Prefer sprintf("%s", "Hello") over sprintf("%<greeting>s", greeting: "Hello")
# because it should be easy enough to see which token is which, and it saves
# space.
Style/FormatStringToken:
EnforcedStyle: unannotated
# String literals are not frozen by default, which makes this comment a # String literals are not frozen by default, which makes this comment a
# pointless bit of boilerplate that we neither need nor want. # pointless bit of boilerplate that we neither need nor want.
Style/FrozenStringLiteralComment: Style/FrozenStringLiteralComment:

View File

@@ -81,7 +81,8 @@ end
# class Array # class Array
#=============================================================================== #===============================================================================
class Array class Array
def ^(other) # xor of two arrays # xor of two arrays
def ^(other)
return (self | other) - (self & other) return (self | other) - (self & other)
end end
@@ -401,5 +402,5 @@ def lerp(start_val, end_val, duration, delta, now = nil)
delta = now - delta if now delta = now - delta if now
return start_val if delta <= 0 return start_val if delta <= 0
return end_val if delta >= duration return end_val if delta >= duration
return start_val + (end_val - start_val) * delta / duration.to_f return start_val + ((end_val - start_val) * delta / duration.to_f)
end end

View File

@@ -248,8 +248,7 @@ module PluginManager
incompats = [incompats] if !incompats.is_a?(Array) incompats = [incompats] if !incompats.is_a?(Array)
incompats.each do |incompat| incompats.each do |incompat|
if self.installed?(incompat) if self.installed?(incompat)
self.error("Plugin '#{name}' is incompatible with '#{incompat}'. " + self.error("Plugin '#{name}' is incompatible with '#{incompat}'. They cannot both be used at the same time.")
"They cannot both be used at the same time.")
end end
end end
when :credits # Plugin credits when :credits # Plugin credits
@@ -271,8 +270,7 @@ module PluginManager
end end
@@Plugins.each_value do |plugin| @@Plugins.each_value do |plugin|
if plugin[:incompatibilities]&.include?(name) if plugin[:incompatibilities]&.include?(name)
self.error("Plugin '#{plugin[:name]}' is incompatible with '#{name}'. " + self.error("Plugin '#{plugin[:name]}' is incompatible with '#{name}'. They cannot both be used at the same time.")
"They cannot both be used at the same time.")
end end
end end
# Add plugin to class variable # Add plugin to class variable

View File

@@ -9,15 +9,15 @@ class SpriteAnimation
@sprite = sprite @sprite = sprite
end end
["x", "y", "ox", "oy", "viewport", "flash", "src_rect", "opacity", "tone"].each do |def_name| def x(*arg); @sprite.x(*arg); end
eval <<-__END__ def y(*arg); @sprite.y(*arg); end
def ox(*arg); @sprite.ox(*arg); end
def #{def_name}(*arg) # def x(*arg) def oy(*arg); @sprite.oy(*arg); end
@sprite.#{def_name}(*arg) # @sprite.x(*arg) def viewport(*arg); @sprite.viewport(*arg); end
end # end def flash(*arg); @sprite.flash(*arg); end
def src_rect(*arg); @sprite.src_rect(*arg); end
__END__ def opacity(*arg); @sprite.opacity(*arg); end
end def tone(*arg); @sprite.tone(*arg); end
def self.clear def self.clear
@@_animations.clear @@_animations.clear
@@ -151,7 +151,7 @@ class SpriteAnimation
end end
end end
def update_loop_animation(quick_update = false) def update_loop_animation
new_index = ((System.uptime - @_loop_animation_timer_start) / @_loop_animation_time_per_frame).to_i new_index = ((System.uptime - @_loop_animation_timer_start) / @_loop_animation_time_per_frame).to_i
new_index %= @_loop_animation_duration new_index %= @_loop_animation_duration
quick_update = (@_loop_animation_index == new_index) quick_update = (@_loop_animation_index == new_index)

View File

@@ -210,7 +210,8 @@ class HandlerHashEnum
@symbolCache = {} @symbolCache = {}
end end
def [](sym) # 'sym' can be an ID or symbol # 'sym' can be an ID or symbol.
def [](sym)
id = fromSymbol(sym) id = fromSymbol(sym)
ret = nil ret = nil
ret = @hash[id] if id && @hash[id] # Real ID from the item ret = @hash[id] if id && @hash[id] # Real ID from the item
@@ -246,7 +247,8 @@ class HandlerHashEnum
return ret return ret
end end
def add(sym, handler = nil, &handlerBlock) # 'sym' can be an ID or symbol # 'sym' can be an ID or symbol.
def add(sym, handler = nil, &handlerBlock)
if ![Proc, Hash].include?(handler.class) && !block_given? if ![Proc, Hash].include?(handler.class) && !block_given?
raise ArgumentError, "#{self.class.name} for #{sym.inspect} has no valid handler (#{handler.inspect} was given)" raise ArgumentError, "#{self.class.name} for #{sym.inspect} has no valid handler (#{handler.inspect} was given)"
end end

View File

@@ -93,7 +93,8 @@ class Game_Screen
movement_per_second = @shake_power * @shake_speed * 4 movement_per_second = @shake_power * @shake_speed * 4
limit = @shake_power * 2.5 # Maximum pixel displacement limit = @shake_power * 2.5 # Maximum pixel displacement
phase = (delta_t * movement_per_second / limit).to_i % 4 phase = (delta_t * movement_per_second / limit).to_i % 4
if phase == 0 || phase == 2 case phase
when 0, 2
@shake = (movement_per_second * delta_t) % limit @shake = (movement_per_second * delta_t) % limit
@shake *= -1 if phase == 2 @shake *= -1 if phase == 2
else else

View File

@@ -448,13 +448,13 @@ class Game_Map
if (@scroll_distance_x || 0) != 0 if (@scroll_distance_x || 0) != 0
duration = @scroll_distance_x.abs * TILE_WIDTH.to_f / (10 * (2**@scroll_speed)) duration = @scroll_distance_x.abs * TILE_WIDTH.to_f / (10 * (2**@scroll_speed))
scroll_offset = lerp(0, @scroll_distance_x, duration, @scroll_timer_start, uptime_now) scroll_offset = lerp(0, @scroll_distance_x, duration, @scroll_timer_start, uptime_now)
self.display_x = @scroll_start_x + scroll_offset * REAL_RES_X self.display_x = @scroll_start_x + (scroll_offset * REAL_RES_X)
@scroll_distance_x = 0 if scroll_offset == @scroll_distance_x @scroll_distance_x = 0 if scroll_offset == @scroll_distance_x
end end
if (@scroll_distance_y || 0) != 0 if (@scroll_distance_y || 0) != 0
duration = @scroll_distance_y.abs * TILE_HEIGHT.to_f / (10 * (2**@scroll_speed)) duration = @scroll_distance_y.abs * TILE_HEIGHT.to_f / (10 * (2**@scroll_speed))
scroll_offset = lerp(0, @scroll_distance_y, duration, @scroll_timer_start, uptime_now) scroll_offset = lerp(0, @scroll_distance_y, duration, @scroll_timer_start, uptime_now)
self.display_y = @scroll_start_y + scroll_offset * REAL_RES_Y self.display_y = @scroll_start_y + (scroll_offset * REAL_RES_Y)
@scroll_distance_y = 0 if scroll_offset == @scroll_distance_y @scroll_distance_y = 0 if scroll_offset == @scroll_distance_y
end end
# Only update events that are on-screen # Only update events that are on-screen

View File

@@ -25,7 +25,7 @@ class Game_Character
attr_accessor :animation_id attr_accessor :animation_id
attr_accessor :transparent attr_accessor :transparent
attr_reader :move_speed attr_reader :move_speed
attr_accessor :jump_speed attr_reader :jump_speed
attr_accessor :walk_anime attr_accessor :walk_anime
attr_writer :bob_height attr_writer :bob_height
@@ -116,13 +116,21 @@ class Game_Character
# 4 => 0.125 # Running speed (2x walking speed) # 4 => 0.125 # Running speed (2x walking speed)
# 5 => 0.1 # Cycling speed (1.25x running speed) # 5 => 0.1 # Cycling speed (1.25x running speed)
# 6 => 0.05 # 6 => 0.05
@move_time = (val == 6) ? 0.05 : (val == 5) ? 0.1 : 2.0 / (2**val) case val
when 6 then @move_time = 0.05
when 5 then @move_time = 0.1
else @move_time = 2.0 / (2**val)
end
end end
# Takes the same values as move_speed above. # Takes the same values as move_speed above.
def jump_speed=(val) def jump_speed=(val)
@jump_speed = val @jump_speed = val
@jump_time = (val == 6) ? 0.05 : (val == 5) ? 0.1 : 2.0 / (2**val) case val
when 6 then @jump_time = 0.05
when 5 then @jump_time = 0.1
else @jump_time = 2.0 / (2**val)
end
end end
# Returns time in seconds for one full cycle (4 frames) of an animating # Returns time in seconds for one full cycle (4 frames) of an animating
@@ -629,7 +637,8 @@ class Game_Character
end end
end end
def moveLeft90 # anticlockwise # Anticlockwise.
def moveLeft90
case self.direction case self.direction
when 2 then move_right # down when 2 then move_right # down
when 4 then move_down # left when 4 then move_down # left
@@ -638,7 +647,8 @@ class Game_Character
end end
end end
def moveRight90 # clockwise # Clockwise.
def moveRight90
case self.direction case self.direction
when 2 then move_left # down when 2 then move_left # down
when 4 then move_up # left when 4 then move_up # left
@@ -765,10 +775,10 @@ class Game_Character
end end
@jump_initial_x = @x @jump_initial_x = @x
@jump_initial_y = @y @jump_initial_y = @y
@x = @x + x_plus @x += x_plus
@y = @y + y_plus @y += y_plus
@jump_timer = 0.0 @jump_timer = 0.0
real_distance = Math.sqrt(x_plus**2 + y_plus**2) real_distance = Math.sqrt((x_plus**2) + (y_plus**2))
distance = [1, real_distance].max distance = [1, real_distance].max
@jump_peak = distance * Game_Map::TILE_HEIGHT * 3 / 8 # 3/4 of tile for ledge jumping @jump_peak = distance * Game_Map::TILE_HEIGHT * 3 / 8 # 3/4 of tile for ledge jumping
@jump_distance = [x_plus.abs * Game_Map::REAL_RES_X, y_plus.abs * Game_Map::REAL_RES_Y].max @jump_distance = [x_plus.abs * Game_Map::REAL_RES_X, y_plus.abs * Game_Map::REAL_RES_Y].max

View File

@@ -1,5 +1,5 @@
class Sprite_SurfBase class Sprite_SurfBase
attr_reader :visible attr_reader :visible
def initialize(parent_sprite, viewport = nil) def initialize(parent_sprite, viewport = nil)
@parent_sprite = parent_sprite @parent_sprite = parent_sprite

View File

@@ -44,7 +44,8 @@ class Spriteset_Map
@@viewport3 = Viewport.new(0, 0, Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT) # Flashing @@viewport3 = Viewport.new(0, 0, Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT) # Flashing
@@viewport3.z = 500 @@viewport3.z = 500
def self.viewport # For access by Spriteset_Global # For access by Spriteset_Global.
def self.viewport
return @@viewport1 return @@viewport1
end end

View File

@@ -105,7 +105,8 @@ class Sprite_Shadow < RPG::Sprite
end end
end end
def in_range?(element, object, range) # From Near's Anti Lag Script, edited # From Near's Anti Lag Script, edited.
def in_range?(element, object, range)
elemScreenX = ScreenPosHelper.pbScreenX(element) elemScreenX = ScreenPosHelper.pbScreenX(element)
elemScreenY = ScreenPosHelper.pbScreenY(element) elemScreenY = ScreenPosHelper.pbScreenY(element)
objScreenX = ScreenPosHelper.pbScreenX(object) objScreenX = ScreenPosHelper.pbScreenX(object)

View File

@@ -53,8 +53,8 @@ def getCubicPoint2(src, t)
y1 = src[7] y1 = src[7]
x1 = cx1 + ((x1 - cx1) * t) x1 = cx1 + ((x1 - cx1) * t)
x0 = x0 + ((cx0 - x0) * t) x0 += ((cx0 - x0) * t)
cx0 = cx0 + ((cx1 - cx0) * t) cx0 += ((cx1 - cx0) * t)
cx1 = cx0 + ((x1 - cx0) * t) cx1 = cx0 + ((x1 - cx0) * t)
cx0 = x0 + ((cx0 - x0) * t) cx0 = x0 + ((cx0 - x0) * t)
cx = cx0 + ((cx1 - cx0) * t) cx = cx0 + ((cx1 - cx0) * t)
@@ -64,8 +64,8 @@ def getCubicPoint2(src, t)
# d = x0 # d = x0
# cx = a*t*t*t + b*t*t + c*t + d # cx = a*t*t*t + b*t*t + c*t + d
y1 = cy1 + ((y1 - cy1) * t) y1 = cy1 + ((y1 - cy1) * t)
y0 = y0 + ((cy0 - y0) * t) y0 += ((cy0 - y0) * t)
cy0 = cy0 + ((cy1 - cy0) * t) cy0 += ((cy1 - cy0) * t)
cy1 = cy0 + ((y1 - cy0) * t) cy1 = cy0 + ((y1 - cy0) * t)
cy0 = y0 + ((cy0 - y0) * t) cy0 = y0 + ((cy0 - y0) * t)
cy = cy0 + ((cy1 - cy0) * t) cy = cy0 + ((cy1 - cy0) * t)

View File

@@ -108,7 +108,7 @@ module MessageConfig
when 2 then return 1 / 80.0 # Fast when 2 then return 1 / 80.0 # Fast
when 3 then return 0 # Instant when 3 then return 0 # Instant
end end
return TEXT_SPEED || 2 / 80.0 # Normal return TEXT_SPEED || (2 / 80.0) # Normal
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------

View File

@@ -302,7 +302,7 @@ class Window
mustchange = false mustchange = false
if @active if @active
cursor_time = System.uptime / 0.4 cursor_time = System.uptime / 0.4
if cursor_time.to_i % 2 == 0 if cursor_time.to_i.even?
@cursoropacity = lerp(255, 128, 0.4, cursor_time % 2) @cursoropacity = lerp(255, 128, 0.4, cursor_time % 2)
else else
@cursoropacity = lerp(128, 255, 0.4, (cursor_time - 1) % 2) @cursoropacity = lerp(128, 255, 0.4, (cursor_time - 1) % 2)

View File

@@ -300,7 +300,7 @@ class SpriteWindow < Window
mustchange = false mustchange = false
if @active if @active
cursor_time = System.uptime / 0.4 cursor_time = System.uptime / 0.4
if cursor_time.to_i % 2 == 0 if cursor_time.to_i.even?
@cursoropacity = lerp(255, 128, 0.4, cursor_time % 2) @cursoropacity = lerp(255, 128, 0.4, cursor_time % 2)
else else
@cursoropacity = lerp(128, 255, 0.4, (cursor_time - 1) % 2) @cursoropacity = lerp(128, 255, 0.4, (cursor_time - 1) % 2)
@@ -852,7 +852,8 @@ class SpriteWindow_Base < SpriteWindow
end end
end end
def setSkin(skin) # Filename of windowskin to apply. Supports XP, VX, and animated skins. # Filename of windowskin to apply. Supports XP, VX, and animated skins.
def setSkin(skin)
@customskin&.dispose @customskin&.dispose
@customskin = nil @customskin = nil
resolvedName = pbResolveBitmap(skin) resolvedName = pbResolveBitmap(skin)

View File

@@ -47,7 +47,8 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
return ret return ret
end end
def resizeToFitInternal(text, maxwidth) # maxwidth is maximum acceptable window width # maxwidth is maximum acceptable window width.
def resizeToFitInternal(text, maxwidth)
dims = [0, 0] dims = [0, 0]
cwidth = maxwidth < 0 ? Graphics.width : maxwidth cwidth = maxwidth < 0 ? Graphics.width : maxwidth
getLineBrokenChunks(self.contents, text, getLineBrokenChunks(self.contents, text,
@@ -60,14 +61,16 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
self.text = text self.text = text
end end
def resizeToFit(text, maxwidth = -1) # maxwidth is maximum acceptable window width # maxwidth is maximum acceptable window width.
def resizeToFit(text, maxwidth = -1)
dims = resizeToFitInternal(text, maxwidth) dims = resizeToFitInternal(text, maxwidth)
self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXT_PADDING self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXT_PADDING
self.height = dims[1] + self.borderY self.height = dims[1] + self.borderY
refresh refresh
end end
def resizeHeightToFit(text, width = -1) # width is current window width # width is current window width.
def resizeHeightToFit(text, width = -1)
dims = resizeToFitInternal(text, width) dims = resizeToFitInternal(text, width)
self.width = (width < 0) ? Graphics.width : width self.width = (width < 0) ? Graphics.width : width
self.height = dims[1] + self.borderY self.height = dims[1] + self.borderY
@@ -685,7 +688,7 @@ class Window_InputNumberPokemon < SpriteWindow_Base
def update def update
super super
digits = @digits_max + (@sign ? 1 : 0) digits = @digits_max + (@sign ? 1 : 0)
cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i % 2 == 0 cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i.even?
if cursor_to_show != @cursor_shown if cursor_to_show != @cursor_shown
@cursor_shown = cursor_to_show @cursor_shown = cursor_to_show
refresh refresh
@@ -1128,11 +1131,13 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx
return Rect.new(rect.x + 16, rect.y, rect.width - 16, rect.height) return Rect.new(rect.x + 16, rect.y, rect.width - 16, rect.height)
end end
def itemCount # to be implemented by derived classes # To be implemented by derived classes.
def itemCount
return 0 return 0
end end
def drawItem(index, count, rect); end # to be implemented by derived classes # To be implemented by derived classes.
def drawItem(index, count, rect); end
def refresh def refresh
@item_max = itemCount @item_max = itemCount

View File

@@ -819,23 +819,22 @@ def getLineBrokenText(bitmap, value, width, dims)
words = [ccheck] words = [ccheck]
words.length.times do |i| words.length.times do |i|
word = words[i] word = words[i]
if word && word != "" next if nil_or_empty?(word)
textSize = bitmap.text_size(word) textSize = bitmap.text_size(word)
textwidth = textSize.width textwidth = textSize.width
if x > 0 && x + textwidth >= width - 2 if x > 0 && x + textwidth >= width - 2
# Zero-length word break # Zero-length word break
ret.push(["", x, y, 0, textheight, line, position, column, 0]) ret.push(["", x, y, 0, textheight, line, position, column, 0])
x = 0 x = 0
column = 0 column = 0
y += (textheight == 0) ? bitmap.text_size("X").height : textheight y += (textheight == 0) ? bitmap.text_size("X").height : textheight
line += 1 line += 1
textheight = 0 textheight = 0
end
textheight = [textheight, textSize.height].max
ret.push([word, x, y, textwidth, textheight, line, position, column, length])
x += textwidth
dims[0] = x if dims && dims[0] < x
end end
textheight = [textheight, textSize.height].max
ret.push([word, x, y, textwidth, textheight, line, position, column, length])
x += textwidth
dims[0] = x if dims && dims[0] < x
end end
position += length position += length
column += length column += length
@@ -912,16 +911,15 @@ def renderLineBrokenChunksWithShadow(bitmap, xDst, yDst, normtext, maxheight, ba
width = text[3] width = text[3]
textx = text[1] + xDst textx = text[1] + xDst
texty = text[2] + yDst texty = text[2] + yDst
if maxheight == 0 || text[2] < maxheight next if maxheight != 0 && text[2] >= maxheight
height = text[4] height = text[4]
text = text[0] text = text[0]
bitmap.font.color = shadowColor bitmap.font.color = shadowColor
bitmap.draw_text(textx + 2, texty, width + 2, height, text) bitmap.draw_text(textx + 2, texty, width + 2, height, text)
bitmap.draw_text(textx, texty + 2, width + 2, height, text) bitmap.draw_text(textx, texty + 2, width + 2, height, text)
bitmap.draw_text(textx + 2, texty + 2, width + 2, height, text) bitmap.draw_text(textx + 2, texty + 2, width + 2, height, text)
bitmap.font.color = baseColor bitmap.font.color = baseColor
bitmap.draw_text(textx, texty, width + 2, height, text) bitmap.draw_text(textx, texty, width + 2, height, text)
end
end end
end end

View File

@@ -104,7 +104,7 @@ class ChooseNumberParams
end end
def initialNumber def initialNumber
return clamp(@initialNumber, self.minNumber, self.maxNumber) return @initialNumber.clamp(self.minNumber, self.maxNumber)
end end
def cancelNumber def cancelNumber
@@ -149,10 +149,6 @@ class ChooseNumberParams
private private
def clamp(v, mn, mx)
return v < mn ? mn : (v > mx ? mx : v)
end
def numDigits(number) def numDigits(number)
ans = 1 ans = 1
number = number.abs number = number.abs

View File

@@ -148,7 +148,7 @@ class Window_TextEntry < SpriteWindow_Base
end end
def update def update
cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i % 2 == 0 cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i.even?
if cursor_to_show != @cursor_shown if cursor_to_show != @cursor_shown
@cursor_shown = cursor_to_show @cursor_shown = cursor_to_show
refresh refresh
@@ -225,7 +225,7 @@ end
#=============================================================================== #===============================================================================
class Window_TextEntry_Keyboard < Window_TextEntry class Window_TextEntry_Keyboard < Window_TextEntry
def update def update
cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i % 2 == 0 cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i.even?
if cursor_to_show != @cursor_shown if cursor_to_show != @cursor_shown
@cursor_shown = cursor_to_show @cursor_shown = cursor_to_show
refresh refresh
@@ -394,19 +394,11 @@ class Window_MultilineTextEntry < SpriteWindow_Base
thispos = text[6] thispos = text[6]
thiscolumn = text[7] thiscolumn = text[7]
thislength = text[8] thislength = text[8]
if thisline == line next if thisline != line
endpos = thispos + thislength endpos = thispos + thislength
# echoln [endpos,thispos+(column-thiscolumn),textchars[i]] next if column < thiscolumn || column > thiscolumn + thislength || thislength == 0
if column >= thiscolumn && column <= thiscolumn + thislength && thislength > 0 return thispos + column - thiscolumn
return thispos + (column - thiscolumn)
end
end
end end
# if endpos==0
# echoln [totallines,line,column]
# echoln textchars
# end
# echoln "endpos=#{endpos}"
return endpos return endpos
end end
@@ -465,7 +457,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
end end
def update def update
cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i % 2 == 0 cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i.even?
if cursor_to_show != @cursor_shown if cursor_to_show != @cursor_shown
@cursor_shown = cursor_to_show @cursor_shown = cursor_to_show
refresh refresh
@@ -544,18 +536,17 @@ class Window_MultilineTextEntry < SpriteWindow_Base
thisline = text[5] thisline = text[5]
thiscolumn = text[7] thiscolumn = text[7]
thislength = text[8] thislength = text[8]
if thisline == @cursorLine && @cursorColumn >= thiscolumn && next if thisline != @cursorLine || @cursorColumn < thiscolumn ||
@cursorColumn <= thiscolumn + thislength @cursorColumn > thiscolumn + thislength
cursorY = text[2] - startY cursorY = text[2] - startY
cursorX = text[1] cursorX = text[1]
textheight = text[4] textheight = text[4]
posToCursor = @cursorColumn - thiscolumn posToCursor = @cursorColumn - thiscolumn
if posToCursor >= 0 if posToCursor >= 0
partialString = text[0].scan(/./m)[0, posToCursor].join partialString = text[0].scan(/./m)[0, posToCursor].join
cursorX += bitmap.text_size(partialString).width cursorX += bitmap.text_size(partialString).width
end
break
end end
break
end end
cursorY += 4 cursorY += 4
cursorHeight = [4, textheight - 4, bitmap.text_size("X").height - 4].max cursorHeight = [4, textheight - 4, bitmap.text_size("X").height - 4].max

View File

@@ -530,7 +530,7 @@ class Battle
return 2 if counts[0] < counts[1] # Loss (foe has more able Pokémon) return 2 if counts[0] < counts[1] # Loss (foe has more able Pokémon)
return 1 if hpTotals[0] > hpTotals[1] # Win (player has more HP in total) return 1 if hpTotals[0] > hpTotals[1] # Win (player has more HP in total)
return 2 if hpTotals[0] < hpTotals[1] # Loss (foe has more HP in total) return 2 if hpTotals[0] < hpTotals[1] # Loss (foe has more HP in total)
return 5 # Draw return 5 # Draw
end end
# Unused # Unused
@@ -549,10 +549,10 @@ class Battle
return 2 if counts[0] < counts[1] # Loss (foe has more able Pokémon) return 2 if counts[0] < counts[1] # Loss (foe has more able Pokémon)
return 1 if hpTotals[0] > hpTotals[1] # Win (player has a bigger average HP %) return 1 if hpTotals[0] > hpTotals[1] # Win (player has a bigger average HP %)
return 2 if hpTotals[0] < hpTotals[1] # Loss (foe has a bigger average HP %) return 2 if hpTotals[0] < hpTotals[1] # Loss (foe has a bigger average HP %)
return 5 # Draw return 5 # Draw
end end
def pbDecisionOnDraw; return 5; end # Draw def pbDecisionOnDraw; return 5; end # Draw
def pbJudge def pbJudge
fainted1 = pbAllFainted?(0) fainted1 = pbAllFainted?(0)

View File

@@ -126,7 +126,7 @@ class Battle
if Settings::SCALED_EXP_FORMULA if Settings::SCALED_EXP_FORMULA
exp /= 5 exp /= 5
levelAdjust = ((2 * level) + 10.0) / (pkmn.level + level + 10.0) levelAdjust = ((2 * level) + 10.0) / (pkmn.level + level + 10.0)
levelAdjust = levelAdjust**5 levelAdjust **= 5
levelAdjust = Math.sqrt(levelAdjust) levelAdjust = Math.sqrt(levelAdjust)
exp *= levelAdjust exp *= levelAdjust
exp = exp.floor exp = exp.floor

View File

@@ -145,7 +145,8 @@ class Battle::Move
def nonLethal?(_user, _target); return false; end # For False Swipe def nonLethal?(_user, _target); return false; end # For False Swipe
def preventsBattlerConsumingHealingBerry?(battler, targets); return false; end # For Bug Bite/Pluck def preventsBattlerConsumingHealingBerry?(battler, targets); return false; end # For Bug Bite/Pluck
def ignoresSubstitute?(user) # user is the Pokémon using this move # user is the Pokémon using this move.
def ignoresSubstitute?(user)
if Settings::MECHANICS_GENERATION >= 6 if Settings::MECHANICS_GENERATION >= 6
return true if soundMove? return true if soundMove?
return true if user&.hasActiveAbility?(:INFILTRATOR) return true if user&.hasActiveAbility?(:INFILTRATOR)

View File

@@ -318,7 +318,8 @@ class Battle::Move::TwoTurnMove < Battle::Move
return !@damagingTurn # Deliberately not "return @chargingTurn" return !@damagingTurn # Deliberately not "return @chargingTurn"
end end
def pbDamagingMove? # Stops damage being dealt in the first (charging) turn # Stops damage being dealt in the first (charging) turn.
def pbDamagingMove?
return false if !@damagingTurn return false if !@damagingTurn
return super return super
end end

View File

@@ -604,7 +604,8 @@ end
class Battle::Move::AttackTwoTurnsLater < Battle::Move class Battle::Move::AttackTwoTurnsLater < Battle::Move
def targetsPosition?; return true; end def targetsPosition?; return true; end
def pbDamagingMove? # Stops damage being dealt in the setting-up turn # Stops damage being dealt in the setting-up turn.
def pbDamagingMove?
return false if !@battle.futureSight return false if !@battle.futureSight
return super return super
end end

View File

@@ -606,7 +606,8 @@ class Battle::Move::MultiTurnAttackBideThenReturnDoubleDamage < Battle::Move::Fi
end end
end end
def pbDamagingMove? # Stops damage being dealt in the charging turns # Stops damage being dealt in the charging turns.
def pbDamagingMove?
return false if !@damagingTurn return false if !@damagingTurn
return super return super
end end

View File

@@ -6,7 +6,7 @@ class Battle::Scene::PokemonDataBox < Sprite
attr_accessor :selected attr_accessor :selected
# Time in seconds to fully fill the Exp bar (from empty). # Time in seconds to fully fill the Exp bar (from empty).
EXP_BAR_FILL_TIME = 1.75 EXP_BAR_FILL_TIME = 1.75
# Time in seconds for this data box to flash when the Exp fully fills. # Time in seconds for this data box to flash when the Exp fully fills.
EXP_FULL_FLASH_DURATION = 0.2 EXP_FULL_FLASH_DURATION = 0.2
# Maximum time in seconds to make a change to the HP bar. # Maximum time in seconds to make a change to the HP bar.

View File

@@ -139,8 +139,8 @@ class Battle::AI
# Find items usable on other Pokémon in the user's team # Find items usable on other Pokémon in the user's team
# NOTE: Currently only checks Revives. # NOTE: Currently only checks Revives.
usable_items = {} usable_items = {}
@battle.eachInTeamFromBattlerIndex(@user.index) do |pkmn, i| @battle.eachInTeamFromBattlerIndex(@user.index) do |team_pkmn, i|
next if !pkmn.fainted? # Remove this line to check unfainted Pokémon too next if !team_pkmn.fainted? # Remove this line to check unfainted Pokémon too
items.each do |item| items.each do |item|
usage = get_usability_of_item_on_pkmn(item, i, @user.side) usage = get_usability_of_item_on_pkmn(item, i, @user.side)
usage.each_pair do |key, vals| usage.each_pair do |key, vals|

View File

@@ -9,7 +9,7 @@ class Battle::AI
# Returns a value between 0.0 and 1.0. All move scores are lowered by this # Returns a value between 0.0 and 1.0. All move scores are lowered by this
# value multiplied by the highest-scoring move's score. # value multiplied by the highest-scoring move's score.
def move_score_threshold def move_score_threshold
return 0.6 + 0.35 * (([@trainer.skill, 100].min / 100.0) ** 0.5) # 0.635 to 0.95 return 0.6 + (0.35 * (([@trainer.skill, 100].min / 100.0)**0.5)) # 0.635 to 0.95
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -161,7 +161,7 @@ class Battle::AI
@target&.refresh_battler @target&.refresh_battler
if @target && @move.function_code == "UseLastMoveUsedByTarget" if @target && @move.function_code == "UseLastMoveUsedByTarget"
if @target.battler.lastRegularMoveUsed && if @target.battler.lastRegularMoveUsed &&
GameData::Move.exists?(@target.battler.lastRegularMoveUsed) && GameData::Move.exists?(@target.battler.lastRegularMoveUsed) &&
GameData::Move.get(@target.battler.lastRegularMoveUsed).has_flag?("CanMirrorMove") GameData::Move.get(@target.battler.lastRegularMoveUsed).has_flag?("CanMirrorMove")
@battle.moldBreaker = @user.has_mold_breaker? @battle.moldBreaker = @user.has_mold_breaker?
mov = Battle::Move.from_pokemon_move(@battle, Pokemon::Move.new(@target.battler.lastRegularMoveUsed)) mov = Battle::Move.from_pokemon_move(@battle, Pokemon::Move.new(@target.battler.lastRegularMoveUsed))
@@ -278,7 +278,7 @@ class Battle::AI
PBDebug.log_score_change(score - old_score, "function code modifier (generic)") PBDebug.log_score_change(score - old_score, "function code modifier (generic)")
# Modify the score according to various other effects # Modify the score according to various other effects
score = Battle::AI::Handlers.apply_general_move_score_modifiers( score = Battle::AI::Handlers.apply_general_move_score_modifiers(
score, @move, @user, self, @battle) score, @move, @user, self, @battle)
end end
score = score.to_i score = score.to_i
score = 0 if score < 0 score = 0 if score < 0
@@ -307,7 +307,7 @@ class Battle::AI
PBDebug.log_score_change(score - old_score, "function code modifier (against target)") PBDebug.log_score_change(score - old_score, "function code modifier (against target)")
# Modify the score according to various other effects against the target # Modify the score according to various other effects against the target
score = Battle::AI::Handlers.apply_general_move_against_target_score_modifiers( score = Battle::AI::Handlers.apply_general_move_against_target_score_modifiers(
score, @move, @user, @target, self, @battle) score, @move, @user, @target, self, @battle)
end end
# Add the score against the target to the overall score # Add the score against the target to the overall score
target_data = @move.pbTarget(@user.battler) target_data = @move.pbTarget(@user.battler)

View File

@@ -232,15 +232,14 @@ class Battle::AI
target_speed = target.rough_stat(:SPEED) target_speed = target.rough_stat(:SPEED)
each_foe_battler(target.side) do |b, i| each_foe_battler(target.side) do |b, i|
b_speed = b.rough_stat(:SPEED) b_speed = b.rough_stat(:SPEED)
next if b_speed <= target_speed # Target already outspeeds the foe b
next if b_speed > target_speed * 2.5 # Much too slow to reasonably catch up next if b_speed > target_speed * 2.5 # Much too slow to reasonably catch up
if b_speed > target_speed if b_speed < target_speed * (increment + 2) / 2
if b_speed < target_speed * (increment + 2) / 2 score += 15 * inc_mult # Target will become faster than the foe b
score += 15 * inc_mult # Target will become faster than b else
else score += 8 * inc_mult
score += 8 * inc_mult
end
break
end end
break
end end
# Prefer if the target has Electro Ball or Power Trip/Stored Power # Prefer if the target has Electro Ball or Power Trip/Stored Power
moves_that_prefer_high_speed = [ moves_that_prefer_high_speed = [
@@ -524,15 +523,14 @@ class Battle::AI
target_speed = target.rough_stat(:SPEED) target_speed = target.rough_stat(:SPEED)
each_foe_battler(target.side) do |b, i| each_foe_battler(target.side) do |b, i|
b_speed = b.rough_stat(:SPEED) b_speed = b.rough_stat(:SPEED)
next if target_speed < b_speed # Target is already slower than foe b
next if target_speed > b_speed * 2.5 # Much too fast to reasonably be overtaken next if target_speed > b_speed * 2.5 # Much too fast to reasonably be overtaken
if target_speed > b_speed if target_speed < b_speed * 2 / (decrement + 2)
if target_speed < b_speed * 2 / (decrement + 2) score += 15 * dec_mult # Target will become slower than foe b
score += 15 * dec_mult # Target will become slower than b else
else score += 8 * dec_mult
score += 8 * dec_mult
end
break
end end
break
end end
# Prefer if any ally has Electro Ball # Prefer if any ally has Electro Ball
each_foe_battler(target.side) do |b, i| each_foe_battler(target.side) do |b, i|

View File

@@ -489,7 +489,7 @@ Battle::AI::Handlers::GeneralMoveAgainstTargetScore.add(:damaging_a_biding_targe
hits_possible = target.effects[PBEffects::Bide] - 1 hits_possible = target.effects[PBEffects::Bide] - 1
eor_dmg *= hits_possible eor_dmg *= hits_possible
hits_possible += 1 if user.faster_than?(target) hits_possible += 1 if user.faster_than?(target)
next score if dmg * hits_possible + eor_dmg > target.hp * 1.1 next score if (dmg * hits_possible) + eor_dmg > target.hp * 1.1
end end
old_score = score old_score = score
score -= 20 score -= 20

View File

@@ -189,7 +189,7 @@ class Battle::AI
# Type power boosters # Type power boosters
:BLACKBELT, :BLACKGLASSES, :CHARCOAL, :DRAGONFANG, :HARDSTONE, :BLACKBELT, :BLACKGLASSES, :CHARCOAL, :DRAGONFANG, :HARDSTONE,
:MAGNET, :METALCOAT, :MIRACLESEED, :MYSTICWATER, :NEVERMELTICE, :MAGNET, :METALCOAT, :MIRACLESEED, :MYSTICWATER, :NEVERMELTICE,
:POISONBARB, :SHARPBEAK, :SILKSCARF,:SILVERPOWDER, :SOFTSAND, :POISONBARB, :SHARPBEAK, :SILKSCARF, :SILVERPOWDER, :SOFTSAND,
:SPELLTAG, :TWISTEDSPOON, :SPELLTAG, :TWISTEDSPOON,
:ODDINCENSE, :ROCKINCENSE, :ROSEINCENSE, :SEAINCENSE, :WAVEINCENSE, :ODDINCENSE, :ROCKINCENSE, :ROSEINCENSE, :SEAINCENSE, :WAVEINCENSE,
# Plates # Plates
@@ -218,8 +218,7 @@ class Battle::AI
:BUGMEMORY, :DARKMEMORY, :DRAGONMEMORY, :ELECTRICMEMORY, :BUGMEMORY, :DARKMEMORY, :DRAGONMEMORY, :ELECTRICMEMORY,
:FAIRYMEMORY, :FIGHTINGMEMORY, :FIREMEMORY, :FLYINGMEMORY, :FAIRYMEMORY, :FIGHTINGMEMORY, :FIREMEMORY, :FLYINGMEMORY,
:GHOSTMEMORY, :GRASSMEMORY, :GROUNDMEMORY, :ICEMEMORY, :POISONMEMORY, :GHOSTMEMORY, :GRASSMEMORY, :GROUNDMEMORY, :ICEMEMORY, :POISONMEMORY,
:PSYCHICMEMORY, :ROCKMEMORY, :STEELMEMORY, :WATERMEMORY :PSYCHICMEMORY, :ROCKMEMORY, :STEELMEMORY, :WATERMEMORY],
],
0 => [:SMOKEBALL], 0 => [:SMOKEBALL],
-5 => [:FULLINCENSE, :LAGGINGTAIL, :RINGTARGET], -5 => [:FULLINCENSE, :LAGGINGTAIL, :RINGTARGET],
-6 => [:MACHOBRACE, :POWERANKLET, :POWERBAND, :POWERBELT, :POWERBRACER, -6 => [:MACHOBRACE, :POWERANKLET, :POWERBAND, :POWERBELT, :POWERBRACER,
@@ -852,7 +851,7 @@ Battle::AI::Handlers::ItemRanking.addIf(:type_boosting_items,
:PSYCHIC => [:TWISTEDSPOON, :MINDPLATE, :ODDINCENSE], :PSYCHIC => [:TWISTEDSPOON, :MINDPLATE, :ODDINCENSE],
:ROCK => [:HARDSTONE, :STONEPLATE, :ROCKINCENSE], :ROCK => [:HARDSTONE, :STONEPLATE, :ROCKINCENSE],
:STEEL => [:METALCOAT, :IRONPLATE], :STEEL => [:METALCOAT, :IRONPLATE],
:WATER => [:MYSTICWATER, :SPLASHPLATE, :SEAINCENSE, :WAVEINCENSE], :WATER => [:MYSTICWATER, :SPLASHPLATE, :SEAINCENSE, :WAVEINCENSE]
} }
boosted_type = nil boosted_type = nil
boosters.each_pair do |type, items| boosters.each_pair do |type, items|
@@ -891,7 +890,7 @@ Battle::AI::Handlers::ItemRanking.addIf(:gems,
:PSYCHICGEM => :PSYCHIC, :PSYCHICGEM => :PSYCHIC,
:ROCKGEM => :ROCK, :ROCKGEM => :ROCK,
:STEELGEM => :STEEL, :STEELGEM => :STEEL,
:WATERGEM => :WATER, :WATERGEM => :WATER
}[item] }[item]
next score if boosted_type && battler.has_damaging_move_of_type?(boosted_type) next score if boosted_type && battler.has_damaging_move_of_type?(boosted_type)
next 0 next 0

View File

@@ -238,14 +238,15 @@ class Battle::AI::AIMove
end end
# Mud Sport and Water Sport # Mud Sport and Water Sport
if @ai.trainer.medium_skill? if @ai.trainer.medium_skill?
if calc_type == :ELECTRIC case calc_type
when :ELECTRIC
if @ai.battle.allBattlers.any? { |b| b.effects[PBEffects::MudSport] } if @ai.battle.allBattlers.any? { |b| b.effects[PBEffects::MudSport] }
multipliers[:power_multiplier] /= 3 multipliers[:power_multiplier] /= 3
end end
if @ai.battle.field.effects[PBEffects::MudSportField] > 0 if @ai.battle.field.effects[PBEffects::MudSportField] > 0
multipliers[:power_multiplier] /= 3 multipliers[:power_multiplier] /= 3
end end
elsif calc_type == :FIRE when :FIRE
if @ai.battle.allBattlers.any? { |b| b.effects[PBEffects::WaterSport] } if @ai.battle.allBattlers.any? { |b| b.effects[PBEffects::WaterSport] }
multipliers[:power_multiplier] /= 3 multipliers[:power_multiplier] /= 3
end end

View File

@@ -635,7 +635,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("RaiseTargetAttack2Confus
score = ai.get_score_for_target_stat_raise(score, target, [:ATTACK, 2], false) score = ai.get_score_for_target_stat_raise(score, target, [:ATTACK, 2], false)
# Score for confusing the target # Score for confusing the target
next Battle::AI::Handlers.apply_move_effect_against_target_score( next Battle::AI::Handlers.apply_move_effect_against_target_score(
"ConfuseTarget", score, move, user, target, ai, battle) "ConfuseTarget", score, move, user, target, ai, battle)
} }
) )
@@ -657,7 +657,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("RaiseTargetSpAtk1Confuse
score = ai.get_score_for_target_stat_raise(score, target, [:SPECIAL_ATTACK, 1], false) score = ai.get_score_for_target_stat_raise(score, target, [:SPECIAL_ATTACK, 1], false)
# Score for confusing the target # Score for confusing the target
next Battle::AI::Handlers.apply_move_effect_against_target_score( next Battle::AI::Handlers.apply_move_effect_against_target_score(
"ConfuseTarget", score, move, user, target, ai, battle) "ConfuseTarget", score, move, user, target, ai, battle)
} }
) )

View File

@@ -463,7 +463,7 @@ Battle::AI::Handlers::MoveEffectScore.add("EnsureNextCriticalHit",
next Battle::AI::MOVE_USELESS_SCORE next Battle::AI::MOVE_USELESS_SCORE
end end
# Prefer if user knows a damaging move which won't definitely critical hit # Prefer if user knows a damaging move which won't definitely critical hit
if user.check_for_move { |m| m.damagingMove? && m.function_code != "AlwaysCriticalHit"} if user.check_for_move { |m| m.damagingMove? && m.function_code != "AlwaysCriticalHit" }
score += 15 score += 15
end end
next score next score
@@ -860,7 +860,7 @@ Battle::AI::Handlers::MoveEffectScore.add("ProtectUserFromDamagingMovesKingsShie
# Prefer if the foe's Attack can be lowered by this move # Prefer if the foe's Attack can be lowered by this move
if b.battler.affectedByContactEffect? && b.check_for_move { |m| m.contactMove? } if b.battler.affectedByContactEffect? && b.check_for_move { |m| m.contactMove? }
drop_score = ai.get_score_for_target_stat_drop( drop_score = ai.get_score_for_target_stat_drop(
0, b, [:ATTACK, (Settings::MECHANICS_GENERATION >= 8) ? 1 : 2], false) 0, b, [:ATTACK, (Settings::MECHANICS_GENERATION >= 8) ? 1 : 2], false)
score += drop_score / 2 # Halved because we don't know what move b will use score += drop_score / 2 # Halved because we don't know what move b will use
end end
# Prefer if the foe is in the middle of using a two turn attack # Prefer if the foe is in the middle of using a two turn attack

View File

@@ -387,7 +387,7 @@ Battle::AI::Handlers::MoveFailureAgainstTargetCheck.add("StartDamageTargetEachTu
Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("StartDamageTargetEachTurnIfTargetAsleep", Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("StartDamageTargetEachTurnIfTargetAsleep",
proc { |score, move, user, target, ai, battle| proc { |score, move, user, target, ai, battle|
next Battle::AI::MOVE_USELESS_SCORE if target.statusCount <= 1 next Battle::AI::MOVE_USELESS_SCORE if target.statusCount <= 1
next score + 8 * target.statusCount next score + (8 * target.statusCount)
} }
) )

View File

@@ -835,7 +835,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("DisableTargetHealingMove
) )
#=============================================================================== #===============================================================================
#. #
#=============================================================================== #===============================================================================
Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("DisableTargetSoundMoves", Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("DisableTargetSoundMoves",
proc { |score, move, user, target, ai, battle| proc { |score, move, user, target, ai, battle|

View File

@@ -185,7 +185,8 @@ class RPG::Animation
self.timings.push(timing) self.timings.push(timing)
end end
def addAnimation(otherAnim, frame, x, y) # frame is zero-based # frame is zero-based.
def addAnimation(otherAnim, frame, x, y)
if frame + otherAnim.frames.length >= self.frames.length if frame + otherAnim.frames.length >= self.frames.length
totalframes = frame + otherAnim.frames.length + 1 totalframes = frame + otherAnim.frames.length + 1
(totalframes - self.frames.length).times do (totalframes - self.frames.length).times do

View File

@@ -21,7 +21,7 @@ def pbCaveEntranceEx(exiting)
y = 0 y = 0
# Calculate color of each band # Calculate color of each band
totalBands.times do |k| totalBands.times do |k|
grays[k] = lerp(start_gray, end_gray, duration, timer_start + k * duration / totalBands, System.uptime) grays[k] = lerp(start_gray, end_gray, duration, timer_start + (k * duration / totalBands), System.uptime)
end end
# Draw gray rectangles # Draw gray rectangles
rectwidth = Graphics.width rectwidth = Graphics.width

View File

@@ -4,7 +4,7 @@
# Pokérus check # Pokérus check
EventHandlers.add(:on_frame_update, :pokerus_counter, EventHandlers.add(:on_frame_update, :pokerus_counter,
proc { proc {
next if !$player&.party.any? { |pkmn| pkmn.pokerusStage == 1 } next if !$player || $player.party.none? { |pkmn| pkmn.pokerusStage == 1 }
last = $PokemonGlobal.pokerusTime last = $PokemonGlobal.pokerusTime
next if !last next if !last
now = pbGetTimeNow now = pbGetTimeNow

View File

@@ -392,7 +392,7 @@ SpecialBattleIntroAnimations.register("alternate_vs_trainer_animation", 50, #
if delta_t <= shudder_time if delta_t <= shudder_time
# +2, -2, -2, +2, repeat # +2, -2, -2, +2, repeat
period = (delta_t / 0.025).to_i % 4 period = (delta_t / 0.025).to_i % 4
shudder_delta = [2, 0 , -2, 0][period] shudder_delta = [2, 0, -2, 0][period]
vs.x = vs_x + shudder_delta vs.x = vs_x + shudder_delta
vs.y = vs_y - shudder_delta vs.y = vs_y - shudder_delta
elsif delta_t <= zoom_time elsif delta_t <= zoom_time

View File

@@ -234,7 +234,7 @@ end
#=============================================================================== #===============================================================================
# Moon phases and Zodiac # Moon phases and Zodiac
#=============================================================================== #===============================================================================
# Calculates the phase of the moon. # Calculates the phase of the moon. time is in UTC.
# 0 - New Moon # 0 - New Moon
# 1 - Waxing Crescent # 1 - Waxing Crescent
# 2 - First Quarter # 2 - First Quarter
@@ -243,7 +243,7 @@ end
# 5 - Waning Gibbous # 5 - Waning Gibbous
# 6 - Last Quarter # 6 - Last Quarter
# 7 - Waning Crescent # 7 - Waning Crescent
def moonphase(time = nil) # in UTC def moonphase(time = nil)
time = pbGetTimeNow if !time time = pbGetTimeNow if !time
transitions = [ transitions = [
1.8456618033125, 1.8456618033125,

View File

@@ -103,7 +103,7 @@ def pbHiddenMoveAnimation(pokemon)
when 1 # Expand viewport height from zero to full when 1 # Expand viewport height from zero to full
viewport.rect.y = lerp(Graphics.height / 2, (Graphics.height - bg.bitmap.height) / 2, viewport.rect.y = lerp(Graphics.height / 2, (Graphics.height - bg.bitmap.height) / 2,
0.25, timer_start, System.uptime) 0.25, timer_start, System.uptime)
viewport.rect.height = Graphics.height - viewport.rect.y * 2 viewport.rect.height = Graphics.height - (viewport.rect.y * 2)
bg.oy = (bg.bitmap.height - viewport.rect.height) / 2 bg.oy = (bg.bitmap.height - viewport.rect.height) / 2
if viewport.rect.y == (Graphics.height - bg.bitmap.height) / 2 if viewport.rect.y == (Graphics.height - bg.bitmap.height) / 2
phase = 2 phase = 2
@@ -134,7 +134,7 @@ def pbHiddenMoveAnimation(pokemon)
when 5 # Shrink viewport height from full to zero when 5 # Shrink viewport height from full to zero
viewport.rect.y = lerp((Graphics.height - bg.bitmap.height) / 2, Graphics.height / 2, viewport.rect.y = lerp((Graphics.height - bg.bitmap.height) / 2, Graphics.height / 2,
0.25, timer_start, System.uptime) 0.25, timer_start, System.uptime)
viewport.rect.height = Graphics.height - viewport.rect.y * 2 viewport.rect.height = Graphics.height - (viewport.rect.y * 2)
bg.oy = (bg.bitmap.height - viewport.rect.height) / 2 bg.oy = (bg.bitmap.height - viewport.rect.height) / 2
phase = 6 if viewport.rect.y == Graphics.height / 2 phase = 6 if viewport.rect.y == Graphics.height / 2
end end

View File

@@ -17,11 +17,13 @@ module ItemHandlers
return !UseText[item].nil? return !UseText[item].nil?
end end
def self.hasOutHandler(item) # Shows "Use" option in Bag # Shows "Use" option in Bag.
def self.hasOutHandler(item)
return !UseFromBag[item].nil? || !UseInField[item].nil? || !UseOnPokemon[item].nil? return !UseFromBag[item].nil? || !UseInField[item].nil? || !UseOnPokemon[item].nil?
end end
def self.hasUseInFieldHandler(item) # Shows "Register" option in Bag # Shows "Register" option in Bag.
def self.hasUseInFieldHandler(item)
return !UseInField[item].nil? return !UseInField[item].nil?
end end

View File

@@ -376,7 +376,8 @@ def pbUnlockWallpaper(index)
$PokemonStorage.unlockedWallpapers[index] = true $PokemonStorage.unlockedWallpapers[index] = true
end end
def pbLockWallpaper(index) # Don't know why you'd want to do this # NOTE: I don't know why you'd want to do this, but here you go.
def pbLockWallpaper(index)
$PokemonStorage.unlockedWallpapers[index] = false $PokemonStorage.unlockedWallpapers[index] = false
end end

View File

@@ -46,7 +46,8 @@ class Pokemon
return (formName && !formName.empty?) ? formName : _INTL("Mega {1}", species_data.name) return (formName && !formName.empty?) ? formName : _INTL("Mega {1}", species_data.name)
end end
def megaMessage # 0=default message, 1=Rayquaza message # 0=default message, 1=Rayquaza message.
def megaMessage
megaForm = self.getMegaForm megaForm = self.getMegaForm
message_number = GameData::Species.get_species_form(@species, megaForm)&.mega_message message_number = GameData::Species.get_species_form(@species, megaForm)&.mega_message
return message_number || 0 return message_number || 0

View File

@@ -19,10 +19,6 @@ class Trainer
return _INTL("{1} {2}", trainer_type_name, @name) return _INTL("{1} {2}", trainer_type_name, @name)
end end
def skill_level
return GameData::TrainerType.try_get(self.trainer_type)&.skill_level || 0
end
#============================================================================= #=============================================================================
# Portion of the ID which is visible on the Trainer Card # Portion of the ID which is visible on the Trainer Card
@@ -46,13 +42,13 @@ class Trainer
#============================================================================= #=============================================================================
def trainer_type_name; return GameData::TrainerType.get(self.trainer_type).name; end def trainer_type_name; return GameData::TrainerType.get(self.trainer_type).name; end
def base_money; return GameData::TrainerType.get(self.trainer_type).base_money; end def base_money; return GameData::TrainerType.get(self.trainer_type).base_money; end
def gender; return GameData::TrainerType.get(self.trainer_type).gender; end def gender; return GameData::TrainerType.get(self.trainer_type).gender; end
def male?; return GameData::TrainerType.get(self.trainer_type).male?; end def male?; return GameData::TrainerType.get(self.trainer_type).male?; end
def female?; return GameData::TrainerType.get(self.trainer_type).female?; end def female?; return GameData::TrainerType.get(self.trainer_type).female?; end
def skill_level; return GameData::TrainerType.get(self.trainer_type).skill_level; end def skill_level; return GameData::TrainerType.get(self.trainer_type).skill_level; end
def flags; return GameData::TrainerType.get(self.trainer_type).flags; end def flags; return GameData::TrainerType.get(self.trainer_type).flags; end
def has_flag?(flag); return GameData::TrainerType.get(self.trainer_type).has_flag?(flag); end def has_flag?(flag); return GameData::TrainerType.get(self.trainer_type).has_flag?(flag); end
#============================================================================= #=============================================================================

View File

@@ -35,7 +35,8 @@ class TrainerWalkingCharSprite < Sprite
end end
end end
def altcharset=(value) # Used for box icon in the naming screen # Used for the box icon in the naming screen.
def altcharset=(value)
@animbitmap&.dispose @animbitmap&.dispose
@animbitmap = nil @animbitmap = nil
@charset = pbResolveBitmap(value) @charset = pbResolveBitmap(value)

View File

@@ -166,7 +166,8 @@ class PokemonEggHatch_Scene
@sprites["hatch"].x = @sprites["pokemon"].x @sprites["hatch"].x = @sprites["pokemon"].x
end end
def updateScene(duration = 0.01) # Can be used for "wait" effect # Can be used for "wait" effect.
def updateScene(duration = 0.01)
timer_start = System.uptime timer_start = System.uptime
while System.uptime - timer_start < duration while System.uptime - timer_start < duration
Graphics.update Graphics.update

View File

@@ -202,8 +202,8 @@ class HallOfFame_Scene
distance = (y_direction > 0) ? end_y : Graphics.height - end_y distance = (y_direction > 0) ? end_y : Graphics.height - end_y
distance += @sprites["pokemon#{i}"].bitmap.height / 2 distance += @sprites["pokemon#{i}"].bitmap.height / 2
end end
start_x = end_x - x_direction * distance start_x = end_x - (x_direction * distance)
start_y = end_y - y_direction * distance start_y = end_y - (y_direction * distance)
@sprites["pokemon#{i}"].x = start_x @sprites["pokemon#{i}"].x = start_x
@sprites["pokemon#{i}"].y = start_y @sprites["pokemon#{i}"].y = start_y
@movements[i] = [start_x, end_x, start_y, end_y] @movements[i] = [start_x, end_x, start_y, end_y]

View File

@@ -227,7 +227,7 @@ class Scene_Credits
end end
return if cancel? return if cancel?
return if last? return if last?
@realOY = SCROLL_SPEED * (System.uptime - @timer_start) - Graphics.height + @trim @realOY = (SCROLL_SPEED * (System.uptime - @timer_start)) - Graphics.height + @trim
@credit_sprites.each_with_index { |s, i| s.oy = @realOY - (@bitmap_height * i) } @credit_sprites.each_with_index { |s, i| s.oy = @realOY - (@bitmap_height * i) }
end end
end end

View File

@@ -67,7 +67,8 @@ class PokemonPokedexInfo_Scene
pbFadeInAndShow(@sprites) { pbUpdate } pbFadeInAndShow(@sprites) { pbUpdate }
end end
def pbStartSceneBrief(species) # For standalone access, shows first page only # For standalone access, shows first page only.
def pbStartSceneBrief(species)
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999 @viewport.z = 99999
dexnum = 0 dexnum = 0
@@ -165,7 +166,7 @@ class PokemonPokedexInfo_Scene
next if !$player.pokedex.seen_form?(@species, real_gender, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS next if !$player.pokedex.seen_form?(@species, real_gender, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS
real_gender = 2 if sp.gender_ratio == :Genderless real_gender = 2 if sp.gender_ratio == :Genderless
ret.push([sp.form_name, real_gender, sp.form]) ret.push([sp.form_name, real_gender, sp.form])
elsif sp.form == 0 && # Form 0 and no gender differences elsif sp.form == 0 && !gender_differences
2.times do |real_gndr| 2.times do |real_gndr|
next if !$player.pokedex.seen_form?(@species, real_gndr, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS next if !$player.pokedex.seen_form?(@species, real_gndr, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS
ret.push([sp.form_name || _INTL("One Form"), 0, sp.form]) ret.push([sp.form_name || _INTL("One Form"), 0, sp.form])
@@ -587,7 +588,8 @@ class PokemonPokedexInfoScreen
return ret # Index of last species viewed in dexlist return ret # Index of last species viewed in dexlist
end end
def pbStartSceneSingle(species) # For use from a Pokémon's summary screen # For use from a Pokémon's summary screen.
def pbStartSceneSingle(species)
region = -1 region = -1
if Settings::USE_CURRENT_REGION_DEX if Settings::USE_CURRENT_REGION_DEX
region = pbGetCurrentRegion region = pbGetCurrentRegion
@@ -610,7 +612,8 @@ class PokemonPokedexInfoScreen
@scene.pbEndScene @scene.pbEndScene
end end
def pbDexEntry(species) # For use when capturing a new species # For use when capturing or otherwise obtaining a new species.
def pbDexEntry(species)
@scene.pbStartSceneBrief(species) @scene.pbStartSceneBrief(species)
@scene.pbSceneBrief @scene.pbSceneBrief
@scene.pbEndScene @scene.pbEndScene

View File

@@ -660,12 +660,12 @@ class PokemonParty_Scene
new_mult = newid.even? ? -1 : 1 new_mult = newid.even? ? -1 : 1
timer_start = System.uptime timer_start = System.uptime
loop do loop do
oldsprite.x = lerp(old_start_x, old_start_x + old_mult * Graphics.width / 2, 0.4, timer_start, System.uptime) oldsprite.x = lerp(old_start_x, old_start_x + (old_mult * Graphics.width / 2), 0.4, timer_start, System.uptime)
newsprite.x = lerp(new_start_x, new_start_x + new_mult * Graphics.width / 2, 0.4, timer_start, System.uptime) newsprite.x = lerp(new_start_x, new_start_x + (new_mult * Graphics.width / 2), 0.4, timer_start, System.uptime)
Graphics.update Graphics.update
Input.update Input.update
self.update self.update
break if oldsprite.x == old_start_x + old_mult * Graphics.width / 2 break if oldsprite.x == old_start_x + (old_mult * Graphics.width / 2)
end end
end end
@@ -681,12 +681,12 @@ class PokemonParty_Scene
new_mult = newid.even? ? -1 : 1 new_mult = newid.even? ? -1 : 1
timer_start = System.uptime timer_start = System.uptime
loop do loop do
oldsprite.x = lerp(old_start_x, old_start_x - old_mult * Graphics.width / 2, 0.4, timer_start, System.uptime) oldsprite.x = lerp(old_start_x, old_start_x - (old_mult * Graphics.width / 2), 0.4, timer_start, System.uptime)
newsprite.x = lerp(new_start_x, new_start_x - new_mult * Graphics.width / 2, 0.4, timer_start, System.uptime) newsprite.x = lerp(new_start_x, new_start_x - (new_mult * Graphics.width / 2), 0.4, timer_start, System.uptime)
Graphics.update Graphics.update
Input.update Input.update
self.update self.update
break if oldsprite.x == old_start_x - old_mult * Graphics.width / 2 break if oldsprite.x == old_start_x - (old_mult * Graphics.width / 2)
end end
Settings::MAX_PARTY_SIZE.times do |i| Settings::MAX_PARTY_SIZE.times do |i|
@sprites["pokemon#{i}"].preselected = false @sprites["pokemon#{i}"].preselected = false
@@ -987,8 +987,9 @@ class PokemonPartyScreen
return @scene.pbShowCommands(helptext, commands, index) return @scene.pbShowCommands(helptext, commands, index)
end end
# Checks for identical species # Checks for identical species.
def pbCheckSpecies(array) # Unused # Unused.
def pbCheckSpecies(array)
array.length.times do |i| array.length.times do |i|
(i + 1...array.length).each do |j| (i + 1...array.length).each do |j|
return false if array[i].species == array[j].species return false if array[i].species == array[j].species
@@ -997,8 +998,9 @@ class PokemonPartyScreen
return true return true
end end
# Checks for identical held items # Checks for identical held items.
def pbCheckItems(array) # Unused # Unused.
def pbCheckItems(array)
array.length.times do |i| array.length.times do |i|
next if !array[i].hasItem? next if !array[i].hasItem?
(i + 1...array.length).each do |j| (i + 1...array.length).each do |j|
@@ -1031,7 +1033,8 @@ class PokemonPartyScreen
return @scene.pbShowCommands(helptext, movenames, index) return @scene.pbShowCommands(helptext, movenames, index)
end end
def pbRefreshAnnotations(ableProc) # For after using an evolution stone # For after using an evolution stone.
def pbRefreshAnnotations(ableProc)
return if !@scene.pbHasAnnotations? return if !@scene.pbHasAnnotations?
annot = [] annot = []
@party.each do |pkmn| @party.each do |pkmn|

View File

@@ -208,7 +208,7 @@ class PokemonRegionMap_Scene
end end
end end
def pbGetMapDetails(x, y) # From Wichu, with my help def pbGetMapDetails(x, y)
return "" if !@map.point return "" if !@map.point
@map.point.each do |point| @map.point.each do |point|
next if point[0] != x || point[1] != y next if point[0] != x || point[1] != y

View File

@@ -69,7 +69,10 @@ class ReadyMenuButton < Sprite
self.bitmap.clear self.bitmap.clear
rect = Rect.new(0, (sel) ? @button.height / 2 : 0, @button.width, @button.height / 2) rect = Rect.new(0, (sel) ? @button.height / 2 : 0, @button.width, @button.height / 2)
self.bitmap.blt(0, 0, @button.bitmap, rect) self.bitmap.blt(0, 0, @button.bitmap, rect)
textx = (@command[2]) ? 164 : (GameData::Item.get(@command[0]).is_important?) ? 146 : 124 textx = 164
if !@command[2]
textx = (GameData::Item.get(@command[0]).is_important?) ? 146 : 124
end
textpos = [ textpos = [
[@command[1], textx, 24, :center, Color.new(248, 248, 248), Color.new(40, 40, 40), :outline] [@command[1], textx, 24, :center, Color.new(248, 248, 248), Color.new(40, 40, 40), :outline]
] ]

View File

@@ -1658,15 +1658,18 @@ class PokemonStorageScreen
$game_temp.in_storage = false $game_temp.in_storage = false
end end
def pbUpdate # For debug # For debug purposes.
def pbUpdate
@scene.update @scene.update
end end
def pbHardRefresh # For debug # For debug purposes.
def pbHardRefresh
@scene.pbHardRefresh @scene.pbHardRefresh
end end
def pbRefreshSingle(i) # For debug # For debug purposes.
def pbRefreshSingle(i)
@scene.pbUpdateOverlay(i[1], (i[0] == -1) ? @storage.party : nil) @scene.pbUpdateOverlay(i[1], (i[0] == -1) ? @storage.party : nil)
@scene.pbHardRefresh @scene.pbHardRefresh
end end

View File

@@ -35,7 +35,8 @@ def pbDrawGauge(bitmap, rect, color, value, maxValue)
end end
end end
def calcPoint(x, y, distance, angle) # angle in degrees # angle is in degrees.
def calcPoint(x, y, distance, angle)
angle -= (angle / 360.0).floor * 360 # normalize angle -= (angle / 360.0).floor * 360 # normalize
angle = (angle / 360.0) * (2 * Math::PI) # convert to radians angle = (angle / 360.0) * (2 * Math::PI) # convert to radians
angle = -angle % (2 * Math::PI) # normalize radians angle = -angle % (2 * Math::PI) # normalize radians
@@ -162,7 +163,8 @@ class PurifyChamber
NUMSETS = 9 NUMSETS = 9
SETSIZE = 4 SETSIZE = 4
def self.maximumTempo # Calculates the maximum possible tempo # Calculates the maximum possible tempo.
def self.maximumTempo
x = SETSIZE + 1 x = SETSIZE + 1
return (((x * x) + x) / 2) - 1 return (((x * x) + x) / 2) - 1
end end
@@ -187,7 +189,8 @@ class PurifyChamber
return @sets[set].list return @sets[set].list
end end
def chamberFlow(chamber) # for speeding up purification # For speeding up purification.
def chamberFlow(chamber)
return 0 if chamber < 0 || chamber >= NUMSETS return 0 if chamber < 0 || chamber >= NUMSETS
return @sets[chamber].flow return @sets[chamber].flow
end end
@@ -197,7 +200,8 @@ class PurifyChamber
return @sets[chamber].shadow return @sets[chamber].shadow
end end
def setShadow(chamber, value) # allow only "shadow" Pokemon # Allow only Shadow Pokemon.
def setShadow(chamber, value)
return if chamber < 0 || chamber >= NUMSETS return if chamber < 0 || chamber >= NUMSETS
@sets[chamber].shadow = value @sets[chamber].shadow = value
end end

View File

@@ -614,7 +614,7 @@ class TriadScreen
if numcards.odd? if numcards.odd?
numcards = (numcards / 2) + 1 numcards = (numcards / 2) + 1
else else
numcards = numcards / 2 numcards /= 2
end end
return numcards return numcards
end end

View File

@@ -46,10 +46,11 @@ class SlotMachineReel < BitmapSprite
def stopSpinning(noslipping = false) def stopSpinning(noslipping = false)
@stopping = true @stopping = true
@slipping = SLIPPING.sample @slipping = SLIPPING.sample
if @difficulty == 0 # Easy case @difficulty
when 0 # Easy
second_slipping = SLIPPING.sample second_slipping = SLIPPING.sample
@slipping = [@slipping, second_slipping].min @slipping = [@slipping, second_slipping].min
elsif @difficulty == 2 # Hard when 2 # Hard
second_slipping = SLIPPING.sample second_slipping = SLIPPING.sample
@slipping = [@slipping, second_slipping].max @slipping = [@slipping, second_slipping].max
end end

View File

@@ -82,7 +82,8 @@ class MiningGameCursor < BitmapSprite
TOOL_POSITIONS = [[1, 0], [1, 1], [1, 1], [0, 0], [0, 0], TOOL_POSITIONS = [[1, 0], [1, 1], [1, 1], [0, 0], [0, 0],
[0, 2], [0, 2], [0, 0], [0, 0], [0, 2], [0, 2]] # Graphic, position [0, 2], [0, 2], [0, 0], [0, 0], [0, 2], [0, 2]] # Graphic, position
def initialize(position, mode, viewport) # mode: 0=pick, 1=hammer # mode: 0=pick, 1=hammer.
def initialize(position, mode, viewport)
@viewport = viewport @viewport = viewport
super(Graphics.width, Graphics.height, @viewport) super(Graphics.width, Graphics.height, @viewport)
@position = position @position = position

View File

@@ -385,7 +385,7 @@ class TilePuzzleScene
pbUpdateSpriteHash(@sprites) pbUpdateSpriteHash(@sprites)
Graphics.update Graphics.update
Input.update Input.update
break if @sprites["tile#{@tiles[movetile]}"].y == start_sprite_pos + @tileheight * dist break if @sprites["tile#{@tiles[movetile]}"].y == start_sprite_pos + (@tileheight * dist)
end end
else # Swap horizontally else # Swap horizontally
start_sprite_pos = @sprites["tile#{@tiles[movetile]}"].x start_sprite_pos = @sprites["tile#{@tiles[movetile]}"].x
@@ -398,7 +398,7 @@ class TilePuzzleScene
pbUpdateSpriteHash(@sprites) pbUpdateSpriteHash(@sprites)
Graphics.update Graphics.update
Input.update Input.update
break if @sprites["tile#{@tiles[movetile]}"].x == start_sprite_pos - @tilewidth * dist break if @sprites["tile#{@tiles[movetile]}"].x == start_sprite_pos - (@tilewidth * dist)
end end
end end
@tiles[cursor], @tiles[movetile] = @tiles[movetile], @tiles[cursor] @tiles[cursor], @tiles[movetile] = @tiles[movetile], @tiles[cursor]
@@ -446,29 +446,28 @@ class TilePuzzleScene
end end
duration = 0.3 duration = 0.3
timer_start = System.uptime timer_start = System.uptime
start_pos = []
if [2, 8].include?(dir) if [2, 8].include?(dir)
start_pos = []
tiles.each { |i| start_pos.push(@sprites["tile#{@tiles[i]}"].y) } tiles.each { |i| start_pos.push(@sprites["tile#{@tiles[i]}"].y) }
loop do loop do
tiles.each_with_index do |idx, i| tiles.each_with_index do |idx, i|
@sprites["tile#{@tiles[idx]}"].y = lerp(start_pos[i], start_pos[i] - @tileheight * dist, duration, timer_start, System.uptime) @sprites["tile#{@tiles[idx]}"].y = lerp(start_pos[i], start_pos[i] - (@tileheight * dist), duration, timer_start, System.uptime)
end end
pbUpdateSpriteHash(@sprites) pbUpdateSpriteHash(@sprites)
Graphics.update Graphics.update
Input.update Input.update
break if @sprites["tile#{@tiles[tiles[0]]}"].y == start_pos[0] - @tileheight * dist break if @sprites["tile#{@tiles[tiles[0]]}"].y == start_pos[0] - (@tileheight * dist)
end end
else else
start_pos = []
tiles.each { |i| start_pos.push(@sprites["tile#{@tiles[i]}"].x) } tiles.each { |i| start_pos.push(@sprites["tile#{@tiles[i]}"].x) }
loop do loop do
tiles.each_with_index do |idx, i| tiles.each_with_index do |idx, i|
@sprites["tile#{@tiles[idx]}"].x = lerp(start_pos[i], start_pos[i] + @tilewidth * dist, duration, timer_start, System.uptime) @sprites["tile#{@tiles[idx]}"].x = lerp(start_pos[i], start_pos[i] + (@tilewidth * dist), duration, timer_start, System.uptime)
end end
pbUpdateSpriteHash(@sprites) pbUpdateSpriteHash(@sprites)
Graphics.update Graphics.update
Input.update Input.update
break if @sprites["tile#{@tiles[tiles[0]]}"].x == start_pos[0] + @tilewidth * dist break if @sprites["tile#{@tiles[tiles[0]]}"].x == start_pos[0] + (@tilewidth * dist)
end end
end end
end end

View File

@@ -231,7 +231,7 @@ class PlayerRating
t = (deviation * deviation) + (volatility * volatility) t = (deviation * deviation) + (volatility * volatility)
deviation = 1.0 / Math.sqrt((1.0 / t) + (1.0 / variance)) deviation = 1.0 / Math.sqrt((1.0 / t) + (1.0 / variance))
# Update rating # Update rating
rating = rating + (deviation * deviation * sum) rating += deviation * deviation * sum
setRating2(rating) setRating2(rating)
setDeviation2(deviation) setDeviation2(deviation)
setVolatility2(volatility) setVolatility2(volatility)

View File

@@ -1,7 +1,8 @@
#=============================================================================== #===============================================================================
# Load various wild battle music # Load various wild battle music
#=============================================================================== #===============================================================================
def pbGetWildBattleBGM(_wildParty) # wildParty is an array of Pokémon objects # wildParty is an array of Pokémon objects.
def pbGetWildBattleBGM(_wildParty)
return $PokemonGlobal.nextBattleBGM.clone if $PokemonGlobal.nextBattleBGM return $PokemonGlobal.nextBattleBGM.clone if $PokemonGlobal.nextBattleBGM
ret = nil ret = nil
if !ret if !ret
@@ -70,7 +71,8 @@ def pbPlayTrainerIntroBGM(trainer_type)
pbBGMPlay(bgm) pbBGMPlay(bgm)
end end
def pbGetTrainerBattleBGM(trainer) # can be a Player, NPCTrainer or an array of them # Can be a Player, NPCTrainer or an array of them.
def pbGetTrainerBattleBGM(trainer)
return $PokemonGlobal.nextBattleBGM.clone if $PokemonGlobal.nextBattleBGM return $PokemonGlobal.nextBattleBGM.clone if $PokemonGlobal.nextBattleBGM
ret = nil ret = nil
music = nil music = nil
@@ -112,7 +114,8 @@ def pbGetTrainerBattleBGMFromType(trainertype)
return ret return ret
end end
def pbGetTrainerVictoryBGM(trainer) # can be a Player, NPCTrainer or an array of them # Can be a Player, NPCTrainer or an array of them.
def pbGetTrainerVictoryBGM(trainer)
if $PokemonGlobal.nextBattleVictoryBGM if $PokemonGlobal.nextBattleVictoryBGM
return $PokemonGlobal.nextBattleVictoryBGM.clone return $PokemonGlobal.nextBattleVictoryBGM.clone
end end

View File

@@ -430,8 +430,8 @@ class MapScreenScene
if @dragging if @dragging
if @dragmapid >= 0 if @dragmapid >= 0
sprite = getMapSprite(@dragmapid) sprite = getMapSprite(@dragmapid)
x = x + @dragOffsetX x += @dragOffsetX
y = y + @dragOffsetY y += @dragOffsetY
sprite.x = x & ~3 sprite.x = x & ~3
sprite.y = y & ~3 sprite.y = y & ~3
@sprites["title"].text = _ISPRINTF("D: Help [{1:03d}: {2:s}]", mapid, @mapinfos[@dragmapid].name) @sprites["title"].text = _ISPRINTF("D: Help [{1:03d}: {2:s}]", mapid, @mapinfos[@dragmapid].name)

View File

@@ -73,23 +73,27 @@ module BattleAnimationEditor
return @invalid return @invalid
end end
def invalidate # Marks that the control must be redrawn to reflect current logic # Marks that the control must be redrawn to reflect current logic.
def invalidate
@invalid = true @invalid = true
end end
def update; end # Updates the logic on the control, invalidating it if necessary # Updates the logic on the control, invalidating it if necessary.
def update; end
def refresh; end # Redraws the control # Redraws the control.
def refresh; end
def validate # Makes the control no longer invalid # Makes the control no longer invalid.
def validate
@invalid = false @invalid = false
end end
def repaint # Redraws the control only if it is invalid # Redraws the control only if it is invalid.
if self.invalid? def repaint
self.refresh return if !self.invalid?
self.validate self.refresh
end self.validate
end end
end end
@@ -275,7 +279,7 @@ module BattleAnimationEditor
end end
def update def update
cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i % 2 == 0 cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i.even?
self.changed = false self.changed = false
if cursor_to_show != @cursor_shown if cursor_to_show != @cursor_shown
@cursor_shown = cursor_to_show @cursor_shown = cursor_to_show

View File

@@ -154,7 +154,8 @@ module BooleanProperty2
end end
def self.format(value) def self.format(value)
return (value) ? _INTL("True") : (!value.nil?) ? _INTL("False") : "-" return _INTL("True") if value
return (value.nil?) ? "-" : _INTL("False")
end end
end end
@@ -576,7 +577,9 @@ module GenderProperty
def self.format(value) def self.format(value)
return "-" if !value return "-" if !value
return (value == 0) ? _INTL("Male") : (value == 1) ? _INTL("Female") : "-" return _INTL("Male") if value == 0
return _INTL("Female") if value == 1
return "-"
end end
end end

View File

@@ -875,7 +875,6 @@ MenuHandlers.add(:debug_menu, :set_money, {
params.setDefaultValue($player.battle_points) params.setDefaultValue($player.battle_points)
$player.battle_points = pbMessageChooseNumber("\\ts[]" + _INTL("Set the player's BP amount."), params) $player.battle_points = pbMessageChooseNumber("\\ts[]" + _INTL("Set the player's BP amount."), params)
end end
end end
} }
}) })

View File

@@ -361,7 +361,8 @@ class SpeciesLister
return @index return @index
end end
def commands # Sorted alphabetically # Sorted alphabetically.
def commands
@commands.clear @commands.clear
@ids.clear @ids.clear
cmds = [] cmds = []
@@ -420,7 +421,8 @@ class ItemLister
return @index return @index
end end
def commands # Sorted alphabetically # Sorted alphabetically.
def commands
@commands.clear @commands.clear
@ids.clear @ids.clear
cmds = [] cmds = []

View File

@@ -261,7 +261,7 @@ module Compiler
value = values[i] value = values[i]
next if !value || value.empty? next if !value || value.empty?
quote_count = value.count('"') quote_count = value.count('"')
if !quote_count.zero? if quote_count != 0
# Quote marks found in value # Quote marks found in value
(i...(values.length - 1)).each do |j| (i...(values.length - 1)).each do |j|
quote_count = values[i].count('"') quote_count = values[i].count('"')