diff --git a/.rubocop.yml b/.rubocop.yml index e0b0273c4..915f71a06 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -128,6 +128,12 @@ Style/EndlessMethod: Style/FormatString: EnforcedStyle: sprintf +# Prefer sprintf("%s", "Hello") over sprintf("%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 # pointless bit of boilerplate that we neither need nor want. Style/FrozenStringLiteralComment: diff --git a/Data/Scripts/001_Technical/002_RubyUtilities.rb b/Data/Scripts/001_Technical/002_RubyUtilities.rb index dfbed4a78..0ec29d553 100644 --- a/Data/Scripts/001_Technical/002_RubyUtilities.rb +++ b/Data/Scripts/001_Technical/002_RubyUtilities.rb @@ -81,7 +81,8 @@ end # class Array #=============================================================================== class Array - def ^(other) # xor of two arrays + # xor of two arrays + def ^(other) return (self | other) - (self & other) end @@ -401,5 +402,5 @@ def lerp(start_val, end_val, duration, delta, now = nil) delta = now - delta if now return start_val if delta <= 0 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 diff --git a/Data/Scripts/001_Technical/005_PluginManager.rb b/Data/Scripts/001_Technical/005_PluginManager.rb index 192944e25..b84f390ab 100644 --- a/Data/Scripts/001_Technical/005_PluginManager.rb +++ b/Data/Scripts/001_Technical/005_PluginManager.rb @@ -248,8 +248,7 @@ module PluginManager incompats = [incompats] if !incompats.is_a?(Array) incompats.each do |incompat| if self.installed?(incompat) - self.error("Plugin '#{name}' is incompatible with '#{incompat}'. " + - "They cannot both be used at the same time.") + self.error("Plugin '#{name}' is incompatible with '#{incompat}'. They cannot both be used at the same time.") end end when :credits # Plugin credits @@ -271,8 +270,7 @@ module PluginManager end @@Plugins.each_value do |plugin| if plugin[:incompatibilities]&.include?(name) - self.error("Plugin '#{plugin[:name]}' is incompatible with '#{name}'. " + - "They cannot both be used at the same time.") + self.error("Plugin '#{plugin[:name]}' is incompatible with '#{name}'. They cannot both be used at the same time.") end end # Add plugin to class variable diff --git a/Data/Scripts/001_Technical/006_RPG_Sprite.rb b/Data/Scripts/001_Technical/006_RPG_Sprite.rb index 097c3802a..735b1de7a 100644 --- a/Data/Scripts/001_Technical/006_RPG_Sprite.rb +++ b/Data/Scripts/001_Technical/006_RPG_Sprite.rb @@ -9,15 +9,15 @@ class SpriteAnimation @sprite = sprite end - ["x", "y", "ox", "oy", "viewport", "flash", "src_rect", "opacity", "tone"].each do |def_name| - eval <<-__END__ - - def #{def_name}(*arg) # def x(*arg) - @sprite.#{def_name}(*arg) # @sprite.x(*arg) - end # end - - __END__ - end + def x(*arg); @sprite.x(*arg); end + def y(*arg); @sprite.y(*arg); end + def ox(*arg); @sprite.ox(*arg); end + def oy(*arg); @sprite.oy(*arg); end + def viewport(*arg); @sprite.viewport(*arg); end + def flash(*arg); @sprite.flash(*arg); end + def src_rect(*arg); @sprite.src_rect(*arg); end + def opacity(*arg); @sprite.opacity(*arg); end + def tone(*arg); @sprite.tone(*arg); end def self.clear @@_animations.clear @@ -151,7 +151,7 @@ class SpriteAnimation 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 %= @_loop_animation_duration quick_update = (@_loop_animation_index == new_index) diff --git a/Data/Scripts/003_Game processing/005_Event_Handlers.rb b/Data/Scripts/003_Game processing/005_Event_Handlers.rb index b65dffb52..9986977bb 100644 --- a/Data/Scripts/003_Game processing/005_Event_Handlers.rb +++ b/Data/Scripts/003_Game processing/005_Event_Handlers.rb @@ -210,7 +210,8 @@ class HandlerHashEnum @symbolCache = {} end - def [](sym) # 'sym' can be an ID or symbol + # 'sym' can be an ID or symbol. + def [](sym) id = fromSymbol(sym) ret = nil ret = @hash[id] if id && @hash[id] # Real ID from the item @@ -246,7 +247,8 @@ class HandlerHashEnum return ret 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? raise ArgumentError, "#{self.class.name} for #{sym.inspect} has no valid handler (#{handler.inspect} was given)" end diff --git a/Data/Scripts/004_Game classes/001_Game_Screen.rb b/Data/Scripts/004_Game classes/001_Game_Screen.rb index ff62915f2..34bdb74b5 100644 --- a/Data/Scripts/004_Game classes/001_Game_Screen.rb +++ b/Data/Scripts/004_Game classes/001_Game_Screen.rb @@ -93,7 +93,8 @@ class Game_Screen movement_per_second = @shake_power * @shake_speed * 4 limit = @shake_power * 2.5 # Maximum pixel displacement 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 *= -1 if phase == 2 else diff --git a/Data/Scripts/004_Game classes/004_Game_Map.rb b/Data/Scripts/004_Game classes/004_Game_Map.rb index 66e9af7d4..3fda78303 100644 --- a/Data/Scripts/004_Game classes/004_Game_Map.rb +++ b/Data/Scripts/004_Game classes/004_Game_Map.rb @@ -448,13 +448,13 @@ class Game_Map if (@scroll_distance_x || 0) != 0 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) - 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 end if (@scroll_distance_y || 0) != 0 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) - 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 end # Only update events that are on-screen diff --git a/Data/Scripts/004_Game classes/006_Game_Character.rb b/Data/Scripts/004_Game classes/006_Game_Character.rb index f4257d27e..d7f33659c 100644 --- a/Data/Scripts/004_Game classes/006_Game_Character.rb +++ b/Data/Scripts/004_Game classes/006_Game_Character.rb @@ -25,7 +25,7 @@ class Game_Character attr_accessor :animation_id attr_accessor :transparent attr_reader :move_speed - attr_accessor :jump_speed + attr_reader :jump_speed attr_accessor :walk_anime attr_writer :bob_height @@ -116,13 +116,21 @@ class Game_Character # 4 => 0.125 # Running speed (2x walking speed) # 5 => 0.1 # Cycling speed (1.25x running speed) # 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 # Takes the same values as move_speed above. def 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 # Returns time in seconds for one full cycle (4 frames) of an animating @@ -629,7 +637,8 @@ class Game_Character end end - def moveLeft90 # anticlockwise + # Anticlockwise. + def moveLeft90 case self.direction when 2 then move_right # down when 4 then move_down # left @@ -638,7 +647,8 @@ class Game_Character end end - def moveRight90 # clockwise + # Clockwise. + def moveRight90 case self.direction when 2 then move_left # down when 4 then move_up # left @@ -765,10 +775,10 @@ class Game_Character end @jump_initial_x = @x @jump_initial_y = @y - @x = @x + x_plus - @y = @y + y_plus + @x += x_plus + @y += y_plus @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 @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 diff --git a/Data/Scripts/005_Sprites/005_Sprite_SurfBase.rb b/Data/Scripts/005_Sprites/005_Sprite_SurfBase.rb index 7051a0262..323f35ce4 100644 --- a/Data/Scripts/005_Sprites/005_Sprite_SurfBase.rb +++ b/Data/Scripts/005_Sprites/005_Sprite_SurfBase.rb @@ -1,5 +1,5 @@ class Sprite_SurfBase - attr_reader :visible + attr_reader :visible def initialize(parent_sprite, viewport = nil) @parent_sprite = parent_sprite diff --git a/Data/Scripts/005_Sprites/007_Spriteset_Map.rb b/Data/Scripts/005_Sprites/007_Spriteset_Map.rb index b171ff793..5972effb8 100644 --- a/Data/Scripts/005_Sprites/007_Spriteset_Map.rb +++ b/Data/Scripts/005_Sprites/007_Spriteset_Map.rb @@ -44,7 +44,8 @@ class Spriteset_Map @@viewport3 = Viewport.new(0, 0, Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT) # Flashing @@viewport3.z = 500 - def self.viewport # For access by Spriteset_Global + # For access by Spriteset_Global. + def self.viewport return @@viewport1 end diff --git a/Data/Scripts/005_Sprites/009_Sprite_DynamicShadows.rb b/Data/Scripts/005_Sprites/009_Sprite_DynamicShadows.rb index 2d31f812b..4f56f2879 100644 --- a/Data/Scripts/005_Sprites/009_Sprite_DynamicShadows.rb +++ b/Data/Scripts/005_Sprites/009_Sprite_DynamicShadows.rb @@ -105,7 +105,8 @@ class Sprite_Shadow < RPG::Sprite 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) elemScreenY = ScreenPosHelper.pbScreenY(element) objScreenX = ScreenPosHelper.pbScreenX(object) diff --git a/Data/Scripts/005_Sprites/010_PictureEx.rb b/Data/Scripts/005_Sprites/010_PictureEx.rb index 14c8bbc28..783ae6bfd 100644 --- a/Data/Scripts/005_Sprites/010_PictureEx.rb +++ b/Data/Scripts/005_Sprites/010_PictureEx.rb @@ -53,8 +53,8 @@ def getCubicPoint2(src, t) y1 = src[7] x1 = cx1 + ((x1 - cx1) * t) - x0 = x0 + ((cx0 - x0) * t) - cx0 = cx0 + ((cx1 - cx0) * t) + x0 += ((cx0 - x0) * t) + cx0 += ((cx1 - cx0) * t) cx1 = cx0 + ((x1 - cx0) * t) cx0 = x0 + ((cx0 - x0) * t) cx = cx0 + ((cx1 - cx0) * t) @@ -64,8 +64,8 @@ def getCubicPoint2(src, t) # d = x0 # cx = a*t*t*t + b*t*t + c*t + d y1 = cy1 + ((y1 - cy1) * t) - y0 = y0 + ((cy0 - y0) * t) - cy0 = cy0 + ((cy1 - cy0) * t) + y0 += ((cy0 - y0) * t) + cy0 += ((cy1 - cy0) * t) cy1 = cy0 + ((y1 - cy0) * t) cy0 = y0 + ((cy0 - y0) * t) cy = cy0 + ((cy1 - cy0) * t) diff --git a/Data/Scripts/007_Objects and windows/002_MessageConfig.rb b/Data/Scripts/007_Objects and windows/002_MessageConfig.rb index 8183d8bfe..47813fd34 100644 --- a/Data/Scripts/007_Objects and windows/002_MessageConfig.rb +++ b/Data/Scripts/007_Objects and windows/002_MessageConfig.rb @@ -108,7 +108,7 @@ module MessageConfig when 2 then return 1 / 80.0 # Fast when 3 then return 0 # Instant end - return TEXT_SPEED || 2 / 80.0 # Normal + return TEXT_SPEED || (2 / 80.0) # Normal end #----------------------------------------------------------------------------- diff --git a/Data/Scripts/007_Objects and windows/003_Window.rb b/Data/Scripts/007_Objects and windows/003_Window.rb index 97ac83f9a..bf2fee04e 100644 --- a/Data/Scripts/007_Objects and windows/003_Window.rb +++ b/Data/Scripts/007_Objects and windows/003_Window.rb @@ -302,7 +302,7 @@ class Window mustchange = false if @active 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) else @cursoropacity = lerp(128, 255, 0.4, (cursor_time - 1) % 2) diff --git a/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb b/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb index 46091b4bc..c579631b9 100644 --- a/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb +++ b/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb @@ -300,7 +300,7 @@ class SpriteWindow < Window mustchange = false if @active 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) else @cursoropacity = lerp(128, 255, 0.4, (cursor_time - 1) % 2) @@ -852,7 +852,8 @@ class SpriteWindow_Base < SpriteWindow 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 = nil resolvedName = pbResolveBitmap(skin) diff --git a/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb b/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb index 0ef48d242..1e0297ede 100644 --- a/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb +++ b/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb @@ -47,7 +47,8 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base return ret end - def resizeToFitInternal(text, maxwidth) # maxwidth is maximum acceptable window width + # maxwidth is maximum acceptable window width. + def resizeToFitInternal(text, maxwidth) dims = [0, 0] cwidth = maxwidth < 0 ? Graphics.width : maxwidth getLineBrokenChunks(self.contents, text, @@ -60,14 +61,16 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base self.text = text 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) self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXT_PADDING self.height = dims[1] + self.borderY refresh 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) self.width = (width < 0) ? Graphics.width : width self.height = dims[1] + self.borderY @@ -685,7 +688,7 @@ class Window_InputNumberPokemon < SpriteWindow_Base def update super 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 @cursor_shown = cursor_to_show refresh @@ -1128,11 +1131,13 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx return Rect.new(rect.x + 16, rect.y, rect.width - 16, rect.height) end - def itemCount # to be implemented by derived classes + # To be implemented by derived classes. + def itemCount return 0 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 @item_max = itemCount diff --git a/Data/Scripts/007_Objects and windows/010_DrawText.rb b/Data/Scripts/007_Objects and windows/010_DrawText.rb index fd47e4f45..2d6b723b7 100644 --- a/Data/Scripts/007_Objects and windows/010_DrawText.rb +++ b/Data/Scripts/007_Objects and windows/010_DrawText.rb @@ -819,23 +819,22 @@ def getLineBrokenText(bitmap, value, width, dims) words = [ccheck] words.length.times do |i| word = words[i] - if word && word != "" - textSize = bitmap.text_size(word) - textwidth = textSize.width - if x > 0 && x + textwidth >= width - 2 - # Zero-length word break - ret.push(["", x, y, 0, textheight, line, position, column, 0]) - x = 0 - column = 0 - y += (textheight == 0) ? bitmap.text_size("X").height : textheight - line += 1 - 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 + next if nil_or_empty?(word) + textSize = bitmap.text_size(word) + textwidth = textSize.width + if x > 0 && x + textwidth >= width - 2 + # Zero-length word break + ret.push(["", x, y, 0, textheight, line, position, column, 0]) + x = 0 + column = 0 + y += (textheight == 0) ? bitmap.text_size("X").height : textheight + line += 1 + 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 position += length column += length @@ -912,16 +911,15 @@ def renderLineBrokenChunksWithShadow(bitmap, xDst, yDst, normtext, maxheight, ba width = text[3] textx = text[1] + xDst texty = text[2] + yDst - if maxheight == 0 || text[2] < maxheight - height = text[4] - text = text[0] - bitmap.font.color = shadowColor - bitmap.draw_text(textx + 2, texty, 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.font.color = baseColor - bitmap.draw_text(textx, texty, width + 2, height, text) - end + next if maxheight != 0 && text[2] >= maxheight + height = text[4] + text = text[0] + bitmap.font.color = shadowColor + bitmap.draw_text(textx + 2, texty, 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.font.color = baseColor + bitmap.draw_text(textx, texty, width + 2, height, text) end end diff --git a/Data/Scripts/007_Objects and windows/011_Messages.rb b/Data/Scripts/007_Objects and windows/011_Messages.rb index b0b0b35cd..91c985bd0 100644 --- a/Data/Scripts/007_Objects and windows/011_Messages.rb +++ b/Data/Scripts/007_Objects and windows/011_Messages.rb @@ -104,7 +104,7 @@ class ChooseNumberParams end def initialNumber - return clamp(@initialNumber, self.minNumber, self.maxNumber) + return @initialNumber.clamp(self.minNumber, self.maxNumber) end def cancelNumber @@ -149,10 +149,6 @@ class ChooseNumberParams private - def clamp(v, mn, mx) - return v < mn ? mn : (v > mx ? mx : v) - end - def numDigits(number) ans = 1 number = number.abs diff --git a/Data/Scripts/007_Objects and windows/012_TextEntry.rb b/Data/Scripts/007_Objects and windows/012_TextEntry.rb index 14de3bff9..4258af660 100644 --- a/Data/Scripts/007_Objects and windows/012_TextEntry.rb +++ b/Data/Scripts/007_Objects and windows/012_TextEntry.rb @@ -148,7 +148,7 @@ class Window_TextEntry < SpriteWindow_Base end 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 @cursor_shown = cursor_to_show refresh @@ -225,7 +225,7 @@ end #=============================================================================== class Window_TextEntry_Keyboard < Window_TextEntry 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 @cursor_shown = cursor_to_show refresh @@ -394,19 +394,11 @@ class Window_MultilineTextEntry < SpriteWindow_Base thispos = text[6] thiscolumn = text[7] thislength = text[8] - if thisline == line - endpos = thispos + thislength -# echoln [endpos,thispos+(column-thiscolumn),textchars[i]] - if column >= thiscolumn && column <= thiscolumn + thislength && thislength > 0 - return thispos + (column - thiscolumn) - end - end + next if thisline != line + endpos = thispos + thislength + next if column < thiscolumn || column > thiscolumn + thislength || thislength == 0 + return thispos + column - thiscolumn end -# if endpos==0 -# echoln [totallines,line,column] -# echoln textchars -# end -# echoln "endpos=#{endpos}" return endpos end @@ -465,7 +457,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base end 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 @cursor_shown = cursor_to_show refresh @@ -544,18 +536,17 @@ class Window_MultilineTextEntry < SpriteWindow_Base thisline = text[5] thiscolumn = text[7] thislength = text[8] - if thisline == @cursorLine && @cursorColumn >= thiscolumn && - @cursorColumn <= thiscolumn + thislength - cursorY = text[2] - startY - cursorX = text[1] - textheight = text[4] - posToCursor = @cursorColumn - thiscolumn - if posToCursor >= 0 - partialString = text[0].scan(/./m)[0, posToCursor].join - cursorX += bitmap.text_size(partialString).width - end - break + next if thisline != @cursorLine || @cursorColumn < thiscolumn || + @cursorColumn > thiscolumn + thislength + cursorY = text[2] - startY + cursorX = text[1] + textheight = text[4] + posToCursor = @cursorColumn - thiscolumn + if posToCursor >= 0 + partialString = text[0].scan(/./m)[0, posToCursor].join + cursorX += bitmap.text_size(partialString).width end + break end cursorY += 4 cursorHeight = [4, textheight - 4, bitmap.text_size("X").height - 4].max diff --git a/Data/Scripts/011_Battle/001_Battle/002_Battle_StartAndEnd.rb b/Data/Scripts/011_Battle/001_Battle/002_Battle_StartAndEnd.rb index b707720a7..54d4f8d6a 100644 --- a/Data/Scripts/011_Battle/001_Battle/002_Battle_StartAndEnd.rb +++ b/Data/Scripts/011_Battle/001_Battle/002_Battle_StartAndEnd.rb @@ -530,7 +530,7 @@ class Battle 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 2 if hpTotals[0] < hpTotals[1] # Loss (foe has more HP in total) - return 5 # Draw + return 5 # Draw end # Unused @@ -549,10 +549,10 @@ class Battle 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 2 if hpTotals[0] < hpTotals[1] # Loss (foe has a bigger average HP %) - return 5 # Draw + return 5 # Draw end - def pbDecisionOnDraw; return 5; end # Draw + def pbDecisionOnDraw; return 5; end # Draw def pbJudge fainted1 = pbAllFainted?(0) diff --git a/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb b/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb index afc8fed01..36d74aa2c 100644 --- a/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb +++ b/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb @@ -126,7 +126,7 @@ class Battle if Settings::SCALED_EXP_FORMULA exp /= 5 levelAdjust = ((2 * level) + 10.0) / (pkmn.level + level + 10.0) - levelAdjust = levelAdjust**5 + levelAdjust **= 5 levelAdjust = Math.sqrt(levelAdjust) exp *= levelAdjust exp = exp.floor diff --git a/Data/Scripts/011_Battle/003_Move/001_Battle_Move.rb b/Data/Scripts/011_Battle/003_Move/001_Battle_Move.rb index 2eb7cd72e..f59849cee 100644 --- a/Data/Scripts/011_Battle/003_Move/001_Battle_Move.rb +++ b/Data/Scripts/011_Battle/003_Move/001_Battle_Move.rb @@ -145,7 +145,8 @@ class Battle::Move def nonLethal?(_user, _target); return false; end # For False Swipe 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 return true if soundMove? return true if user&.hasActiveAbility?(:INFILTRATOR) diff --git a/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb b/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb index 8cd9a05c2..654ae157d 100644 --- a/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb +++ b/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb @@ -318,7 +318,8 @@ class Battle::Move::TwoTurnMove < Battle::Move return !@damagingTurn # Deliberately not "return @chargingTurn" 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 super end diff --git a/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb b/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb index a5428c74d..fd0968291 100644 --- a/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb +++ b/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb @@ -604,7 +604,8 @@ end class Battle::Move::AttackTwoTurnsLater < Battle::Move 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 super end diff --git a/Data/Scripts/011_Battle/003_Move/009_MoveEffects_MultiHit.rb b/Data/Scripts/011_Battle/003_Move/009_MoveEffects_MultiHit.rb index b9a774fbd..2e4ef4cc0 100644 --- a/Data/Scripts/011_Battle/003_Move/009_MoveEffects_MultiHit.rb +++ b/Data/Scripts/011_Battle/003_Move/009_MoveEffects_MultiHit.rb @@ -606,7 +606,8 @@ class Battle::Move::MultiTurnAttackBideThenReturnDoubleDamage < Battle::Move::Fi 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 super end diff --git a/Data/Scripts/011_Battle/004_Scene/006_Battle_Scene_Objects.rb b/Data/Scripts/011_Battle/004_Scene/006_Battle_Scene_Objects.rb index a777a24c5..49c3dd968 100644 --- a/Data/Scripts/011_Battle/004_Scene/006_Battle_Scene_Objects.rb +++ b/Data/Scripts/011_Battle/004_Scene/006_Battle_Scene_Objects.rb @@ -6,7 +6,7 @@ class Battle::Scene::PokemonDataBox < Sprite attr_accessor :selected # 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. EXP_FULL_FLASH_DURATION = 0.2 # Maximum time in seconds to make a change to the HP bar. diff --git a/Data/Scripts/011_Battle/005_AI/003_AI_UseItem.rb b/Data/Scripts/011_Battle/005_AI/003_AI_UseItem.rb index 1ba07e286..faebf7b77 100644 --- a/Data/Scripts/011_Battle/005_AI/003_AI_UseItem.rb +++ b/Data/Scripts/011_Battle/005_AI/003_AI_UseItem.rb @@ -139,8 +139,8 @@ class Battle::AI # Find items usable on other Pokémon in the user's team # NOTE: Currently only checks Revives. usable_items = {} - @battle.eachInTeamFromBattlerIndex(@user.index) do |pkmn, i| - next if !pkmn.fainted? # Remove this line to check unfainted Pokémon too + @battle.eachInTeamFromBattlerIndex(@user.index) do |team_pkmn, i| + next if !team_pkmn.fainted? # Remove this line to check unfainted Pokémon too items.each do |item| usage = get_usability_of_item_on_pkmn(item, i, @user.side) usage.each_pair do |key, vals| diff --git a/Data/Scripts/011_Battle/005_AI/005_AI_ChooseMove.rb b/Data/Scripts/011_Battle/005_AI/005_AI_ChooseMove.rb index 6d35f0d85..2fc420528 100644 --- a/Data/Scripts/011_Battle/005_AI/005_AI_ChooseMove.rb +++ b/Data/Scripts/011_Battle/005_AI/005_AI_ChooseMove.rb @@ -9,7 +9,7 @@ class Battle::AI # 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. 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 #----------------------------------------------------------------------------- @@ -161,7 +161,7 @@ class Battle::AI @target&.refresh_battler if @target && @move.function_code == "UseLastMoveUsedByTarget" 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") @battle.moldBreaker = @user.has_mold_breaker? 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)") # Modify the score according to various other effects score = Battle::AI::Handlers.apply_general_move_score_modifiers( - score, @move, @user, self, @battle) + score, @move, @user, self, @battle) end score = score.to_i score = 0 if score < 0 @@ -307,7 +307,7 @@ class Battle::AI PBDebug.log_score_change(score - old_score, "function code modifier (against target)") # Modify the score according to various other effects against the target score = Battle::AI::Handlers.apply_general_move_against_target_score_modifiers( - score, @move, @user, @target, self, @battle) + score, @move, @user, @target, self, @battle) end # Add the score against the target to the overall score target_data = @move.pbTarget(@user.battler) diff --git a/Data/Scripts/011_Battle/005_AI/006_AI_ChooseMove_GenericEffects.rb b/Data/Scripts/011_Battle/005_AI/006_AI_ChooseMove_GenericEffects.rb index c5d062481..2c5babf09 100644 --- a/Data/Scripts/011_Battle/005_AI/006_AI_ChooseMove_GenericEffects.rb +++ b/Data/Scripts/011_Battle/005_AI/006_AI_ChooseMove_GenericEffects.rb @@ -232,15 +232,14 @@ class Battle::AI target_speed = target.rough_stat(:SPEED) each_foe_battler(target.side) do |b, i| 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 - if b_speed > target_speed - if b_speed < target_speed * (increment + 2) / 2 - score += 15 * inc_mult # Target will become faster than b - else - score += 8 * inc_mult - end - break + if b_speed < target_speed * (increment + 2) / 2 + score += 15 * inc_mult # Target will become faster than the foe b + else + score += 8 * inc_mult end + break end # Prefer if the target has Electro Ball or Power Trip/Stored Power moves_that_prefer_high_speed = [ @@ -524,15 +523,14 @@ class Battle::AI target_speed = target.rough_stat(:SPEED) each_foe_battler(target.side) do |b, i| 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 - if target_speed > b_speed - if target_speed < b_speed * 2 / (decrement + 2) - score += 15 * dec_mult # Target will become slower than b - else - score += 8 * dec_mult - end - break + if target_speed < b_speed * 2 / (decrement + 2) + score += 15 * dec_mult # Target will become slower than foe b + else + score += 8 * dec_mult end + break end # Prefer if any ally has Electro Ball each_foe_battler(target.side) do |b, i| diff --git a/Data/Scripts/011_Battle/005_AI/007_AI_ChooseMove_OtherScores.rb b/Data/Scripts/011_Battle/005_AI/007_AI_ChooseMove_OtherScores.rb index 69786a800..178c21633 100644 --- a/Data/Scripts/011_Battle/005_AI/007_AI_ChooseMove_OtherScores.rb +++ b/Data/Scripts/011_Battle/005_AI/007_AI_ChooseMove_OtherScores.rb @@ -489,7 +489,7 @@ Battle::AI::Handlers::GeneralMoveAgainstTargetScore.add(:damaging_a_biding_targe hits_possible = target.effects[PBEffects::Bide] - 1 eor_dmg *= hits_possible 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 old_score = score score -= 20 diff --git a/Data/Scripts/011_Battle/005_AI/008_AI_Utilities.rb b/Data/Scripts/011_Battle/005_AI/008_AI_Utilities.rb index b4ae0d3c8..42f5aad89 100644 --- a/Data/Scripts/011_Battle/005_AI/008_AI_Utilities.rb +++ b/Data/Scripts/011_Battle/005_AI/008_AI_Utilities.rb @@ -189,7 +189,7 @@ class Battle::AI # Type power boosters :BLACKBELT, :BLACKGLASSES, :CHARCOAL, :DRAGONFANG, :HARDSTONE, :MAGNET, :METALCOAT, :MIRACLESEED, :MYSTICWATER, :NEVERMELTICE, - :POISONBARB, :SHARPBEAK, :SILKSCARF,:SILVERPOWDER, :SOFTSAND, + :POISONBARB, :SHARPBEAK, :SILKSCARF, :SILVERPOWDER, :SOFTSAND, :SPELLTAG, :TWISTEDSPOON, :ODDINCENSE, :ROCKINCENSE, :ROSEINCENSE, :SEAINCENSE, :WAVEINCENSE, # Plates @@ -218,8 +218,7 @@ class Battle::AI :BUGMEMORY, :DARKMEMORY, :DRAGONMEMORY, :ELECTRICMEMORY, :FAIRYMEMORY, :FIGHTINGMEMORY, :FIREMEMORY, :FLYINGMEMORY, :GHOSTMEMORY, :GRASSMEMORY, :GROUNDMEMORY, :ICEMEMORY, :POISONMEMORY, - :PSYCHICMEMORY, :ROCKMEMORY, :STEELMEMORY, :WATERMEMORY - ], + :PSYCHICMEMORY, :ROCKMEMORY, :STEELMEMORY, :WATERMEMORY], 0 => [:SMOKEBALL], -5 => [:FULLINCENSE, :LAGGINGTAIL, :RINGTARGET], -6 => [:MACHOBRACE, :POWERANKLET, :POWERBAND, :POWERBELT, :POWERBRACER, @@ -852,7 +851,7 @@ Battle::AI::Handlers::ItemRanking.addIf(:type_boosting_items, :PSYCHIC => [:TWISTEDSPOON, :MINDPLATE, :ODDINCENSE], :ROCK => [:HARDSTONE, :STONEPLATE, :ROCKINCENSE], :STEEL => [:METALCOAT, :IRONPLATE], - :WATER => [:MYSTICWATER, :SPLASHPLATE, :SEAINCENSE, :WAVEINCENSE], + :WATER => [:MYSTICWATER, :SPLASHPLATE, :SEAINCENSE, :WAVEINCENSE] } boosted_type = nil boosters.each_pair do |type, items| @@ -891,7 +890,7 @@ Battle::AI::Handlers::ItemRanking.addIf(:gems, :PSYCHICGEM => :PSYCHIC, :ROCKGEM => :ROCK, :STEELGEM => :STEEL, - :WATERGEM => :WATER, + :WATERGEM => :WATER }[item] next score if boosted_type && battler.has_damaging_move_of_type?(boosted_type) next 0 diff --git a/Data/Scripts/011_Battle/005_AI/011_AIMove.rb b/Data/Scripts/011_Battle/005_AI/011_AIMove.rb index cdcc7a761..ef17fa87e 100644 --- a/Data/Scripts/011_Battle/005_AI/011_AIMove.rb +++ b/Data/Scripts/011_Battle/005_AI/011_AIMove.rb @@ -238,14 +238,15 @@ class Battle::AI::AIMove end # Mud Sport and Water Sport if @ai.trainer.medium_skill? - if calc_type == :ELECTRIC + case calc_type + when :ELECTRIC if @ai.battle.allBattlers.any? { |b| b.effects[PBEffects::MudSport] } multipliers[:power_multiplier] /= 3 end if @ai.battle.field.effects[PBEffects::MudSportField] > 0 multipliers[:power_multiplier] /= 3 end - elsif calc_type == :FIRE + when :FIRE if @ai.battle.allBattlers.any? { |b| b.effects[PBEffects::WaterSport] } multipliers[:power_multiplier] /= 3 end diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/002_AI_MoveEffects_BattlerStats.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/002_AI_MoveEffects_BattlerStats.rb index 49490f8bd..70afbeb5c 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/002_AI_MoveEffects_BattlerStats.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/002_AI_MoveEffects_BattlerStats.rb @@ -635,7 +635,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("RaiseTargetAttack2Confus score = ai.get_score_for_target_stat_raise(score, target, [:ATTACK, 2], false) # Score for confusing the target 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 for confusing the target next Battle::AI::Handlers.apply_move_effect_against_target_score( - "ConfuseTarget", score, move, user, target, ai, battle) + "ConfuseTarget", score, move, user, target, ai, battle) } ) diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/004_AI_MoveEffects_MoveAttributes.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/004_AI_MoveEffects_MoveAttributes.rb index ae88162ff..3a03769a0 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/004_AI_MoveEffects_MoveAttributes.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/004_AI_MoveEffects_MoveAttributes.rb @@ -463,7 +463,7 @@ Battle::AI::Handlers::MoveEffectScore.add("EnsureNextCriticalHit", next Battle::AI::MOVE_USELESS_SCORE end # 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 end next score @@ -860,7 +860,7 @@ Battle::AI::Handlers::MoveEffectScore.add("ProtectUserFromDamagingMovesKingsShie # Prefer if the foe's Attack can be lowered by this move if b.battler.affectedByContactEffect? && b.check_for_move { |m| m.contactMove? } 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 end # Prefer if the foe is in the middle of using a two turn attack diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/006_AI_MoveEffects_Healing.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/006_AI_MoveEffects_Healing.rb index bcc093dfe..400b10ef7 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/006_AI_MoveEffects_Healing.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/006_AI_MoveEffects_Healing.rb @@ -387,7 +387,7 @@ Battle::AI::Handlers::MoveFailureAgainstTargetCheck.add("StartDamageTargetEachTu Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("StartDamageTargetEachTurnIfTargetAsleep", proc { |score, move, user, target, ai, battle| next Battle::AI::MOVE_USELESS_SCORE if target.statusCount <= 1 - next score + 8 * target.statusCount + next score + (8 * target.statusCount) } ) diff --git a/Data/Scripts/011_Battle/006_AI MoveEffects/009_AI_MoveEffects_SwitchingActing.rb b/Data/Scripts/011_Battle/006_AI MoveEffects/009_AI_MoveEffects_SwitchingActing.rb index 7956aee86..5d7403633 100644 --- a/Data/Scripts/011_Battle/006_AI MoveEffects/009_AI_MoveEffects_SwitchingActing.rb +++ b/Data/Scripts/011_Battle/006_AI MoveEffects/009_AI_MoveEffects_SwitchingActing.rb @@ -835,7 +835,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("DisableTargetHealingMove ) #=============================================================================== -#. +# #=============================================================================== Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("DisableTargetSoundMoves", proc { |score, move, user, target, ai, battle| diff --git a/Data/Scripts/011_Battle/007_Other battle code/007_BattleAnimationPlayer.rb b/Data/Scripts/011_Battle/007_Other battle code/007_BattleAnimationPlayer.rb index 02704740f..7f98e089e 100644 --- a/Data/Scripts/011_Battle/007_Other battle code/007_BattleAnimationPlayer.rb +++ b/Data/Scripts/011_Battle/007_Other battle code/007_BattleAnimationPlayer.rb @@ -185,7 +185,8 @@ class RPG::Animation self.timings.push(timing) 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 totalframes = frame + otherAnim.frames.length + 1 (totalframes - self.frames.length).times do diff --git a/Data/Scripts/012_Overworld/001_Overworld visuals/003_Overworld_MapTransitionAnims.rb b/Data/Scripts/012_Overworld/001_Overworld visuals/003_Overworld_MapTransitionAnims.rb index f20fe7f1a..9ee9320e2 100644 --- a/Data/Scripts/012_Overworld/001_Overworld visuals/003_Overworld_MapTransitionAnims.rb +++ b/Data/Scripts/012_Overworld/001_Overworld visuals/003_Overworld_MapTransitionAnims.rb @@ -21,7 +21,7 @@ def pbCaveEntranceEx(exiting) y = 0 # Calculate color of each band 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 # Draw gray rectangles rectwidth = Graphics.width diff --git a/Data/Scripts/012_Overworld/001_Overworld.rb b/Data/Scripts/012_Overworld/001_Overworld.rb index 6f1cb6c91..605ea27ab 100644 --- a/Data/Scripts/012_Overworld/001_Overworld.rb +++ b/Data/Scripts/012_Overworld/001_Overworld.rb @@ -4,7 +4,7 @@ # Pokérus check EventHandlers.add(:on_frame_update, :pokerus_counter, proc { - next if !$player&.party.any? { |pkmn| pkmn.pokerusStage == 1 } + next if !$player || $player.party.none? { |pkmn| pkmn.pokerusStage == 1 } last = $PokemonGlobal.pokerusTime next if !last now = pbGetTimeNow diff --git a/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb b/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb index 00724fe29..7d8152237 100644 --- a/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb +++ b/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb @@ -392,7 +392,7 @@ SpecialBattleIntroAnimations.register("alternate_vs_trainer_animation", 50, # if delta_t <= shudder_time # +2, -2, -2, +2, repeat 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.y = vs_y - shudder_delta elsif delta_t <= zoom_time diff --git a/Data/Scripts/012_Overworld/003_Overworld_Time.rb b/Data/Scripts/012_Overworld/003_Overworld_Time.rb index 212628766..60508e982 100644 --- a/Data/Scripts/012_Overworld/003_Overworld_Time.rb +++ b/Data/Scripts/012_Overworld/003_Overworld_Time.rb @@ -234,7 +234,7 @@ end #=============================================================================== # Moon phases and Zodiac #=============================================================================== -# Calculates the phase of the moon. +# Calculates the phase of the moon. time is in UTC. # 0 - New Moon # 1 - Waxing Crescent # 2 - First Quarter @@ -243,7 +243,7 @@ end # 5 - Waning Gibbous # 6 - Last Quarter # 7 - Waning Crescent -def moonphase(time = nil) # in UTC +def moonphase(time = nil) time = pbGetTimeNow if !time transitions = [ 1.8456618033125, diff --git a/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb b/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb index e297c413b..babbd67ed 100644 --- a/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb +++ b/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb @@ -103,7 +103,7 @@ def pbHiddenMoveAnimation(pokemon) when 1 # Expand viewport height from zero to full viewport.rect.y = lerp(Graphics.height / 2, (Graphics.height - bg.bitmap.height) / 2, 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 if viewport.rect.y == (Graphics.height - bg.bitmap.height) / 2 phase = 2 @@ -134,7 +134,7 @@ def pbHiddenMoveAnimation(pokemon) when 5 # Shrink viewport height from full to zero viewport.rect.y = lerp((Graphics.height - bg.bitmap.height) / 2, Graphics.height / 2, 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 phase = 6 if viewport.rect.y == Graphics.height / 2 end diff --git a/Data/Scripts/013_Items/001_Item_Utilities.rb b/Data/Scripts/013_Items/001_Item_Utilities.rb index a8f1cc908..8d2550412 100644 --- a/Data/Scripts/013_Items/001_Item_Utilities.rb +++ b/Data/Scripts/013_Items/001_Item_Utilities.rb @@ -17,11 +17,13 @@ module ItemHandlers return !UseText[item].nil? 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? end - def self.hasUseInFieldHandler(item) # Shows "Register" option in Bag + # Shows "Register" option in Bag. + def self.hasUseInFieldHandler(item) return !UseInField[item].nil? end diff --git a/Data/Scripts/014_Pokemon/001_Pokemon-related/004_PokemonStorage.rb b/Data/Scripts/014_Pokemon/001_Pokemon-related/004_PokemonStorage.rb index 9866d3a21..05fc72461 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/004_PokemonStorage.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/004_PokemonStorage.rb @@ -376,7 +376,8 @@ def pbUnlockWallpaper(index) $PokemonStorage.unlockedWallpapers[index] = true 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 end diff --git a/Data/Scripts/014_Pokemon/002_Pokemon_MegaEvolution.rb b/Data/Scripts/014_Pokemon/002_Pokemon_MegaEvolution.rb index 7773e6bec..517ae905b 100644 --- a/Data/Scripts/014_Pokemon/002_Pokemon_MegaEvolution.rb +++ b/Data/Scripts/014_Pokemon/002_Pokemon_MegaEvolution.rb @@ -46,7 +46,8 @@ class Pokemon return (formName && !formName.empty?) ? formName : _INTL("Mega {1}", species_data.name) end - def megaMessage # 0=default message, 1=Rayquaza message + # 0=default message, 1=Rayquaza message. + def megaMessage megaForm = self.getMegaForm message_number = GameData::Species.get_species_form(@species, megaForm)&.mega_message return message_number || 0 diff --git a/Data/Scripts/015_Trainers and player/001_Trainer.rb b/Data/Scripts/015_Trainers and player/001_Trainer.rb index 37baaf4e7..8a33185b8 100644 --- a/Data/Scripts/015_Trainers and player/001_Trainer.rb +++ b/Data/Scripts/015_Trainers and player/001_Trainer.rb @@ -19,10 +19,6 @@ class Trainer return _INTL("{1} {2}", trainer_type_name, @name) 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 @@ -46,13 +42,13 @@ class Trainer #============================================================================= - 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 gender; return GameData::TrainerType.get(self.trainer_type).gender; end - def male?; return GameData::TrainerType.get(self.trainer_type).male?; 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 flags; return GameData::TrainerType.get(self.trainer_type).flags; 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 gender; return GameData::TrainerType.get(self.trainer_type).gender; end + def male?; return GameData::TrainerType.get(self.trainer_type).male?; 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 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 #============================================================================= diff --git a/Data/Scripts/015_Trainers and player/003_Trainer_Sprites.rb b/Data/Scripts/015_Trainers and player/003_Trainer_Sprites.rb index a02b04512..1d63fa344 100644 --- a/Data/Scripts/015_Trainers and player/003_Trainer_Sprites.rb +++ b/Data/Scripts/015_Trainers and player/003_Trainer_Sprites.rb @@ -35,7 +35,8 @@ class TrainerWalkingCharSprite < Sprite 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 = nil @charset = pbResolveBitmap(value) diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb index 51d9447ba..788f2eb59 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb @@ -166,7 +166,8 @@ class PokemonEggHatch_Scene @sprites["hatch"].x = @sprites["pokemon"].x 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 while System.uptime - timer_start < duration Graphics.update diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb b/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb index fe9ed2657..99d2cc3a6 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb @@ -202,8 +202,8 @@ class HallOfFame_Scene distance = (y_direction > 0) ? end_y : Graphics.height - end_y distance += @sprites["pokemon#{i}"].bitmap.height / 2 end - start_x = end_x - x_direction * distance - start_y = end_y - y_direction * distance + start_x = end_x - (x_direction * distance) + start_y = end_y - (y_direction * distance) @sprites["pokemon#{i}"].x = start_x @sprites["pokemon#{i}"].y = start_y @movements[i] = [start_x, end_x, start_y, end_y] diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/007_UI_Credits.rb b/Data/Scripts/016_UI/001_Non-interactive UI/007_UI_Credits.rb index 56a889df3..693ba9389 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/007_UI_Credits.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/007_UI_Credits.rb @@ -227,7 +227,7 @@ class Scene_Credits end return if cancel? 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) } end end diff --git a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb index d10e1965d..57cab9f4b 100644 --- a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb +++ b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb @@ -67,7 +67,8 @@ class PokemonPokedexInfo_Scene pbFadeInAndShow(@sprites) { pbUpdate } 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.z = 99999 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 real_gender = 2 if sp.gender_ratio == :Genderless 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| 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]) @@ -587,7 +588,8 @@ class PokemonPokedexInfoScreen return ret # Index of last species viewed in dexlist 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 if Settings::USE_CURRENT_REGION_DEX region = pbGetCurrentRegion @@ -610,7 +612,8 @@ class PokemonPokedexInfoScreen @scene.pbEndScene 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.pbSceneBrief @scene.pbEndScene diff --git a/Data/Scripts/016_UI/005_UI_Party.rb b/Data/Scripts/016_UI/005_UI_Party.rb index b166fb51c..3f874cd88 100644 --- a/Data/Scripts/016_UI/005_UI_Party.rb +++ b/Data/Scripts/016_UI/005_UI_Party.rb @@ -660,12 +660,12 @@ class PokemonParty_Scene new_mult = newid.even? ? -1 : 1 timer_start = System.uptime loop do - 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) + 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) Graphics.update Input.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 @@ -681,12 +681,12 @@ class PokemonParty_Scene new_mult = newid.even? ? -1 : 1 timer_start = System.uptime loop do - 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) + 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) Graphics.update Input.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 Settings::MAX_PARTY_SIZE.times do |i| @sprites["pokemon#{i}"].preselected = false @@ -987,8 +987,9 @@ class PokemonPartyScreen return @scene.pbShowCommands(helptext, commands, index) end - # Checks for identical species - def pbCheckSpecies(array) # Unused + # Checks for identical species. + # Unused. + def pbCheckSpecies(array) array.length.times do |i| (i + 1...array.length).each do |j| return false if array[i].species == array[j].species @@ -997,8 +998,9 @@ class PokemonPartyScreen return true end - # Checks for identical held items - def pbCheckItems(array) # Unused + # Checks for identical held items. + # Unused. + def pbCheckItems(array) array.length.times do |i| next if !array[i].hasItem? (i + 1...array.length).each do |j| @@ -1031,7 +1033,8 @@ class PokemonPartyScreen return @scene.pbShowCommands(helptext, movenames, index) end - def pbRefreshAnnotations(ableProc) # For after using an evolution stone + # For after using an evolution stone. + def pbRefreshAnnotations(ableProc) return if !@scene.pbHasAnnotations? annot = [] @party.each do |pkmn| diff --git a/Data/Scripts/016_UI/009_UI_RegionMap.rb b/Data/Scripts/016_UI/009_UI_RegionMap.rb index 9a4caeb5b..4124fa833 100644 --- a/Data/Scripts/016_UI/009_UI_RegionMap.rb +++ b/Data/Scripts/016_UI/009_UI_RegionMap.rb @@ -208,7 +208,7 @@ class PokemonRegionMap_Scene end end - def pbGetMapDetails(x, y) # From Wichu, with my help + def pbGetMapDetails(x, y) return "" if !@map.point @map.point.each do |point| next if point[0] != x || point[1] != y diff --git a/Data/Scripts/016_UI/016_UI_ReadyMenu.rb b/Data/Scripts/016_UI/016_UI_ReadyMenu.rb index 76ec996ad..f20379b99 100644 --- a/Data/Scripts/016_UI/016_UI_ReadyMenu.rb +++ b/Data/Scripts/016_UI/016_UI_ReadyMenu.rb @@ -69,7 +69,10 @@ class ReadyMenuButton < Sprite self.bitmap.clear rect = Rect.new(0, (sel) ? @button.height / 2 : 0, @button.width, @button.height / 2) 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 = [ [@command[1], textx, 24, :center, Color.new(248, 248, 248), Color.new(40, 40, 40), :outline] ] diff --git a/Data/Scripts/016_UI/017_UI_PokemonStorage.rb b/Data/Scripts/016_UI/017_UI_PokemonStorage.rb index ac4120f64..5c4ac4766 100644 --- a/Data/Scripts/016_UI/017_UI_PokemonStorage.rb +++ b/Data/Scripts/016_UI/017_UI_PokemonStorage.rb @@ -1658,15 +1658,18 @@ class PokemonStorageScreen $game_temp.in_storage = false end - def pbUpdate # For debug + # For debug purposes. + def pbUpdate @scene.update end - def pbHardRefresh # For debug + # For debug purposes. + def pbHardRefresh @scene.pbHardRefresh end - def pbRefreshSingle(i) # For debug + # For debug purposes. + def pbRefreshSingle(i) @scene.pbUpdateOverlay(i[1], (i[0] == -1) ? @storage.party : nil) @scene.pbHardRefresh end diff --git a/Data/Scripts/016_UI/023_UI_PurifyChamber.rb b/Data/Scripts/016_UI/023_UI_PurifyChamber.rb index 803197396..db36770ee 100644 --- a/Data/Scripts/016_UI/023_UI_PurifyChamber.rb +++ b/Data/Scripts/016_UI/023_UI_PurifyChamber.rb @@ -35,7 +35,8 @@ def pbDrawGauge(bitmap, rect, color, value, maxValue) 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) * (2 * Math::PI) # convert to radians angle = -angle % (2 * Math::PI) # normalize radians @@ -162,7 +163,8 @@ class PurifyChamber NUMSETS = 9 SETSIZE = 4 - def self.maximumTempo # Calculates the maximum possible tempo + # Calculates the maximum possible tempo. + def self.maximumTempo x = SETSIZE + 1 return (((x * x) + x) / 2) - 1 end @@ -187,7 +189,8 @@ class PurifyChamber return @sets[set].list end - def chamberFlow(chamber) # for speeding up purification + # For speeding up purification. + def chamberFlow(chamber) return 0 if chamber < 0 || chamber >= NUMSETS return @sets[chamber].flow end @@ -197,7 +200,8 @@ class PurifyChamber return @sets[chamber].shadow end - def setShadow(chamber, value) # allow only "shadow" Pokemon + # Allow only Shadow Pokemon. + def setShadow(chamber, value) return if chamber < 0 || chamber >= NUMSETS @sets[chamber].shadow = value end diff --git a/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb b/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb index 138a43e91..8f94568f7 100644 --- a/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb +++ b/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb @@ -614,7 +614,7 @@ class TriadScreen if numcards.odd? numcards = (numcards / 2) + 1 else - numcards = numcards / 2 + numcards /= 2 end return numcards end diff --git a/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb b/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb index ba49fdeb2..e08ff911d 100644 --- a/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb +++ b/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb @@ -46,10 +46,11 @@ class SlotMachineReel < BitmapSprite def stopSpinning(noslipping = false) @stopping = true @slipping = SLIPPING.sample - if @difficulty == 0 # Easy + case @difficulty + when 0 # Easy second_slipping = SLIPPING.sample @slipping = [@slipping, second_slipping].min - elsif @difficulty == 2 # Hard + when 2 # Hard second_slipping = SLIPPING.sample @slipping = [@slipping, second_slipping].max end diff --git a/Data/Scripts/017_Minigames/006_Minigame_Mining.rb b/Data/Scripts/017_Minigames/006_Minigame_Mining.rb index c17a9585d..3a1381794 100644 --- a/Data/Scripts/017_Minigames/006_Minigame_Mining.rb +++ b/Data/Scripts/017_Minigames/006_Minigame_Mining.rb @@ -82,7 +82,8 @@ class MiningGameCursor < BitmapSprite 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 - def initialize(position, mode, viewport) # mode: 0=pick, 1=hammer + # mode: 0=pick, 1=hammer. + def initialize(position, mode, viewport) @viewport = viewport super(Graphics.width, Graphics.height, @viewport) @position = position diff --git a/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb b/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb index dc9d6cbe3..5468fe64b 100644 --- a/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb +++ b/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb @@ -385,7 +385,7 @@ class TilePuzzleScene pbUpdateSpriteHash(@sprites) Graphics.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 else # Swap horizontally start_sprite_pos = @sprites["tile#{@tiles[movetile]}"].x @@ -398,7 +398,7 @@ class TilePuzzleScene pbUpdateSpriteHash(@sprites) Graphics.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 @tiles[cursor], @tiles[movetile] = @tiles[movetile], @tiles[cursor] @@ -446,29 +446,28 @@ class TilePuzzleScene end duration = 0.3 timer_start = System.uptime + start_pos = [] if [2, 8].include?(dir) - start_pos = [] tiles.each { |i| start_pos.push(@sprites["tile#{@tiles[i]}"].y) } loop do 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 pbUpdateSpriteHash(@sprites) Graphics.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 else - start_pos = [] tiles.each { |i| start_pos.push(@sprites["tile#{@tiles[i]}"].x) } loop do 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 pbUpdateSpriteHash(@sprites) Graphics.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 diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb index 5fc3c47d2..3d74238e2 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb @@ -231,7 +231,7 @@ class PlayerRating t = (deviation * deviation) + (volatility * volatility) deviation = 1.0 / Math.sqrt((1.0 / t) + (1.0 / variance)) # Update rating - rating = rating + (deviation * deviation * sum) + rating += deviation * deviation * sum setRating2(rating) setDeviation2(deviation) setVolatility2(volatility) diff --git a/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb b/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb index 9cf9eba5c..8d8c58bc5 100644 --- a/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb +++ b/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb @@ -1,7 +1,8 @@ #=============================================================================== # 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 ret = nil if !ret @@ -70,7 +71,8 @@ def pbPlayTrainerIntroBGM(trainer_type) pbBGMPlay(bgm) 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 ret = nil music = nil @@ -112,7 +114,8 @@ def pbGetTrainerBattleBGMFromType(trainertype) return ret 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 return $PokemonGlobal.nextBattleVictoryBGM.clone end diff --git a/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb b/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb index 61edbe939..5b198f655 100644 --- a/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb +++ b/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb @@ -430,8 +430,8 @@ class MapScreenScene if @dragging if @dragmapid >= 0 sprite = getMapSprite(@dragmapid) - x = x + @dragOffsetX - y = y + @dragOffsetY + x += @dragOffsetX + y += @dragOffsetY sprite.x = x & ~3 sprite.y = y & ~3 @sprites["title"].text = _ISPRINTF("D: Help [{1:03d}: {2:s}]", mapid, @mapinfos[@dragmapid].name) diff --git a/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb b/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb index 234d0f2a2..0e7ecbe33 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb @@ -73,23 +73,27 @@ module BattleAnimationEditor return @invalid 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 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 end - def repaint # Redraws the control only if it is invalid - if self.invalid? - self.refresh - self.validate - end + # Redraws the control only if it is invalid. + def repaint + return if !self.invalid? + self.refresh + self.validate end end @@ -275,7 +279,7 @@ module BattleAnimationEditor end 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 if cursor_to_show != @cursor_shown @cursor_shown = cursor_to_show diff --git a/Data/Scripts/020_Debug/002_Editor_DataTypes.rb b/Data/Scripts/020_Debug/002_Editor_DataTypes.rb index 5dd3e6e12..ee08fe755 100644 --- a/Data/Scripts/020_Debug/002_Editor_DataTypes.rb +++ b/Data/Scripts/020_Debug/002_Editor_DataTypes.rb @@ -154,7 +154,8 @@ module BooleanProperty2 end def self.format(value) - return (value) ? _INTL("True") : (!value.nil?) ? _INTL("False") : "-" + return _INTL("True") if value + return (value.nil?) ? "-" : _INTL("False") end end @@ -576,7 +577,9 @@ module GenderProperty def self.format(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 diff --git a/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb b/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb index f43fad853..99c875507 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb @@ -875,7 +875,6 @@ MenuHandlers.add(:debug_menu, :set_money, { params.setDefaultValue($player.battle_points) $player.battle_points = pbMessageChooseNumber("\\ts[]" + _INTL("Set the player's BP amount."), params) end - end } }) diff --git a/Data/Scripts/020_Debug/003_Editor_Listers.rb b/Data/Scripts/020_Debug/003_Editor_Listers.rb index 35b5e92fe..802d0c620 100644 --- a/Data/Scripts/020_Debug/003_Editor_Listers.rb +++ b/Data/Scripts/020_Debug/003_Editor_Listers.rb @@ -361,7 +361,8 @@ class SpeciesLister return @index end - def commands # Sorted alphabetically + # Sorted alphabetically. + def commands @commands.clear @ids.clear cmds = [] @@ -420,7 +421,8 @@ class ItemLister return @index end - def commands # Sorted alphabetically + # Sorted alphabetically. + def commands @commands.clear @ids.clear cmds = [] diff --git a/Data/Scripts/021_Compiler/001_Compiler.rb b/Data/Scripts/021_Compiler/001_Compiler.rb index c29dbf756..0eb7a5de2 100644 --- a/Data/Scripts/021_Compiler/001_Compiler.rb +++ b/Data/Scripts/021_Compiler/001_Compiler.rb @@ -261,7 +261,7 @@ module Compiler value = values[i] next if !value || value.empty? quote_count = value.count('"') - if !quote_count.zero? + if quote_count != 0 # Quote marks found in value (i...(values.length - 1)).each do |j| quote_count = values[i].count('"')