More Rubocopping

This commit is contained in:
Maruno17
2021-12-20 17:18:21 +00:00
parent db4acd3369
commit 33fcbf623b
154 changed files with 1388 additions and 1420 deletions

View File

@@ -9,7 +9,7 @@ class Dir
files = []
filters = [filters] if !filters.is_a?(Array)
self.chdir(dir) do
for filter in filters
filters.each do |filter|
self.glob(filter) { |f| files.push(full ? (dir + "/" + f) : f) }
end
end
@@ -22,7 +22,7 @@ class Dir
# sets variables for starting
files = []
subfolders = []
for file in self.get(dir, filters, full)
self.get(dir, filters, full).each do |file|
# engages in recursion to read the entire file tree
if self.safe?(file) # Is a directory
subfolders += self.all(file, filters, full)
@@ -157,7 +157,7 @@ def canonicalize(c)
pos = -1
ret = []
retstr = ""
for x in csplit
csplit.each do |x|
if x == ".."
if pos >= 0
ret.delete_at(pos)
@@ -168,7 +168,7 @@ def canonicalize(c)
pos += 1
end
end
for i in 0...ret.length
ret.length.times do |i|
retstr += "/" if i > 0
retstr += ret[i]
end
@@ -184,7 +184,7 @@ module RTP
return false if nil_or_empty?(filename)
eachPathFor(filename) { |path|
return true if safeExists?(path)
for ext in extensions
extensions.each do |ext|
return true if safeExists?(path + ext)
end
}
@@ -203,7 +203,7 @@ module RTP
return filename if nil_or_empty?(filename)
eachPathFor(filename) { |path|
return path if safeExists?(path)
for ext in extensions
extensions.each do |ext|
file = path + ext
return file if safeExists?(file)
end
@@ -449,7 +449,8 @@ class StringInput
def gets
raise IOError, 'closed stream' if @closed
if idx = @string.index(?\n, @pos)
idx = @string.index("\n", @pos)
if idx
idx += 1 # "\n".size
line = @string[@pos...idx]
@pos = idx

View File

@@ -37,7 +37,7 @@ class String
width -= bitmap.text_size("...").width
string_width = 0
text = []
for char in string.scan(/./)
string.scan(/./).each do |char|
wdh = bitmap.text_size(char).width
next if (wdh + string_width) > width
string_width += wdh
@@ -45,7 +45,7 @@ class String
end
text.push("...") if text.length < string.length
new_string = ""
for char in text
text.each do |char|
new_string += char
end
return new_string
@@ -97,7 +97,7 @@ class Hash
h = self.clone
# failsafe
return h if !hash.is_a?(Hash)
for key in hash.keys
hash.keys.each do |key|
if self[key].is_a?(Hash)
h.deep_merge!(hash[key])
else
@@ -109,7 +109,7 @@ class Hash
def deep_merge!(hash)
return if !hash.is_a?(Hash)
for key in hash.keys
hash.keys.each do |key|
if self[key].is_a?(Hash)
self[key].deep_merge!(hash[key])
else
@@ -139,7 +139,9 @@ class File
data = ""
t = Time.now
File.open(source, 'rb') do |f|
while r = f.read(4096)
loop do
r = f.read(4096)
break if !r
if Time.now - t > 1
Graphics.update
t = Time.now

View File

@@ -24,7 +24,7 @@ def pbSetTextMessages
begin
t = Time.now.to_i
texts = []
for script in $RGSS_SCRIPTS
$RGSS_SCRIPTS.each do |script|
if Time.now.to_i - t >= 5
t = Time.now.to_i
Graphics.update
@@ -34,8 +34,8 @@ def pbSetTextMessages
end
if safeExists?("Data/PluginScripts.rxdata")
plugin_scripts = load_data("Data/PluginScripts.rxdata")
for plugin in plugin_scripts
for script in plugin[2]
plugin_scripts.each do |plugin|
plugin[2].each do |script|
if Time.now.to_i - t >= 5
t = Time.now.to_i
Graphics.update
@@ -50,7 +50,7 @@ def pbSetTextMessages
commonevents = load_data("Data/CommonEvents.rxdata")
items = []
choices = []
for event in commonevents.compact
commonevents.compact.each do |event|
if Time.now.to_i - t >= 5
t = Time.now.to_i
Graphics.update
@@ -58,7 +58,7 @@ def pbSetTextMessages
begin
neednewline = false
lastitem = ""
for j in 0...event.list.size
event.list.size.times do |j|
list = event.list[j]
if neednewline && list.code != 401
if lastitem != ""
@@ -72,7 +72,7 @@ def pbSetTextMessages
lastitem += "#{list.parameters[0]}"
neednewline = true
elsif list.code == 102
for k in 0...list.parameters[0].length
list.parameters[0].length.times do |k|
choices.push(list.parameters[0][k])
end
neednewline = false
@@ -86,7 +86,7 @@ def pbSetTextMessages
pbAddScriptTexts(items, list.parameters[1])
elsif list.code == 209
route = list.parameters[1]
for k in 0...route.list.size
route.list.size.times do |k|
if route.list[k].code == 45
pbAddScriptTexts(items, route.list[k].parameters[0])
end
@@ -110,7 +110,7 @@ def pbSetTextMessages
items.concat(choices)
MessageTypes.setMapMessagesAsHash(0, items)
mapinfos = pbLoadMapInfos
for id in mapinfos.keys
mapinfos.keys.each do |id|
if Time.now.to_i - t >= 5
t = Time.now.to_i
Graphics.update
@@ -120,16 +120,16 @@ def pbSetTextMessages
map = load_data(filename)
items = []
choices = []
for event in map.events.values
map.events.values.each do |event|
if Time.now.to_i - t >= 5
t = Time.now.to_i
Graphics.update
end
begin
for i in 0...event.pages.size
event.pages.size.times do |i|
neednewline = false
lastitem = ""
for j in 0...event.pages[i].list.size
event.pages[i].list.size.times do |j|
list = event.pages[i].list[j]
if neednewline && list.code != 401
if lastitem != ""
@@ -143,7 +143,7 @@ def pbSetTextMessages
lastitem += "#{list.parameters[0]}"
neednewline = true
elsif list.code == 102
for k in 0...list.parameters[0].length
list.parameters[0].length.times do |k|
choices.push(list.parameters[0][k])
end
neednewline = false
@@ -157,7 +157,7 @@ def pbSetTextMessages
pbAddScriptTexts(items, list.parameters[1])
elsif list.code == 209
route = list.parameters[1]
for k in 0...route.list.size
route.list.size.times do |k|
if route.list[k].code == 45
pbAddScriptTexts(items, route.list[k].parameters[0])
end
@@ -312,7 +312,7 @@ class OrderedHash < Hash
def inspect
str = "{"
for i in 0...@keys.length
@keys.length.times do |i|
str += ", " if i > 0
str += @keys[i].inspect + "=>" + self[@keys[i]].inspect
end
@@ -330,7 +330,7 @@ class OrderedHash < Hash
@keys |= []
@keys -= [key]
end
return super(key, value)
super(key, value)
end
def self._load(string)
@@ -338,7 +338,7 @@ class OrderedHash < Hash
keysvalues = Marshal.load(string)
keys = keysvalues[0]
values = keysvalues[1]
for i in 0...keys.length
keys.length.times do |i|
ret[keys[i]] = values[i]
end
return ret
@@ -346,7 +346,7 @@ class OrderedHash < Hash
def _dump(_depth = 100)
values = []
for key in @keys
@keys.each do |key|
values.push(self[key])
end
return Marshal.dump([@keys, values])
@@ -415,7 +415,7 @@ class Messages
case msgs
when Array
f.write("[#{secname}]\r\n")
for j in 0...msgs.length
msgs.length.times do |j|
next if nil_or_empty?(msgs[j])
value = Messages.normalizeValue(msgs[j])
origValue = ""
@@ -431,7 +431,7 @@ class Messages
when OrderedHash
f.write("[#{secname}]\r\n")
keys = msgs.keys
for key in keys
keys.each do |key|
next if nil_or_empty?(msgs[key])
value = Messages.normalizeValue(msgs[key])
valkey = Messages.normalizeValue(key)
@@ -456,12 +456,12 @@ class Messages
f.write("# To localize this text for a particular language, please\r\n")
f.write("# translate every second line of this file.\r\n")
if origMessages.messages[0]
for i in 0...origMessages.messages[0].length
origMessages.messages[0].length.times do |i|
msgs = origMessages.messages[0][i]
Messages.writeObject(f, msgs, "Map#{i}", origMessages)
end
end
for i in 1...origMessages.messages.length
(1...origMessages.messages.length).each do |i|
msgs = origMessages.messages[i]
Messages.writeObject(f, msgs, i, origMessages)
end
@@ -471,7 +471,7 @@ class Messages
def setMessages(type, array)
@messages = [] if !@messages
arr = []
for i in 0...array.length
array.length.times do |i|
arr[i] = (array[i]) ? array[i] : ""
end
@messages[type] = arr
@@ -480,7 +480,7 @@ class Messages
def addMessages(type, array)
@messages = [] if !@messages
arr = (@messages[type]) ? @messages[type] : []
for i in 0...array.length
array.length.times do |i|
arr[i] = (array[i]) ? array[i] : (arr[i]) ? arr[i] : ""
end
@messages[type] = arr
@@ -488,7 +488,7 @@ class Messages
def self.createHash(_type, array)
arr = OrderedHash.new
for i in 0...array.length
array.length.times do |i|
if array[i]
key = Messages.stringToKey(array[i])
arr[key] = array[i]
@@ -499,7 +499,7 @@ class Messages
def self.addToHash(_type, array, hash)
hash = OrderedHash.new if !hash
for i in 0...array.length
array.length.times do |i|
if array[i]
key = Messages.stringToKey(array[i])
hash[key] = array[i]
@@ -738,7 +738,7 @@ def _INTL(*arg)
string = arg[0]
end
string = string.clone
for i in 1...arg.length
(1...arg.length).each do |i|
string.gsub!(/\{#{i}\}/, "#{arg[i]}")
end
return string
@@ -754,7 +754,7 @@ def _ISPRINTF(*arg)
string = arg[0]
end
string = string.clone
for i in 1...arg.length
(1...arg.length).each do |i|
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m|
next sprintf("%" + $1, arg[i])
}
@@ -769,7 +769,7 @@ end
def _MAPINTL(mapid, *arg)
string = MessageTypes.getFromMapHash(mapid, arg[0])
string = string.clone
for i in 1...arg.length
(1...arg.length).each do |i|
string.gsub!(/\{#{i}\}/, "#{arg[i]}")
end
return string
@@ -778,7 +778,7 @@ end
def _MAPISPRINTF(mapid, *arg)
string = MessageTypes.getFromMapHash(mapid, arg[0])
string = string.clone
for i in 1...arg.length
(1...arg.length).each do |i|
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m|
next sprintf("%" + $1, arg[i])
}

View File

@@ -185,7 +185,7 @@ module PluginManager
idx_b = order.index(b) || order.size
next idx_a <=> idx_b
end
for key in keys
keys.each do |key|
value = options[key]
case key
when :name # Plugin name
@@ -211,7 +211,7 @@ module PluginManager
when :dependencies # Plugin dependencies
dependencies = value
dependencies = [dependencies] if !dependencies.is_a?(Array) || !dependencies[0].is_a?(Array)
for dep in value
value.each do |dep|
case dep
when String # "plugin name"
if !self.installed?(dep)
@@ -238,7 +238,8 @@ module PluginManager
if self.installed?(dep_name) # Have plugin but lower version
msg = "Plugin '#{name}' requires plugin '#{dep_name}' version #{dep_version} or higher, " +
"but the installed version is #{self.version(dep_name)}."
if dep_link = self.link(dep_name)
dep_link = self.link(dep_name)
if dep_link
msg += "\r\nCheck #{dep_link} for an update to plugin '#{dep_name}'."
end
self.error(msg)
@@ -308,7 +309,7 @@ module PluginManager
when :incompatibilities # Plugin incompatibilities
incompats = value
incompats = [incompats] if !incompats.is_a?(Array)
for incompat in incompats
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.")
@@ -317,7 +318,7 @@ module PluginManager
when :credits # Plugin credits
value = [value] if value.is_a?(String)
if value.is_a?(Array)
for entry in value
value.each do |entry|
if !entry.is_a?(String)
self.error("Plugin '#{name}'s credits array contains a non-string value.")
else
@@ -331,7 +332,7 @@ module PluginManager
self.error("Invalid plugin registry key '#{key}'.")
end
end
for plugin in @@Plugins.values
@@Plugins.values.each do |plugin|
if plugin[:incompatibilities] && plugin[:incompatibilities].include?(name)
self.error("Plugin '#{plugin[:name]}' is incompatible with '#{name}'. " +
"They cannot both be used at the same time.")
@@ -422,7 +423,7 @@ module PluginManager
while d2[-1] == "." # Turn "123." into "123"
d2 = d2[0..-2]
end
for i in 0...[d1.size, d2.size].max # Compare each digit in turn
[d1.size, d2.size].max.times do |i| # Compare each digit in turn
c1 = d1[i]
c2 = d2[i]
if c1
@@ -445,7 +446,7 @@ module PluginManager
message += "Error in Plugin [#{name}]:\r\n"
message += "#{$!.class} occurred.\r\n"
# go through message content
for line in $!.message.split("\r\n")
$!.message.split("\r\n").each do |line|
next if nil_or_empty?(line)
n = line[/\d+/]
err = line.split(":")[-1].strip
@@ -538,7 +539,7 @@ module PluginManager
# be loaded (files listed in the meta file are loaded first)
meta[:scripts] = [] if !meta[:scripts]
# get all script files from plugin Dir
for fl in Dir.all(dir)
Dir.all(dir).each do |fl|
next if !fl.include?(".rb")
meta[:scripts].push(fl.gsub("#{dir}/", ""))
end
@@ -566,7 +567,7 @@ module PluginManager
return nil if !meta[name] || !meta[name][:dependencies]
og = [name] if !og
# go through all dependencies
for dname in meta[name][:dependencies]
meta[name][:dependencies].each do |dname|
# clean the name to a simple string
dname = dname[0] if dname.is_a?(Array) && dname.length == 2
dname = dname[1] if dname.is_a?(Array) && dname.length == 3
@@ -583,10 +584,10 @@ module PluginManager
#-----------------------------------------------------------------------------
def self.sortLoadOrder(order, plugins)
# go through the load order
for o in order
order.each do |o|
next if !plugins[o] || !plugins[o][:dependencies]
# go through all dependencies
for dname in plugins[o][:dependencies]
plugins[o][:dependencies].each do |dname|
optional = false
# clean the name to a simple string
if dname.is_a?(Array)
@@ -615,7 +616,7 @@ module PluginManager
order = []
# Find all plugin folders that have a meta.txt and add them to the list of
# plugins.
for dir in self.listAll
self.listAll.each do |dir|
# skip if there is no meta file
next if !safeExists?(dir + "/meta.txt")
ndx = order.length
@@ -646,11 +647,11 @@ module PluginManager
return true if Input.press?(Input::CTRL)
# analyze whether or not to push recompile
mtime = File.mtime("Data/PluginScripts.rxdata")
for o in order
order.each do |o|
# go through all the registered plugin scripts
scr = plugins[o][:scripts]
dir = plugins[o][:dir]
for sc in scr
scr.each do |sc|
return true if File.mtime("#{dir}/#{sc}") > mtime
end
return true if File.mtime("#{dir}/meta.txt") > mtime
@@ -664,14 +665,14 @@ module PluginManager
Console.echo_li "Compiling plugin scripts..."
scripts = []
# go through the entire order one by one
for o in order
order.each do |o|
# save name, metadata and scripts array
meta = plugins[o].clone
meta.delete(:scripts)
meta.delete(:dir)
dat = [o, meta, []]
# iterate through each file to deflate
for file in plugins[o][:scripts]
plugins[o][:scripts].each do |file|
File.open("#{plugins[o][:dir]}/#{file}", 'rb') do |f|
dat[2].push([file, Zlib::Deflate.deflate(f.read)])
end
@@ -697,7 +698,7 @@ module PluginManager
# load plugins
scripts = load_data("Data/PluginScripts.rxdata")
echoed_plugins = []
for plugin in scripts
scripts.each do |plugin|
# get the required data
name, meta, script = plugin
if !meta[:essentials] || !meta[:essentials].include?(Essentials::VERSION)
@@ -706,7 +707,7 @@ module PluginManager
# register plugin
self.register(meta)
# go through each script and interpret
for scr in script
script.each do |scr|
# turn code into plaintext
code = Zlib::Inflate.inflate(scr[1]).force_encoding(Encoding::UTF_8)
# get rid of tabs

View File

@@ -100,7 +100,7 @@ class SpriteAnimation
sprite.bitmap.dispose
end
end
for sprite in @_animation_sprites
@_animation_sprites.each do |sprite|
sprite.dispose
end
@_animation_sprites = nil
@@ -116,7 +116,7 @@ class SpriteAnimation
sprite.bitmap.dispose
end
end
for sprite in @_loop_animation_sprites
@_loop_animation_sprites.each do |sprite|
sprite.dispose
end
@_loop_animation_sprites = nil
@@ -160,7 +160,7 @@ class SpriteAnimation
position = @_animation.position
animation_set_sprites(@_animation_sprites, cell_data, position, quick_update)
return if quick_update
for timing in @_animation.timings
@_animation.timings.each do |timing|
next if timing.frame != frame_index
animation_process_timing(timing, @_animation_hit)
end
@@ -172,7 +172,7 @@ class SpriteAnimation
position = @_loop_animation.position
animation_set_sprites(@_loop_animation_sprites, cell_data, position, quick_update)
return if quick_update
for timing in @_loop_animation.timings
@_loop_animation.timings.each do |timing|
next if timing.frame != frame_index
animation_process_timing(timing, true)
end
@@ -192,7 +192,7 @@ class SpriteAnimation
sprite_y += self.src_rect.height / 2 if position == 1
sprite_y += self.src_rect.height if position == 2
end
for i in 0..15
16.times do |i|
sprite = sprites[i]
pattern = cell_data[i, 0]
if sprite == nil || pattern == nil || pattern == -1
@@ -247,12 +247,12 @@ class SpriteAnimation
sx = x - self.x
return if sx == 0
if @_animation_sprites != nil
for i in 0..15
16.times do |i|
@_animation_sprites[i].x += sx
end
end
if @_loop_animation_sprites != nil
for i in 0..15
16.times do |i|
@_loop_animation_sprites[i].x += sx
end
end
@@ -262,12 +262,12 @@ class SpriteAnimation
sy = y - self.y
return if sy == 0
if @_animation_sprites != nil
for i in 0..15
16.times do |i|
@_animation_sprites[i].y += sy
end
end
if @_loop_animation_sprites != nil
for i in 0..15
16.times do |i|
@_loop_animation_sprites[i].y += sy
end
end
@@ -376,7 +376,7 @@ module RPG
end
def pushAnimation(array, anim)
for i in 0...array.length
array.length.times do |i|
next if array[i] && array[i].active?
array[i] = anim
return
@@ -405,14 +405,14 @@ module RPG
end
def dispose_animation
for a in @animations
@animations.each do |a|
a.dispose_animation if a
end
@animations.clear
end
def dispose_loop_animation
for a in @loopAnimations
@loopAnimations.each do |a|
a.dispose_loop_animation if a
end
@loopAnimations.clear
@@ -440,7 +440,7 @@ module RPG
return true if @_escape_duration > 0
return true if @_collapse_duration > 0
return true if @_damage_duration > 0
for a in @animations
@animations.each do |a|
return true if a.effect?
end
return false
@@ -481,10 +481,10 @@ module RPG
dispose_damage
end
end
for a in @animations
@animations.each do |a|
a.update
end
for a in @loopAnimations
@loopAnimations.each do |a|
a.update
end
if @_blink
@@ -500,32 +500,32 @@ module RPG
end
def update_animation
for a in @animations
@animations.each do |a|
a.update_animation if a && a.active?
end
end
def update_loop_animation
for a in @loopAnimations
@loopAnimations.each do |a|
a.update_loop_animation if a && a.active?
end
end
def x=(x)
for a in @animations
@animations.each do |a|
a.x = x if a
end
for a in @loopAnimations
@loopAnimations.each do |a|
a.x = x if a
end
super
end
def y=(y)
for a in @animations
@animations.each do |a|
a.y = y if a
end
for a in @loopAnimations
@loopAnimations.each do |a|
a.y = y if a
end
super

View File

@@ -334,20 +334,20 @@ SaveData.register_conversion(:v20_convert_pokemon_markings_variables) do
display_title 'Updating format of Pokémon markings (3/4)'
to_all do |save_data|
variables = save_data[:variables]
for i in 0..5000
(0..5000).each do |i|
value = variables[i]
next if value.nil?
if value.is_a?(Array)
value.each do |value2|
if value2.is_a?(Pokemon) && value2.markings.is_a?(Integer)
markings = []
6.times { |i| markings[i] = ((value2.markings & (1 << i)) == 0) ? 0 : 1 }
6.times { |j| markings[j] = ((value2.markings & (1 << j)) == 0) ? 0 : 1 }
value2.markings = markings
end
end
elsif value.is_a?(Pokemon) && value.markings.is_a?(Integer)
markings = []
6.times { |i| markings[i] = ((value.markings & (1 << i)) == 0) ? 0 : 1 }
6.times { |j| markings[j] = ((value.markings & (1 << j)) == 0) ? 0 : 1 }
value.markings = markings
end
end
@@ -359,12 +359,12 @@ SaveData.register_conversion(:v20_convert_pokemon_markings_storage) do
display_title 'Updating format of Pokémon markings (4/4)'
to_value :storage_system do |storage|
storage.instance_eval do
for box in 0...self.maxBoxes
for i in 0...self.maxPokemon(box)
self.maxBoxes.times do |box|
self.maxPokemon(box).times do |i|
pkmn = self[box, i]
next if !pkmn || !pkmn.markings.is_a?(Integer)
markings = []
6.times { |i| markings[i] = ((pkmn.markings & (1 << i)) == 0) ? 0 : 1 }
6.times { |j| markings[j] = ((pkmn.markings & (1 << j)) == 0) ? 0 : 1 }
pkmn.markings = markings
end
end

View File

@@ -9,7 +9,7 @@ class Scene_Map
def spriteset(map_id = -1)
return @spritesets[map_id] if map_id > 0 && @spritesets[map_id]
for i in @spritesets.values
@spritesets.values.each do |i|
return i if i.map == $game_map
end
return @spritesets.values[0]
@@ -19,7 +19,7 @@ class Scene_Map
@map_renderer = TilemapRenderer.new(Spriteset_Map.viewport)
@spritesetGlobal = Spriteset_Global.new
@spritesets = {}
for map in $map_factory.maps
$map_factory.maps.each do |map|
@spritesets[map.map_id] = Spriteset_Map.new(map)
end
$map_factory.setSceneStarted(self)
@@ -36,7 +36,7 @@ class Scene_Map
def disposeSpritesets
return if !@spritesets
for i in @spritesets.keys
@spritesets.keys.each do |i|
next if !@spritesets[i]
@spritesets[i].dispose
@spritesets[i] = nil
@@ -132,7 +132,7 @@ class Scene_Map
end
def updateMaps
for map in $map_factory.maps
$map_factory.maps.each do |map|
map.update
end
$map_factory.updateMaps(self)
@@ -140,11 +140,11 @@ class Scene_Map
def updateSpritesets
@spritesets = {} if !@spritesets
for map in $map_factory.maps
$map_factory.maps.each do |map|
@spritesets[map.map_id] = Spriteset_Map.new(map) if !@spritesets[map.map_id]
end
keys = @spritesets.keys.clone
for i in keys
keys.each do |i|
if !$map_factory.hasMap?(i)
@spritesets[i].dispose if @spritesets[i]
@spritesets[i] = nil

View File

@@ -60,7 +60,7 @@ class Interpreter
return
end
# Check all map events for one that wants to start, and set it up
for event in $game_map.events.values
$game_map.events.values.each do |event|
next if !event.starting
if event.trigger < 3 # Isn't autorun or parallel processing
event.lock
@@ -70,7 +70,7 @@ class Interpreter
return
end
# Check all common events for one that is autorun, and set it up
for common_event in $data_common_events.compact
$data_common_events.compact.each do |common_event|
next if common_event.trigger != 1 || !$game_switches[common_event.switch_id]
setup(common_event.list, 0)
return
@@ -107,7 +107,7 @@ class Interpreter
# Do nothing if any event or the player is in the middle of a move route
if @move_route_waiting
return if $game_player.move_route_forcing
for event in $game_map.events.values
$game_map.events.values.each do |event|
return if event.move_route_forcing
end
$game_temp.followers.each_follower do |event, follower|
@@ -386,7 +386,7 @@ class Interpreter
time = time.to_i
pbSetSelfSwitch(@event_id, "A", true)
$PokemonGlobal.eventvars[[@map_id, @event_id]] = time
for otherevt in arg
arg.each do |otherevt|
pbSetSelfSwitch(otherevt, "A", true)
$PokemonGlobal.eventvars[[@map_id, otherevt]] = time
end

View File

@@ -190,7 +190,7 @@ class Interpreter
@message_waiting = true # Lets parallel process events work while a message is displayed
if commands
cmd_texts = []
for cmd in commands[0]
commands[0].each do |cmd|
cmd_texts.push(_MAPINTL($game_map.map_id, cmd))
end
command = pbMessage(message + message_end, cmd_texts, commands[1])
@@ -272,7 +272,7 @@ class Interpreter
Input.update
pbUpdateSceneMap
# Check for input and break if there is one
for i in 1..18
(1..18).each do |i|
ret = i if Input.trigger?(i)
end
break if ret != 0
@@ -460,7 +460,7 @@ class Interpreter
#-----------------------------------------------------------------------------
def command_121
should_refresh = false
for i in @parameters[0]..@parameters[1]
(@parameters[0]..@parameters[1]).each do |i|
next if $game_switches[i] == (@parameters[2] == 0)
$game_switches[i] = (@parameters[2] == 0)
should_refresh = true
@@ -506,7 +506,7 @@ class Interpreter
end
end
# Apply value and operation to all specified game variables
for i in @parameters[0]..@parameters[1]
(@parameters[0]..@parameters[1]).each do |i|
case @parameters[2]
when 0 # set
next if $game_variables[i] == value
@@ -573,7 +573,7 @@ class Interpreter
# * Change Windowskin
#-----------------------------------------------------------------------------
def command_131
for i in 0...Settings::SPEECH_WINDOWSKINS.length
Settings::SPEECH_WINDOWSKINS.length.times do |i|
next if Settings::SPEECH_WINDOWSKINS[i] != @parameters[0]
$PokemonSystem.textskin = i
MessageConfig.pbSetSpeechFrame("Graphics/Windowskins/" + Settings::SPEECH_WINDOWSKINS[i])

View File

@@ -39,7 +39,7 @@ class Event
# proc { |sender,arg0,arg1,...| }
def trigger(*arg)
arglist = arg[1, arg.length]
for callback in @callbacks
@callbacks.each do |callback|
if callback.arity > 2 && arg.length == callback.arity
# Retrofitted for callbacks that take three or more arguments
callback.call(*arg)
@@ -53,7 +53,7 @@ class Event
# by the code where the event occurred. The first argument is the sender of
# the event, the other arguments are the event's parameters.
def trigger2(*arg)
for callback in @callbacks
@callbacks.each do |callback|
callback.call(*arg)
end
end
@@ -83,7 +83,7 @@ class HandlerHash
return ret if ret
mod = Object.const_get(@mod) rescue nil
return nil if !mod
for key in mod.constants
mod.constants.each do |key|
next if mod.const_get(key) != sym
ret = key.to_sym
@symbolCache[sym] = ret
@@ -112,7 +112,7 @@ class HandlerHash
def copy(src, *dests)
handler = self[src]
if handler
for dest in dests
dests.each do |dest|
self.add(dest, handler)
end
end
@@ -125,7 +125,7 @@ class HandlerHash
symbol = toSymbol(sym)
ret = @hash[symbol] if symbol && @hash[symbol] # Symbol or string
unless ret
for addif in @addIfs
@addIfs.each do |addif|
return addif[1] if addif[0].call(id)
end
end
@@ -155,7 +155,7 @@ class HandlerHash2
def [](sym)
sym = sym.id if !sym.is_a?(Symbol) && sym.respond_to?("id")
return @hash[sym] if sym && @hash[sym]
for add_if in @add_ifs
@add_ifs.each do |add_if|
return add_if[1] if add_if[0].call(sym)
end
return nil
@@ -178,7 +178,7 @@ class HandlerHash2
def copy(src, *dests)
handler = self[src]
return if !handler
for dest in dests
dests.each do |dest|
self.add(dest, handler)
end
end
@@ -209,7 +209,7 @@ class HandlerHashBasic
ret = nil
ret = @hash[entry] if entry && @hash[entry]
unless ret
for addif in @addIfs
@addIfs.each do |addif|
return addif[1] if addif[0].call(entry)
end
end

View File

@@ -158,14 +158,14 @@ module EncounterModifier
end
def self.trigger(encounter)
for prc in @@procs
@@procs.each do |prc|
encounter = prc.call(encounter)
end
return encounter
end
def self.triggerEncounterEnd
for prc in @@procsEnd
@@procsEnd.each do |prc|
prc.call
end
end

View File

@@ -36,7 +36,7 @@ class Game_Screen
@shake_direction = 1
@shake = 0
@pictures = [nil]
for i in 1..100
(1..100).each do |i|
@pictures.push(Game_Picture.new(i))
end
@weather_type = 0
@@ -125,11 +125,11 @@ class Game_Screen
@shake_duration -= 1 if @shake_duration >= 1
end
if $game_temp.in_battle
for i in 51..100
(51..100).each do |i|
@pictures[i].update
end
else
for i in 1..50
(1..50).each do |i|
@pictures[i].update
end
end
@@ -141,7 +141,7 @@ end
#===============================================================================
def pbToneChangeAll(tone, duration)
$game_screen.start_tone_change(tone, duration * Graphics.frame_rate / 20)
for picture in $game_screen.pictures
$game_screen.pictures.each do |picture|
picture.start_tone_change(tone, duration * Graphics.frame_rate / 20) if picture
end
end

View File

@@ -59,11 +59,11 @@ class Game_Map
@need_refresh = false
Events.onMapCreate.trigger(self, map_id, @map, tileset)
@events = {}
for i in @map.events.keys
@map.events.keys.each do |i|
@events[i] = Game_Event.new(@map_id, @map.events[i], self)
end
@common_events = {}
for i in 1...$data_common_events.size
(1...$data_common_events.size).each do |i|
@common_events[i] = Game_CommonEvent.new(i)
end
@scroll_direction = 2
@@ -148,7 +148,7 @@ class Game_Map
def passable?(x, y, d, self_event = nil)
return false if !valid?(x, y)
bit = (1 << ((d / 2) - 1)) & 0x0f
for event in events.values
events.values.each do |event|
next if event.tile_id <= 0
next if event == self_event
next if !event.at_coordinate?(x, y)
@@ -186,12 +186,12 @@ class Game_Map
newy -= 1
end
return false if !valid?(newx, newy)
for i in [2, 1, 0]
[2, 1, 0].each do |i|
tile_id = data[x, y, i]
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
# If already on water, only allow movement to another water tile
if self_event != nil && terrain.can_surf_freely
for j in [2, 1, 0]
[2, 1, 0].each do |j|
facing_tile_id = data[newx, newy, j]
return false if facing_tile_id == nil
facing_terrain = GameData::TerrainTag.try_get(@terrain_tags[facing_tile_id])
@@ -205,7 +205,7 @@ class Game_Map
return false
elsif self_event != nil && self_event.x == x && self_event.y == y
# Can't walk onto ledges
for j in [2, 1, 0]
[2, 1, 0].each do |j|
facing_tile_id = data[newx, newy, j]
return false if facing_tile_id == nil
facing_terrain = GameData::TerrainTag.try_get(@terrain_tags[facing_tile_id])
@@ -225,7 +225,7 @@ class Game_Map
def playerPassable?(x, y, d, self_event = nil)
bit = (1 << ((d / 2) - 1)) & 0x0f
for i in [2, 1, 0]
[2, 1, 0].each do |i|
tile_id = data[x, y, i]
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
passage = @passages[tile_id]
@@ -254,14 +254,14 @@ class Game_Map
# event there, and the tile is fully passable in all directions)
def passableStrict?(x, y, d, self_event = nil)
return false if !valid?(x, y)
for event in events.values
events.values.each do |event|
next if event == self_event || event.tile_id < 0 || event.through
next if !event.at_coordinate?(x, y)
next if GameData::TerrainTag.try_get(@terrain_tags[event.tile_id]).ignore_passability
return false if @passages[event.tile_id] & 0x0f != 0
return true if @priorities[event.tile_id] == 0
end
for i in [2, 1, 0]
[2, 1, 0].each do |i|
tile_id = data[x, y, i]
next if GameData::TerrainTag.try_get(@terrain_tags[tile_id]).ignore_passability
return false if @passages[tile_id] & 0x0f != 0
@@ -271,7 +271,7 @@ class Game_Map
end
def bush?(x, y)
for i in [2, 1, 0]
[2, 1, 0].each do |i|
tile_id = data[x, y, i]
return false if GameData::TerrainTag.try_get(@terrain_tags[tile_id]).bridge &&
$PokemonGlobal.bridge > 0
@@ -281,7 +281,7 @@ class Game_Map
end
def deepBush?(x, y)
for i in [2, 1, 0]
[2, 1, 0].each do |i|
tile_id = data[x, y, i]
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
return false if terrain.bridge && $PokemonGlobal.bridge > 0
@@ -291,7 +291,7 @@ class Game_Map
end
def counter?(x, y)
for i in [2, 1, 0]
[2, 1, 0].each do |i|
tile_id = data[x, y, i]
passage = @passages[tile_id]
return true if passage & 0x80 == 0x80
@@ -301,7 +301,7 @@ class Game_Map
def terrain_tag(x, y, countBridge = false)
if valid?(x, y)
for i in [2, 1, 0]
[2, 1, 0].each do |i|
tile_id = data[x, y, i]
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
next if terrain.id == :None || terrain.ignore_passability
@@ -314,7 +314,7 @@ class Game_Map
# Unused.
def check_event(x, y)
for event in self.events.values
self.events.values.each do |event|
return event.id if event.at_coordinate?(x, y)
end
end
@@ -394,10 +394,10 @@ class Game_Map
end
def refresh
for event in @events.values
@events.values.each do |event|
event.refresh
end
for common_event in @common_events.values
@common_events.values.each do |common_event|
common_event.refresh
end
@need_refresh = false
@@ -406,7 +406,7 @@ class Game_Map
def update
# refresh maps if necessary
if $map_factory
for i in $map_factory.maps
$map_factory.maps.each do |i|
i.refresh if i.need_refresh
end
$map_factory.setCurrentMap
@@ -424,11 +424,11 @@ class Game_Map
@scroll_rest -= distance
end
# Only update events that are on-screen
for event in @events.values
@events.values.each do |event|
event.update
end
# Update common events
for common_event in @common_events.values
@common_events.values.each do |common_event|
common_event.update
end
# Update fog

View File

@@ -38,21 +38,21 @@ class PokemonMapFactory
end
def hasMap?(id)
for map in @maps
@maps.each do |map|
return true if map.map_id == id
end
return false
end
def getMapIndex(id)
for i in 0...@maps.length
@maps.length.times do |i|
return i if @maps[i].map_id == id
end
return -1
end
def getMap(id, add = true)
for map in @maps
@maps.each do |map|
return map if map.map_id == id
end
map = Game_Map.new
@@ -69,7 +69,7 @@ class PokemonMapFactory
id = $game_map.map_id
conns = MapFactoryHelper.getMapConnections
if conns[id]
for conn in conns[id]
conns[id].each do |conn|
mapidB = nil
newx = 0
newy = 0
@@ -119,7 +119,7 @@ class PokemonMapFactory
id = $game_map.map_id
conns = MapFactoryHelper.getMapConnections
if conns[id]
for conn in conns[id]
conns[id].each do |conn|
if conn[0] == id
mapA = getMap(conn[0])
newdispx = ((conn[4] - conn[1]) * Game_Map::REAL_RES_X) + mapA.display_x
@@ -180,7 +180,7 @@ class PokemonMapFactory
return false unless map.passable?(x, y, 0, thisEvent)
end
# Check passability of event(s) in that spot
for event in map.events.values
map.events.values.each do |event|
next if event == thisEvent || !event.at_coordinate?(x, y)
return false if !event.through && event.character_name != ""
end
@@ -207,7 +207,7 @@ class PokemonMapFactory
elsif !map.passableStrict?(x, y, 0, thisEvent)
return false
end
for event in map.events.values
map.events.values.each do |event|
next if event == thisEvent || !event.at_coordinate?(x, y)
return false if !event.through && event.character_name != ""
end
@@ -236,7 +236,7 @@ class PokemonMapFactory
return true if mapID1 == mapID2
conns = MapFactoryHelper.getMapConnections
if conns[mapID1]
for conn in conns[mapID1]
conns[mapID1].each do |conn|
return true if conn[0] == mapID2 || conn[3] == mapID2
end
end
@@ -250,7 +250,7 @@ class PokemonMapFactory
end
conns = MapFactoryHelper.getMapConnections
if conns[thisMapID]
for conn in conns[thisMapID]
conns[thisMapID].each do |conn|
if conn[0] == otherMapID
posX = conn[4] - conn[1] + otherX - thisX
posY = conn[5] - conn[2] + otherY - thisY
@@ -332,7 +332,7 @@ class PokemonMapFactory
return [id, x, y] if getMapNoAdd(id).valid?(x, y)
conns = MapFactoryHelper.getMapConnections
if conns[id]
for conn in conns[id]
conns[id].each do |conn|
if conn[0] == id
newX = x + conn[4] - conn[1]
newY = y + conn[5] - conn[2]
@@ -510,7 +510,7 @@ end
# Unused
def updateTilesets
maps = $map_factory.maps
for map in maps
maps.each do |map|
map.updateTileset if map
end
end

View File

@@ -88,8 +88,8 @@ class Game_Character
end
def each_occupied_tile
for i in @x...(@x + @width)
for j in (@y - @height + 1)..@y
(@x...(@x + @width)).each do |i|
((@y - @height + 1)..@y).each do |j|
yield i, j
end
end
@@ -240,7 +240,7 @@ class Game_Character
return false unless self.map.passable?(x, y, d, self)
return false unless self.map.passable?(new_x, new_y, 10 - d, self)
end
for event in self.map.events.values
self.map.events.values.each do |event|
next if self == event || !event.at_coordinate?(new_x, new_y) || event.through
return false if self != $game_player || event.character_name != ""
end
@@ -254,24 +254,24 @@ class Game_Character
case dir
when 2, 8 # Down, up
y_diff = (dir == 8) ? @height - 1 : 0
for i in start_x...(start_x + @width)
(start_x...(start_x + @width)).each do |i|
return false if !passable?(i, start_y - y_diff, dir, strict)
end
return true
when 4, 6 # Left, right
x_diff = (dir == 6) ? @width - 1 : 0
for i in (start_y - @height + 1)..start_y
((start_y - @height + 1)..start_y).each do |i|
return false if !passable?(start_x + x_diff, i, dir, strict)
end
return true
when 1, 3 # Down diagonals
# Treated as moving down first and then horizontally, because that
# describes which tiles the character's feet touch
for i in start_x...(start_x + @width)
(start_x...(start_x + @width)).each do |i|
return false if !passable?(i, start_y, 2, strict)
end
x_diff = (dir == 3) ? @width - 1 : 0
for i in (start_y - @height + 1)..start_y
((start_y - @height + 1)..start_y).each do |i|
return false if !passable?(start_x + x_diff, i + 1, dir + 3, strict)
end
return true
@@ -279,11 +279,11 @@ class Game_Character
# Treated as moving horizontally first and then up, because that describes
# which tiles the character's feet touch
x_diff = (dir == 9) ? @width - 1 : 0
for i in (start_y - @height + 1)..start_y
((start_y - @height + 1)..start_y).each do |i|
return false if !passable?(start_x + x_diff, i, dir - 3, strict)
end
x_offset = (dir == 9) ? 1 : -1
for i in start_x...(start_x + @width)
(start_x...(start_x + @width)).each do |i|
return false if !passable?(i + x_offset, start_y - @height + 1, 8, strict)
end
return true

View File

@@ -181,7 +181,7 @@ class Game_Event < Game_Character
def refresh
new_page = nil
unless @erased
for page in @event.pages.reverse
@event.pages.reverse.each do |page|
c = page.condition
next if c.switch1_valid && !switchIsOn?(c.switch1_id)
next if c.switch2_valid && !switchIsOn?(c.switch2_id)

View File

@@ -184,7 +184,7 @@ class Game_Player < Game_Character
# If event is running
return result if checkIfRunning && $game_system.map_interpreter.running?
# All event loops
for event in $game_map.events.values
$game_map.events.values.each do |event|
next if !event.name[/trainer\((\d+)\)/i]
distance = $~[1].to_i
# If event coordinates and triggers are consistent
@@ -201,7 +201,7 @@ class Game_Player < Game_Character
# If event is running
return result if checkIfRunning && $game_system.map_interpreter.running?
# All event loops
for event in $game_map.events.values
$game_map.events.values.each do |event|
next if !event.name[/counter\((\d+)\)/i]
distance = $~[1].to_i
# If event coordinates and triggers are consistent
@@ -219,7 +219,7 @@ class Game_Player < Game_Character
ret = pbTriggeredTrainerEvents(triggers)
ret.concat(pbTriggeredCounterEvents(triggers))
return false if ret.length == 0
for event in ret
ret.each do |event|
event.start
end
return true
@@ -236,7 +236,7 @@ class Game_Player < Game_Character
new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
return nil if !$game_map.valid?(new_x, new_y)
for event in $game_map.events.values
$game_map.events.values.each do |event|
next if !event.at_coordinate?(new_x, new_y)
next if event.jumping? || event.over_trigger?
return event
@@ -245,7 +245,7 @@ class Game_Player < Game_Character
if $game_map.counter?(new_x, new_y)
new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
for event in $game_map.events.values
$game_map.events.values.each do |event|
next if !event.at_coordinate?(new_x, new_y)
next if event.jumping? || event.over_trigger?
return event
@@ -330,7 +330,7 @@ class Game_Player < Game_Character
# If event is running
return result if $game_system.map_interpreter.running?
# All event loops
for event in $game_map.events.values
$game_map.events.values.each do |event|
# If event coordinates and triggers are consistent
next if !event.at_coordinate?(@x, @y)
next if !triggers.include?(event.trigger)
@@ -354,7 +354,7 @@ class Game_Player < Game_Character
new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
return false if !$game_map.valid?(new_x, new_y)
# All event loops
for event in $game_map.events.values
$game_map.events.values.each do |event|
# If event coordinates and triggers are consistent
next if !event.at_coordinate?(new_x, new_y)
next if !triggers.include?(event.trigger)
@@ -372,7 +372,7 @@ class Game_Player < Game_Character
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
return false if !$game_map.valid?(new_x, new_y)
# All event loops
for event in $game_map.events.values
$game_map.events.values.each do |event|
# If event coordinates and triggers are consistent
next if !event.at_coordinate?(new_x, new_y)
next if !triggers.include?(event.trigger)
@@ -395,7 +395,7 @@ class Game_Player < Game_Character
# All event loops
x_offset = (dir == 4) ? -1 : (dir == 6) ? 1 : 0
y_offset = (dir == 8) ? -1 : (dir == 2) ? 1 : 0
for event in $game_map.events.values
$game_map.events.values.each do |event|
next if ![1, 2].include?(event.trigger) # Player touch, event touch
# If event coordinates and triggers are consistent
next if !event.at_coordinate?(@x + x_offset, @y + y_offset)

View File

@@ -166,7 +166,7 @@ class Game_Follower < Game_Event
passed_tile_checks = false
bit = (1 << ((direction / 2) - 1)) & 0x0f
# Check all events for ones using tiles as graphics, and see if they're passable
for event in this_map.events.values
this_map.events.values.each do |event|
next if event.tile_id < 0 || event.through || !event.at_coordinate?(x, y)
tile_data = GameData::TerrainTag.try_get(this_map.terrain_tags[event.tile_id])
next if tile_data.ignore_passability
@@ -180,7 +180,7 @@ class Game_Follower < Game_Event
end
# Check if tiles at (x, y) allow passage for followe
if !passed_tile_checks
for i in [2, 1, 0]
[2, 1, 0].each do |i|
tile_id = this_map.data[x, y, i] || 0
next if tile_id == 0
tile_data = GameData::TerrainTag.try_get(this_map.terrain_tags[tile_id])
@@ -194,7 +194,7 @@ class Game_Follower < Game_Event
end
end
# Check all events on the map to see if any are in the way
for event in this_map.events.values
this_map.events.values.each do |event|
next if !event.at_coordinate?(x, y)
return false if !event.through && event.character_name != ""
end

View File

@@ -28,7 +28,7 @@ class BushBitmap
ret = Bitmap.new(bitmap.width, bitmap.height)
charheight = ret.height / 4
cy = charheight - depth - 2
for i in 0...4
4.times do |i|
y = i * charheight
if cy >= 0
ret.blt(0, y, bitmap, Rect.new(0, y, ret.width, cy))

View File

@@ -8,7 +8,7 @@ class Spriteset_Global
@follower_sprites = FollowerSprites.new(Spriteset_Map.viewport)
@playersprite = Sprite_Character.new(Spriteset_Map.viewport, $game_player)
@picture_sprites = []
for i in 1..100
(1..100).each do |i|
@picture_sprites.push(Sprite_Picture.new(@@viewport2, $game_screen.pictures[i]))
end
@timer_sprite = Sprite_Timer.new

View File

@@ -54,7 +54,7 @@ class Spriteset_Map
@fog = AnimatedPlane.new(@@viewport1)
@fog.z = 3000
@character_sprites = []
for i in @map.events.keys.sort
@map.events.keys.sort.each do |i|
sprite = Sprite_Character.new(@@viewport1, @map.events[i])
@character_sprites.push(sprite)
end
@@ -119,7 +119,7 @@ class Spriteset_Map
@fog.tone = @map.fog_tone
@panorama.update
@fog.update
for sprite in @character_sprites
@character_sprites.each do |sprite|
sprite.update
end
if self.map != $game_map

View File

@@ -56,29 +56,24 @@ class Spriteset_Map
return sprite
end
def addUserSprite(sprite)
for i in 0...@usersprites.length
if @usersprites[i] == nil || @usersprites[i].disposed?
@usersprites[i] = sprite
def addUserSprite(new_sprite)
@usersprites.each_with_index do |sprite, i|
next if sprite && !sprite.disposed?
@usersprites[i] = new_sprite
return
end
end
@usersprites.push(sprite)
@usersprites.push(new_sprite)
end
def dispose
_animationSprite_dispose
for i in 0...@usersprites.length
@usersprites[i].dispose
end
@usersprites.each { |sprite| sprite.dispose }
@usersprites.clear
end
def update
@@viewport3.tone.set(0, 0, 0, 0)
_animationSprite_update
for i in 0...@usersprites.length
@usersprites[i].update if !@usersprites[i].disposed?
end
@usersprites.each { |sprite| sprite.update if !sprite.disposed? }
end
end

View File

@@ -135,14 +135,14 @@ class Sprite_Character < RPG::Sprite
if character.is_a?(Game_Event) && shadows.length > 0
params = XPML_read(map, "Shadow", @character, 4)
if params != nil
for i in 0...shadows.size
@ombrelist.push(Sprite_Shadow.new(viewport, @character, shadows[i]))
shadows.each do |shadow|
@ombrelist.push(Sprite_Shadow.new(viewport, @character, shadows))
end
end
end
if character.is_a?(Game_Player) && shadows.length > 0
for i in 0...shadows.size
@ombrelist.push(Sprite_Shadow.new(viewport, $game_player, shadows[i]))
shadows.each do |shadow|
@ombrelist.push(Sprite_Shadow.new(viewport, $game_player, shadow))
end
end
update
@@ -157,11 +157,7 @@ class Sprite_Character < RPG::Sprite
def update
shadow_update
if @ombrelist.length > 0
for i in 0...@ombrelist.size
@ombrelist[i].update
end
end
@ombrelist.each { |ombre| ombre.update }
end
end
@@ -187,7 +183,7 @@ class Spriteset_Map
@shadows = []
warn = false
map = $game_map if !map
for k in map.events.keys.sort
map.events.keys.sort.each do |k|
ev = map.events[k]
warn = true if (ev.list != nil && ev.list.length > 0 &&
ev.list[0].code == 108 &&
@@ -199,7 +195,7 @@ class Spriteset_Map
p "Warning : At least one event on this map uses the obsolete way to add shadows"
end
shadow_initialize(map)
for sprite in @character_sprites
@character_sprites.each do |sprite|
sprite.setShadows(map, @shadows)
end
$scene.spritesetGlobal.playersprite.setShadows(map, @shadows)
@@ -230,11 +226,11 @@ end
def XPML_read(map, markup, event, max_param_number = 0)
parameter_list = nil
return nil if !event || event.list == nil
for i in 0...event.list.size
event.list.size.times do |i|
if event.list[i].code == 108 &&
event.list[i].parameters[0].downcase == "begin " + markup.downcase
parameter_list = [] if parameter_list == nil
for j in (i + 1)...event.list.size
((i + 1)...event.list.size).each do |j|
if event.list[j].code == 108
parts = event.list[j].parameters[0].split
if parts.size != 1 && parts[0].downcase != "begin"

View File

@@ -31,7 +31,7 @@ class Particle_Engine
def dispose
return if disposed?
for particle in @effect
@effect.each do |particle|
next if particle.nil?
particle.dispose
end
@@ -80,13 +80,12 @@ class Particle_Engine
def update
if @firsttime
@firsttime = false
for event in @map.events.values
@map.events.values.each do |event|
remove_effect(event)
add_effect(event)
end
end
for i in 0...@effect.length
particle = @effect[i]
@effect.each_with_index do |particle, i|
next if particle.nil?
if particle.event.pe_refresh
event = particle.event
@@ -217,7 +216,7 @@ class ParticleEffect_Event < ParticleEffect
@zoffset = zOffset
@bmwidth = 32
@bmheight = 32
for i in 0...@maxparticless
@maxparticless.times do |i|
@particlex[i] = -@xoffset
@particley[i] = -@yoffset
@particles[i] = ParticleSprite.new(@viewport)
@@ -275,7 +274,7 @@ class ParticleEffect_Event < ParticleEffect
end
end
particleZ = selfZ + @zoffset
for i in 0...@maxparticless
@maxparticless.times do |i|
@particles[i].z = particleZ
if @particles[i].y <= @ytop
@particles[i].y = @startingy + @yoffset
@@ -347,10 +346,10 @@ class ParticleEffect_Event < ParticleEffect
end
def dispose
for particle in @particles
@particles.each do |particle|
particle.dispose
end
for bitmap in @bitmaps.values
@bitmaps.values.each do |bitmap|
bitmap.dispose
end
@particles.clear
@@ -388,7 +387,7 @@ class Particle_Engine::Teleport < ParticleEffect_Event
setParameters([1, 1, 1, 10, rand(360), 1, -64,
Graphics.height, -64, Graphics.width, 0, 3, -8, -15, 20, 0])
initParticles("wideportal", 250)
for i in 0...@maxparticless
@maxparticless.times do |i|
@particles[i].ox = 16
@particles[i].oy = 16
end
@@ -447,7 +446,7 @@ class Particle_Engine::SootSmoke < ParticleEffect_Event
setParameters([0, 0, 0, 30, 0, 0.5, -64,
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80])
initParticles("smoke", 100, 0)
for i in 0...@maxparticless
@maxparticless.times do |i|
@particles[i].blend_type = rand(6) < 3 ? 1 : 2
end
end
@@ -472,7 +471,7 @@ class Particle_Engine::FixedTeleport < ParticleEffect_Event
setParameters([1, 0, 1, 10, rand(360), 1,
-Graphics.height, Graphics.height, 0, Graphics.width, 0, 3, -8, -15, 20, 0])
initParticles("wideportal", 250)
for i in 0...@maxparticless
@maxparticless.times do |i|
@particles[i].ox = 16
@particles[i].oy = 16
end
@@ -488,7 +487,7 @@ class Particle_Engine::StarTeleport < ParticleEffect_Event
setParameters([0, 0, 1, 10, 0, 1,
-Graphics.height, Graphics.height, 0, Graphics.width, 0, 3, -8, -15, 10, 0])
initParticles("star", 250)
for i in 0...@maxparticless
@maxparticless.times do |i|
@particles[i].ox = 48
@particles[i].oy = 48
end
@@ -503,7 +502,7 @@ class Particle_Engine::Smokescreen < ParticleEffect_Event
setParameters([0, 0, 0, 250, 0, 0.2, -64,
Graphics.height, -64, Graphics.width, 0.8, 0.8, -5, -15, 5, 80])
initParticles(nil, 100)
for i in 0...@maxparticless
@maxparticless.times do |i|
rnd = rand(3)
@opacity[i] = (rnd == 0) ? 1 : 100
filename = (rnd == 0) ? "explosionsmoke" : "smoke"
@@ -555,7 +554,7 @@ class Particle_Engine::Splash < ParticleEffect_Event
def update
super
for i in 0...@maxparticless
@maxparticless.times do |i|
@particles[i].opacity = 50
@particles[i].update
end

View File

@@ -142,7 +142,7 @@ class PictureEx
def totalDuration
ret = 0
for process in @processes
@processes.each do |process|
dur = process[1] + process[2]
ret = dur if dur > ret
end
@@ -186,7 +186,7 @@ class PictureEx
end
def adjustPosition(xOffset, yOffset)
for process in @processes
@processes.each do |process|
next if process[0] != Processes::XY
process[5] += xOffset
process[6] += yOffset
@@ -345,8 +345,7 @@ class PictureEx
def update
procEnded = false
@frameUpdates.clear
for i in 0...@processes.length
process = @processes[i]
@processes.each_with_index do |process, i|
# Decrease delay of processes that are scheduled to start later
if process[1] >= 0
# Set initial values if the process will start this frame
@@ -465,8 +464,8 @@ end
#===============================================================================
def setPictureSprite(sprite, picture, iconSprite = false)
return if picture.frameUpdates.length == 0
for i in 0...picture.frameUpdates.length
case picture.frameUpdates[i]
picture.frameUpdates.each do |type|
case type
when Processes::XY, Processes::DeltaXY
sprite.x = picture.x.round
sprite.y = picture.y.round

View File

@@ -25,7 +25,7 @@ class Interpolator
@frames = frames
@step = 0
@sprite = sprite
for item in items
items.each do |item|
case item[0]
when ZOOM_X
@tweensteps[item[0]] = [sprite.zoom_x, item[1] - sprite.zoom_x]
@@ -52,7 +52,7 @@ class Interpolator
def update
if @tweening
t = @step.to_f / @frames
for i in 0...@tweensteps.length
@tweensteps.length.times do |i|
item = @tweensteps[i]
next if !item
case i

View File

@@ -572,9 +572,9 @@ class TilemapRenderer
end_y = [end_y, map.height - map_display_y_tile - 1].min
next if start_x > end_x || start_y > end_y || end_x < 0 || end_y < 0
# Update all tile sprites representing this map
for i in start_x..end_x
(start_x..end_x).each do |i|
tile_x = i + map_display_x_tile
for j in start_y..end_y
(start_y..end_y).each do |j|
tile_y = j + map_display_y_tile
@tiles[i][j].each_with_index do |tile, layer|
tile_id = map.data[tile_x, tile_y, layer]

View File

@@ -60,7 +60,7 @@ class TileDrawingHelper
def self.fromTileset(tileset)
bmtileset = pbGetTileset(tileset.tileset_name)
bmautotiles = []
for i in 0...7
7.times do |i|
bmautotiles.push(pbGetAutotile(tileset.autotile_names[i]))
end
return self.new(bmtileset, bmautotiles)
@@ -81,8 +81,8 @@ class TileDrawingHelper
def dispose
@tileset.dispose if @tileset
@tileset = nil
for i in 0...@autotiles.length
@autotiles[i].dispose
@autotiles.each_with_index do |autotile, i|
autotile.dispose
@autotiles[i] = nil
end
end
@@ -102,7 +102,7 @@ class TileDrawingHelper
id %= 48
tiles = AUTOTILE_PATTERNS[id >> 3][id & 7]
src = Rect.new(0, 0, 0, 0)
for i in 0...4
4.times do |i|
tile_position = tiles[i] - 1
src.set((tile_position % 6 * 16) + anim, tile_position / 6 * 16, 16, 16)
bitmap.stretch_blt(Rect.new((i % 2 * cxTile) + x, (i / 2 * cyTile) + y, cxTile, cyTile),
@@ -155,9 +155,9 @@ def createMinimap(mapid)
tileset = tilesets[map.tileset_id]
return bitmap if !tileset
helper = TileDrawingHelper.fromTileset(tileset)
for y in 0...map.height
for x in 0...map.width
for z in 0..2
map.height.times do |y|
map.width.times do |x|
3.times do |z|
id = map.data[x, y, z]
id = 0 if !id
helper.bltSmallTile(bitmap, x * 4, y * 4, 4, 4, id)
@@ -178,7 +178,7 @@ def bltMinimapAutotile(dstBitmap, x, y, srcBitmap, id)
cyTile = 3
tiles = TileDrawingHelper::AUTOTILE_PATTERNS[id >> 3][id & 7]
src = Rect.new(0, 0, 0, 0)
for i in 0...4
4.times do |i|
tile_position = tiles[i] - 1
src.set((tile_position % 6 * cxTile) + anim,
tile_position / 6 * cyTile, cxTile, cyTile)
@@ -200,10 +200,10 @@ def getPassabilityMinimap(mapid)
ret = Bitmap.new(map.width * 6, map.height * 6)
passtable = Table.new(map.width, map.height)
passages = tileset.passages
for i in 0...map.width
for j in 0...map.height
map.width.times do |i|
map.height.times do |j|
pass = true
for z in [2, 1, 0]
[2, 1, 0].each do |z|
if !passable?(passages, map.data[i, j, z])
pass = false
break
@@ -213,8 +213,8 @@ def getPassabilityMinimap(mapid)
end
end
neighbors = TileDrawingHelper::NEIGHBORS_TO_AUTOTILE_INDEX
for i in 0...map.width
for j in 0...map.height
map.width.times do |i|
map.height.times do |j|
if passtable[i, j] == 0
nb = TileDrawingHelper.tableNeighbors(passtable, i, j)
tile = neighbors[nb]

View File

@@ -144,13 +144,13 @@ module MessageConfig
end
def self.pbTryFonts(*args)
for a in args
args.each do |a|
next if !a
case a
when String
return a if Font.exist?(a)
when Array
for aa in a
a.each do |aa|
ret = MessageConfig.pbTryFonts(aa)
return ret if ret != ""
end
@@ -455,14 +455,14 @@ end
def pbSetSpritesToColor(sprites, color)
return if !sprites || !color
colors = {}
for i in sprites
sprites.each do |i|
next if !i[1] || pbDisposed?(i[1])
colors[i[0]] = i[1].color.clone
i[1].color = pbSrcOver(i[1].color, color)
end
Graphics.update
Input.update
for i in colors
colors.each do |i|
next if !sprites[i[0]]
sprites[i[0]].color = i[1]
end
@@ -480,7 +480,7 @@ def using(window)
end
def pbUpdateSpriteHash(windows)
for i in windows
windows.each do |i|
window = i[1]
if window
if window.is_a?(Sprite) || window.is_a?(Window)
@@ -503,7 +503,7 @@ end
# Disposes all objects in the specified hash.
def pbDisposeSpriteHash(sprites)
return if !sprites
for i in sprites.keys
sprites.keys.each do |i|
pbDisposeSprite(sprites, i)
end
sprites.clear
@@ -552,7 +552,7 @@ def pbFadeOutIn(z = 99999, nofadeout = false)
viewport.z = z
numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil
for j in 0..numFrames
(0..numFrames).each do |j|
col.set(0, 0, 0, j * alphaDiff)
viewport.color = col
Graphics.update
@@ -566,7 +566,7 @@ def pbFadeOutIn(z = 99999, nofadeout = false)
ensure
pbPopFade
if !nofadeout
for j in 0..numFrames
(0..numFrames).each do |j|
col.set(0, 0, 0, (numFrames - j) * alphaDiff)
viewport.color = col
Graphics.update
@@ -583,7 +583,7 @@ def pbFadeOutInWithUpdate(z, sprites, nofadeout = false)
viewport.z = z
numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil
for j in 0..numFrames
(0..numFrames).each do |j|
col.set(0, 0, 0, j * alphaDiff)
viewport.color = col
pbUpdateSpriteHash(sprites)
@@ -596,7 +596,7 @@ def pbFadeOutInWithUpdate(z, sprites, nofadeout = false)
ensure
pbPopFade
if !nofadeout
for j in 0..numFrames
(0..numFrames).each do |j|
col.set(0, 0, 0, (numFrames - j) * alphaDiff)
viewport.color = col
pbUpdateSpriteHash(sprites)
@@ -629,12 +629,12 @@ def pbFadeOutAndHide(sprites)
numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil
pbDeactivateWindows(sprites) {
for j in 0..numFrames
(0..numFrames).each do |j|
pbSetSpritesToColor(sprites, Color.new(0, 0, 0, j * alphaDiff))
(block_given?) ? yield : pbUpdateSpriteHash(sprites)
end
}
for i in sprites
sprites.each do |i|
next if !i[1]
next if pbDisposed?(i[1])
visiblesprites[i[0]] = true if i[1].visible
@@ -645,7 +645,7 @@ end
def pbFadeInAndShow(sprites, visiblesprites = nil)
if visiblesprites
for i in visiblesprites
visiblesprites.each do |i|
if i[1] && sprites[i[0]] && !pbDisposed?(sprites[i[0]])
sprites[i[0]].visible = true
end
@@ -654,7 +654,7 @@ def pbFadeInAndShow(sprites, visiblesprites = nil)
numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil
pbDeactivateWindows(sprites) {
for j in 0..numFrames
(0..numFrames).each do |j|
pbSetSpritesToColor(sprites, Color.new(0, 0, 0, ((numFrames - j) * alphaDiff)))
(block_given?) ? yield : pbUpdateSpriteHash(sprites)
end
@@ -665,7 +665,7 @@ end
# _activeStatuses_ is the result of a previous call to pbActivateWindows
def pbRestoreActivations(sprites, activeStatuses)
return if !sprites || !activeStatuses
for k in activeStatuses.keys
activeStatuses.keys.each do |k|
if sprites[k] && sprites[k].is_a?(Window) && !pbDisposed?(sprites[k])
sprites[k].active = activeStatuses[k] ? true : false
end
@@ -688,7 +688,7 @@ end
def pbActivateWindow(sprites, key)
return if !sprites
activeStatuses = {}
for i in sprites
sprites.each do |i|
if i[1] && i[1].is_a?(Window) && !pbDisposed?(i[1])
activeStatuses[i[0]] = i[1].active
i[1].active = (i[0] == key)
@@ -723,7 +723,7 @@ def addBackgroundPlane(sprites, planename, background, viewport = nil)
sprites[planename].visible = false
else
sprites[planename].setBitmap(bitmapName)
for spr in sprites.values
sprites.values.each do |spr|
if spr.is_a?(Window)
spr.windowskin = nil
end
@@ -745,7 +745,7 @@ def addBackgroundOrColoredPlane(sprites, planename, background, color, viewport
else
sprites[planename] = AnimatedPlane.new(viewport)
sprites[planename].setBitmap(bitmapName)
for spr in sprites.values
sprites.values.each do |spr|
if spr.is_a?(Window)
spr.windowskin = nil
end
@@ -772,7 +772,7 @@ end
if !defined?(_INTL)
def _INTL(*args)
string = args[0].clone
for i in 1...args.length
(1...args.length).each do |i|
string.gsub!(/\{#{i}\}/, "#{args[i]}")
end
return string
@@ -782,7 +782,7 @@ end
if !defined?(_ISPRINTF)
def _ISPRINTF(*args)
string = args[0].clone
for i in 1...args.length
(1...args.length).each do |i|
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m|
next sprintf("%" + $1, args[i])
}
@@ -794,7 +794,7 @@ end
if !defined?(_MAPINTL)
def _MAPINTL(*args)
string = args[1].clone
for i in 2...args.length
(2...args.length).each do |i|
string.gsub!(/\{#{i}\}/, "#{args[i + 1]}")
end
return string

View File

@@ -89,7 +89,7 @@ class Window
@cursorbitmap = nil
@bgbitmap = nil
@viewport = viewport
for i in @spritekeys
@spritekeys.each do |i|
@sprites[i] = Sprite.new(@viewport)
end
@disposed = false
@@ -126,12 +126,12 @@ class Window
def dispose
if !self.disposed?
for i in @sprites
@sprites.each do |i|
i[1].dispose if i[1]
@sprites[i[0]] = nil
end
for i in 0...@sidebitmaps.length
@sidebitmaps[i].dispose if @sidebitmaps[i]
@sidebitmaps.each_with_index do |bitmap, i|
bitmap.dispose if bitmap
@sidebitmaps[i] = nil
end
@blankcontents.dispose
@@ -164,7 +164,7 @@ class Window
def viewport=(value)
@viewport = value
for i in @spritekeys
@spritekeys.each do |i|
@sprites[i].dispose
if @sprites[i].is_a?(Sprite)
@sprites[i] = Sprite.new(@viewport)
@@ -286,7 +286,7 @@ class Window
def flash(color, duration)
return if disposed?
for i in @sprites
@sprites.each do |i|
i[1].flash(color, duration)
end
end
@@ -313,7 +313,7 @@ class Window
mustchange = true
end
privRefresh if mustchange
for i in @sprites
@sprites.each do |i|
i[1].update
end
end
@@ -350,14 +350,14 @@ class Window
backopac = self.back_opacity * self.opacity / 255
contopac = self.contents_opacity
cursoropac = @cursoropacity * contopac / 255
for i in 0...4
4.times do |i|
@sprites["corner#{i}"].bitmap = @_windowskin
@sprites["scroll#{i}"].bitmap = @_windowskin
end
@sprites["pause"].bitmap = @_windowskin
@sprites["contents"].bitmap = @contents
if @_windowskin && !@_windowskin.disposed?
for i in 0...4
4.times do |i|
@sprites["corner#{i}"].opacity = @opacity
@sprites["corner#{i}"].tone = @tone
@sprites["corner#{i}"].color = @color
@@ -374,7 +374,7 @@ class Window
@sprites["scroll#{i}"].color = @color
@sprites["scroll#{i}"].visible = @visible
end
for i in ["back", "cursor", "pause", "contents"]
["back", "cursor", "pause", "contents"].each do |i|
@sprites[i].color = @color
@sprites[i].tone = @tone
@sprites[i].blend_type = @blend_type
@@ -396,7 +396,7 @@ class Window
@sprites["scroll3"].visible = @visible && hascontents &&
(@contents.height - @oy) > @height - 32
else
for i in 0...4
4.times do |i|
@sprites["corner#{i}"].visible = false
@sprites["side#{i}"].visible = false
@sprites["scroll#{i}"].visible = false
@@ -410,7 +410,7 @@ class Window
@sprites["pause"].visible = false
@sprites["cursor"].visible = false
end
for i in @sprites
@sprites.each do |i|
i[1].z = @z
end
if @rpgvx
@@ -540,7 +540,7 @@ class Window
@sprites["cursor"].visible = false
@sprites["cursor"].src_rect.set(0, 0, 0, 0)
end
for i in 0...4
4.times do |i|
dwidth = [0, 3].include?(i) ? @width - 32 : 16
dheight = [0, 3].include?(i) ? 16 : @height - 32
@sidebitmaps[i] = ensureBitmap(@sidebitmaps[i], dwidth, dheight)
@@ -573,7 +573,7 @@ class Window
end
if @openness != 255
opn = @openness / 255.0
for k in @spritekeys
@spritekeys.each do |k|
sprite = @sprites[k]
ratio = (@height <= 0) ? 0 : (sprite.y - @y) / @height.to_f
sprite.zoom_y = opn
@@ -581,14 +581,14 @@ class Window
sprite.y = (@y + (@height / 2.0) + (@height * ratio * opn) - (@height / 2 * opn)).floor
end
else
for k in @spritekeys
@spritekeys.each do |k|
sprite = @sprites[k]
sprite.zoom_y = 1.0
end
end
i = 0
# Ensure Z order
for k in @spritekeys
@spritekeys.each do |k|
sprite = @sprites[k]
y = sprite.y
sprite.y = i

View File

@@ -66,7 +66,7 @@ class SpriteWindow < Window
@sidebitmaps = [nil, nil, nil, nil]
@cursorbitmap = nil
@bgbitmap = nil
for i in @spritekeys
@spritekeys.each do |i|
@sprites[i] = Sprite.new(@viewport)
end
@disposed = false
@@ -112,12 +112,12 @@ class SpriteWindow < Window
def dispose
if !self.disposed?
for i in @sprites
@sprites.each do |i|
i[1].dispose if i[1]
@sprites[i[0]] = nil
end
for i in 0...@sidebitmaps.length
@sidebitmaps[i].dispose if @sidebitmaps[i]
@sidebitmaps.each_with_index do |bitmap, i|
bitmap.dispose if bitmap
@sidebitmaps[i] = nil
end
@blankcontents.dispose
@@ -142,7 +142,7 @@ class SpriteWindow < Window
def viewport=(value)
@viewport = value
for i in @spritekeys
@spritekeys.each do |i|
@sprites[i].dispose if @sprites[i]
if @sprites[i].is_a?(Sprite)
@sprites[i] = Sprite.new(@viewport)
@@ -288,7 +288,7 @@ class SpriteWindow < Window
def flash(color, duration)
return if disposed?
@flash = duration + 1
for i in @sprites
@sprites.each do |i|
i[1].flash(color, duration)
end
end
@@ -317,7 +317,7 @@ class SpriteWindow < Window
end
privRefresh if mustchange
if @flash > 0
for i in @sprites.values
@sprites.values.each do |i|
i.update
end
@flash -= 1
@@ -477,14 +477,14 @@ class SpriteWindow < Window
contopac = self.contents_opacity
cursoropac = @cursoropacity * contopac / 255
haveskin = @_windowskin && !@_windowskin.disposed?
for i in 0...4
4.times do |i|
@sprites["corner#{i}"].bitmap = @_windowskin
@sprites["scroll#{i}"].bitmap = @_windowskin
end
@sprites["pause"].bitmap = @_windowskin
@sprites["contents"].bitmap = @contents
if haveskin
for i in 0...4
4.times do |i|
@sprites["corner#{i}"].opacity = @opacity
@sprites["corner#{i}"].tone = @tone
@sprites["corner#{i}"].color = @color
@@ -501,7 +501,7 @@ class SpriteWindow < Window
@sprites["scroll#{i}"].visible = @visible
@sprites["scroll#{i}"].blend_type = @blend_type
end
for i in ["back", "cursor", "pause", "contents"]
["back", "cursor", "pause", "contents"].each do |i|
@sprites[i].color = @color
@sprites[i].tone = @tone
@sprites[i].blend_type = @blend_type
@@ -524,7 +524,7 @@ class SpriteWindow < Window
@sprites["scroll2"].visible = false
@sprites["scroll3"].visible = false
else
for i in 0...4
4.times do |i|
@sprites["corner#{i}"].visible = false
@sprites["side#{i}"].visible = false
@sprites["scroll#{i}"].visible = false
@@ -538,7 +538,7 @@ class SpriteWindow < Window
@sprites["pause"].visible = false
@sprites["cursor"].visible = false
end
for i in @spritekeys
@spritekeys.each do |i|
@sprites[i].z = @z
end
if (@compat & CompatBits::CorrectZ) > 0 && @skinformat == 0 && !@rpgvx
@@ -725,7 +725,7 @@ class SpriteWindow < Window
@sprites["cursor"].src_rect.set(0, 0, 0, 0)
end
end
for i in 0..3
4.times do |i|
case i
when 0
dwidth = @width - startX - endX
@@ -783,7 +783,7 @@ class SpriteWindow < Window
end
if @openness != 255
opn = @openness / 255.0
for k in @spritekeys
@spritekeys.each do |k|
sprite = @sprites[k]
ratio = (@height <= 0) ? 0 : (sprite.y - @y) / @height.to_f
sprite.zoom_y = opn
@@ -792,7 +792,7 @@ class SpriteWindow < Window
sprite.y = (@y + (@height / 2.0) + (@height * ratio * opn) - (@height / 2 * opn)).floor
end
else
for k in @spritekeys
@spritekeys.each do |k|
sprite = @sprites[k]
sprite.zoom_x = 1.0
sprite.zoom_y = 1.0
@@ -800,7 +800,7 @@ class SpriteWindow < Window
end
i = 0
# Ensure Z order
for k in @spritekeys
@spritekeys.each do |k|
sprite = @sprites[k]
y = sprite.y
sprite.y = i

View File

@@ -235,7 +235,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
cwidth = (maxwidth < 0) ? Graphics.width : maxwidth
chars = getFormattedTextForDims(self.contents, 0, 0,
cwidth - self.borderX - 2 - 6, -1, text, @lineHeight, true)
for ch in chars
chars.each do |ch|
dims[0] = [dims[0], ch[1] + ch[3]].max
dims[1] = [dims[1], ch[2] + ch[4]].max
end
@@ -312,7 +312,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
self.width - self.borderX - SpriteWindow_Base::TEXTPADDING, -1,
shadowctag(@baseColor, @shadowColor) + value, 32, true)
@oldfont = self.contents.font.clone
for ch in fmt
fmt.each do |ch|
chx = ch[1] + ch[3]
chy = ch[2] + ch[4]
width = chx if width < chx
@@ -340,7 +340,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
self.width - self.borderX - SpriteWindow_Base::TEXTPADDING, -1,
shadowctag(@baseColor, @shadowColor) + value, 32, true)
@oldfont = self.contents.font.clone
for ch in @fmtchars
@fmtchars.each do |ch|
chx = ch[1] + ch[3]
chy = ch[2] + ch[4]
width = chx if width < chx
@@ -390,7 +390,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
def maxPosition
pos = 0
for ch in @fmtchars
@fmtchars.each do |ch|
# index after the last character's index
pos = ch[14] + 1 if pos < ch[14] + 1
end
@@ -481,7 +481,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
end
maxX = self.width - self.borderX
maxY = self.height - self.borderY
for i in @drawncurchar + 1..numchars
(@drawncurchar + 1..numchars).each do |i|
next if i >= @fmtchars.length
if !self.letterbyletter
next if @fmtchars[i][1] >= maxX
@@ -667,7 +667,7 @@ class Window_InputNumberPokemon < SpriteWindow_Base
if @sign
textHelper(0, 0, @negative ? "-" : "+", 0)
end
for i in 0...@digits_max
@digits_max.times do |i|
index = i + (@sign ? 1 : 0)
textHelper(index * 24, 0, s[i, 1], index)
end
@@ -1084,7 +1084,7 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx
width = 0
tmpbitmap = BitmapWrapper.new(1, 1)
pbSetSystemFont(tmpbitmap)
for i in commands
commands.each do |i|
width = [width, tmpbitmap.text_size(i).width].max
end
# one 16 to allow cursor
@@ -1125,7 +1125,7 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx
dheight = self.height - self.borderY
self.contents = pbDoEnsureBitmap(self.contents, dwidth, dheight)
self.contents.clear
for i in 0...@item_max
@item_max.times do |i|
next if i < self.top_item || i > self.top_item + self.page_item_max
drawItem(i, @item_max, itemRect(i))
end
@@ -1250,7 +1250,7 @@ class Window_AdvancedCommandPokemon < Window_DrawableCommand
chars = getFormattedText(bitmap, 0, 0,
Graphics.width - self.borderX - SpriteWindow_Base::TEXTPADDING - 16,
-1, text, self.rowHeight, true, true)
for ch in chars
chars.each do |ch|
dims[0] = dims[0] ? [dims[0], ch[1]].min : ch[1]
dims[1] = [dims[1], ch[1] + ch[3]].max
end

View File

@@ -57,7 +57,7 @@ class PngAnimatedBitmap
end
@frameDelay = delay
subWidth = panorama.width / numFrames
for i in 0...numFrames
numFrames.times do |i|
subBitmap = BitmapWrapper.new(subWidth, panorama.height)
subBitmap.blt(0, 0, panorama, Rect.new(subWidth * i, 0, subWidth, panorama.height))
@frames.push(subBitmap)
@@ -76,7 +76,7 @@ class PngAnimatedBitmap
def height; self.bitmap.height; end
def deanimate
for i in 1...@frames.length
(1...@frames.length).each do |i|
@frames[i].dispose
end
@frames = [@frames[0]]
@@ -134,9 +134,7 @@ class PngAnimatedBitmap
def copy
x = self.clone
x.frames = x.frames.clone
for i in 0...x.frames.length
x.frames[i] = x.frames[i].copy
end
x.frames.each_with_index { |frame, i| x.frames[i] = frame.copy }
return x
end
end

View File

@@ -238,7 +238,7 @@ def getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheig
lastword[0] += 1
y += 1
x = 0
for i in lastword[0]...characters.length
(lastword[0]...characters.length).each do |i|
characters[i][2] += lineheight
charwidth = characters[i][3] - 2
characters[i][1] = x
@@ -251,12 +251,12 @@ def getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheig
# Eliminate spaces before newlines and pause character
if havenl
firstspace = -1
for i in 0...characters.length
characters.length.times do |i|
if characters[i][5] != false # If not a character
firstspace = -1
elsif (characters[i][0] == "\n" || isWaitChar(characters[i][0])) &&
firstspace >= 0
for j in firstspace...i
(firstspace...i).each do |j|
characters[j] = nil
end
firstspace = -1
@@ -267,21 +267,17 @@ def getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheig
end
end
if firstspace > 0
for j in firstspace...characters.length
(firstspace...characters.length).each do |j|
characters[j] = nil
end
end
characters.compact!
end
for i in 0...characters.length
characters[i][1] = xDst + characters[i][1]
end
characters.each { |char| char[1] = xDst + char[1] }
# Remove all characters with Y greater or equal to _yDst_+_heightDst_
if heightDst >= 0
for i in 0...characters.length
if characters[i][2] >= yDst + heightDst
characters[i] = nil
end
characters.each_with_index do |char, i|
characters[i] = nil if char[2] >= yDst + heightDst
end
characters.compact!
end
@@ -397,7 +393,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
end
textchunks = []
controls = []
oldtext = text
# oldtext = text
while text[FORMATREGEXP]
textchunks.push($~.pre_match)
if $~[3]
@@ -424,7 +420,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
# realtextStart = oldtext[0, oldtext.length - realtext.length]
# end
textchunks.push(text)
for chunk in textchunks
textchunks.each do |chunk|
chunk.gsub!(/&lt;/, "<")
chunk.gsub!(/&gt;/, ">")
chunk.gsub!(/&apos;/, "'")
@@ -432,9 +428,9 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
chunk.gsub!(/&amp;/, "&")
end
textlen = 0
for i in 0...controls.length
controls.each_with_index do |control, i|
textlen += textchunks[i].scan(/./m).length
controls[i][2] = textlen
control[2] = textlen
end
text = textchunks.join("")
textchars = text.scan(/./m)
@@ -475,7 +471,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
graphicWidth = nil
graphicHeight = nil
graphicRect = nil
for i in 0...controls.length
controls.length.times do |i|
if controls[i] && controls[i][2] == position
control = controls[i][0]
param = controls[i][1]
@@ -694,7 +690,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
lastword[0] += 1
y += 1
x = 0
for i in lastword[0]...characters.length
(lastword[0]...characters.length).each do |i|
characters[i][2] += lineheight
charactersInternal[i][1] += 1
extraspace = (charactersInternal[i][4]) ? charactersInternal[i][4] : 0
@@ -754,12 +750,12 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
if havenl
# Eliminate spaces before newlines and pause character
firstspace = -1
for i in 0...characters.length
characters.length.times do |i|
if characters[i][5] != false # If not a character
firstspace = -1
elsif (characters[i][0] == "\n" || isWaitChar(characters[i][0])) &&
firstspace >= 0
for j in firstspace...i
(firstspace...i).each do |j|
characters[j] = nil
charactersInternal[j] = nil
end
@@ -773,7 +769,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
end
end
if firstspace > 0
for j in firstspace...characters.length
(firstspace...characters.length).each do |j|
characters[j] = nil
charactersInternal[j] = nil
end
@@ -788,7 +784,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
lastalign = 0
lasty = 0
runstart = 0
for i in 0...characters.length
characters.length.times do |i|
c = characters[i]
if i > 0 && (charactersInternal[i][0] != lastalign ||
charactersInternal[i][1] != lasty)
@@ -806,7 +802,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
if collapseAlignments
# Calculate the total width of each line
totalLineWidths = []
for block in widthblocks
widthblocks.each do |block|
y = block[4]
if !totalLineWidths[y]
totalLineWidths[y] = 0
@@ -821,9 +817,9 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
widthDst = [widthDst, (totalLineWidths.compact.max || 0)].min
end
# Now, based on the text runs found, recalculate Xs
for block in widthblocks
widthblocks.each do |block|
next if block[0] >= block[1]
for i in block[0]...block[1]
(block[0]...block[1]).each do |i|
case block[2]
when 1 then characters[i][1] = xDst + (widthDst - block[3] - 4) + characters[i][1]
when 2 then characters[i][1] = xDst + ((widthDst / 2) - (block[3] / 2)) + characters[i][1]
@@ -874,7 +870,7 @@ def getLineBrokenText(bitmap, value, width, dims)
next
end
words = [ccheck]
for i in 0...words.length
words.length.times do |i|
word = words[i]
if word && word != ""
textSize = bitmap.text_size(word)
@@ -929,7 +925,7 @@ def getLineBrokenChunks(bitmap, value, width, dims, plain = false)
else
words = [ccheck]
end
for i in 0...words.length
words.length.times do |i|
word = words[i]
if word && word != ""
textSize = bitmap.text_size(word)
@@ -955,25 +951,25 @@ def getLineBrokenChunks(bitmap, value, width, dims, plain = false)
end
def renderLineBrokenChunks(bitmap, xDst, yDst, normtext, maxheight = 0)
for i in 0...normtext.length
width = normtext[i][3]
textx = normtext[i][1] + xDst
texty = normtext[i][2] + yDst
if maxheight == 0 || normtext[i][2] < maxheight
bitmap.font.color = normtext[i][5]
bitmap.draw_text(textx, texty, width + 2, normtext[i][4], normtext[i][0])
normtext.each do |text|
width = text[3]
textx = text[1] + xDst
texty = text[2] + yDst
if maxheight == 0 || text[2] < maxheight
bitmap.font.color = text[5]
bitmap.draw_text(textx, texty, width + 2, text[4], text[0])
end
end
end
def renderLineBrokenChunksWithShadow(bitmap, xDst, yDst, normtext, maxheight, baseColor, shadowColor)
for i in 0...normtext.length
width = normtext[i][3]
textx = normtext[i][1] + xDst
texty = normtext[i][2] + yDst
if maxheight == 0 || normtext[i][2] < maxheight
height = normtext[i][4]
text = normtext[i][0]
normtext.each do |text|
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)
@@ -987,7 +983,7 @@ end
def drawBitmapBuffer(chars)
width = 1
height = 1
for ch in chars
chars.each do |ch|
chx = ch[1] + ch[3]
chy = ch[2] + ch[4]
width = chx if width < chx
@@ -1057,7 +1053,7 @@ end
def drawFormattedChars(bitmap, chars)
return if chars.length == 0 || !bitmap || bitmap.disposed?
oldfont = bitmap.font.clone
for ch in chars
chars.each do |ch|
drawSingleFormattedChar(bitmap, ch)
end
bitmap.font = oldfont
@@ -1066,10 +1062,10 @@ end
# Unused
def drawTextTable(bitmap, x, y, totalWidth, rowHeight, columnWidthPercents, table)
yPos = y
for i in 0...table.length
table.length.times do |i|
row = table[i]
xPos = x
for j in 0...row.length
row.length.times do |j|
cell = row[j]
cellwidth = columnWidthPercents[j] * totalWidth / 100
chars = getFormattedText(bitmap, xPos, yPos, cellwidth, -1, cell, rowHeight)
@@ -1149,7 +1145,7 @@ end
# 5 - Shadow color
# 6 - If true or 1, the text has an outline. Otherwise, the text has a shadow.
def pbDrawTextPositions(bitmap, textpos)
for i in textpos
textpos.each do |i|
textsize = bitmap.text_size(i[0])
x = i[1]
y = i[2] + 6
@@ -1178,7 +1174,7 @@ def pbCopyBitmap(dstbm, srcbm, x, y, opacity = 255)
end
def pbDrawImagePositions(bitmap, textpos)
for i in textpos
textpos.each do |i|
srcbitmap = AnimatedBitmap.new(pbBitmapName(i[0]))
x = i[1]
y = i[2]

View File

@@ -28,12 +28,12 @@ def pbEventCommentInput(*args)
trigger = args[2] # Trigger
return nil if list == nil
return nil unless list.is_a?(Array)
for item in list
list.each do |item|
next unless item.code == 108 || item.code == 408
if item.parameters[0] == trigger
start = list.index(item) + 1
finish = start + elements
for id in start...finish
(start...finish).each do |id|
next if !list[id]
parameters.push(list[id].parameters[0])
end
@@ -225,8 +225,7 @@ class FaceWindowVX < SpriteWindow_Base
@facebitmaptmp = AnimatedBitmap.new(facefile)
@facebitmap = BitmapWrapper.new(96, 96)
@facebitmap.blt(0, 0, @facebitmaptmp.bitmap,
Rect.new((@faceIndex % 4) * 96, (@faceIndex / 4) * 96, 96, 96)
)
Rect.new((@faceIndex % 4) * 96, (@faceIndex / 4) * 96, 96, 96))
self.contents = @facebitmap
end
@@ -235,8 +234,7 @@ class FaceWindowVX < SpriteWindow_Base
if @facebitmaptmp.totalFrames > 1
@facebitmaptmp.update
@facebitmap.blt(0, 0, @facebitmaptmp.bitmap,
Rect.new((@faceIndex % 4) * 96, (@faceIndex / 4) * 96, 96, 96)
)
Rect.new((@faceIndex % 4) * 96, (@faceIndex / 4) * 96, 96, 96))
end
end
@@ -504,11 +502,11 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
text = $~.post_match
end
textchunks.push(text)
for chunk in textchunks
textchunks.each do |chunk|
chunk.gsub!(/\005/, "\\")
end
textlen = 0
for i in 0...controls.length
controls.length.times do |i|
control = controls[i][0]
case control
when "wt", "wtnp", ".", "|"
@@ -524,7 +522,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
signWaitTime = Graphics.frame_rate / 2
haveSpecialClose = false
specialCloseSE = ""
for i in 0...controls.length
controls.length.times do |i|
control = controls[i][0]
param = controls[i][1]
case control
@@ -582,7 +580,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
msgwindow.y = Graphics.height - (msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime)
end
end
for i in 0...controls.length
controls.length.times do |i|
next if !controls[i]
next if controls[i][2] > msgwindow.position || msgwindow.waitcount != 0
control = controls[i][0]
@@ -686,7 +684,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
if haveSpecialClose
pbSEPlay(pbStringToAudioFile(specialCloseSE))
atTop = (msgwindow.y == 0)
for i in 0..signWaitTime
(0..signWaitTime).each do |i|
if atTop
msgwindow.y = -msgwindow.height * i / signWaitTime
else

View File

@@ -41,7 +41,7 @@ class CharacterEntryHelper
return false if @maxlength >= 0 && chars.length >= @maxlength
chars.insert(@cursor, ch)
@text = ""
for ch in chars
chars.each do |ch|
@text += ch if ch
end
@cursor += 1
@@ -59,7 +59,7 @@ class CharacterEntryHelper
return false if chars.length <= 0 || @cursor <= 0
chars.delete_at(@cursor - 1)
@text = ""
for ch in chars
chars.each do |ch|
@text += ch if ch
end
@cursor -= 1
@@ -75,7 +75,7 @@ class CharacterEntryHelper
chars = chars[0, @maxlength]
end
@text = ""
for ch in chars
chars.each do |ch|
@text += ch if ch
end
end
@@ -198,7 +198,7 @@ class Window_TextEntry < SpriteWindow_Base
break if fromcursor > width - 4
startpos -= 1
end
for i in startpos...scanlength
(startpos...scanlength).each do |i|
c = (@helper.passwordChar != "") ? @helper.passwordChar : textscan[i]
textwidth = bitmap.text_size(c).width
next if c == "\n"
@@ -352,9 +352,9 @@ class Window_MultilineTextEntry < SpriteWindow_Base
line = 0 if line < 0
line = totallines - 1 if line >= totallines
maximumY = 0
for i in 0...textchars.length
thisline = textchars[i][5]
y = textchars[i][2]
textchars.each do |text|
thisline = text[5]
y = text[2]
return y if thisline == line
maximumY = y if maximumY < y
end
@@ -368,9 +368,9 @@ class Window_MultilineTextEntry < SpriteWindow_Base
line = 0 if line < 0
line = totallines - 1 if line >= totallines
endpos = 0
for i in 0...textchars.length
thisline = textchars[i][5]
thislength = textchars[i][8]
textchars.each do |text|
thisline = text[5]
thislength = text[8]
endpos += thislength if thisline == line
end
return endpos
@@ -383,11 +383,11 @@ class Window_MultilineTextEntry < SpriteWindow_Base
line = 0 if line < 0
line = totallines - 1 if line >= totallines
endpos = 0
for i in 0...textchars.length
thisline = textchars[i][5]
thispos = textchars[i][6]
thiscolumn = textchars[i][7]
thislength = textchars[i][8]
textchars.each do |text|
thisline = text[5]
thispos = text[6]
thiscolumn = text[7]
thislength = text[8]
if thisline == line
endpos = thispos + thislength
# echoln [endpos,thispos+(column-thiscolumn),textchars[i]]
@@ -510,40 +510,40 @@ class Window_MultilineTextEntry < SpriteWindow_Base
cursorcolor = Color.new(0, 0, 0)
textchars = getTextChars
startY = getLineY(@firstline)
for i in 0...textchars.length
thisline = textchars[i][5]
thiscolumn = textchars[i][7]
thislength = textchars[i][8]
textY = textchars[i][2] - startY
textchars.each do |text|
thisline = text[5]
thiscolumn = text[7]
thislength = text[8]
textY = text[2] - startY
# Don't draw lines before the first or zero-length segments
next if thisline < @firstline || thislength == 0
# Don't draw lines beyond the window's height
break if textY >= height
c = textchars[i][0]
c = text[0]
# Don't draw spaces
next if c == " "
textwidth = textchars[i][3] + 4 # add 4 to prevent draw_text from stretching text
textheight = textchars[i][4]
textwidth = text[3] + 4 # add 4 to prevent draw_text from stretching text
textheight = text[4]
# Draw text
pbDrawShadowText(bitmap, textchars[i][1], textY, textwidth, textheight, c, @baseColor, @shadowColor)
pbDrawShadowText(bitmap, text[1], textY, textwidth, textheight, c, @baseColor, @shadowColor)
end
# Draw cursor
if ((@frame / 10) & 1) == 0
textheight = bitmap.text_size("X").height
cursorY = (textheight * @cursorLine) - startY
cursorX = 0
for i in 0...textchars.length
thisline = textchars[i][5]
thiscolumn = textchars[i][7]
thislength = textchars[i][8]
textchars.each do |text|
thisline = text[5]
thiscolumn = text[7]
thislength = text[8]
if thisline == @cursorLine && @cursorColumn >= thiscolumn &&
@cursorColumn <= thiscolumn + thislength
cursorY = textchars[i][2] - startY
cursorX = textchars[i][1]
textheight = textchars[i][4]
cursorY = text[2] - startY
cursorX = text[1]
textheight = text[4]
posToCursor = @cursorColumn - thiscolumn
if posToCursor >= 0
partialString = textchars[i][0].scan(/./m)[0, posToCursor].join("")
partialString = text[0].scan(/./m)[0, posToCursor].join("")
cursorX += bitmap.text_size(partialString).width
end
break

View File

@@ -4,7 +4,7 @@
$AtExitProcs = [] if !$AtExitProcs
def exit(code = 0)
for p in $AtExitProcs
$AtExitProcs.each do |p|
p.call
end
raise SystemExit.new(code)
@@ -51,7 +51,7 @@ def oggfiletime(file)
i = -1
pcmlengths = []
rates = []
for page in pages
pages.each do |page|
header = page[0]
serial = header[10, 4].unpack("V")
frame = header[2, 8].unpack("C*")
@@ -78,9 +78,7 @@ def oggfiletime(file)
pcmlengths[i] = frameno
end
ret = 0.0
for i in 0...pcmlengths.length
ret += pcmlengths[i].to_f / rates[i]
end
pcmlengths.each_with_index { |length, i| ret += length.to_f / rates[i] }
return ret * 256.0
end

View File

@@ -176,8 +176,8 @@ module Transitions
# Overworld sprites
sprite_width = @overworld_bitmap.width / NUM_SPRITES_X
sprite_height = @overworld_bitmap.height / NUM_SPRITES_Y
for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X
NUM_SPRITES_Y.times do |j|
NUM_SPRITES_X.times do |i|
idx_sprite = (j * NUM_SPRITES_X) + i
@sprites[idx_sprite] = new_sprite(i * sprite_width, j * sprite_height, @overworld_bitmap)
@sprites[idx_sprite].src_rect.set(i * sprite_width, j * sprite_height, sprite_width, sprite_height)
@@ -187,8 +187,8 @@ module Transitions
def set_up_timings
@start_y = []
for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X
NUM_SPRITES_Y.times do |j|
NUM_SPRITES_X.times do |i|
idx_sprite = (j * NUM_SPRITES_X) + i
@start_y[idx_sprite] = @sprites[idx_sprite].y
@timings[idx_sprite] = 0.5 + rand
@@ -217,8 +217,8 @@ module Transitions
# Overworld sprites
sprite_width = @overworld_bitmap.width / NUM_SPRITES_X
sprite_height = @overworld_bitmap.height / NUM_SPRITES_Y
for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X
NUM_SPRITES_Y.times do |j|
NUM_SPRITES_X.times do |i|
idx_sprite = (j * NUM_SPRITES_X) + i
@sprites[idx_sprite] = new_sprite((i + 0.5) * sprite_width, (j + 0.5) * sprite_height,
@overworld_bitmap, sprite_width / 2, sprite_height / 2)
@@ -256,8 +256,8 @@ module Transitions
# Overworld sprites
sprite_width = @overworld_bitmap.width / NUM_SPRITES_X
sprite_height = @overworld_bitmap.height / NUM_SPRITES_Y
for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X
NUM_SPRITES_Y.times do |j|
NUM_SPRITES_X.times do |i|
idx_sprite = (j * NUM_SPRITES_X) + i
@sprites[idx_sprite] = new_sprite((i + 0.5) * sprite_width, (j + 0.5) * sprite_height,
@overworld_bitmap, sprite_width / 2, sprite_height / 2)
@@ -270,8 +270,8 @@ module Transitions
@start_positions = []
@move_vectors = []
vague = (@parameters[0] || 9.6) * SPEED
for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X
NUM_SPRITES_Y.times do |j|
NUM_SPRITES_X.times do |i|
idx_sprite = (j * NUM_SPRITES_X) + i
spr = @sprites[idx_sprite]
@start_positions[idx_sprite] = [spr.x, spr.y]
@@ -329,8 +329,8 @@ module Transitions
num_stripes_x = 1
num_stripes_y = @overworld_bitmap.height / STRIPE_WIDTH
end
for j in 0...num_stripes_y
for i in 0...num_stripes_x
num_stripes_y.times do |j|
num_stripes_x.times do |i|
idx_sprite = (j * num_stripes_x) + i
@sprites[idx_sprite] = new_sprite(i * sprite_width, j * sprite_height, @overworld_bitmap)
@sprites[idx_sprite].src_rect.set(i * sprite_width, j * sprite_height, sprite_width, sprite_height)
@@ -339,7 +339,7 @@ module Transitions
end
def set_up_timings
for i in 0...@sprites.length
@sprites.length.times do |i|
@timings[i] = @duration * i / @sprites.length
end
@timings.shuffle!
@@ -464,8 +464,8 @@ module Transitions
end
def initialize_sprites
for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X
NUM_SPRITES_Y.times do |j|
NUM_SPRITES_X.times do |i|
idx_sprite = (j * NUM_SPRITES_X) + i
if idx_sprite >= TOTAL_SPRITES / 2
sprite_x = ((j.odd?) ? i : (NUM_SPRITES_X - i - 1)) * @black_bitmap.width
@@ -483,8 +483,8 @@ module Transitions
def set_up_timings
time_between_zooms = (@duration - TIME_TO_ZOOM) * 2 / (TOTAL_SPRITES - 1)
for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X
NUM_SPRITES_Y.times do |j|
NUM_SPRITES_X.times do |i|
idx_sprite = (j * NUM_SPRITES_X) + i
idx_from_start = (idx_sprite >= TOTAL_SPRITES / 2) ? TOTAL_SPRITES - 1 - idx_sprite : idx_sprite
@timings[idx_sprite] = time_between_zooms * idx_from_start
@@ -532,8 +532,8 @@ module Transitions
end
def initialize_sprites
for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X
NUM_SPRITES_Y.times do |j|
NUM_SPRITES_X.times do |i|
idx_sprite = (j * NUM_SPRITES_X) + i
@sprites[idx_sprite] = new_sprite(((i * @bitmap.width) + (@bitmap.width / 2)) * @zoom_x_target,
((j * @bitmap.height) + (@bitmap.height / 2)) * @zoom_y_target,
@@ -544,8 +544,8 @@ module Transitions
end
def set_up_timings
for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X
NUM_SPRITES_Y.times do |j|
NUM_SPRITES_X.times do |i|
idx_from_start = (j * NUM_SPRITES_X) + i # Top left -> bottom right
case @parameters[0] # Origin
when 1 # Top right -> bottom left
@@ -603,7 +603,7 @@ module Transitions
@overworld_sprite.visible = false
# Overworld strips (they go all wavy)
rect = Rect.new(0, 0, Graphics.width, 2)
for i in 0...Graphics.height / 2
(Graphics.height / 2).times do |i|
@sprites[i] = new_sprite(0, i * 2, @overworld_bitmap)
@sprites[i].z = 2
rect.y = i * 2
@@ -679,7 +679,7 @@ module Transitions
@overworld_sprite.oy = @overworld_bitmap.height / 2
# Balls that roll across the screen
@ball_sprites = []
for i in 0...2
2.times do |i|
x = ((1 - i) * Graphics.width) + ((1 - (i * 2)) * @ball_bitmap.width / 2)
y = (Graphics.height + (((i * 2) - 1) * @ball_bitmap.width)) / 2
@ball_sprites[i] = new_sprite(x, y, @ball_bitmap,
@@ -687,7 +687,7 @@ module Transitions
@ball_sprites[i].z = 2
end
# Black foreground sprites
for i in 0...2
2.times do |i|
@sprites[i] = new_sprite((1 - (i * 2)) * Graphics.width, i * Graphics.height / 2, @black_bitmap)
@sprites[i].z = 1
end
@@ -756,7 +756,7 @@ module Transitions
@overworld_sprites = []
@black_sprites = []
@ball_sprites = []
for i in 0...2
2.times do |i|
# Overworld sprites (they split apart)
@overworld_sprites[i] = new_sprite(Graphics.width / 2, Graphics.height / 2, @overworld_bitmap,
Graphics.width / 2, (1 - i) * Graphics.height / 2)
@@ -857,8 +857,8 @@ module Transitions
@overworld_sprite.ox = @overworld_bitmap.width / 2
@overworld_sprite.oy = @overworld_bitmap.height / 2
# Black squares
for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X
NUM_SPRITES_Y.times do |j|
NUM_SPRITES_X.times do |i|
idx_sprite = (j * NUM_SPRITES_X) + i
@sprites[idx_sprite] = new_sprite(i * @black_bitmap.width * @zoom_x_target,
j * @black_bitmap.height * @zoom_y_target, @black_bitmap)
@@ -867,7 +867,7 @@ module Transitions
end
# Falling balls
@ball_sprites = []
for i in 0...3
3.times do |i|
@ball_sprites[i] = new_sprite((Graphics.width / 2) + ((i - 1) * 160),
-@ball_bitmap.height - BALL_START_Y_OFFSETS[i],
@ball_bitmap, @ball_bitmap.width / 2, @ball_bitmap.height / 2)
@@ -879,9 +879,9 @@ module Transitions
@black_appear_start = @duration * 0.2
appear_order = [0, 4, 1, 6, 7, 2, 5, 3]
period = @duration - @black_appear_start
for j in 0...NUM_SPRITES_Y
NUM_SPRITES_Y.times do |j|
row_offset = NUM_SPRITES_Y - j - 1
for i in 0...NUM_SPRITES_X
NUM_SPRITES_X.times do |i|
idx_sprite = (j * NUM_SPRITES_X) + i
@timings[idx_sprite] = period * ((row_offset * NUM_SPRITES_X) + appear_order[i]) / TOTAL_SPRITES
@timings[idx_sprite] += @black_appear_start
@@ -1015,7 +1015,7 @@ module Transitions
@overworld_sprite.visible = false
# Overworld strips (they go all wavy)
rect = Rect.new(0, 0, Graphics.width, 4)
for i in 0...Graphics.height / 4
(Graphics.height / 4).times do |i|
@sprites[i] = new_sprite(0, i * 4, @overworld_bitmap)
@sprites[i].z = 2
rect.y = i * 4
@@ -1023,7 +1023,7 @@ module Transitions
end
# Ball sprites
@ball_sprites = []
for i in 0...3
3.times do |i|
@ball_sprites[i] = new_sprite(((2 * i) + 1) * Graphics.width / 6,
BALL_OFFSETS[i] * Graphics.height,
@ball_bitmap, @ball_bitmap.width / 2, @ball_bitmap.height / 2)
@@ -1031,7 +1031,7 @@ module Transitions
end
# Black columns that follow the ball sprites
@black_trail_sprites = []
for i in 0...3
3.times do |i|
@black_trail_sprites[i] = new_sprite((i - 1) * Graphics.width * 2 / 3,
BALL_OFFSETS[i] * Graphics.height, @black_bitmap)
@black_trail_sprites[i].z = 3
@@ -1096,7 +1096,7 @@ module Transitions
@overworld_sprite.visible = false
# Overworld strips (they go all wavy)
rect = Rect.new(0, 0, Graphics.width, 4)
for i in 0...Graphics.height / 4
(Graphics.height / 4).times do |i|
@sprites[i] = new_sprite(0, i * 4, @overworld_bitmap)
@sprites[i].z = 2
rect.y = i * 4
@@ -1172,13 +1172,13 @@ module Transitions
def initialize_sprites
# Ball sprites
@ball_sprites = []
for i in 0...4
4.times do |i|
@ball_sprites[i] = new_sprite(Graphics.width / 2, Graphics.height / 2, @ball_bitmap,
@ball_bitmap.width / 2, @ball_bitmap.height / 2)
@ball_sprites[i].z = [2, 1, 3, 0][i]
end
# Black wedges
for i in 0...4
4.times do |i|
b = [@black_1_bitmap, @black_2_bitmap, @black_3_bitmap, @black_4_bitmap][i]
@sprites[i] = new_sprite((i == 1) ? 0 : Graphics.width / 2, (i == 2) ? 0 : Graphics.height / 2, b,
(i.even?) ? b.width / 2 : 0, (i.even?) ? 0 : b.height / 2)

View File

@@ -80,10 +80,10 @@ class EventScene
def dispose
return if disposed?
for sprite in @picturesprites
@picturesprites.each do |sprite|
sprite.dispose
end
for sprite in @usersprites
@usersprites.each do |sprite|
sprite.dispose
end
@onCTrigger.clear
@@ -143,7 +143,7 @@ class EventScene
def pictureWait(extraframes = 0)
loop do
hasRunning = false
for pic in @pictures
@pictures.each do |pic|
hasRunning = true if pic.running?
end
break if !hasRunning
@@ -156,13 +156,13 @@ class EventScene
return if disposed?
Graphics.update
Input.update
for picture in @pictures
@pictures.each do |picture|
picture.update
end
for sprite in @picturesprites
@picturesprites.each do |sprite|
sprite.update
end
for sprite in @usersprites
@usersprites.each do |sprite|
next if !sprite || sprite.disposed? || !sprite.is_a?(Sprite)
sprite.update
end

View File

@@ -64,7 +64,7 @@ module GameData
return ArgumentError.new("Exp amount #{level} is invalid.") if !exp || exp < 0
max = GrowthRate.max_level
return max if exp >= maximum_exp
for level in 1..max
(1..max).each do |level|
return level - 1 if exp < minimum_exp_for_level(level)
end
return max

View File

@@ -13,7 +13,7 @@ module GameData
factors.push([1, try_form, ""]) if form > 0
factors.push([0, try_species, "000"])
# Go through each combination of parameters in turn to find an existing sprite
for i in 0...2**factors.length
(2**factors.length).times do |i|
# Set try_ parameters for this combination
factors.each_with_index do |factor, index|
value = ((i / (2**index)).even?) ? factor[1] : factor[2]

View File

@@ -281,7 +281,7 @@ class Battle
# on the given side of battle.
def pbNumPositions(side, idxTrainer)
ret = 0
for i in 0...pbSideSize(side)
pbSideSize(side).times do |i|
t = pbGetOwnerIndexFromBattlerIndex((i * 2) + side)
next if t != idxTrainer
ret += 1
@@ -618,7 +618,7 @@ class Battle
PBEffects::SkyDrop,
PBEffects::TrappingUser]
allBattlers.each do |b|
for i in effectsToSwap
effectsToSwap.each do |i|
next if b.effects[i] != idxA && b.effects[i] != idxB
b.effects[i] = (b.effects[i] == idxA) ? idxB : idxA
end

View File

@@ -43,12 +43,12 @@ class Battle
# side if necessary
loop do
needsChanging = false
for side in 0...2 # Each side in turn
2.times do |side| # Each side in turn
next if side == 1 && wildBattle? # Wild side's size already checked above
sideCounts = (side == 0) ? side1counts : side2counts
requireds = []
# Find out how many Pokémon each trainer on side needs to have
for i in 0...@sideSizes[side]
@sideSizes[side].times do |i|
idxTrainer = pbGetOwnerIndexFromBattlerIndex((i * 2) + side)
requireds[idxTrainer] = 0 if requireds[idxTrainer].nil?
requireds[idxTrainer] += 1
@@ -90,7 +90,7 @@ class Battle
if newSize == 0
raise _INTL("Couldn't lower either side's size any further, battle isn't possible")
end
for side in 0...2
2.times do |side|
next if side == 1 && wildBattle? # Wild Pokémon's side size is fixed
next if @sideSizes[side] == 1 || newSize > @sideSizes[side]
@sideSizes[side] = newSize
@@ -115,7 +115,7 @@ class Battle
def pbSetUpSides
ret = [[], []]
for side in 0...2
2.times do |side|
# Set up wild Pokémon
if side == 1 && wildBattle?
pbParty(1).each_with_index do |pkmn, idxPkmn|
@@ -131,7 +131,7 @@ class Battle
trainer = (side == 0) ? @player : @opponent
requireds = []
# Find out how many Pokémon each trainer on side needs to have
for i in 0...@sideSizes[side]
@sideSizes[side].times do |i|
idxTrainer = pbGetOwnerIndexFromBattlerIndex((i * 2) + side)
requireds[idxTrainer] = 0 if requireds[idxTrainer].nil?
requireds[idxTrainer] += 1
@@ -184,7 +184,7 @@ class Battle
end
end
# Send out Pokémon (opposing trainers first)
for side in [1, 0]
[1, 0].each do |side|
next if side == 1 && wildBattle?
msg = ""
toSendOut = []
@@ -496,7 +496,7 @@ class Battle
def pbDecisionOnTime
counts = [0, 0]
hpTotals = [0, 0]
for side in 0...2
2.times do |side|
pbParty(side).each do |pkmn|
next if !pkmn || !pkmn.able?
counts[side] += 1
@@ -514,7 +514,7 @@ class Battle
def pbDecisionOnTime2
counts = [0, 0]
hpTotals = [0, 0]
for side in 0...2
2.times do |side|
pbParty(side).each do |pkmn|
next if !pkmn || !pkmn.able?
counts[side] += 1

View File

@@ -144,7 +144,7 @@ class Battle
randomOrder[i], randomOrder[r] = randomOrder[r], randomOrder[i]
end
@priority.clear
for i in 0..maxBattlerIndex
(0..maxBattlerIndex).each do |i|
b = @battlers[i]
next if !b
# [battler, speed, sub-priority, priority, tie-breaker order]

View File

@@ -179,7 +179,7 @@ class Battle
pbClearChoice(i) if pbCanShowCommands?(i)
end
# Reset choices to perform Mega Evolution if it wasn't done somehow
for side in 0...2
2.times do |side|
@megaEvolution[side].each_with_index do |megaEvo, i|
@megaEvolution[side][i] = -1 if megaEvo >= 0
end

View File

@@ -148,7 +148,7 @@ class Battle
# is not generalised to larger side sizes.
if !singleBattle?
swaps = [] # Each element is an array of two battler indices to swap
for side in 0...2
2.times do |side|
next if pbSideSize(side) == 1 # Only battlers on sides of size 2+ need to move
# Check if any battler on this side is near any battler on the other side
anyNear = false
@@ -256,7 +256,7 @@ class Battle
pbDisplay(_INTL("{1}'s wish came true!", wishMaker))
end
# Sea of Fire damage (Fire Pledge + Grass Pledge combination)
for side in 0...2
2.times do |side|
next if sides[side].effects[PBEffects::SeaOfFire] == 0
@battle.pbCommonAnimation("SeaOfFire") if side == 0
@battle.pbCommonAnimation("SeaOfFireOpp") if side == 1
@@ -516,7 +516,7 @@ class Battle
pbGainExp
return
end
for side in 0...2
2.times do |side|
# Reflect
pbEORCountDownSideEffect(side, PBEffects::Reflect,
_INTL("{1}'s Reflect wore off!", @battlers[side].pbTeam))
@@ -664,7 +664,7 @@ class Battle
b.lastFoeAttacker.clear
end
# Reset/count down side-specific effects (no messages)
for side in 0...2
2.times do |side|
@sides[side].effects[PBEffects::CraftyShield] = false
if !@sides[side].effects[PBEffects::EchoedVoiceUsed]
@sides[side].effects[PBEffects::EchoedVoiceCounter] = 0

View File

@@ -414,7 +414,7 @@ class Battle::Battler
numHits = move.pbNumHits(user, targets)
# Process each hit in turn
realNumHits = 0
for i in 0...numHits
numHits.times do |i|
break if magicCoater >= 0 || magicBouncer >= 0
success = pbProcessMoveHit(move, user, targets, i, skipAccuracyCheck)
if !success

View File

@@ -241,7 +241,7 @@ class Battle::Move
def pbAnimateHitAndHPLost(user, targets)
# Animate allies first, then foes
animArray = []
for side in 0...2 # side here means "allies first, then foes"
2.times do |side| # side here means "allies first, then foes"
targets.each do |b|
next if b.damageState.unaffected || b.damageState.hpLost == 0
next if (side == 0 && b.opposes?(user)) || (side == 1 && !b.opposes?(user))

View File

@@ -113,7 +113,7 @@ class Battle::Move::MultiStatUpMove < Battle::Move
def pbMoveFailed?(user, targets)
return false if damagingMove?
failed = true
for i in 0...@statUp.length / 2
(@statUp.length / 2).times do |i|
next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self)
failed = false
break
@@ -128,7 +128,7 @@ class Battle::Move::MultiStatUpMove < Battle::Move
def pbEffectGeneral(user)
return if damagingMove?
showAnim = true
for i in 0...@statUp.length / 2
(@statUp.length / 2).times do |i|
next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self)
if user.pbRaiseStatStage(@statUp[i * 2], @statUp[(i * 2) + 1], user, showAnim)
showAnim = false
@@ -138,7 +138,7 @@ class Battle::Move::MultiStatUpMove < Battle::Move
def pbAdditionalEffect(user, target)
showAnim = true
for i in 0...@statUp.length / 2
(@statUp.length / 2).times do |i|
next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self)
if user.pbRaiseStatStage(@statUp[i * 2], @statUp[(i * 2) + 1], user, showAnim)
showAnim = false
@@ -154,7 +154,7 @@ class Battle::Move::StatDownMove < Battle::Move
def pbEffectWhenDealingDamage(user, target)
return if @battle.pbAllFainted?(target.idxOwnSide)
showAnim = true
for i in 0...@statDown.length / 2
(@statDown.length / 2).times do |i|
next if !user.pbCanLowerStatStage?(@statDown[i * 2], user, self)
if user.pbLowerStatStage(@statDown[i * 2], @statDown[(i * 2) + 1], user, showAnim)
showAnim = false
@@ -195,7 +195,7 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
return false if damagingMove?
failed = true
for i in 0...@statDown.length / 2
(@statDown.length / 2).times do |i|
next if !target.pbCanLowerStatStage?(@statDown[i * 2], user, self)
failed = false
break
@@ -205,14 +205,14 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move
# is shown here, I know.
canLower = false
if target.hasActiveAbility?(:CONTRARY) && !@battle.moldBreaker
for i in 0...@statDown.length / 2
(@statDown.length / 2).times do |i|
next if target.statStageAtMax?(@statDown[i * 2])
canLower = true
break
end
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!", user.pbThis)) if !canLower && show_message
else
for i in 0...@statDown.length / 2
(@statDown.length / 2).times do |i|
next if target.statStageAtMin?(@statDown[i * 2])
canLower = true
break
@@ -230,7 +230,7 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move
def pbCheckForMirrorArmor(user, target)
if target.hasActiveAbility?(:MIRRORARMOR) && user.index != target.index
failed = true
for i in 0...@statDown.length / 2
(@statDown.length / 2).times do |i|
next if target.statStageAtMin?(@statDown[i * 2])
next if !user.pbCanLowerStatStage?(@statDown[i * 2], target, self, false, false, true)
failed = false
@@ -253,7 +253,7 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move
return if !pbCheckForMirrorArmor(user, target)
showAnim = true
showMirrorArmorSplash = true
for i in 0...@statDown.length / 2
(@statDown.length / 2).times do |i|
next if !target.pbCanLowerStatStage?(@statDown[i * 2], user, self)
if target.pbLowerStatStage(@statDown[i * 2], @statDown[(i * 2) + 1], user,
showAnim, false, (showMirrorArmorSplash) ? 1 : 3)

View File

@@ -482,7 +482,7 @@ class Battle::Move::SwapSideEffects < Battle::Move
def pbMoveFailed?(user, targets)
has_effect = false
for side in 0...2
2.times do |side|
effects = @battle.sides[side].effects
@number_effects.each do |e|
next if effects[e] == 0

View File

@@ -417,13 +417,13 @@ class Battle::Move::LowerUserDefSpDef1RaiseUserAtkSpAtkSpd2 < Battle::Move
def pbMoveFailed?(user, targets)
failed = true
for i in 0...@statUp.length / 2
(@statUp.length / 2).times do |i|
if user.pbCanRaiseStatStage?(@statUp[i * 2], user, self)
failed = false
break
end
end
for i in 0...@statDown.length / 2
(@statDown.length / 2).times do |i|
if user.pbCanLowerStatStage?(@statDown[i * 2], user, self)
failed = false
break
@@ -438,14 +438,14 @@ class Battle::Move::LowerUserDefSpDef1RaiseUserAtkSpAtkSpd2 < Battle::Move
def pbEffectGeneral(user)
showAnim = true
for i in 0...@statDown.length / 2
(@statDown.length / 2).times do |i|
next if !user.pbCanLowerStatStage?(@statDown[i * 2], user, self)
if user.pbLowerStatStage(@statDown[i * 2], @statDown[(i * 2) + 1], user, showAnim)
showAnim = false
end
end
showAnim = true
for i in 0...@statUp.length / 2
(@statUp.length / 2).times do |i|
next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self)
if user.pbRaiseStatStage(@statUp[i * 2], @statUp[(i * 2) + 1], user, showAnim)
showAnim = false
@@ -1359,7 +1359,7 @@ class Battle::Move::LowerPoisonedTargetAtkSpAtkSpd1 < Battle::Move
def pbCheckForMirrorArmor(user, target)
if target.hasActiveAbility?(:MIRRORARMOR) && user.index != target.index
failed = true
for i in 0...@statDown.length / 2
(@statDown.length / 2).times do |i|
next if target.statStageAtMin?(@statDown[i * 2])
next if !user.pbCanLowerStatStage?(@statDown[i * 2], target, self, false, false, true)
failed = false
@@ -1383,7 +1383,7 @@ class Battle::Move::LowerPoisonedTargetAtkSpAtkSpd1 < Battle::Move
return if !pbCheckForMirrorArmor(user, target)
showAnim = true
showMirrorArmorSplash = true
for i in 0...@statDown.length / 2
(@statDown.length / 2).times do |i|
next if !target.pbCanLowerStatStage?(@statDown[i * 2], user, self)
if target.pbLowerStatStage(@statDown[i * 2], @statDown[(i * 2) + 1], user,
showAnim, false, (showMirrorArmorSplash) ? 1 : 3)

View File

@@ -381,7 +381,7 @@ class Battle::Scene
#=============================================================================
def pbSelectBattler(idxBattler, selectMode = 1)
numWindows = @battle.sideSizes.max * 2
for i in 0...numWindows
numWindows.times do |i|
sel = (idxBattler.is_a?(Array)) ? !idxBattler[i].nil? : i == idxBattler
selVal = (sel) ? selectMode : 0
@sprites["dataBox_#{i}"].selected = selVal if @sprites["dataBox_#{i}"]

View File

@@ -48,13 +48,13 @@ class Battle::Scene
@sprites["targetWindow"] = TargetMenu.new(@viewport, 200, @battle.sideSizes)
pbShowWindow(MESSAGE_BOX)
# The party lineup graphics (bar and balls) for both sides
for side in 0...2
2.times do |side|
partyBar = pbAddSprite("partyBar_#{side}", 0, 0,
"Graphics/Pictures/Battle/overlay_lineup", @viewport)
partyBar.z = 120
partyBar.mirror = true if side == 0 # Player's lineup bar only
partyBar.visible = false
for i in 0...NUM_BALLS
NUM_BALLS.times do |i|
ball = pbAddSprite("partyBall_#{side}_#{i}", 0, 0, nil, @viewport)
ball.z = 121
ball.visible = false
@@ -137,7 +137,7 @@ class Battle::Scene
bg = pbAddSprite("battle_bg2", -Graphics.width, 0, battleBG, @viewport)
bg.z = 0
bg.mirror = true
for side in 0...2
2.times do |side|
baseX, baseY = Battle::Scene.pbBattlerPosition(side)
base = pbAddSprite("base_#{side}", baseX, baseY,
(side == 0) ? playerBase : enemyBase, @viewport)

View File

@@ -27,7 +27,7 @@ class Battle::Scene
# data box(es), return the wild Pokémon's sprite(s) to normal colour, show
# shiny animation(s)
# Set up data box animation
for i in 0...@battle.sideSizes[1]
@battle.sideSizes[1].times do |i|
idxBattler = (2 * i) + 1
next if !@battle.battlers[idxBattler]
dataBoxAnim = Animation::DataBoxAppear.new(@sprites, @viewport, idxBattler)
@@ -42,7 +42,7 @@ class Battle::Scene
end
# Show shiny animation for wild Pokémon
if @battle.showAnims
for i in 0...@battle.sideSizes[1]
@battle.sideSizes[1].times do |i|
idxBattler = (2 * i) + 1
next if !@battle.battlers[idxBattler] || !@battle.battlers[idxBattler].shiny?
if Settings::SUPER_SHINY && @battle.battlers[idxBattler].super_shiny?
@@ -400,7 +400,7 @@ class Battle::Scene
# Yield to other code, i.e. playing an animation
yield
# Restore shadow visibility
for i in 0...@battle.battlers.length
@battle.battlers.length.times do |i|
shadow = @sprites["shadow_#{i}"]
shadow.visible = shadows[i] if shadow
end

View File

@@ -38,21 +38,21 @@ class Battle::Scene::MenuBase
def z=(value)
@z = value
for i in @sprites
@sprites.each do |i|
i[1].z = value if !i[1].disposed?
end
end
def visible=(value)
@visible = value
for i in @sprites
@sprites.each do |i|
i[1].visible = (value && @visibility[i[0]]) if !i[1].disposed?
end
end
def color=(value)
@color = value
for i in @sprites
@sprites.each do |i|
i[1].color = value if !i[1].disposed?
end
end
@@ -174,7 +174,7 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
@msgBox.text = value[0]
return if USE_GRAPHICS
commands = []
for i in 1..4
(1..4).each do |i|
commands.push(value[i]) if value[i] && value[i] != nil
end
@cmdWindow.commands = commands
@@ -182,8 +182,7 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
def refreshButtons
return if !USE_GRAPHICS
for i in 0...@buttons.length
button = @buttons[i]
@buttons.each_with_index do |button, i|
button.src_rect.x = (i == @index) ? @buttonBitmap.width / 2 : 0
button.src_rect.y = MODES[@mode][i] * BUTTON_HEIGHT
button.z = self.z + ((i == @index) ? 3 : 2)
@@ -343,7 +342,7 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
if !USE_GRAPHICS
# Fill in command window
commands = []
for i in 0...[4, moves.length].max
[4, moves.length].max.times do |i|
commands.push((moves[i]) ? moves[i].name : "-")
end
@cmdWindow.commands = commands

View File

@@ -133,14 +133,14 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
def opacity=(value)
super
for i in @sprites
@sprites.each do |i|
i[1].opacity = value if !i[1].disposed?
end
end
def visible=(value)
super
for i in @sprites
@sprites.each do |i|
i[1].visible = value if !i[1].disposed?
end
@expBar.visible = (value && @showExp)
@@ -148,7 +148,7 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
def color=(value)
super
for i in @sprites
@sprites.each do |i|
i[1].color = value if !i[1].disposed?
end
end
@@ -335,7 +335,7 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
@expFlash = Graphics.frame_rate / 5
pbSEPlay("Pkmn exp full")
self.flash(Color.new(64, 200, 248, 192), @expFlash)
for i in @sprites
@sprites.each do |i|
i[1].flash(Color.new(64, 200, 248, 192), @expFlash) if !i[1].disposed?
end
else

View File

@@ -169,7 +169,7 @@ module Battle::Scene::Animation::BallAnimationMixin
a = (2 * startY) - (4 * midY) + (2 * endY)
b = (4 * midY) - (3 * startY) - endY
c = startY
for i in 1..duration
(1..duration).each do |i|
t = i.to_f / duration # t ranges from 0 to 1
x = startX + ((endX - startX) * t) # Linear in t
y = (a * (t**2)) + (b * t) + c # Quadratic in t
@@ -188,7 +188,7 @@ module Battle::Scene::Animation::BallAnimationMixin
end
if numFrames > 1
curFrame = 0
for i in 1..duration
(1..duration).each do |i|
thisFrame = numFrames * numTumbles * i / duration
if thisFrame > curFrame
curFrame = thisFrame

View File

@@ -33,7 +33,7 @@ class Battle::Scene::Animation::Intro < Battle::Scene::Animation
end
end
# Shadows
for i in 0...@battle.battlers.length
@battle.battlers.length.times do |i|
makeSlideSprite("shadow_#{i}", (i.even?) ? 1 : -1, appearTime, PictureOrigin::Center)
end
# Fading blackness over whole screen
@@ -70,7 +70,7 @@ class Battle::Scene::Animation::Intro2 < Battle::Scene::Animation
end
def createProcesses
for i in 0...@sideSize
@sideSize.times do |i|
idxBattler = (2 * i) + 1
next if !@sprites["pokemon_#{idxBattler}"]
battler = addSprite(@sprites["pokemon_#{idxBattler}"], PictureOrigin::Bottom)
@@ -117,7 +117,7 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation
bar.y = barY
bar.opacity = 255
bar.visible = false
for i in 0...Battle::Scene::NUM_BALLS
Battle::Scene::NUM_BALLS.times do |i|
ball = sprites["partyBall_#{@side}_#{i}"]
ball.x = ballX
ball.y = ballY
@@ -154,7 +154,7 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation
bar.setDelta(0, dir * Graphics.width / 2, 0)
bar.moveDelta(0, 8, -dir * Graphics.width / 2, 0)
delay = bar.totalDuration
for i in 0...Battle::Scene::NUM_BALLS
Battle::Scene::NUM_BALLS.times do |i|
createBall(i, (@fullAnim) ? delay + (i * 2) : 0, dir)
end
end
@@ -339,7 +339,7 @@ class Battle::Scene::Animation::PlayerFade < Battle::Scene::Animation
partyBar.setVisible(delay + 12, false)
partyBar.setOpacity(delay + 12, 255)
end
for i in 0...Battle::Scene::NUM_BALLS
Battle::Scene::NUM_BALLS.times do |i|
next if !@sprites["partyBall_0_#{i}"] || !@sprites["partyBall_0_#{i}"].visible
partyBall = addSprite(@sprites["partyBall_0_#{i}"])
partyBall.moveDelta(delay + (2 * i), 16, -Graphics.width, 0) if @fullAnim
@@ -384,7 +384,7 @@ class Battle::Scene::Animation::TrainerFade < Battle::Scene::Animation
partyBar.setVisible(delay + 12, false)
partyBar.setOpacity(delay + 12, 255)
end
for i in 0...Battle::Scene::NUM_BALLS
Battle::Scene::NUM_BALLS.times do |i|
next if !@sprites["partyBall_1_#{i}"] || !@sprites["partyBall_1_#{i}"].visible
partyBall = addSprite(@sprites["partyBall_1_#{i}"])
partyBall.moveDelta(delay + (2 * i), 16, Graphics.width, 0) if @fullAnim
@@ -777,7 +777,7 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation
delay = ball.totalDuration + 3
end
# Poké Ball drops to the ground
for i in 0...4
4.times do |i|
t = [4, 4, 3, 2][i] # Time taken to rise or fall for each bounce
d = [1, 2, 4, 8][i] # Fraction of the starting height each bounce rises to
delay -= t if i == 0
@@ -793,7 +793,7 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation
battler.setXY(ball.totalDuration, ballEndX, ballGroundY)
# Poké Ball shakes
delay = ball.totalDuration + 12
for i in 0...[@numShakes, 3].min
[@numShakes, 3].min.times do |i|
ball.setSE(delay, "Battle ball shake")
ball.moveXY(delay, 2, ballEndX - (2 * (4 - i)), ballGroundY)
ball.moveAngle(delay, 2, 5 * (4 - i)) # positive means counterclockwise

View File

@@ -193,7 +193,7 @@ module Battle::CatchAndStoreMixin
end
# Calculate the number of shakes
numShakes = 0
for i in 0...4
4.times do |i|
break if numShakes < i
numShakes += 1 if pbRandom(65536) < y
end

View File

@@ -123,10 +123,10 @@ def pbConvertRPGAnimation(animation)
pbAnim.position = animation.position
yOffset = -64 if animation.position == 0
yOffset = 64 if animation.position == 2
for i in 0...animation.frames.length
animation.frames.length.times do |i|
frame = pbAnim.addFrame
animFrame = animation.frames[i]
for j in 0...animFrame.cell_max
animFrame.cell_max.times do |j|
data = animFrame.cell_data
if data[j, 0] == -1
frame.push(nil)
@@ -152,8 +152,7 @@ def pbConvertRPGAnimation(animation)
frame.push(cel)
end
end
for i in 0...animation.timings.length
timing = animation.timings[i]
animation.timings.each do |timing|
newTiming = PBAnimTiming.new
newTiming.frame = timing.frame
newTiming.name = timing.se.name
@@ -193,18 +192,18 @@ class RPG::Animation
def addAnimation(otherAnim, frame, x, y) # frame is zero-based
if frame + otherAnim.frames.length >= self.frames.length
totalframes = frame + otherAnim.frames.length + 1
for i in self.frames.length...totalframes
(totalframes - self.frames.length).times do
self.frames.push(RPG::Animation::Frame.new)
end
end
self.frame_max = self.frames.length
for i in 0...otherAnim.frame_max
otherAnim.frame_max.times do |i|
thisframe = self.frames[frame + i]
otherframe = otherAnim.frames[i]
cellStart = thisframe.cell_max
thisframe.cell_max += otherframe.cell_max
thisframe.cell_data.resize(thisframe.cell_max, 8)
for j in 0...otherframe.cell_max
otherframe.cell_max.times do |j|
thisframe.cell_data[cellStart + j, 0] = otherframe.cell_data[j, 0]
thisframe.cell_data[cellStart + j, 1] = otherframe.cell_data[j, 1] + x
thisframe.cell_data[cellStart + j, 2] = otherframe.cell_data[j, 2] + y
@@ -215,9 +214,8 @@ class RPG::Animation
thisframe.cell_data[cellStart + j, 7] = otherframe.cell_data[j, 7]
end
end
for i in 0...otherAnim.timings.length
otherAnim.timings.each do |othertiming|
timing = RPG::Animation::Timing.new
othertiming = otherAnim.timings[i]
timing.frame = frame + othertiming.frame
timing.se = RPG::AudioFile.new(othertiming.se.name.clone,
othertiming.se.volume,
@@ -398,13 +396,9 @@ class PBAnimations < Array
idxStart = @array.length
idxEnd = len
if idxStart > idxEnd
for i in idxEnd...idxStart
@array.pop
end
(idxStart - idxEnd).times { @array.pop }
else
for i in idxStart...idxEnd
@array.push(PBAnimation.new)
end
(idxEnd - idxStart).times { @array.push(PBAnimation.new) }
end
self.selected = len if self.selected >= len
end
@@ -494,7 +488,7 @@ class PBAnimation < Array
end
def playTiming(frame, bgGraphic, bgColor, foGraphic, foColor, oldbg = [], oldfo = [], user = nil)
for i in @timing
@timing.each do |i|
next if i.frame != frame
case i.timingType
when 0 # Play SE
@@ -562,7 +556,7 @@ class PBAnimation < Array
end
end
end
for i in @timing
@timing.each do |i|
case i.timingType
when 2
next if !i.duration || i.duration <= 0
@@ -729,7 +723,7 @@ class PBAnimationPlayerX
@animsprites = []
@animsprites[0] = @usersprite
@animsprites[1] = @targetsprite
for i in 2...MAX_SPRITES
(2...MAX_SPRITES).each do |i|
@animsprites[i] = Sprite.new(@viewport)
@animsprites[i].bitmap = nil
@animsprites[i].visible = false
@@ -768,7 +762,7 @@ class PBAnimationPlayerX
def dispose
@animbitmap.dispose if @animbitmap
for i in 2...MAX_SPRITES
(2...MAX_SPRITES).each do |i|
@animsprites[i].dispose if @animsprites[i]
end
@bgGraphic.dispose
@@ -807,7 +801,7 @@ class PBAnimationPlayerX
if !@animbitmap || @animbitmap.disposed?
@animbitmap = AnimatedBitmap.new("Graphics/Animations/" + @animation.graphic,
@animation.hue).deanimate
for i in 0...MAX_SPRITES
MAX_SPRITES.times do |i|
@animsprites[i].bitmap = @animbitmap if @animsprites[i]
end
end
@@ -821,11 +815,11 @@ class PBAnimationPlayerX
if @framesPerTick == 1 || (@frame % @framesPerTick) == 0
thisframe = @animation[animFrame]
# Make all cel sprites invisible
for i in 0...MAX_SPRITES
MAX_SPRITES.times do |i|
@animsprites[i].visible = false if @animsprites[i]
end
# Set each cel sprite acoordingly
for i in 0...thisframe.length
thisframe.length.times do |i|
cel = thisframe[i]
next if !cel
sprite = @animsprites[i]

View File

@@ -123,7 +123,7 @@ class BattlePalaceBattle < Battle
category = 2
end
moves = []
for i in 0...this_battler.moves.length
this_battler.moves.length.times do |i|
next if !pbCanChooseMovePartial?(idxBattler, i)
next if pbMoveCategory(this_battler.moves[i]) != category
moves[moves.length] = i

View File

@@ -64,7 +64,7 @@ class BattleArenaBattle < Battle
return if !favorDraws && @decision > 0
pbJudge
return if @decision > 0
for side in 0...2
2.times do |side|
next if !@battlers[side].fainted?
next if @partyindexes[side] + 1 >= self.pbParty(side).length
@partyindexes[side] += 1
@@ -77,7 +77,7 @@ class BattleArenaBattle < Battle
def pbOnAllBattlersEnteringBattle
@battlersChanged = true
for side in 0...2
2.times do |side|
@mind[side] = 0
@skill[side] = 0
@starthp[side] = battlers[side].hp
@@ -88,7 +88,7 @@ class BattleArenaBattle < Battle
def pbRecordBattlerAsActive(battler)
@battlersChanged = true
for side in 0...2
2.times do |side|
@mind[side] = 0
@skill[side] = 0
@starthp[side] = @battlers[side].hp
@@ -122,7 +122,7 @@ class BattleArenaBattle < Battle
return if @decision != 0
# Update mind rating (asserting that a move was chosen)
# TODO: Actually done at Pokémon's turn
for side in 0...2
2.times do |side|
if @choices[side][2] && @choices[side][0] == :UseMove
@mind[side] += pbMindScore(@choices[side][2])
end
@@ -133,7 +133,7 @@ class BattleArenaBattle < Battle
super
return if @decision != 0
# Update skill rating
for side in 0...2
2.times do |side|
@skill[side] += self.successStates[side].skill
end
# PBDebug.log("[Mind: #{@mind.inspect}, Skill: #{@skill.inspect}]")
@@ -234,7 +234,7 @@ class Battle::Scene
def updateJudgment(window, phase, battler1, battler2, ratings1, ratings2)
total1 = 0
total2 = 0
for i in 0...phase
phase.times do |i|
total1 += ratings1[i]
total2 += ratings2[i]
end
@@ -253,7 +253,7 @@ class Battle::Scene
]
pbDrawTextPositions(window.contents, textpos)
images = []
for i in 0...phase
phase.times do |i|
y = [48, 80, 112][i]
x = (ratings1[i] == ratings2[i]) ? 64 : ((ratings1[i] > ratings2[i]) ? 0 : 32)
images.push(["Graphics/Pictures/judgment", 64 - 16, y, x, 0, 32, 32])
@@ -287,7 +287,7 @@ class Battle::Scene
infowindow.height - infowindow.borderY)
infowindow.z = 99999
infowindow.visible = false
for i in 0..10
11.times do |i|
pbGraphicsUpdate
pbInputUpdate
msgwindow.update
@@ -296,7 +296,7 @@ class Battle::Scene
end
updateJudgment(infowindow, 0, battler1, battler2, ratings1, ratings2)
infowindow.visible = true
for i in 0..10
11.times do |i|
pbGraphicsUpdate
pbInputUpdate
msgwindow.update
@@ -326,7 +326,7 @@ class Battle::Scene
}
total1 = 0
total2 = 0
for i in 0...3
3.times do |i|
total1 += ratings1[i]
total2 += ratings2[i]
end
@@ -356,7 +356,7 @@ class Battle::Scene
end
infowindow.visible = false
msgwindow.visible = false
for i in 0..10
11.times do |i|
pbGraphicsUpdate
pbInputUpdate
msgwindow.update

View File

@@ -29,11 +29,11 @@ module RecordedBattleModule
return nil if !trainer
if trainer.is_a?(Array)
ret = []
for i in 0...trainer.length
if trainer[i].is_a?(Player)
ret.push([trainer[i].trainer_type, trainer[i].name.clone, trainer[i].id, trainer[i].badges.clone])
trainer.each do |tr|
if tr.is_a?(Player)
ret.push([tr.trainer_type, tr.name.clone, tr.id, tr.badges.clone])
else # NPCTrainer
ret.push([trainer[i].trainer_type, trainer[i].name.clone, trainer[i].id])
ret.push([tr.trainer_type, tr.name.clone, tr.id])
end
end
return ret
@@ -202,7 +202,7 @@ module RecordedBattlePlaybackModule
def pbCommandPhaseLoop(isPlayer)
return if !isPlayer
@roundindex += 1
for i in 0...4
4.times do |i|
next if @rounds[@roundindex][i].length == 0
pbClearChoice(i)
case @rounds[@roundindex][i][0]

View File

@@ -120,7 +120,7 @@ module RPG
return if @max == value
@max = value.clamp(0, MAX_SPRITES)
ensureSprites
for i in 0...MAX_SPRITES
MAX_SPRITES.times do |i|
@sprites[i].visible = (i < @max) if @sprites[i]
end
end
@@ -149,7 +149,7 @@ module RPG
weather_data = GameData::Weather.get(new_type)
bitmap_names = weather_data.graphics
@weatherTypes[new_type] = [weather_data, [], []]
for i in 0...2 # 0=particles, 1=tiles
2.times do |i| # 0=particles, 1=tiles
next if !bitmap_names[i]
bitmap_names[i].each do |name|
bitmap = RPG::Cache.load_bitmap("Graphics/Weather/", name)
@@ -160,7 +160,7 @@ module RPG
def ensureSprites
if @sprites.length < MAX_SPRITES && @weatherTypes[@type] && @weatherTypes[@type][1].length > 0
for i in 0...MAX_SPRITES
MAX_SPRITES.times do |i|
if !@sprites[i]
sprite = Sprite.new(@origViewport)
sprite.z = 1000
@@ -175,7 +175,7 @@ module RPG
end
if @fading && @new_sprites.length < MAX_SPRITES && @weatherTypes[@target_type] &&
@weatherTypes[@target_type][1].length > 0
for i in 0...MAX_SPRITES
MAX_SPRITES.times do |i|
if !@new_sprites[i]
sprite = Sprite.new(@origViewport)
sprite.z = 1000
@@ -192,7 +192,7 @@ module RPG
def ensureTiles
return if @tiles.length >= @tiles_wide * @tiles_tall
for i in 0...(@tiles_wide * @tiles_tall)
(@tiles_wide * @tiles_tall).times do |i|
if !@tiles[i]
sprite = Sprite.new(@origViewport)
sprite.z = 1000
@@ -497,7 +497,7 @@ module RPG
# Update weather particles (raindrops, snowflakes, etc.)
if @weatherTypes[@type] && @weatherTypes[@type][1].length > 0
ensureSprites
for i in 0...MAX_SPRITES
MAX_SPRITES.times do |i|
update_sprite_position(@sprites[i], i, false)
end
elsif @sprites.length > 0
@@ -507,7 +507,7 @@ module RPG
# Update new weather particles (while fading in only)
if @fading && @weatherTypes[@target_type] && @weatherTypes[@target_type][1].length > 0
ensureSprites
for i in 0...MAX_SPRITES
MAX_SPRITES.times do |i|
update_sprite_position(@new_sprites[i], i, true)
end
elsif @new_sprites.length > 0

View File

@@ -74,8 +74,8 @@ class DarknessSprite < SpriteWrapper
cy = Graphics.height / 2
cradius = @radius
numfades = 5
for i in 1..numfades
for j in cx - cradius..cx + cradius
(1..numfades).each do |i|
(cx - cradius..cx + cradius).each do |j|
diff2 = (cradius * cradius) - ((j - cx) * (j - cx))
diff = Math.sqrt(diff2)
@darkness.fill_rect(j, cy - diff, 1, diff * 2, Color.new(0, 0, 0, 255.0 * (numfades - i) / numfades))
@@ -209,7 +209,7 @@ Events.onSpritesetCreate += proc { |_sender, e|
spriteset = e[0] # Spriteset being created
viewport = e[1] # Viewport used for tilemap and characters
map = spriteset.map # Map associated with the spriteset (not necessarily the current map)
for i in map.events.keys
map.events.keys.each do |i|
if map.events[i].name[/^outdoorlight\((\w+)\)$/i]
filename = $~[1].to_s
spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i], viewport, map, filename))

View File

@@ -18,7 +18,7 @@ def pbCaveEntranceEx(exiting)
x = 0
y = 0
# Calculate color of each band
for k in 0...totalBands
totalBands.times do |k|
next if k >= totalBands * j / totalFrames
inc = increment
inc *= -1 if exiting
@@ -28,7 +28,7 @@ def pbCaveEntranceEx(exiting)
# Draw gray rectangles
rectwidth = Graphics.width
rectheight = Graphics.height
for i in 0...totalBands
totalBands.times do |i|
currentGray = grays[i]
sprite.bitmap.fill_rect(Rect.new(x, y, rectwidth, rectheight),
Color.new(currentGray, currentGray, currentGray))
@@ -47,7 +47,7 @@ def pbCaveEntranceEx(exiting)
pbToneChangeAll(Tone.new(-255, -255, -255), 0)
end
# Animate fade to white (if exiting) or black (if entering)
for j in 0...totalFrames
totalFrames.times do |j|
if exiting
sprite.color = Color.new(255, 255, 255, j * increment)
else

View File

@@ -7,7 +7,7 @@ Events.onMapUpdate += proc { |_sender, _e|
last = $PokemonGlobal.pokerusTime
now = pbGetTimeNow
if !last || last.year != now.year || last.month != now.month || last.day != now.day
for i in $player.pokemon_party
$player.pokemon_party.each do |i|
i.lowerPokerusCount
end
$PokemonGlobal.pokerusTime = now
@@ -18,7 +18,7 @@ Events.onMapUpdate += proc { |_sender, _e|
# healed Pokémon has it.
def pbPokerus?
return false if $game_switches[Settings::SEEN_POKERUS_SWITCH]
for i in $player.party
$player.party.each do |i|
return true if i.pokerusStage == 1
end
return false
@@ -78,7 +78,7 @@ Events.onStepTaken += proc {
$PokemonGlobal.happinessSteps = 0 if !$PokemonGlobal.happinessSteps
$PokemonGlobal.happinessSteps += 1
if $PokemonGlobal.happinessSteps >= 128
for pkmn in $player.able_party
$player.able_party.each do |pkmn|
pkmn.changeHappiness("walking") if rand(2) == 0
end
$PokemonGlobal.happinessSteps = 0
@@ -91,7 +91,7 @@ Events.onStepTakenTransferPossible += proc { |_sender, e|
next if handled[0]
if $PokemonGlobal.stepcount % 4 == 0 && Settings::POISON_IN_FIELD
flashed = false
for i in $player.able_party
$player.able_party.each do |i|
if i.status == :POISON && !i.hasAbility?(:IMMUNITY)
if !flashed
pbFlash(Color.new(255, 0, 0, 128), 8)
@@ -131,7 +131,7 @@ Events.onStepTakenFieldMovement += proc { |_sender, e|
event = e[0] # Get the event affected by field movement
thistile = $map_factory.getRealTilePos(event.map.map_id, event.x, event.y)
map = $map_factory.getMap(thistile[0])
for i in [2, 1, 0]
[2, 1, 0].each do |i|
tile_id = map.data[thistile[1], thistile[2], i]
next if tile_id == nil
next if GameData::TerrainTag.try_get(map.terrain_tags[tile_id]).id != :SootGrass
@@ -284,7 +284,7 @@ Events.onMapSceneChange += proc { |_sender, e|
if mapChanged && map_metadata && map_metadata.announce_location
nosignpost = false
if $PokemonGlobal.mapTrail[1]
for i in 0...Settings::NO_SIGNPOSTS.length / 2
(Settings::NO_SIGNPOSTS.length / 2).times do |i|
nosignpost = true if Settings::NO_SIGNPOSTS[2 * i] == $PokemonGlobal.mapTrail[1] &&
Settings::NO_SIGNPOSTS[(2 * i) + 1] == $game_map.map_id
nosignpost = true if Settings::NO_SIGNPOSTS[(2 * i) + 1] == $PokemonGlobal.mapTrail[1] &&
@@ -691,7 +691,7 @@ def pbRegisterPartner(tr_type, tr_name, tr_id = 0)
pbCancelVehicles
trainer = pbLoadTrainer(tr_type, tr_name, tr_id)
Events.onTrainerPartyLoad.trigger(nil, trainer)
for i in trainer.party
trainer.party.each do |i|
i.owner = Pokemon::Owner.new_from_trainer(trainer)
i.calc_stats
end

View File

@@ -66,7 +66,7 @@ end
def setBattleRule(*args)
r = nil
for arg in args
args.each do |arg|
if r
$game_temp.add_battle_rule(r, arg)
r = nil
@@ -234,7 +234,7 @@ def pbWildBattleCore(*args)
# Generate wild Pokémon based on the species and level
foeParty = []
sp = nil
for arg in args
args.each do |arg|
if arg.is_a?(Pokemon)
foeParty.push(arg)
elsif arg.is_a?(Array)
@@ -382,7 +382,7 @@ def pbTrainerBattleCore(*args)
foeEndSpeeches = []
foeParty = []
foePartyStarts = []
for arg in args
args.each do |arg|
case arg
when NPCTrainer
foeTrainers.push(arg)
@@ -483,7 +483,7 @@ def pbTrainerBattle(trainerID, trainerName, endSpeech = nil,
# Find all other triggered trainer events
triggeredEvents = $game_player.pbTriggeredTrainerEvents([2], false)
otherEvent = []
for i in triggeredEvents
triggeredEvents.each do |i|
next if i.id == thisEvent.id
next if $game_self_switches[[$game_map.map_id, i.id, "A"]]
otherEvent.push(i)
@@ -632,9 +632,7 @@ end
def pbDynamicItemList(*args)
ret = []
for i in 0...args.length
ret.push(args[i]) if GameData::Item.exists?(args[i])
end
args.each { |arg| ret.push(arg) if GameData::Item.exists?(arg) }
return ret
end
@@ -685,10 +683,10 @@ def pbPickup(pkmn)
pkmnLevel = [100, pkmn.level].min
itemStartIndex = (pkmnLevel - 1) / 10
itemStartIndex = 0 if itemStartIndex < 0
for i in 0...9
9.times do |i|
items.push(pickupList[itemStartIndex + i])
end
for i in 0...2
2.times do |i|
items.push(pickupListRare[itemStartIndex + i])
end
# Probabilities of choosing each item in turn from the pool

View File

@@ -109,7 +109,7 @@ def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil)
alphaDiff = (255.0 / halfFlashTime).ceil
2.times do
viewport.color.alpha = 0
for i in 0...halfFlashTime * 2
(halfFlashTime * 2).times do |i|
if i < halfFlashTime
viewport.color.alpha += alphaDiff
else
@@ -238,7 +238,7 @@ SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50
flash.opacity = 0
# Animate bars sliding in from either side
slideInTime = (Graphics.frame_rate * 0.25).floor
for i in 0...slideInTime
slideInTime.times do |i|
bar1.x = xoffset * (i + 1 - slideInTime) / slideInTime
bar2.x = xoffset * (slideInTime - i - 1) / slideInTime
pbWait(1)
@@ -263,7 +263,7 @@ SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50
trainer.tone = Tone.new(-255, -255, -255)
# Dim the flash and make the trainer sprites appear, while animating bars
animTime = (Graphics.frame_rate * 1.2).floor
for i in 0...animTime
animTime.times do |i|
flash.opacity -= 52 * 20 / Graphics.frame_rate if flash.opacity > 0
bar1.ox -= 32 * 20 / Graphics.frame_rate
bar2.ox += 32 * 20 / Graphics.frame_rate
@@ -294,7 +294,7 @@ SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50
shudderTime = (Graphics.frame_rate * 1.75).floor
zoomTime = (Graphics.frame_rate * 2.5).floor
shudderDelta = [4 * 20 / Graphics.frame_rate, 1].max
for i in 0...animTime
animTime.times do |i|
if i < shudderTime # Fade out the white flash
flash.opacity -= 52 * 20 / Graphics.frame_rate if flash.opacity > 0
elsif i == shudderTime # Make the flash black

View File

@@ -18,7 +18,7 @@ end
# Resets all roaming Pokemon that were defeated without having been caught.
def pbResetAllRoamers
return if !$PokemonGlobal.roamPokemon
for i in 0...$PokemonGlobal.roamPokemon.length
$PokemonGlobal.roamPokemon.length.times do |i|
next if $PokemonGlobal.roamPokemon[i] != true || !$PokemonGlobal.roamPokemonCaught[i]
$PokemonGlobal.roamPokemon[i] = nil
end
@@ -45,14 +45,14 @@ def pbRoamPokemon
# Start all roamers off in random maps
if !$PokemonGlobal.roamPosition
$PokemonGlobal.roamPosition = {}
for i in 0...Settings::ROAMING_SPECIES.length
Settings::ROAMING_SPECIES.length.times do |i|
next if !GameData::Species.exists?(Settings::ROAMING_SPECIES[i][0])
keys = pbRoamingAreas(i).keys
$PokemonGlobal.roamPosition[i] = keys[rand(keys.length)]
end
end
# Roam each Pokémon in turn
for i in 0...Settings::ROAMING_SPECIES.length
Settings::ROAMING_SPECIES.length.times do |i|
pbRoamPokemonOne(i)
end
end
@@ -77,7 +77,7 @@ def pbRoamPokemonOne(idxRoamer)
newMapChoices = []
nextMaps = pbRoamingAreas(idxRoamer)[currentMap]
return if !nextMaps
for map in nextMaps
nextMaps.each do |map|
# Only add map as a choice if the player hasn't been there recently
newMapChoices.push(map)
end

View File

@@ -73,7 +73,7 @@ class PokemonGlobalMetadata
@pokedexDex = (numRegions == 0) ? -1 : 0
@pokedexIndex = []
@pokedexMode = 0
for i in 0...numRegions + 1 # National Dex isn't a region, but is included
(numRegions + 1).times do |i| # National Dex isn't a region, but is included
@pokedexIndex[i] = 0
end
# Day Care
@@ -153,13 +153,13 @@ class PokemonMapMetadata
end
def updateMap
for i in @erasedEvents
@erasedEvents.each do |i|
if i[0][0] == $game_map.map_id && i[1]
event = $game_map.events[i[0][1]]
event.erase if event
end
end
for i in @movedEvents
@movedEvents.each do |i|
if i[0][0] == $game_map.map_id && i[1]
next if !$game_map.events[i[0][1]]
$game_map.events[i[0][1]].moveto(i[1][0], i[1][1])

View File

@@ -154,7 +154,7 @@ def moonphase(time = nil) # in UTC
v = (j - 2451550.1) / 29.530588853
v = ((v - v.floor) + (v < 0 ? 1 : 0))
ag = v * 29.53
for i in 0...transitions.length
transitions.length.times do |i|
return i if ag <= transitions[i]
end
return 0
@@ -177,7 +177,7 @@ def zodiac(month, day)
1, 20, 2, 18, # Aquarius
2, 19, 3, 20 # Pisces
]
for i in 0...12
(time.length / 4).times do |i|
return i if month == time[i * 4] && day >= time[(i * 4) + 1]
return i if month == time[(i * 4) + 2] && day <= time[(i * 4) + 3]
end
@@ -207,7 +207,7 @@ def pbIsWeekday(wdayVariable, *arg)
timenow = pbGetTimeNow
wday = timenow.wday
ret = false
for wd in arg
arg.each do |wd|
ret = true if wd == wday
end
if wdayVariable > 0
@@ -232,7 +232,7 @@ def pbIsMonth(monVariable, *arg)
timenow = pbGetTimeNow
thismon = timenow.mon
ret = false
for wd in arg
arg.each do |wd|
ret = true if wd == thismon
end
if monVariable > 0
@@ -282,7 +282,7 @@ end
def pbIsSeason(seasonVariable, *arg)
thisseason = pbGetSeason
ret = false
for wd in arg
arg.each do |wd|
ret = true if wd == thisseason
end
if seasonVariable > 0

View File

@@ -155,7 +155,7 @@ def pbHiddenMoveAnimation(pokemon)
phase = 6 if interp.done?
end
# Constantly stream the strobes across the screen
for strobe in strobes
strobes.each do |strobe|
strobe.ox = strobe.viewport.rect.x
strobe.oy = strobe.viewport.rect.y
if !strobe.visible # Initial placement of strobes
@@ -175,7 +175,7 @@ def pbHiddenMoveAnimation(pokemon)
break if phase == 6
end
sprite.dispose
for strobe in strobes
strobes.each do |strobe|
strobe.dispose
end
strobes.clear

View File

@@ -91,9 +91,9 @@ module RandomDungeonGenerator
tiles = []
x_offset = (CELL_WIDTH - CORRIDOR_WIDTH) / 2
y_offset = (CELL_HEIGHT - CORRIDOR_WIDTH) / 2
for combo in 0...16
16.times do |combo|
tiles[combo] = []
for i in 0...CELL_WIDTH * CELL_HEIGHT
(CELL_WIDTH * CELL_HEIGHT).times do |i|
tiles[combo][i] = DungeonTile::VOID
end
if (combo & EdgeMasks::NORTH) == 0
@@ -116,8 +116,8 @@ module RandomDungeonGenerator
# Makes all tiles in a particular area corridor tiles.
def paint_corridor(tile, x, y, width, height)
for j in 0...height
for i in 0...width
timesheight.times do |j|
timeswidth.times do |i|
tile[((y + j) * CELL_WIDTH) + (x + i)] = DungeonTile::CORRIDOR
end
end
@@ -127,26 +127,26 @@ module RandomDungeonGenerator
def paint_tile_layout(dungeon, dstX, dstY, tile_layout, rotation)
case rotation
when TURN_NONE
for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH
CELL_HEIGHT.times do |y|
CELL_WIDTH.times do |x|
dungeon[x + dstX, y + dstY] = tile_layout[(y * CELL_WIDTH) + x]
end
end
when TURN_LEFT
for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH
CELL_HEIGHT.times do |y|
CELL_WIDTH.times do |x|
dungeon[y + dstX, CELL_WIDTH - 1 - x + dstY] = tile_layout[(y * CELL_WIDTH) + x]
end
end
when TURN_RIGHT
for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH
CELL_HEIGHT.times do |y|
CELL_WIDTH.times do |x|
dungeon[CELL_HEIGHT - 1 - y + dstX, x + dstY] = tile_layout[(y * CELL_WIDTH) + x]
end
end
when TURN_BACK
for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH
CELL_HEIGHT.times do |y|
CELL_WIDTH.times do |x|
dungeon[CELL_WIDTH - 1 - x + dstX, CELL_HEIGHT - 1 - y + dstY] = tile_layout[(y * CELL_WIDTH) + x]
end
end
@@ -258,7 +258,7 @@ module RandomDungeonGenerator
end
def clearAllCells
for c in 0...cellWidth * cellHeight
(cellWidth * cellHeight).times do |c|
@cells[c] = 0
end
end
@@ -295,7 +295,7 @@ module RandomDungeonGenerator
end
def setAllEdges
for c in 0...nodeWidth * nodeHeight
(nodeWidth * nodeHeight).times do |c|
@nodes[c].set
end
end
@@ -327,7 +327,7 @@ module RandomDungeonGenerator
end
def clearAllEdges
for c in 0...nodeWidth * nodeHeight
(nodeWidth * nodeHeight).times do |c|
@nodes[c].clear
end
end
@@ -373,8 +373,8 @@ module RandomDungeonGenerator
def buildNodeList
list = []
for x in 0...nodeWidth
for y in 0...nodeHeight
nodeWidth.times do |x|
nodeHeight.times do |y|
list.push(NodeListElement.new(x, y))
end
end
@@ -386,7 +386,7 @@ module RandomDungeonGenerator
maxWall = cellWidth if !maxWall
nlist = buildNodeList
return if nlist.length == 0
for c in 0...nlist.length
nlist.length.times do |c|
d = randomDir
len = rand(maxWall + 1)
x = nlist[c].x
@@ -398,7 +398,7 @@ module RandomDungeonGenerator
def recurseDepthFirst(x, y, depth)
setVisited(x, y)
dirs = DIRECTIONS.shuffle
for c in 0...4
4.times do |c|
d = dirs[c]
cx = x
cy = y
@@ -464,7 +464,7 @@ module RandomDungeonGenerator
end
def clear
for i in 0...width * height
(width * height).times do |i|
@array[i] = DungeonTile::VOID
end
end
@@ -472,8 +472,8 @@ module RandomDungeonGenerator
def write
ret = ""
i = 0
for y in 0...@height
for x in 0...@width
@height.times do |y|
@width.times do |x|
ret += DungeonTile.to_text(value(x, y))
i += 1
end
@@ -544,8 +544,8 @@ module RandomDungeonGenerator
end
def paint_room(rect, offsetX, offsetY)
for y in (rect[1] + offsetY)...(rect[1] + offsetY + rect[3])
for x in (rect[0] + offsetX)...(rect[0] + offsetX + rect[2])
((rect[1] + offsetY)...(rect[1] + offsetY + rect[3])).each do |y|
((rect[0] + offsetX)...(rect[0] + offsetX + rect[2])).each do |x|
self[x, y] = DungeonTile::ROOM
end
end
@@ -559,8 +559,8 @@ module RandomDungeonGenerator
cellHeight = DungeonMaze::CELL_HEIGHT
return if maxWidth < 0 || maxHeight < 0
if maxWidth < cellWidth || maxHeight < cellHeight # Map is too small
for x in 0...maxWidth
for y in 0...maxHeight
maxWidth.times do |x|
maxHeight.times do |y|
self[x + BUFFER_X, y + BUFFER_Y] = DungeonTile::ROOM
end
end
@@ -572,8 +572,8 @@ module RandomDungeonGenerator
# Draw each cell's contents in turn (room and corridors)
corridor_patterns = DungeonMaze.generate_corridor_patterns
roomcount = 0
for y in 0...maxHeight / cellHeight
for x in 0...maxWidth / cellWidth
(maxHeight / cellHeight).times do |y|
(maxWidth / cellWidth).times do |x|
pattern = maze.getEdgePattern(x, y)
next if !DungeonMaze.paint_cell_contents(
self, BUFFER_X + (x * cellWidth), BUFFER_Y + (y * cellHeight),
@@ -584,15 +584,15 @@ module RandomDungeonGenerator
end
# If no rooms were generated, make the whole map a room
if roomcount == 0
for x in 0...maxWidth
for y in 0...maxHeight
maxWidth.times do |x|
maxHeight.times do |y|
self[x + BUFFER_X, y + BUFFER_Y] = DungeonTile::ROOM
end
end
end
# Generate walls
for y in 0...@height
for x in 0...@width
@height.times do |y|
@width.times do |x|
self[x, y] = DungeonTile::WALL if isWall?(x, y) # Make appropriate tiles wall tiles
end
end
@@ -601,8 +601,8 @@ module RandomDungeonGenerator
# Convert dungeon layout into proper map tiles
def generateMapInPlace(map)
tbl = DungeonTable.new(self)
for i in 0...map.width
for j in 0...map.height
map.width.times do |i|
map.height.times do |j|
nb = TileDrawingHelper.tableNeighbors(tbl, i, j)
tile = TileDrawingHelper::NEIGHBORS_TO_AUTOTILE_INDEX[nb]
map.data[i, j, 0] = tile + (48 * (tbl[i, j]))
@@ -655,7 +655,7 @@ Events.onMapCreate += proc { |_sender, e|
dungeon.generateMapInPlace(map)
roomtiles = []
# Reposition events
for event in map.events.values
map.events.values.each do |event|
tile = RandomDungeonGenerator.pbRandomRoomTile(dungeon, roomtiles)
if tile
event.x = tile[0]

View File

@@ -183,7 +183,7 @@ def pbChangeLevel(pkmn, new_level, scene)
pkmn.totalhp, pkmn.attack, pkmn.defense, pkmn.spatk, pkmn.spdef, pkmn.speed), scene)
# Learn new moves upon level up
movelist = pkmn.getMoveList
for i in movelist
movelist.each do |i|
next if i[0] <= old_level || i[0] > pkmn.level
pbLearnMove(pkmn, i[1], true) { scene.pbUpdate }
end
@@ -292,7 +292,7 @@ def pbChangeExp(pkmn, new_exp, scene)
pkmn.totalhp, pkmn.attack, pkmn.defense, pkmn.spatk, pkmn.spdef, pkmn.speed), scene)
# Learn new moves upon level up
movelist = pkmn.getMoveList
for i in movelist
movelist.each do |i|
next if i[0] <= old_level || i[0] > pkmn.level
pbLearnMove(pkmn, i[1], true) { scene.pbUpdate }
end
@@ -551,7 +551,7 @@ def pbClosestHiddenItem
result = []
playerX = $game_player.x
playerY = $game_player.y
for event in $game_map.events.values
$game_map.events.values.each do |event|
next if !event.name[/hiddenitem/i]
next if (playerX - event.x).abs >= 8
next if (playerY - event.y).abs >= 6
@@ -561,7 +561,7 @@ def pbClosestHiddenItem
return nil if result.length == 0
ret = nil
retmin = 0
for event in result
result.each do |event|
dist = (playerX - event.x).abs + (playerY - event.y).abs
next if ret && retmin <= dist
ret = event
@@ -663,7 +663,7 @@ def pbUseItem(bag, item, bagscene = nil)
annot = nil
if itm.is_evolution_stone?
annot = []
for pkmn in $player.party
$player.party.each do |pkmn|
elig = pkmn.check_evolution_on_use_item(item)
annot.push((elig) ? _INTL("ABLE") : _INTL("NOT ABLE"))
end
@@ -909,7 +909,7 @@ end
def pbChooseItemFromList(message, variable, *args)
commands = []
itemid = []
for item in args
args.each do |item|
next if !GameData::Item.exists?(item)
itm = GameData::Item.get(item)
next if !$bag.has?(itm)

View File

@@ -193,7 +193,7 @@ ItemHandlers::UseInField.add(:SACREDASH, proc { |item|
next false
end
canrevive = false
for i in $player.pokemon_party
$player.pokemon_party.each do |i|
next if !i.fainted?
canrevive = true
break
@@ -604,7 +604,7 @@ ItemHandlers::UseOnPokemon.add(:MAXETHER, proc { |item, qty, pkmn, scene|
ItemHandlers::UseOnPokemon.add(:ELIXIR, proc { |item, qty, pkmn, scene|
pprestored = 0
for i in 0...pkmn.moves.length
pkmn.moves.length.times do |i|
pprestored += pbRestorePP(pkmn, i, 10)
end
if pprestored == 0
@@ -617,7 +617,7 @@ ItemHandlers::UseOnPokemon.add(:ELIXIR, proc { |item, qty, pkmn, scene|
ItemHandlers::UseOnPokemon.add(:MAXELIXIR, proc { |item, qty, pkmn, scene|
pprestored = 0
for i in 0...pkmn.moves.length
pkmn.moves.length.times do |i|
pprestored += pbRestorePP(pkmn, i, pkmn.moves[i].total_pp - pkmn.moves[i].pp)
end
if pprestored == 0
@@ -1027,7 +1027,7 @@ ItemHandlers::UseOnPokemon.add(:ABILITYCAPSULE, proc { |item, qty, pkmn, scene|
abils = pkmn.getAbilityList
abil1 = nil
abil2 = nil
for i in abils
abils.each do |i|
abil1 = i[0] if i[1] == 0
abil2 = i[0] if i[1] == 1
end

View File

@@ -163,7 +163,7 @@ ItemHandlers::CanUseInBattle.add(:ELIXIR, proc { |item, pokemon, battler, move,
next false
end
canRestore = false
for m in pokemon.moves
pokemon.moves.each do |m|
next if m.id == 0
next if m.total_pp <= 0 || m.pp == m.total_pp
canRestore = true
@@ -502,14 +502,14 @@ ItemHandlers::BattleUseOnPokemon.add(:MAXETHER, proc { |item, pokemon, battler,
})
ItemHandlers::BattleUseOnPokemon.add(:ELIXIR, proc { |item, pokemon, battler, choices, scene|
for i in 0...pokemon.moves.length
pokemon.moves.length.times do |i|
pbBattleRestorePP(pokemon, battler, i, 10)
end
scene.pbDisplay(_INTL("PP was restored."))
})
ItemHandlers::BattleUseOnPokemon.add(:MAXELIXIR, proc { |item, pokemon, battler, choices, scene|
for i in 0...pokemon.moves.length
pokemon.moves.length.times do |i|
pbBattleRestorePP(pokemon, battler, i, pokemon.moves[i].total_pp)
end
scene.pbDisplay(_INTL("PP was restored."))

View File

@@ -67,7 +67,7 @@ def pbRandomPhoneTrainer
this_map_metadata = $game_map.metadata
return nil if !this_map_metadata || !this_map_metadata.town_map_position
currentRegion = this_map_metadata.town_map_position[0]
for num in $PokemonGlobal.phoneNumbers
$PokemonGlobal.phoneNumbers.each do |num|
next if !num[0] || num.length != 8 # if not visible or not a trainer
next if $game_map.map_id == num[6] # Can't call if on same map
caller_map_metadata = GameData::MapMetadata.try_get(num[6])
@@ -82,7 +82,7 @@ end
def pbFindPhoneTrainer(tr_type, tr_name) # Ignores whether visible or not
return nil if !$PokemonGlobal.phoneNumbers
for num in $PokemonGlobal.phoneNumbers
$PokemonGlobal.phoneNumbers.each do |num|
return num if num[1] == tr_type && num[2] == tr_name # If a match
end
return nil
@@ -146,7 +146,7 @@ Events.onMapUpdate += proc { |_sender, _e|
$PokemonGlobal.phoneTime -= 1
# Count down time to next can-battle for each trainer contact
if $PokemonGlobal.phoneTime % Graphics.frame_rate == 0 # Every second
for num in $PokemonGlobal.phoneNumbers
$PokemonGlobal.phoneNumbers.each do |num|
next if !num[0] || num.length != 8 # if not visible or not a trainer
# Reset time to next can-battle if necessary
if num[4] == 0
@@ -291,7 +291,7 @@ def pbPhoneCall(call, phonenum)
trainerspecies = pbTrainerSpecies(phonenum)
trainermap = pbTrainerMapName(phonenum)
messages = call.split("\\m")
for i in 0...messages.length
messages.length.times do |i|
messages[i].gsub!(/\\TN/, phonenum[2])
messages[i].gsub!(/\\TP/, trainerspecies)
messages[i].gsub!(/\\TE/, encspecies)

View File

@@ -58,7 +58,7 @@ end
def pbPokeRadarHighlightGrass(showmessage = true)
grasses = [] # x, y, ring (0-3 inner to outer), rarity
# Choose 1 random tile from each ring around the player
for i in 0...4
4.times do |i|
r = rand((i + 1) * 8)
# Get coordinates of randomly chosen tile
x = $game_player.x
@@ -95,7 +95,7 @@ def pbPokeRadarHighlightGrass(showmessage = true)
pbPokeRadarCancel
else
# Show grass rustling animations
for grass in grasses
grasses.each do |grass|
case grass[3]
when 0 # Normal rustle
$scene.spriteset.addUserAnimation(Settings::RUSTLE_NORMAL_ANIMATION_ID, grass[0], grass[1], true, 1)
@@ -114,7 +114,7 @@ def pbPokeRadarGetShakingGrass
return -1 if !$game_temp.poke_radar_data
grasses = $game_temp.poke_radar_data[3]
return -1 if grasses.length == 0
for i in grasses
grasses.each do |i|
return i[2] if $game_player.x == i[0] && $game_player.y == i[1]
end
return -1
@@ -197,7 +197,7 @@ Events.onWildPokemonCreate += proc { |_sender, e|
next if !$game_temp.poke_radar_data
grasses = $game_temp.poke_radar_data[3]
next if !grasses
for grass in grasses
grasses.each do |grass|
next if $game_player.x != grass[0] || $game_player.y != grass[1]
pokemon.shiny = true if grass[3] == 2
break

View File

@@ -19,7 +19,7 @@ class PokemonBag
@last_viewed_pocket = 1
@pockets = []
@last_pocket_selections = []
for i in 0..PokemonBag.pocket_count
(0..PokemonBag.pocket_count).each do |i|
@pockets[i] = []
@last_pocket_selections[i] = 0
end

View File

@@ -37,9 +37,9 @@ end
def drawSpot(bitmap, spotpattern, x, y, red, green, blue)
height = spotpattern.length
width = spotpattern[0].length
for yy in 0...height
height.times do |yy|
spot = spotpattern[yy]
for xx in 0...width
width.times do |xx|
if spot[xx] == 1
xOrg = (x + xx) << 1
yOrg = (y + yy) << 1
@@ -297,7 +297,7 @@ MultipleForms.register(:ARCEUS, {
}
ret = 0
typeArray.each do |f, items|
for item in items
items.each do |item|
next if !pkmn.hasItem?(item)
ret = f
break
@@ -502,7 +502,7 @@ MultipleForms.register(:SILVALLY, {
}
ret = 0
typeArray.each do |f, items|
for item in items
items.each do |item|
next if !pkmn.hasItem?(item)
ret = f
break

View File

@@ -372,7 +372,7 @@ end
#===============================================================================
class Battle::Move::RemoveAllScreens < Battle::Move
def pbEffectGeneral(user)
for i in @battle.sides
@battle.sides.each do |i|
i.effects[PBEffects::AuroraVeil] = 0
i.effects[PBEffects::Reflect] = 0
i.effects[PBEffects::LightScreen] = 0

View File

@@ -8,12 +8,10 @@ class PokemonBox
BOX_SIZE = BOX_WIDTH * BOX_HEIGHT
def initialize(name, maxPokemon = BOX_SIZE)
@pokemon = []
@name = name
@background = 0
for i in 0...maxPokemon
@pokemon[i] = nil
end
@pokemon = []
maxPokemon.times { |i| @pokemon[i] = nil }
end
def length
@@ -62,14 +60,14 @@ class PokemonStorage
def initialize(maxBoxes = Settings::NUM_STORAGE_BOXES, maxPokemon = PokemonBox::BOX_SIZE)
@boxes = []
for i in 0...maxBoxes
maxBoxes.times do |i|
@boxes[i] = PokemonBox.new(_INTL("Box {1}", i + 1), maxPokemon)
@boxes[i].background = i % BASICWALLPAPERQTY
end
@currentBox = 0
@boxmode = -1
@unlockedWallpapers = []
for i in 0...allWallpapers.length
allWallpapers.length.times do |i|
@unlockedWallpapers[i] = false
end
end
@@ -107,7 +105,7 @@ class PokemonStorage
ret = [[], []] # Names, IDs
papers = allWallpapers
@unlockedWallpapers = [] if !@unlockedWallpapers
for i in 0...papers.length
papers.length.times do |i|
next if !isAvailableWallpaper?(i)
ret[0].push(papers[i])
ret[1].push(i)
@@ -137,7 +135,7 @@ class PokemonStorage
end
def full?
for i in 0...self.maxBoxes
self.maxBoxes.times do |i|
return false if !@boxes[i].full?
end
return true
@@ -148,7 +146,7 @@ class PokemonStorage
ret = self.party.length
return (ret >= Settings::MAX_PARTY_SIZE) ? -1 : ret
end
for i in 0...maxPokemon(box)
maxPokemon(box).times do |i|
return i if !self[box, i]
end
return -1
@@ -158,7 +156,7 @@ class PokemonStorage
if y == nil
return (x == -1) ? self.party : @boxes[x]
else
for i in @boxes
@boxes.each do |i|
raise "Box is a Pokémon, not a box" if i.is_a?(Pokemon)
end
return (x == -1) ? self.party[y] : @boxes[x][y]
@@ -176,7 +174,7 @@ class PokemonStorage
def pbCopy(boxDst, indexDst, boxSrc, indexSrc)
if indexDst < 0 && boxDst < self.maxBoxes
found = false
for i in 0...maxPokemon(boxDst)
maxPokemon(boxDst).times do |i|
next if self[boxDst, i]
found = true
indexDst = i
@@ -213,7 +211,7 @@ class PokemonStorage
end
def pbMoveCaughtToBox(pkmn, box)
for i in 0...maxPokemon(box)
maxPokemon(box).times do |i|
if self[box, i] == nil
if Settings::HEAL_STORED_POKEMON && box >= 0
old_ready_evo = pkmn.ready_to_evolve
@@ -233,14 +231,14 @@ class PokemonStorage
pkmn.heal
pkmn.ready_to_evolve = old_ready_evo
end
for i in 0...maxPokemon(@currentBox)
maxPokemon(@currentBox).times do |i|
if self[@currentBox, i] == nil
self[@currentBox, i] = pkmn
return @currentBox
end
end
for j in 0...self.maxBoxes
for i in 0...maxPokemon(j)
self.maxBoxes.times do |j|
maxPokemon(j).times do |i|
if self[j, i] == nil
self[j, i] = pkmn
@currentBox = j
@@ -259,9 +257,7 @@ class PokemonStorage
end
def clear
for i in 0...self.maxBoxes
@boxes[i].clear
end
self.maxBoxes.times { |i| @boxes[i].clear }
end
end
@@ -393,8 +389,8 @@ end
#===============================================================================
# Yields every Pokémon/egg in storage in turn.
def pbEachPokemon
for i in -1...$PokemonStorage.maxBoxes
for j in 0...$PokemonStorage.maxPokemon(i)
(-1...$PokemonStorage.maxBoxes).each do |i|
$PokemonStorage.maxPokemon(i).times do |j|
pkmn = $PokemonStorage[i][j]
yield(pkmn, i) if pkmn
end

View File

@@ -631,7 +631,7 @@ class Pokemon
@moves.clear
first_move_index = knowable_moves.length - MAX_MOVES
first_move_index = 0 if first_move_index < 0
for i in first_move_index...knowable_moves.length
(first_move_index...knowable_moves.length).each do |i|
@moves.push(Pokemon::Move.new(knowable_moves[i]))
end
end
@@ -744,7 +744,7 @@ class Pokemon
args.each_with_index do |ribbon, i|
this_ribbon_data = GameData::Ribbon.try_get(ribbon)
next if !this_ribbon_data
for j in 0...@ribbons.length
@ribbons.length.times do |j|
next if @ribbons[j] != this_ribbon_data.id
next_ribbon_data = GameData::Ribbon.try_get(args[i + 1])
next if !next_ribbon_data

View File

@@ -11,7 +11,7 @@ end
def pbNewTrainer(tr_type, tr_name, tr_version, save_changes = true)
party = []
for i in 0...Settings::MAX_PARTY_SIZE
Settings::MAX_PARTY_SIZE.times do |i|
if i == 0
pbMessage(_INTL("Please enter the first Pokémon.", i))
elsif !pbConfirmMessage(_INTL("Add another Pokémon?"))
@@ -99,7 +99,7 @@ def pbGetFreeTrainerParty(tr_type, tr_name)
tr_type_data = GameData::TrainerType.try_get(tr_type)
raise _INTL("Trainer type {1} does not exist.", tr_type) if !tr_type_data
tr_type = tr_type_data.id
for i in 0...256
256.times do |i|
return i if !GameData::Trainer.try_get(tr_type, tr_name, i)
end
return -1

View File

@@ -119,7 +119,7 @@ class Player < Trainer
ret = 0
@seen_forms[species_id] ||= [[[], []], [[], []]]
array = @seen_forms[species_id]
for i in 0...[array[0].length, array[1].length].max
[array[0].length, array[1].length].max.times do |i|
ret += 1 if array[0][0][i] || array[0][1][i] || # male or genderless shiny/non-shiny
array[1][0][i] || array[1][1][i] # female shiny/non-shiny
end
@@ -325,7 +325,7 @@ class Player < Trainer
@accessible_dexes.push(-1)
end
else # Regional Dexes + National Dex
for i in 0...dexes_count
dexes_count.times do |i|
dex_list_to_check = (i == dexes_count - 1) ? -1 : i
if self.unlocked?(i) && self.seen_any?(dex_list_to_check)
@accessible_dexes.push(dex_list_to_check)

View File

@@ -77,7 +77,7 @@ class PokemonEggHatch_Scene
# Fade and change the sprite
fadeTime = Graphics.frame_rate * 4 / 10
toneDiff = (255.0 / fadeTime).ceil
for i in 1..fadeTime
(1..fadeTime).each do |i|
@sprites["pokemon"].tone = Tone.new(i * toneDiff, i * toneDiff, i * toneDiff)
@sprites["overlay"].opacity = i * toneDiff
updateScene
@@ -88,7 +88,7 @@ class PokemonEggHatch_Scene
@sprites["pokemon"].y = 264
@pokemon.species_data.apply_metrics_to_sprite(@sprites["pokemon"], 1)
@sprites["hatch"].visible = false
for i in 1..fadeTime
(1..fadeTime).each do |i|
@sprites["pokemon"].tone = Tone.new(255 - (i * toneDiff), 255 - (i * toneDiff), 255 - (i * toneDiff))
@sprites["overlay"].opacity = 255 - (i * toneDiff)
updateScene
@@ -220,10 +220,10 @@ def pbHatch(pokemon)
end
Events.onStepTaken += proc { |_sender, _e|
for egg in $player.party
$player.party.each do |egg|
next if egg.steps_to_hatch <= 0
egg.steps_to_hatch -= 1
for i in $player.pokemon_party
$player.pokemon_party.each do |i|
next if ![:FLAMEBODY, :MAGMAARMOR, :STEAMENGINE].include?(i.ability_id)
egg.steps_to_hatch -= 1
break

View File

@@ -253,12 +253,12 @@ class SpriteMetafilePlayer
def update
if @playing
for j in @index...@metafile.length
(@index...@metafile.length).each do |j|
@index = j + 1
break if @metafile[j][0] < 0
code = @metafile[j][0]
value = @metafile[j][1]
for sprite in @sprites
@sprites.each do |sprite|
case code
when SpriteMetafile::X then sprite.x = value
when SpriteMetafile::Y then sprite.y = value
@@ -379,7 +379,7 @@ class PokemonEvolutionScene
currenttempo = 25
maxtempo = 7 * Graphics.frame_rate
while totaltempo < maxtempo
for j in 0...currenttempo
currenttempo.times do |j|
if alpha < 255
sprite.color.red = 255
sprite.color.green = 255
@@ -395,7 +395,7 @@ class PokemonEvolutionScene
end
totaltempo += currenttempo
if totaltempo + currenttempo < maxtempo
for j in 0...currenttempo
currenttempo.times do |j|
sprite.zoom = [1.1 * (j + 1) / currenttempo, 1.0].min
sprite2.zoom = [1.1 * (currenttempo - j - 1) / currenttempo, 1.0].min
sprite.update
@@ -542,7 +542,7 @@ class PokemonEvolutionScene
pbMEPlay("Evolution start")
pbBGMPlay("Evolution")
canceled = false
begin
loop do
pbUpdateNarrowScreen
metaplayer1.update
metaplayer2.update
@@ -555,7 +555,8 @@ class PokemonEvolutionScene
canceled = true
break
end
end while metaplayer1.playing? && metaplayer2.playing?
break unless metaplayer1.playing? && metaplayer2.playing?
end
pbFlashInOut(canceled, oldstate, oldstate2)
if canceled
$stats.evolutions_cancelled += 1
@@ -595,7 +596,7 @@ class PokemonEvolutionScene
$player.pokedex.set_owned(@newspecies)
# Learn moves upon evolution for evolved species
movelist = @pokemon.getMoveList
for i in movelist
movelist.each do |i|
next if i[0] != 0 && i[0] != @pokemon.level # 0 is "learn upon evolution"
pbLearnMove(@pokemon, i[1], true) { pbUpdate }
end

View File

@@ -8,22 +8,18 @@ class PokemonTrade_Scene
def pbRunPictures(pictures, sprites)
loop do
for i in 0...pictures.length
pictures[i].update
end
for i in 0...sprites.length
if sprites[i].is_a?(IconSprite)
setPictureIconSprite(sprites[i], pictures[i])
pictures.each { |pic| pic.update }
sprites.each_with_index do |sprite, i|
if sprite.is_a?(IconSprite)
setPictureIconSprite(sprite, pictures[i])
else
setPictureSprite(sprites[i], pictures[i])
setPictureSprite(sprite, pictures[i])
end
end
Graphics.update
Input.update
running = false
for i in 0...pictures.length
running = true if pictures[i].running?
end
pictures.each { |pic| running = true if pic.running? }
break if !running
end
end
@@ -119,7 +115,7 @@ class PokemonTrade_Scene
# Dropping ball
y = Graphics.height - 96 - 16 - 16 # end point of Poké Ball
delay = picturePoke.totalDuration + 2
for i in 0...4
4.times do |i|
t = [4, 4, 3, 2][i] # Time taken to rise or fall for each bounce
d = [1, 2, 4, 8][i] # Fraction of the starting height each bounce rises to
delay -= t if i == 0

View File

@@ -96,7 +96,7 @@ class HallOfFame_Scene
exponent = 8 if exponent > 8
max = 2**exponent
speed = (2**8) / max
for j in 0..max
(0..max).each do |j|
if extraWaitExponent > -1
(2**extraWaitExponent).times do
Graphics.update
@@ -117,7 +117,7 @@ class HallOfFame_Scene
# Change the pokémon sprites opacity except the index one
def setPokemonSpritesOpacity(index, opacity = 255)
for n in 0...@hallEntry.size
@hallEntry.size.times do |n|
@sprites["pokemon#{n}"].opacity = (n == index) ? 255 : opacity if @sprites["pokemon#{n}"]
end
end
@@ -201,7 +201,7 @@ class HallOfFame_Scene
def createBattlers(hide = true)
# Movement in animation
for i in 0...6
6.times do |i|
# Clear all 6 pokémon sprites and dispose the ones that exists every time
# that this method is call
restartSpritePosition(@sprites, "pokemon#{i}")

View File

@@ -144,17 +144,17 @@ _END_
@total_height = credit_lines.size * 32
lines_per_bitmap = @bitmap_height / 32
num_bitmaps = (credit_lines.size.to_f / lines_per_bitmap).ceil
for i in 0...num_bitmaps
num_bitmaps.times do |i|
credit_bitmap = Bitmap.new(Graphics.width, @bitmap_height + 16)
pbSetSystemFont(credit_bitmap)
for j in 0...lines_per_bitmap
lines_per_bitmap.times do |j|
line = credit_lines[(i * lines_per_bitmap) + j]
next if !line
line = line.split("<s>")
xpos = 0
align = 1 # Centre align
linewidth = Graphics.width
for k in 0...line.length
line.length.times do |k|
if line.length > 1
xpos = (k == 0) ? 0 : 20 + (Graphics.width / 2)
align = (k == 0) ? 2 : 0 # Right align : left align

View File

@@ -58,7 +58,7 @@ class Window_Pokedex < Window_DrawableCommand
dheight = self.height - self.borderY
self.contents = pbDoEnsureBitmap(self.contents, dwidth, dheight)
self.contents.clear
for i in 0...@item_max
@item_max.times do |i|
next if i < self.top_item || i > self.top_item + self.page_item_max
drawItem(i, @item_max, itemRect(i))
end
@@ -613,7 +613,7 @@ class PokemonPokedex_Scene
# Draw selected option(s) text in top bar
case mode
when 2 # Type icons
for i in 0...2
2.times do |i|
if !sel[i] || sel[i] < 0
textpos.push(["----", 298 + (128 * i), 58, 2, base, shadow, 1])
else
@@ -695,7 +695,7 @@ class PokemonPokedex_Scene
textpos.push([txt1, xpos1 + halfwidth, ypos1, 2, base, nil, 1])
textpos.push([txt2, xpos2 + halfwidth, ypos2, 2, base, nil, 1])
else
for i in 0...sel.length
sel.length.times do |i|
selrect = Rect.new(0, selbuttony, @selbitmap.bitmap.width, selbuttonheight)
if sel[i] >= 0
overlay.blt(xstart + ((sel[i] % cols) * xgap), ystart + ((sel[i] / cols).floor * ygap), @selbitmap.bitmap, selrect)
@@ -707,7 +707,7 @@ class PokemonPokedex_Scene
# Draw options
case mode
when 0, 1 # Order, name
for i in 0...cmds.length
cmds.length.times do |i|
x = xstart + halfwidth + ((i % cols) * xgap)
y = ystart + 6 + ((i / cols).floor * ygap)
textpos.push([cmds[i], x, y, 2, base, shadow, 1])
@@ -718,14 +718,14 @@ class PokemonPokedex_Scene
end
when 2 # Type
typerect = Rect.new(0, 0, 96, 32)
for i in 0...cmds.length
cmds.length.times do |i|
typerect.y = @typeCommands[i].icon_position * 32
overlay.blt(xstart + 14 + ((i % cols) * xgap), ystart + 6 + ((i / cols).floor * ygap), @typebitmap.bitmap, typerect)
end
textpos.push(["----",
xstart + halfwidth + ((cols - 1) * xgap), ystart + 6 + ((cmds.length / cols).floor * ygap), 2, base, shadow, 1])
when 5 # Color
for i in 0...cmds.length
cmds.length.times do |i|
x = xstart + halfwidth + ((i % cols) * xgap)
y = ystart + 6 + ((i / cols).floor * ygap)
textpos.push([cmds[i].name, x, y, 2, base, shadow, 1])
@@ -734,7 +734,7 @@ class PokemonPokedex_Scene
xstart + halfwidth + ((cols - 1) * xgap), ystart + 6 + ((cmds.length / cols).floor * ygap), 2, base, shadow, 1])
when 6 # Shape
shaperect = Rect.new(0, 0, 60, 60)
for i in 0...cmds.length
cmds.length.times do |i|
shaperect.y = @shapeCommands[i].icon_position * 60
overlay.blt(xstart + 4 + ((i % cols) * xgap), ystart + 4 + ((i / cols).floor * ygap), @shapebitmap.bitmap, shaperect)
end
@@ -838,7 +838,7 @@ class PokemonPokedex_Scene
$PokemonGlobal.pokedexMode = MODENUMERICAL
@searchParams = [$PokemonGlobal.pokedexMode, -1, -1, -1, -1, -1, -1, -1, -1, -1]
pbRefreshDexList($PokemonGlobal.pokedexIndex[pbGetSavePositionIndex])
for i in 0...@dexlist.length
@dexlist.length.times do |i|
next if @dexlist[i][0] != oldspecies
@sprites["pokedex"].index = i
pbRefresh
@@ -1202,7 +1202,7 @@ class PokemonPokedex_Scene
params[9] = newparam[0] if newparam != nil
pbRefreshDexSearch(params, index)
when 7 # Clear filters
for i in 0...10
10.times do |i|
params[i] = (i == 0) ? MODENUMERICAL : -1
end
pbRefreshDexSearch(params, index)

View File

@@ -26,7 +26,7 @@ class PokemonPokedexInfo_Scene
@sprites["areamap"].setBitmap("Graphics/Pictures/#{@mapdata[@region][1]}")
@sprites["areamap"].x += (Graphics.width - @sprites["areamap"].bitmap.width) / 2
@sprites["areamap"].y += (Graphics.height + 32 - @sprites["areamap"].bitmap.height) / 2
for hidden in Settings::REGION_MAP_EXTRAS
Settings::REGION_MAP_EXTRAS.each do |hidden|
if hidden[0] == @region && hidden[1] > 0 && $game_switches[hidden[1]]
pbDrawImagePositions(
@sprites["areamap"].bitmap,
@@ -82,7 +82,7 @@ class PokemonPokedexInfo_Scene
dexnumshift = true if dexnum > 0 && Settings::DEXES_WITH_OFFSETS.include?(-1)
end
else
for i in 0...$player.pokedex.dexes_count - 1 # Regional Dexes
($player.pokedex.dexes_count - 1).times do |i| # Regional Dexes
next if !$player.pokedex.unlocked?(i)
num = pbGetRegionalNumber(i, species)
next if num <= 0
@@ -158,7 +158,7 @@ class PokemonPokedexInfo_Scene
real_gender = 2 if sp.gender_ratio == :Genderless
ret.push([sp.form_name, real_gender, sp.form])
else # Both male and female
for real_gender in 0...2
2.times do |real_gender|
next if !$player.pokedex.seen_form?(@species, real_gender, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS
ret.push([sp.form_name, real_gender, sp.form])
break if sp.form_name && !sp.form_name.empty? # Only show 1 entry for each non-0 form
@@ -309,7 +309,7 @@ class PokemonPokedexInfo_Scene
mappos = (map_metadata) ? map_metadata.town_map_position : nil
next if !mappos || mappos[0] != @region
showpoint = true
for loc in @mapdata[@region][2]
@mapdata[@region][2].each do |loc|
showpoint = false if loc[0] == mappos[1] && loc[1] == mappos[2] &&
loc[7] && !$game_switches[loc[7]]
end
@@ -318,8 +318,8 @@ class PokemonPokedexInfo_Scene
if mapsize && mapsize[0] && mapsize[0] > 0
sqwidth = mapsize[0]
sqheight = (mapsize[1].length.to_f / mapsize[0]).ceil
for i in 0...sqwidth
for j in 0...sqheight
sqwidth.times do |i|
sqheight.times do |j|
if mapsize[1][i + (j * sqwidth), 1].to_i > 0
points[mappos[1] + i + ((mappos[2] + j) * mapwidth)] = true
end
@@ -334,7 +334,7 @@ class PokemonPokedexInfo_Scene
pointcolorhl = Color.new(192, 248, 248)
sqwidth = PokemonRegionMap_Scene::SQUARE_WIDTH
sqheight = PokemonRegionMap_Scene::SQUARE_HEIGHT
for j in 0...points.length
points.length.times do |j|
if points[j]
x = (j % mapwidth) * sqwidth
x += (Graphics.width - @sprites["areamap"].bitmap.width) / 2
@@ -377,7 +377,7 @@ class PokemonPokedexInfo_Scene
shadow = Color.new(168, 184, 184)
# Write species and form name
formname = ""
for i in @available
@available.each do |i|
if i[1] == @gender && i[2] == @form
formname = i[0]
break
@@ -415,7 +415,7 @@ class PokemonPokedexInfo_Scene
def pbChooseForm
index = 0
for i in 0...@available.length
@available.length.times do |i|
if @available[i][1] == @gender && @available[i][2] == @form
index = i
break

View File

@@ -108,7 +108,7 @@ end
class Window_CommandPokemonColor < Window_CommandPokemon
def initialize(commands, width = nil)
@colorKey = []
for i in 0...commands.length
commands.length.times do |i|
if commands[i].is_a?(Array)
@colorKey[i] = commands[i][1]
commands[i] = commands[i][0]
@@ -472,7 +472,7 @@ class PokemonParty_Scene
pbBottomLeftLines(@sprites["helpwindow"], 1)
pbSetHelpText(starthelptext)
# Add party Pokémon sprites
for i in 0...Settings::MAX_PARTY_SIZE
Settings::MAX_PARTY_SIZE.times do |i|
if @party[i]
@sprites["pokemon#{i}"] = PokemonPartyPanel.new(@party[i], i, @viewport)
else
@@ -599,7 +599,7 @@ class PokemonParty_Scene
end
def pbAnnotate(annot)
for i in 0...Settings::MAX_PARTY_SIZE
Settings::MAX_PARTY_SIZE.times do |i|
@sprites["pokemon#{i}"].text = (annot) ? annot[i] : nil
end
end
@@ -607,7 +607,7 @@ class PokemonParty_Scene
def pbSelect(item)
@activecmd = item
numsprites = Settings::MAX_PARTY_SIZE + ((@multiselect) ? 2 : 1)
for i in 0...numsprites
numsprites.times do |i|
@sprites["pokemon#{i}"].selected = (i == @activecmd)
end
end
@@ -646,7 +646,7 @@ class PokemonParty_Scene
Input.update
self.update
end
for i in 0...Settings::MAX_PARTY_SIZE
Settings::MAX_PARTY_SIZE.times do |i|
@sprites["pokemon#{i}"].preselected = false
@sprites["pokemon#{i}"].switching = false
end
@@ -654,7 +654,7 @@ class PokemonParty_Scene
end
def pbClearSwitching
for i in 0...Settings::MAX_PARTY_SIZE
Settings::MAX_PARTY_SIZE.times do |i|
@sprites["pokemon#{i}"].preselected = false
@sprites["pokemon#{i}"].switching = false
end
@@ -700,7 +700,7 @@ class PokemonParty_Scene
end
def pbChoosePokemon(switching = false, initialsel = -1, canswitch = 0)
for i in 0...Settings::MAX_PARTY_SIZE
Settings::MAX_PARTY_SIZE.times do |i|
@sprites["pokemon#{i}"].preselected = (switching && i == @activecmd)
@sprites["pokemon#{i}"].switching = switching
end
@@ -722,7 +722,7 @@ class PokemonParty_Scene
if @activecmd != oldsel # Changing selection
pbPlayCursorSE
numsprites = Settings::MAX_PARTY_SIZE + ((@multiselect) ? 2 : 1)
for i in 0...numsprites
numsprites.times do |i|
@sprites["pokemon#{i}"].selected = (i == @activecmd)
end
end
@@ -759,17 +759,19 @@ class PokemonParty_Scene
numsprites = Settings::MAX_PARTY_SIZE + ((@multiselect) ? 2 : 1)
case key
when Input::LEFT
begin
loop do
currentsel -= 1
end while currentsel > 0 && currentsel < @party.length && !@party[currentsel]
break unless currentsel > 0 && currentsel < @party.length && !@party[currentsel]
end
if currentsel >= @party.length && currentsel < Settings::MAX_PARTY_SIZE
currentsel = @party.length - 1
end
currentsel = numsprites - 1 if currentsel < 0
when Input::RIGHT
begin
loop do
currentsel += 1
end while currentsel < @party.length && !@party[currentsel]
break unless currentsel < @party.length && !@party[currentsel]
end
if currentsel == @party.length
currentsel = Settings::MAX_PARTY_SIZE
elsif currentsel == numsprites
@@ -782,9 +784,10 @@ class PokemonParty_Scene
currentsel -= 1
end
else
begin
loop do
currentsel -= 2
end while currentsel > 0 && !@party[currentsel]
break unless currentsel > 0 && !@party[currentsel]
end
end
if currentsel >= @party.length && currentsel < Settings::MAX_PARTY_SIZE
currentsel = @party.length - 1
@@ -809,14 +812,14 @@ class PokemonParty_Scene
def pbHardRefresh
oldtext = []
lastselected = -1
for i in 0...Settings::MAX_PARTY_SIZE
Settings::MAX_PARTY_SIZE.times do |i|
oldtext.push(@sprites["pokemon#{i}"].text)
lastselected = i if @sprites["pokemon#{i}"].selected
@sprites["pokemon#{i}"].dispose
end
lastselected = @party.length - 1 if lastselected >= @party.length
lastselected = 0 if lastselected < 0
for i in 0...Settings::MAX_PARTY_SIZE
Settings::MAX_PARTY_SIZE.times do |i|
if @party[i]
@sprites["pokemon#{i}"] = PokemonPartyPanel.new(@party[i], i, @viewport)
else
@@ -828,7 +831,7 @@ class PokemonParty_Scene
end
def pbRefresh
for i in 0...Settings::MAX_PARTY_SIZE
Settings::MAX_PARTY_SIZE.times do |i|
sprite = @sprites["pokemon#{i}"]
if sprite
if sprite.is_a?(PokemonPartyPanel)
@@ -943,8 +946,8 @@ class PokemonPartyScreen
# Checks for identical species
def pbCheckSpecies(array) # Unused
for i in 0...array.length
for j in i + 1...array.length
array.length.times do |i|
(i + 1...array.length).each do |j|
return false if array[i].species == array[j].species
end
end
@@ -953,9 +956,9 @@ class PokemonPartyScreen
# Checks for identical held items
def pbCheckItems(array) # Unused
for i in 0...array.length
array.length.times do |i|
next if !array[i].hasItem?
for j in i + 1...array.length
(i + 1...array.length).each do |j|
return false if array[i].item == array[j].item
end
end
@@ -974,7 +977,7 @@ class PokemonPartyScreen
def pbChooseMove(pokemon, helptext, index = 0)
movenames = []
for i in pokemon.moves
pokemon.moves.each do |i|
next if !i || !i.id
if i.total_pp <= 0
movenames.push(_INTL("{1} (PP: ---)", i.name))
@@ -988,7 +991,7 @@ class PokemonPartyScreen
def pbRefreshAnnotations(ableProc) # For after using an evolution stone
return if !@scene.pbHasAnnotations?
annot = []
for pkmn in @party
@party.each do |pkmn|
elig = ableProc.call(pkmn)
annot.push((elig) ? _INTL("ABLE") : _INTL("NOT ABLE"))
end
@@ -1006,7 +1009,7 @@ class PokemonPartyScreen
positions = [_INTL("FIRST"), _INTL("SECOND"), _INTL("THIRD"), _INTL("FOURTH"),
_INTL("FIFTH"), _INTL("SIXTH"), _INTL("SEVENTH"), _INTL("EIGHTH"),
_INTL("NINTH"), _INTL("TENTH"), _INTL("ELEVENTH"), _INTL("TWELFTH")]
for i in 0...Settings::MAX_PARTY_SIZE
Settings::MAX_PARTY_SIZE.times do |i|
if i < positions.length
ordinals.push(positions[i])
else
@@ -1016,25 +1019,25 @@ class PokemonPartyScreen
return nil if !ruleset.hasValidTeam?(@party)
ret = nil
addedEntry = false
for i in 0...@party.length
@party.length.times do |i|
statuses[i] = (ruleset.isPokemonValid?(@party[i])) ? 1 : 2
annot[i] = ordinals[statuses[i]]
end
@scene.pbStartScene(@party, _INTL("Choose Pokémon and confirm."), annot, true)
loop do
realorder = []
for i in 0...@party.length
for j in 0...@party.length
@party.length.times do |i|
@party.length.times do |j|
if statuses[j] == i + 3
realorder.push(j)
break
end
end
end
for i in 0...realorder.length
realorder.length.times do |i|
statuses[realorder[i]] = i + 3
end
for i in 0...@party.length
@party.length.times do |i|
annot[i] = ordinals[statuses[i]]
end
@scene.pbAnnotate(annot)
@@ -1046,7 +1049,7 @@ class PokemonPartyScreen
addedEntry = false
if pkmnid == Settings::MAX_PARTY_SIZE # Confirm was chosen
ret = []
for i in realorder
realorder.each do |i|
ret.push(@party[i])
end
error = []
@@ -1092,7 +1095,7 @@ class PokemonPartyScreen
def pbChooseAblePokemon(ableProc, allowIneligible = false)
annot = []
eligibility = []
for pkmn in @party
@party.each do |pkmn|
elig = ableProc.call(pkmn)
eligibility.push(elig)
annot.push((elig) ? _INTL("ABLE") : _INTL("NOT ABLE"))
@@ -1123,7 +1126,7 @@ class PokemonPartyScreen
def pbChooseTradablePokemon(ableProc, allowIneligible = false)
annot = []
eligibility = []
for pkmn in @party
@party.each do |pkmn|
elig = ableProc.call(pkmn)
elig = false if pkmn.egg? || pkmn.shadowPokemon? || pkmn.cannot_trade
eligibility.push(elig)

View File

@@ -402,7 +402,7 @@ class PokemonSummary_Scene
dexnum = @nationalDexList.index(@pokemon.species_data.species) || 0
dexnumshift = true if Settings::DEXES_WITH_OFFSETS.include?(-1)
else
for i in 0...$player.pokedex.dexes_count - 1
($player.pokedex.dexes_count - 1).times do |i|
next if !$player.pokedex.unlocked?(i)
num = pbGetRegionalNumber(i, @pokemon.species)
next if num <= 0
@@ -578,7 +578,7 @@ class PokemonSummary_Scene
best_iv = 0
stats_order = [:HP, :ATTACK, :DEFENSE, :SPEED, :SPECIAL_ATTACK, :SPECIAL_DEFENSE]
start_point = @pokemon.personalID % stats_order.length # Tiebreaker
for i in 0...stats_order.length
stats_order.length.times do |i|
stat = stats_order[(i + start_point) % stats_order.length]
if !best_stat || @pokemon.iv[stat] > @pokemon.iv[best_stat]
best_stat = stat
@@ -694,7 +694,7 @@ class PokemonSummary_Scene
imagepos = []
# Write move names, types and PP amounts for each known move
yPos = 92
for i in 0...Pokemon::MAX_MOVES
Pokemon::MAX_MOVES.times do |i|
move = @pokemon.moves[i]
if move
type_number = GameData::Type.get(move.display_type(@pokemon)).icon_position
@@ -756,7 +756,7 @@ class PokemonSummary_Scene
yPos = 92
yPos -= 76 if move_to_learn
limit = (move_to_learn) ? Pokemon::MAX_MOVES + 1 : Pokemon::MAX_MOVES
for i in 0...limit
limit.times do |i|
move = @pokemon.moves[i]
if i == Pokemon::MAX_MOVES
move = move_to_learn
@@ -842,7 +842,7 @@ class PokemonSummary_Scene
# Show all ribbons
imagepos = []
coord = 0
for i in @ribbonOffset * 4...(@ribbonOffset * 4) + 12
(@ribbonOffset * 4...(@ribbonOffset * 4) + 12).each do |i|
break if !@pokemon.ribbons[i]
ribbon_data = GameData::Ribbon.get(@pokemon.ribbons[i])
ribn = ribbon_data.icon_position

View File

@@ -82,11 +82,13 @@ class Window_PokemonBag < Window_DrawableCommand
if @bag.registered?(item)
pbDrawImagePositions(
self.contents,
[["Graphics/Pictures/Bag/icon_register", rect.x + rect.width - 72, rect.y + 8, 0, 0, -1, 24]])
[["Graphics/Pictures/Bag/icon_register", rect.x + rect.width - 72, rect.y + 8, 0, 0, -1, 24]]
)
elsif pbCanRegisterItem?(item)
pbDrawImagePositions(
self.contents,
[["Graphics/Pictures/Bag/icon_register", rect.x + rect.width - 72, rect.y + 8, 0, 24, -1, 24]])
[["Graphics/Pictures/Bag/icon_register", rect.x + rect.width - 72, rect.y + 8, 0, 24, -1, 24]]
)
end
else
qty = (@filterlist) ? thispocket[@filterlist[@pocket][index]][1] : thispocket[index][1]
@@ -105,7 +107,7 @@ class Window_PokemonBag < Window_DrawableCommand
dheight = self.height - self.borderY
self.contents = pbDoEnsureBitmap(self.contents, dwidth, dheight)
self.contents.clear
for i in 0...@item_max
@item_max.times do |i|
next if i < self.top_item - 1 || i > self.top_item + self.page_item_max
drawItem(i, @item_max, itemRect(i))
end
@@ -147,18 +149,18 @@ class PokemonBag_Scene
if @choosing
numfilledpockets = 0
if @filterlist != nil
for i in 1...@bag.pockets.length
(1...@bag.pockets.length).each do |i|
numfilledpockets += 1 if @filterlist[i].length > 0
end
else
for i in 1...@bag.pockets.length
(1...@bag.pockets.length).each do |i|
numfilledpockets += 1 if @bag.pockets[i].length > 0
end
end
lastpocket = (resetpocket) ? 1 : @bag.last_viewed_pocket
if (@filterlist && @filterlist[lastpocket].length == 0) ||
(!@filterlist && @bag.pockets[lastpocket].length == 0)
for i in 1...@bag.pockets.length
(1...@bag.pockets.length).each do |i|
if @filterlist && @filterlist[i].length > 0
lastpocket = i
break
@@ -267,7 +269,7 @@ class PokemonBag_Scene
# Draw the pocket icons
@sprites["pocketicon"].bitmap.clear
if @choosing && @filterlist
for i in 1...@bag.pockets.length
(1...@bag.pockets.length).each do |i|
if @filterlist[i].length == 0
@sprites["pocketicon"].bitmap.blt(
6 + ((i - 1) * 22), 6, @pocketbitmap.bitmap, Rect.new((i - 1) * 20, 28, 20, 20)
@@ -292,7 +294,8 @@ class PokemonBag_Scene
# Draw the pocket name
pbDrawTextPositions(
overlay,
[[PokemonBag.pocket_names[@bag.last_viewed_pocket - 1], 94, 176, 2, POCKETNAMEBASECOLOR, POCKETNAMESHADOWCOLOR]])
[[PokemonBag.pocket_names[@bag.last_viewed_pocket - 1], 94, 176, 2, POCKETNAMEBASECOLOR, POCKETNAMESHADOWCOLOR]]
)
# Draw slider arrows
showslider = false
if itemlist.top_row > 0
@@ -332,9 +335,9 @@ class PokemonBag_Scene
return if !@choosing
return if @filterproc == nil
@filterlist = []
for i in 1...@bag.pockets.length
(1...@bag.pockets.length).each do |i|
@filterlist[i] = []
for j in 0...@bag.pockets[i].length
@bag.pockets[i].length.times do |j|
@filterlist[i].push(j) if @filterproc.call(@bag.pockets[i][j][0])
end
end

View File

@@ -57,7 +57,7 @@ end
#===============================================================================
class PokemonPokegear_Scene
def pbUpdate
for i in 0...@commands.length
@commands.length.times do |i|
@sprites["button#{i}"].selected = (i == @index)
end
pbUpdateSpriteHash(@sprites)
@@ -75,7 +75,7 @@ class PokemonPokegear_Scene
else
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg")
end
for i in 0...@commands.length
@commands.length.times do |i|
y = 196 - (@commands.length * 24) + (i * 48)
@sprites["button#{i}"] = PokegearButton.new(@commands[i], 118, y, @viewport)
end

View File

@@ -118,7 +118,8 @@ class PokemonRegionMap_Scene
end
pbDrawImagePositions(
@sprites["map2"].bitmap,
[["Graphics/Pictures/#{graphic[4]}", graphic[2] * SQUARE_WIDTH, graphic[3] * SQUARE_HEIGHT]])
[["Graphics/Pictures/#{graphic[4]}", graphic[2] * SQUARE_WIDTH, graphic[3] * SQUARE_HEIGHT]]
)
end
@sprites["mapbottom"] = MapBottomSprite.new(@viewport)
@sprites["mapbottom"].mapname = pbGetMessage(MessageTypes::RegionNames, mapindex)
@@ -179,14 +180,14 @@ class PokemonRegionMap_Scene
def pbSaveMapData
File.open("PBS/town_map.txt", "wb") { |f|
Compiler.add_PBS_header_to_file(f)
for i in 0...@map_data.length
@map_data.length.times do |i|
map = @map_data[i]
next if !map
f.write("\#-------------------------------\r\n")
f.write(sprintf("[%d]\r\n", i))
f.write(sprintf("Name = %s\r\nFilename = %s\r\n",
Compiler.csvQuote(map[0]), Compiler.csvQuote(map[1])))
for loc in map[2]
map[2].each do |loc|
f.write("Point = ")
Compiler.pbWriteCsvRecord(loc, f, [nil, "uussUUUU"])
f.write("\r\n")
@@ -197,7 +198,7 @@ class PokemonRegionMap_Scene
def pbGetMapLocation(x, y)
return "" if !@map[2]
for point in @map[2]
@map[2].each do |point|
next if point[0] != x || point[1] != y
return "" if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]])
name = pbGetMessageFromHash(MessageTypes::PlaceNames, point[2])
@@ -225,7 +226,7 @@ class PokemonRegionMap_Scene
def pbGetMapDetails(x, y) # From Wichu, with my help
return "" if !@map[2]
for point in @map[2]
@map[2].each do |point|
next if point[0] != x || point[1] != y
return "" if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]])
mapdesc = pbGetMessageFromHash(MessageTypes::PlaceDescriptions, point[3])
@@ -236,7 +237,7 @@ class PokemonRegionMap_Scene
def pbGetHealingSpot(x, y)
return nil if !@map[2]
for point in @map[2]
@map[2].each do |point|
next if point[0] != x || point[1] != y
return nil if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]])
return (point[4] && point[5] && point[6]) ? [point[4], point[5], point[6]] : nil
@@ -250,7 +251,8 @@ class PokemonRegionMap_Scene
text = (@mode == 0) ? _INTL("ACTION: Fly") : _INTL("ACTION: Cancel Fly")
pbDrawTextPositions(
@sprites["help"].bitmap,
[[text, Graphics.width - 16, -8, 1, Color.new(248, 248, 248), Color.new(0, 0, 0)]])
[[text, Graphics.width - 16, -8, 1, Color.new(248, 248, 248), Color.new(0, 0, 0)]]
)
@sprites.each do |key, sprite|
next if !key.include?("point")
sprite.visible = (@mode == 1)

View File

@@ -25,7 +25,7 @@ class PokemonPhoneScene
commands = []
@trainers = []
if $PokemonGlobal.phoneNumbers
for num in $PokemonGlobal.phoneNumbers
$PokemonGlobal.phoneNumbers.each do |num|
if num[0] # if visible
if num.length == 8 # if trainer
@trainers.push([num[1], num[2], num[6], (num[4] >= 2)])
@@ -67,7 +67,7 @@ class PokemonPhoneScene
@sprites["icon"].x = 86 - (charwidth / 8)
@sprites["icon"].y = 134 - (charheight / 8)
@sprites["icon"].src_rect = Rect.new(0, 0, charwidth / 4, charheight / 4)
for trainer in @trainers
@trainers.each do |trainer|
if trainer.length == 4
displayname = _INTL("{1} {2}", GameData::TrainerType.get(trainer[0]).name,
pbGetMessageFromHash(MessageTypes::TrainerNames, trainer[1]))
@@ -77,7 +77,7 @@ class PokemonPhoneScene
end
end
@sprites["list"].commands = commands
for i in 0...@sprites["list"].page_item_max
@sprites["list"].page_item_max.times do |i|
@sprites["rematch[#{i}]"] = IconSprite.new(468, 62 + (i * 32), @viewport)
j = i + @sprites["list"].top_item
next if j >= commands.length
@@ -89,7 +89,7 @@ class PokemonPhoneScene
end
end
rematchcount = 0
for trainer in @trainers
@trainers.each do |trainer|
if trainer.length == 4
rematchcount += 1 if trainer[3]
end
@@ -120,7 +120,7 @@ class PokemonPhoneScene
@sprites["icon"].src_rect = Rect.new(0, 0, charwidth / 4, charheight / 4)
mapname = (trainer[2]) ? pbGetMapNameFromId(trainer[2]) : ""
@sprites["bottom"].text = "<ac>" + mapname
for i in 0...@sprites["list"].page_item_max
@sprites["list"].page_item_max.times do |i|
@sprites["rematch[#{i}]"].clearBitmaps
j = i + @sprites["list"].top_item
next if j >= commands.length

View File

@@ -66,7 +66,7 @@ class PokemonTrainerCard_Scene
x = 72
region = pbGetCurrentRegion(0) # Get the current region
imagePositions = []
for i in 0...8
8.times do |i|
if $player.badges[i + (region * 8)]
imagePositions.push(["Graphics/Pictures/Trainer Card/icon_badges", x, 310, i * 32, region * 32, 32, 32])
end

Some files were not shown because too many files have changed in this diff Show More