mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-03-21 23:40:23 +00:00
Code tidying with Rubocop
This commit is contained in:
@@ -128,6 +128,12 @@ Style/EndlessMethod:
|
||||
Style/FormatString:
|
||||
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
|
||||
# pointless bit of boilerplate that we neither need nor want.
|
||||
Style/FrozenStringLiteralComment:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -819,7 +819,7 @@ def getLineBrokenText(bitmap, value, width, dims)
|
||||
words = [ccheck]
|
||||
words.length.times do |i|
|
||||
word = words[i]
|
||||
if word && word != ""
|
||||
next if nil_or_empty?(word)
|
||||
textSize = bitmap.text_size(word)
|
||||
textwidth = textSize.width
|
||||
if x > 0 && x + textwidth >= width - 2
|
||||
@@ -836,7 +836,6 @@ def getLineBrokenText(bitmap, value, width, dims)
|
||||
x += textwidth
|
||||
dims[0] = x if dims && dims[0] < x
|
||||
end
|
||||
end
|
||||
position += length
|
||||
column += length
|
||||
end
|
||||
@@ -912,7 +911,7 @@ 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
|
||||
next if maxheight != 0 && text[2] >= maxheight
|
||||
height = text[4]
|
||||
text = text[0]
|
||||
bitmap.font.color = shadowColor
|
||||
@@ -922,7 +921,6 @@ def renderLineBrokenChunksWithShadow(bitmap, xDst, yDst, normtext, maxheight, ba
|
||||
bitmap.font.color = baseColor
|
||||
bitmap.draw_text(textx, texty, width + 2, height, text)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def drawBitmapBuffer(chars)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
next 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)
|
||||
next if column < thiscolumn || column > thiscolumn + thislength || thislength == 0
|
||||
return thispos + column - thiscolumn
|
||||
end
|
||||
end
|
||||
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,8 +536,8 @@ class Window_MultilineTextEntry < SpriteWindow_Base
|
||||
thisline = text[5]
|
||||
thiscolumn = text[7]
|
||||
thislength = text[8]
|
||||
if thisline == @cursorLine && @cursorColumn >= thiscolumn &&
|
||||
@cursorColumn <= thiscolumn + thislength
|
||||
next if thisline != @cursorLine || @cursorColumn < thiscolumn ||
|
||||
@cursorColumn > thiscolumn + thislength
|
||||
cursorY = text[2] - startY
|
||||
cursorX = text[1]
|
||||
textheight = text[4]
|
||||
@@ -556,7 +548,6 @@ class Window_MultilineTextEntry < SpriteWindow_Base
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
cursorY += 4
|
||||
cursorHeight = [4, textheight - 4, bitmap.text_size("X").height - 4].max
|
||||
bitmap.fill_rect(cursorX, cursorY, 2, cursorHeight, cursorcolor)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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|
|
||||
|
||||
@@ -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
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
@@ -232,16 +232,15 @@ 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
|
||||
score += 15 * inc_mult # Target will become faster than the foe b
|
||||
else
|
||||
score += 8 * inc_mult
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
# Prefer if the target has Electro Ball or Power Trip/Stored Power
|
||||
moves_that_prefer_high_speed = [
|
||||
"PowerHigherWithUserFasterThanTarget",
|
||||
@@ -524,16 +523,15 @@ 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
|
||||
score += 15 * dec_mult # Target will become slower than foe b
|
||||
else
|
||||
score += 8 * dec_mult
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
# Prefer if any ally has Electro Ball
|
||||
each_foe_battler(target.side) do |b, i|
|
||||
next if !b.has_move_with_function?("PowerHigherWithUserFasterThanTarget")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -835,7 +835,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("DisableTargetHealingMove
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
#.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("DisableTargetSoundMoves",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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|
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -614,7 +614,7 @@ class TriadScreen
|
||||
if numcards.odd?
|
||||
numcards = (numcards / 2) + 1
|
||||
else
|
||||
numcards = numcards / 2
|
||||
numcards /= 2
|
||||
end
|
||||
return numcards
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
if [2, 8].include?(dir)
|
||||
start_pos = []
|
||||
if [2, 8].include?(dir)
|
||||
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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -73,25 +73,29 @@ 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?
|
||||
# Redraws the control only if it is invalid.
|
||||
def repaint
|
||||
return if !self.invalid?
|
||||
self.refresh
|
||||
self.validate
|
||||
end
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
@@ -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('"')
|
||||
|
||||
Reference in New Issue
Block a user