Many more Rubocop-inspired code improvements

This commit is contained in:
Maruno17
2021-12-18 19:06:22 +00:00
parent d17fc40a47
commit 13a238cc6a
107 changed files with 651 additions and 652 deletions
@@ -105,12 +105,20 @@ module Console
# status output # status output
def echo_status(status) def echo_status(status)
echoln (status) ? markup_style('OK', text: :green) : markup_style('FAIL', text: :red) if status
echoln markup_style('OK', text: :green)
else
echoln markup_style('FAIL', text: :red)
end
end end
# completion output # completion output
def echo_done(status) def echo_done(status)
echoln (status) ? markup_style('done', text: :green) : markup_style('error', text: :red) if status
echoln markup_style('done', text: :green)
else
echoln markup_style('error', text: :red)
end
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -240,8 +240,6 @@ module RTP
yield ".".gsub(/[\/\\]/, "/").gsub(/[\/\\]$/, "") + "/" yield ".".gsub(/[\/\\]/, "/").gsub(/[\/\\]$/, "") + "/"
end end
private
def self.getSaveFileName(fileName) def self.getSaveFileName(fileName)
File.join(getSaveFolder, fileName) File.join(getSaveFolder, fileName)
end end
@@ -260,15 +258,15 @@ end
module FileTest module FileTest
Image_ext = ['.png', '.gif'] # '.jpg', '.jpeg', '.bmp', IMAGE_EXTENSIONS = ['.png', '.gif'] # '.jpg', '.jpeg', '.bmp',
Audio_ext = ['.mid', '.midi', '.ogg', '.wav', '.wma'] # '.mp3' AUDIO_EXTENSIONS = ['.mid', '.midi', '.ogg', '.wav', '.wma'] # '.mp3'
def self.audio_exist?(filename) def self.audio_exist?(filename)
return RTP.exists?(filename, Audio_ext) return RTP.exists?(filename, AUDIO_EXTENSIONS)
end end
def self.image_exist?(filename) def self.image_exist?(filename)
return RTP.exists?(filename, Image_ext) return RTP.exists?(filename, IMAGE_EXTENSIONS)
end end
end end
@@ -485,8 +483,6 @@ class StringInput
@pos += 1 if @pos == @string.size @pos += 1 if @pos == @string.size
str str
end end
alias read_all read
def read_all; read(); end
alias sysread read alias sysread read
end end
@@ -6,8 +6,8 @@
def pbPostData(url, postdata, filename = nil, depth = 0) def pbPostData(url, postdata, filename = nil, depth = 0)
if url[/^http:\/\/([^\/]+)(.*)$/] if url[/^http:\/\/([^\/]+)(.*)$/]
host = $1 host = $1
path = $2 # path = $2
path = "/" if path.length == 0 # path = "/" if path.length == 0
userAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14" userAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14"
body = postdata.map { |key, value| body = postdata.map { |key, value|
keyString = key.to_s keyString = key.to_s
@@ -254,7 +254,7 @@ def pbGetText(infile)
else else
intlhash = OrderedHash.new intlhash = OrderedHash.new
itemlength = 2 itemlength = 2
if section.length % 2 != 0 if section.length.odd?
raise _INTL("Section {1} has an odd number of entries (section was recognized as a hash because its first line is not a number)", name) raise _INTL("Section {1} has an odd number of entries (section was recognized as a hash because its first line is not a number)", name)
end end
end end
@@ -320,7 +320,7 @@ class OrderedHash < Hash
return str return str
end end
alias :to_s :inspect alias to_s inspect
def []=(key, value) def []=(key, value)
oldvalue = self[key] oldvalue = self[key]
@@ -279,7 +279,8 @@ module PluginManager
msg = "Plugin '#{name}' requires plugin '#{dep_name}', if installed, to be version #{dep_version}" msg = "Plugin '#{name}' requires plugin '#{dep_name}', if installed, to be version #{dep_version}"
msg << " or higher" if !exact msg << " or higher" if !exact
msg << ", but the installed version was #{self.version(dep_name)}." msg << ", but the installed version was #{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}'." msg << "\r\nCheck #{dep_link} for an update to plugin '#{dep_name}'."
end end
self.error(msg) self.error(msg)
@@ -289,16 +290,16 @@ module PluginManager
msg = "Plugin '#{name}' requires plugin '#{dep_name}' to be version #{dep_version}" msg = "Plugin '#{name}' requires plugin '#{dep_name}' to be version #{dep_version}"
msg << " or later" if !exact msg << " or later" if !exact
msg << ", but the installed version was #{self.version(dep_name)}." msg << ", but the installed version was #{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}'." msg << "\r\nCheck #{dep_link} for an update to plugin '#{dep_name}'."
end end
self.error(msg)
else # Don't have plugin else # Don't have plugin
msg = "Plugin '#{name}' requires plugin '#{dep_name}' version #{dep_version} " msg = "Plugin '#{name}' requires plugin '#{dep_name}' version #{dep_version} "
msg << "or later" if !exact msg << "or later " if !exact
msg << "to be installed above it." msg << "to be installed above it."
self.error(msg)
end end
self.error(msg)
end end
end end
end end
@@ -96,9 +96,10 @@ SaveData.register_conversion(:v20_berry_plant_data) do
if global.eventvars if global.eventvars
global.eventvars.each_pair do |key, value| global.eventvars.each_pair do |key, value|
next if !value || !value.is_a?(Array) next if !value || !value.is_a?(Array)
if value.length == 6 # Old berry plant data case value.length
when 6 # Old berry plant data
data = BerryPlantData.new data = BerryPlantData.new
if value[1]&.is_a?(Symbol) if value[1].is_a?(Symbol)
plant_data = GameData::DerryPlant.get(value[1]) plant_data = GameData::DerryPlant.get(value[1])
data.new_mechanics = false data.new_mechanics = false
data.berry_id = value[1] data.berry_id = value[1]
@@ -110,12 +111,12 @@ SaveData.register_conversion(:v20_berry_plant_data) do
data.watering_count = value[4] data.watering_count = value[4]
end end
global.eventvars[key] = data global.eventvars[key] = data
elsif value.length == 7 || value.length == 8 # New berry plant data when 7, 8 # New berry plant data
data = BerryPlantData.new data = BerryPlantData.new
if value[1]&.is_a?(Symbol) if value[1].is_a?(Symbol)
data.new_mechanics = true data.new_mechanics = true
data.berry_id = value[1] data.berry_id = value[1]
data.mulch_id = value[7] if value[7]&.is_a?(Symbol) data.mulch_id = value[7] if value[7].is_a?(Symbol)
data.time_alive = value[2] data.time_alive = value[2]
data.time_last_updated = value[3] data.time_last_updated = value[3]
data.growth_stage = value[0] data.growth_stage = value[0]
@@ -294,13 +295,17 @@ SaveData.register_conversion(:v20_convert_pokemon_markings_global) do
end end
end end
global.purifyChamber.sets.each do |set| global.purifyChamber.sets.each do |set|
set.shadow = PokeBattle_Pokemon.convert(set.shadow) if set.shadow
set.list.each do |pkmn| set.list.each do |pkmn|
next if !pkmn.markings.is_a?(Integer) next if !pkmn.markings.is_a?(Integer)
markings = [] markings = []
6.times { |i| markings[i] = ((pkmn.markings & (1 << i)) == 0) ? 0 : 1 } 6.times { |i| markings[i] = ((pkmn.markings & (1 << i)) == 0) ? 0 : 1 }
pkmn.markings = markings pkmn.markings = markings
end end
if set.shadow && set.shadow.markings.is_a?(Integer)
markings = []
6.times { |i| markings[i] = ((set.shadow.markings & (1 << i)) == 0) ? 0 : 1 }
set.shadow.markings = markings
end
end end
if global.hallOfFame if global.hallOfFame
global.hallOfFame.each do |team| global.hallOfFame.each do |team|
@@ -142,7 +142,7 @@ class Interpreter
return result return result
rescue Exception rescue Exception
e = $! e = $!
raise if e.is_a?(SystemExit) || "#{e.class}" == "Reset" raise if e.is_a?(SystemExit) || e.class.to_s == "Reset"
event = get_self event = get_self
# Gather text for error message # Gather text for error message
message = pbGetExceptionMessage(e) message = pbGetExceptionMessage(e)
@@ -295,7 +295,7 @@ class Interpreter
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Helper function that shows a picture in a script. # Helper function that shows a picture in a script.
def pbShowPicture(number, name, origin, x, y, zoomX = 100, zoomY = 100, opacity = 255, blendType = 0) def pbShowPicture(number, name, origin, x, y, zoomX = 100, zoomY = 100, opacity = 255, blendType = 0)
number = number + ($game_temp.in_battle ? 50 : 0) number += ($game_temp.in_battle ? 50 : 0)
$game_screen.pictures[number].show(name, origin, x, y, zoomX, zoomY, opacity, blendType) $game_screen.pictures[number].show(name, origin, x, y, zoomX, zoomY, opacity, blendType)
end end
@@ -521,10 +521,10 @@ class Interpreter
next if value == 1 next if value == 1
$game_variables[i] *= value $game_variables[i] *= value
when 4 # divide when 4 # divide
next if value == 1 || value == 0 next if [0, 1].include?(value)
$game_variables[i] /= value $game_variables[i] /= value
when 5 # remainder when 5 # remainder
next if value == 1 || value == 0 next if [0, 1].include?(value)
$game_variables[i] %= value $game_variables[i] %= value
end end
$game_variables[i] = 99999999 if $game_variables[i] > 99999999 $game_variables[i] = 99999999 if $game_variables[i] > 99999999
@@ -631,13 +631,12 @@ class Interpreter
$game_temp.player_new_map_id = @parameters[1] $game_temp.player_new_map_id = @parameters[1]
$game_temp.player_new_x = @parameters[2] $game_temp.player_new_x = @parameters[2]
$game_temp.player_new_y = @parameters[3] $game_temp.player_new_y = @parameters[3]
$game_temp.player_new_direction = @parameters[4]
else # Appoint with variables else # Appoint with variables
$game_temp.player_new_map_id = $game_variables[@parameters[1]] $game_temp.player_new_map_id = $game_variables[@parameters[1]]
$game_temp.player_new_x = $game_variables[@parameters[2]] $game_temp.player_new_x = $game_variables[@parameters[2]]
$game_temp.player_new_y = $game_variables[@parameters[3]] $game_temp.player_new_y = $game_variables[@parameters[3]]
$game_temp.player_new_direction = @parameters[4]
end end
$game_temp.player_new_direction = @parameters[4]
@index += 1 @index += 1
# If transition happens with a fade, do the fade # If transition happens with a fade, do the fade
if @parameters[5] == 0 if @parameters[5] == 0
@@ -655,9 +654,10 @@ class Interpreter
character = get_character(@parameters[0]) character = get_character(@parameters[0])
return true if character.nil? return true if character.nil?
# Move the character # Move the character
if @parameters[1] == 0 # Direct appointment case @parameters[1]
when 0 # Direct appointment
character.moveto(@parameters[2], @parameters[3]) character.moveto(@parameters[2], @parameters[3])
elsif @parameters[1] == 1 # Appoint with variables when 1 # Appoint with variables
character.moveto($game_variables[@parameters[2]], $game_variables[@parameters[3]]) character.moveto($game_variables[@parameters[2]], $game_variables[@parameters[3]])
else # Exchange with another event else # Exchange with another event
character2 = get_character(@parameters[2]) character2 = get_character(@parameters[2])
@@ -164,9 +164,9 @@ module EncounterModifier
return encounter return encounter
end end
def self.triggerEncounterEnd() def self.triggerEncounterEnd
for prc in @@procsEnd for prc in @@procsEnd
prc.call() prc.call
end end
end end
end end
@@ -132,12 +132,11 @@ class Game_System
def setDefaultBGM(bgm, volume = 80, pitch = 100) def setDefaultBGM(bgm, volume = 80, pitch = 100)
bgm = RPG::AudioFile.new(bgm, volume, pitch) if bgm.is_a?(String) bgm = RPG::AudioFile.new(bgm, volume, pitch) if bgm.is_a?(String)
@defaultBGM = nil
if bgm != nil && bgm.name != "" if bgm != nil && bgm.name != ""
@defaultBGM = nil
self.bgm_play(bgm) self.bgm_play(bgm)
@defaultBGM = bgm.clone @defaultBGM = bgm.clone
else else
@defaultBGM = nil
self.bgm_play(@playing_bgm) self.bgm_play(@playing_bgm)
end end
end end
@@ -357,7 +357,7 @@ class Game_Map
def start_scroll(direction, distance, speed) def start_scroll(direction, distance, speed)
@scroll_direction = direction @scroll_direction = direction
if direction == 2 || direction == 8 # down or up if [2, 8].include?(direction) # down or up
@scroll_rest = distance * REAL_RES_Y @scroll_rest = distance * REAL_RES_Y
else else
@scroll_rest = distance * REAL_RES_X @scroll_rest = distance * REAL_RES_X
@@ -394,9 +394,9 @@ class PokemonMapFactory
return return
end end
setMapsInRange setMapsInRange
deleted = false old_num_maps = @maps.length
deleted = @maps.delete_if { |map| !MapFactoryHelper.mapInRange?(map) } @maps.delete_if { |map| !MapFactoryHelper.mapInRange?(map) }
@mapIndex = getMapIndex($game_map.map_id) if deleted @mapIndex = getMapIndex($game_map.map_id) if @maps.length != old_num_maps
end end
end end
@@ -476,7 +476,7 @@ module MapFactoryHelper
# Returns the X or Y coordinate of an edge on the map with id. # Returns the X or Y coordinate of an edge on the map with id.
# Considers the special strings "N","W","E","S" # Considers the special strings "N","W","E","S"
def self.getMapEdge(id, edge) def self.getMapEdge(id, edge)
return 0 if edge == "N" || edge == "W" return 0 if ["N", "W"].include?(edge)
dims = getMapDims(id) # Get dimensions dims = getMapDims(id) # Get dimensions
return dims[0] if edge == "E" return dims[0] if edge == "E"
return dims[1] if edge == "S" return dims[1] if edge == "S"
@@ -201,7 +201,6 @@ class Game_Character
@bush_depth = 0 @bush_depth = 0
return return
end end
deep_bush = regular_bush = false
xbehind = @x + (@direction == 4 ? 1 : @direction == 6 ? -1 : 0) xbehind = @x + (@direction == 4 ? 1 : @direction == 6 ? -1 : 0)
ybehind = @y + (@direction == 8 ? 1 : @direction == 2 ? -1 : 0) ybehind = @y + (@direction == 8 ? 1 : @direction == 2 ? -1 : 0)
this_map = (self.map.valid?(@x, @y)) ? [self.map, @x, @y] : $map_factory&.getNewMap(@x, @y) this_map = (self.map.valid?(@x, @y)) ? [self.map, @x, @y] : $map_factory&.getNewMap(@x, @y)
@@ -738,7 +737,7 @@ class Game_Character
end end
@x = @x + x_plus @x = @x + x_plus
@y = @y + y_plus @y = @y + y_plus
real_distance = Math::sqrt(x_plus * x_plus + y_plus * y_plus) real_distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus)
distance = [1, real_distance].max distance = [1, real_distance].max
@jump_peak = distance * Game_Map::TILE_HEIGHT * 3 / 8 # 3/4 of tile for ledge jumping @jump_peak = distance * Game_Map::TILE_HEIGHT * 3 / 8 # 3/4 of tile for ledge jumping
@jump_distance = [x_plus.abs * Game_Map::REAL_RES_X, y_plus.abs * Game_Map::REAL_RES_Y].max @jump_distance = [x_plus.abs * Game_Map::REAL_RES_X, y_plus.abs * Game_Map::REAL_RES_Y].max
@@ -168,11 +168,12 @@ class Game_Event < Game_Character
end end
def check_event_trigger_auto def check_event_trigger_auto
if @trigger == 2 # Event touch case @trigger
when 2 # Event touch
if at_coordinate?($game_player.x, $game_player.y) if at_coordinate?($game_player.x, $game_player.y)
start if !jumping? && over_trigger? start if !jumping? && over_trigger?
end end
elsif @trigger == 3 # Autorun when 3 # Autorun
start start
end end
end end
@@ -157,7 +157,7 @@ class Game_Player < Game_Character
end end
@x = @x + x_plus @x = @x + x_plus
@y = @y + y_plus @y = @y + y_plus
real_distance = Math::sqrt(x_plus * x_plus + y_plus * y_plus) real_distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus)
distance = [1, real_distance].max distance = [1, real_distance].max
@jump_peak = distance * Game_Map::TILE_HEIGHT * 3 / 8 # 3/4 of tile for ledge jumping @jump_peak = distance * Game_Map::TILE_HEIGHT * 3 / 8 # 3/4 of tile for ledge jumping
@jump_distance = [x_plus.abs * Game_Map::REAL_RES_X, y_plus.abs * Game_Map::REAL_RES_Y].max @jump_distance = [x_plus.abs * Game_Map::REAL_RES_X, y_plus.abs * Game_Map::REAL_RES_Y].max
@@ -102,8 +102,8 @@ class Sprite_Character < RPG::Sprite
@character_name = @character.character_name @character_name = @character.character_name
@character_hue = @character.character_hue @character_hue = @character.character_hue
@oldbushdepth = @character.bush_depth @oldbushdepth = @character.bush_depth
@charbitmap.dispose if @charbitmap
if @tile_id >= 384 if @tile_id >= 384
@charbitmap.dispose if @charbitmap
@charbitmap = pbGetTileBitmap(@character.map.tileset_name, @tile_id, @charbitmap = pbGetTileBitmap(@character.map.tileset_name, @tile_id,
@character_hue, @character.width, @character.height) @character_hue, @character.width, @character.height)
@charbitmapAnimated = false @charbitmapAnimated = false
@@ -115,9 +115,7 @@ class Sprite_Character < RPG::Sprite
self.src_rect.set(0, 0, @cw, @ch) self.src_rect.set(0, 0, @cw, @ch)
self.ox = @cw / 2 self.ox = @cw / 2
self.oy = @ch self.oy = @ch
@character.sprite_size = [@cw, @ch]
else else
@charbitmap.dispose if @charbitmap
@charbitmap = AnimatedBitmap.new( @charbitmap = AnimatedBitmap.new(
'Graphics/Characters/' + @character_name, @character_hue) 'Graphics/Characters/' + @character_name, @character_hue)
RPG::Cache.retain('Graphics/Characters/', @character_name, @character_hue) if @character == $game_player RPG::Cache.retain('Graphics/Characters/', @character_name, @character_hue) if @character == $game_player
@@ -128,8 +126,8 @@ class Sprite_Character < RPG::Sprite
@cw = @charbitmap.width / 4 @cw = @charbitmap.width / 4
@ch = @charbitmap.height / 4 @ch = @charbitmap.height / 4
self.ox = @cw / 2 self.ox = @cw / 2
@character.sprite_size = [@cw, @ch]
end end
@character.sprite_size = [@cw, @ch]
end end
@charbitmap.update if @charbitmapAnimated @charbitmap.update if @charbitmapAnimated
bushdepth = @character.bush_depth bushdepth = @character.bush_depth
@@ -35,8 +35,8 @@ class Sprite_Shadow < RPG::Sprite
@tile_id = @character.tile_id @tile_id = @character.tile_id
@character_name = @character.character_name @character_name = @character.character_name
@character_hue = @character.character_hue @character_hue = @character.character_hue
@chbitmap.dispose if @chbitmap
if @tile_id >= 384 if @tile_id >= 384
@chbitmap.dispose if @chbitmap
@chbitmap = pbGetTileBitmap(@character.map.tileset_name, @chbitmap = pbGetTileBitmap(@character.map.tileset_name,
@tile_id, @character.character_hue) @tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32) self.src_rect.set(0, 0, 32, 32)
@@ -45,7 +45,6 @@ class Sprite_Shadow < RPG::Sprite
self.ox = 16 self.ox = 16
self.oy = 32 self.oy = 32
else else
@chbitmap.dispose if @chbitmap
@chbitmap = AnimatedBitmap.new( @chbitmap = AnimatedBitmap.new(
'Graphics/Characters/' + @character.character_name, @character.character_hue) 'Graphics/Characters/' + @character.character_name, @character.character_hue)
@cw = @chbitmap.width / 4 @cw = @chbitmap.width / 4
@@ -124,7 +123,7 @@ end
# ? CLASS Sprite_Character edit # ? CLASS Sprite_Character edit
#=================================================== #===================================================
class Sprite_Character < RPG::Sprite class Sprite_Character < RPG::Sprite
alias :shadow_initialize :initialize alias shadow_initialize initialize
def initialize(viewport, character = nil) def initialize(viewport, character = nil)
@ombrelist = [] @ombrelist = []
@@ -144,8 +144,6 @@ class SpriteWindow < Window
@viewport = value @viewport = value
for i in @spritekeys for i in @spritekeys
@sprites[i].dispose if @sprites[i] @sprites[i].dispose if @sprites[i]
end
for i in @spritekeys
if @sprites[i].is_a?(Sprite) if @sprites[i].is_a?(Sprite)
@sprites[i] = Sprite.new(@viewport) @sprites[i] = Sprite.new(@viewport)
else else
@@ -306,11 +304,10 @@ class SpriteWindow < Window
@cursoropacity += 8 @cursoropacity += 8
@cursorblink = 0 if @cursoropacity >= 255 @cursorblink = 0 if @cursoropacity >= 255
end end
privRefreshCursor
else else
@cursoropacity = 128 @cursoropacity = 128
privRefreshCursor
end end
privRefreshCursor
if @pause if @pause
oldpauseframe = @pauseframe oldpauseframe = @pauseframe
oldpauseopacity = @pauseopacity oldpauseopacity = @pauseopacity
@@ -591,7 +588,7 @@ class SpriteWindow < Window
trimX + 32, trimY + 64, trimX + 32, trimY + 64,
trimX + 48, trimY + 64, trimX + 48, trimY + 64,
trimX + 32, trimY + 80, trimX + 32, trimY + 80,
trimX + 48, trimY + 80, trimX + 48, trimY + 80
] ]
pauseWidth = 16 pauseWidth = 16
pauseHeight = 16 pauseHeight = 16
@@ -838,13 +835,13 @@ class SpriteWindow_Base < SpriteWindow
self.width = width self.width = width
self.height = height self.height = height
self.z = 100 self.z = 100
@curframe = MessageConfig.pbGetSystemFrame() @curframe = MessageConfig.pbGetSystemFrame
@curfont = MessageConfig.pbGetSystemFontName() @curfont = MessageConfig.pbGetSystemFontName
@sysframe = AnimatedBitmap.new(@curframe) @sysframe = AnimatedBitmap.new(@curframe)
RPG::Cache.retain(@curframe) if @curframe && !@curframe.empty? RPG::Cache.retain(@curframe) if @curframe && !@curframe.empty?
@customskin = nil @customskin = nil
__setWindowskin(@sysframe.bitmap) __setWindowskin(@sysframe.bitmap)
__resolveSystemFrame() __resolveSystemFrame
pbSetSystemFont(self.contents) if self.contents pbSetSystemFont(self.contents) if self.contents
end end
@@ -861,7 +858,7 @@ class SpriteWindow_Base < SpriteWindow
def __resolveSystemFrame def __resolveSystemFrame
if self.skinformat == 1 if self.skinformat == 1
if !@resolvedFrame if !@resolvedFrame
@resolvedFrame = MessageConfig.pbGetSystemFrame() @resolvedFrame = MessageConfig.pbGetSystemFrame
@resolvedFrame.sub!(/\.[^\.\/\\]+$/, "") @resolvedFrame.sub!(/\.[^\.\/\\]+$/, "")
end end
self.loadSkinFile("#{@resolvedFrame}.txt") if @resolvedFrame != "" self.loadSkinFile("#{@resolvedFrame}.txt") if @resolvedFrame != ""
@@ -886,7 +883,7 @@ class SpriteWindow_Base < SpriteWindow
@customskin.dispose if @customskin @customskin.dispose if @customskin
@customskin = nil @customskin = nil
__setWindowskin(@sysframe.bitmap) __setWindowskin(@sysframe.bitmap)
__resolveSystemFrame() __resolveSystemFrame
end end
def update def update
@@ -904,23 +901,23 @@ class SpriteWindow_Base < SpriteWindow
end end
end end
end end
if @curframe != MessageConfig.pbGetSystemFrame() if @curframe != MessageConfig.pbGetSystemFrame
@curframe = MessageConfig.pbGetSystemFrame() @curframe = MessageConfig.pbGetSystemFrame
if @sysframe && !@customskin if @sysframe && !@customskin
@sysframe.dispose if @sysframe @sysframe.dispose if @sysframe
@sysframe = AnimatedBitmap.new(@curframe) @sysframe = AnimatedBitmap.new(@curframe)
RPG::Cache.retain(@curframe) if @curframe && !@curframe.empty? RPG::Cache.retain(@curframe) if @curframe && !@curframe.empty?
@resolvedFrame = nil @resolvedFrame = nil
__setWindowskin(@sysframe.bitmap) __setWindowskin(@sysframe.bitmap)
__resolveSystemFrame() __resolveSystemFrame
end end
begin begin
refresh refresh
rescue NoMethodError rescue NoMethodError
end end
end end
if @curfont != MessageConfig.pbGetSystemFontName() if @curfont != MessageConfig.pbGetSystemFontName
@curfont = MessageConfig.pbGetSystemFontName() @curfont = MessageConfig.pbGetSystemFontName
if self.contents && !self.contents.disposed? if self.contents && !self.contents.disposed?
pbSetSystemFont(self.contents) pbSetSystemFont(self.contents)
end end
@@ -13,7 +13,7 @@ class IconWindow < SpriteWindow_Base
end end
def dispose def dispose
clearBitmaps() clearBitmaps
super super
end end
@@ -38,7 +38,7 @@ class IconWindow < SpriteWindow_Base
# Sets the icon's filename. # Sets the icon's filename.
def setBitmap(file, hue = 0) def setBitmap(file, hue = 0)
clearBitmaps() clearBitmaps
@name = file @name = file
return if file == nil return if file == nil
if file != "" if file != ""
@@ -67,7 +67,7 @@ class PictureWindow < SpriteWindow_Base
end end
def dispose def dispose
clearBitmaps() clearBitmaps
super super
end end
@@ -92,7 +92,7 @@ class PictureWindow < SpriteWindow_Base
# Sets the icon's bitmap or filename. (hue parameter # Sets the icon's bitmap or filename. (hue parameter
# is ignored unless pathOrBitmap is a filename) # is ignored unless pathOrBitmap is a filename)
def setBitmap(pathOrBitmap, hue = 0) def setBitmap(pathOrBitmap, hue = 0)
clearBitmaps() clearBitmaps
if pathOrBitmap != nil && pathOrBitmap != "" if pathOrBitmap != nil && pathOrBitmap != ""
if pathOrBitmap.is_a?(Bitmap) if pathOrBitmap.is_a?(Bitmap)
@_iconbitmap = pathOrBitmap @_iconbitmap = pathOrBitmap
@@ -245,13 +245,14 @@ class IconSprite < SpriteWrapper
attr_reader :name attr_reader :name
def initialize(*args) def initialize(*args)
if args.length == 0 case args.length
when 0
super(nil) super(nil)
self.bitmap = nil self.bitmap = nil
elsif args.length == 1 when 1
super(args[0]) super(args[0])
self.bitmap = nil self.bitmap = nil
elsif args.length == 2 when 2
super(nil) super(nil)
self.x = args[0] self.x = args[0]
self.y = args[1] self.y = args[1]
@@ -265,7 +266,7 @@ class IconSprite < SpriteWrapper
end end
def dispose def dispose
clearBitmaps() clearBitmaps
super super
end end
@@ -277,7 +278,7 @@ class IconSprite < SpriteWrapper
# Sets the icon's filename. # Sets the icon's filename.
def setBitmap(file, hue = 0) def setBitmap(file, hue = 0)
oldrc = self.src_rect oldrc = self.src_rect
clearBitmaps() clearBitmaps
@name = file @name = file
return if file == nil return if file == nil
if file != "" if file != ""
@@ -45,26 +45,27 @@ end
def rgbToColor(param) def rgbToColor(param)
return Font.default_color if !param return Font.default_color if !param
baseint = param.to_i(16) baseint = param.to_i(16)
if param.length == 8 # 32-bit hex case param.length
when 8 # 32-bit hex
return Color.new( return Color.new(
(baseint >> 24) & 0xFF, (baseint >> 24) & 0xFF,
(baseint >> 16) & 0xFF, (baseint >> 16) & 0xFF,
(baseint >> 8) & 0xFF, (baseint >> 8) & 0xFF,
(baseint) & 0xFF (baseint) & 0xFF
) )
elsif param.length == 6 # 24-bit hex when 6 # 24-bit hex
return Color.new( return Color.new(
(baseint >> 16) & 0xFF, (baseint >> 16) & 0xFF,
(baseint >> 8) & 0xFF, (baseint >> 8) & 0xFF,
(baseint) & 0xFF (baseint) & 0xFF
) )
elsif param.length == 4 # 16-bit hex when 4 # 16-bit hex
return Color.new( return Color.new(
((baseint) & 0x1F) << 3, ((baseint) & 0x1F) << 3,
((baseint >> 5) & 0x1F) << 3, ((baseint >> 5) & 0x1F) << 3,
((baseint >> 10) & 0x1F) << 3 ((baseint >> 10) & 0x1F) << 3
) )
elsif param.length == 1 # Color number when 1 # Color number
i = param.to_i i = param.to_i
return Font.default_color if i >= 8 return Font.default_color if i >= 8
return [ return [
@@ -291,7 +292,7 @@ def getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheig
end end
def isWaitChar(x) def isWaitChar(x)
return (x == "\001" || x == "\002") return (["\001", "\002"].include?(x))
end end
def getLastParam(array, default) def getLastParam(array, default)
@@ -418,14 +419,13 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
x = y = 0 x = y = 0
characters = [] characters = []
charactersInternal = [] charactersInternal = []
realtext = nil # realtext = nil
realtextStart = "" # realtextStart = ""
if !explicitBreaksOnly && textchunks.join("").length == 0 # if !explicitBreaksOnly && textchunks.join("").length == 0
# All commands occurred at the beginning of the text string # # All commands occurred at the beginning of the text string
realtext = (newlineBreaks) ? text : text.gsub(/\n/, " ") # realtext = (newlineBreaks) ? text : text.gsub(/\n/, " ")
realtextStart = oldtext[0, oldtext.length - realtext.length] # realtextStart = oldtext[0, oldtext.length - realtext.length]
realtextHalf = text.length / 2 # end
end
textchunks.push(text) textchunks.push(text)
for chunk in textchunks for chunk in textchunks
chunk.gsub!(/&lt;/, "<") chunk.gsub!(/&lt;/, "<")
@@ -483,14 +483,15 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
control = controls[i][0] control = controls[i][0]
param = controls[i][1] param = controls[i][1]
endtag = controls[i][3] endtag = controls[i][3]
if control == "c" case control
when "c"
if endtag if endtag
colorstack.pop colorstack.pop
else else
color = rgbToColor(param) color = rgbToColor(param)
colorstack.push([color, nil]) colorstack.push([color, nil])
end end
elsif control == "c2" when "c2"
if endtag if endtag
colorstack.pop colorstack.pop
else else
@@ -498,7 +499,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
shadow = Rgb16ToColor(param[4, 4]) shadow = Rgb16ToColor(param[4, 4])
colorstack.push([base, shadow]) colorstack.push([base, shadow])
end end
elsif control == "c3" when "c3"
if endtag if endtag
colorstack.pop colorstack.pop
else else
@@ -509,25 +510,25 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
shadow = (param[1] && param[1] != "") ? rgbToColor(param[1]) : oldColors[1] shadow = (param[1] && param[1] != "") ? rgbToColor(param[1]) : oldColors[1]
colorstack.push([base, shadow]) colorstack.push([base, shadow])
end end
elsif control == "o" when "o"
if endtag if endtag
opacitystack.pop opacitystack.pop
else else
opacitystack.push(param.sub(/\s+$/, "").to_i) opacitystack.push(param.sub(/\s+$/, "").to_i)
end end
elsif control == "b" when "b"
boldcount += (endtag ? -1 : 1) boldcount += (endtag ? -1 : 1)
elsif control == "i" when "i"
italiccount += (endtag ? -1 : 1) italiccount += (endtag ? -1 : 1)
elsif control == "u" when "u"
underlinecount += (endtag ? -1 : 1) underlinecount += (endtag ? -1 : 1)
elsif control == "s" when "s"
strikecount += (endtag ? -1 : 1) strikecount += (endtag ? -1 : 1)
elsif control == "outln" when "outln"
outlinecount += (endtag ? -1 : 1) outlinecount += (endtag ? -1 : 1)
elsif control == "outln2" when "outln2"
outline2count += (endtag ? -1 : 1) outline2count += (endtag ? -1 : 1)
elsif control == "fs" # Font size when "fs" # Font size
if endtag if endtag
fontsizestack.pop fontsizestack.pop
else else
@@ -535,7 +536,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
end end
fontsize = getLastParam(fontsizestack, defaultfontsize) fontsize = getLastParam(fontsizestack, defaultfontsize)
bitmap.font.size = fontsize bitmap.font.size = fontsize
elsif control == "fn" # Font name when "fn" # Font name
if endtag if endtag
fontnamestack.pop fontnamestack.pop
else else
@@ -544,38 +545,35 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
end end
fontname = getLastParam(fontnamestack, defaultfontname) fontname = getLastParam(fontnamestack, defaultfontname)
bitmap.font.name = fontname bitmap.font.name = fontname
elsif control == "ar" # Right align when "ar" # Right align
if !endtag if endtag
alignstack.pop
else
alignstack.push(1) alignstack.push(1)
nextline = 1 if x > 0 && nextline == 0
else
alignstack.pop
nextline = 1 if x > 0 && nextline == 0
end end
elsif control == "al" # Left align nextline = 1 if x > 0 && nextline == 0
if !endtag when "al" # Left align
if endtag
alignstack.pop
else
alignstack.push(0) alignstack.push(0)
nextline = 1 if x > 0 && nextline == 0
else
alignstack.pop
nextline = 1 if x > 0 && nextline == 0
end end
elsif control == "ac" # Center align nextline = 1 if x > 0 && nextline == 0
if !endtag when "ac" # Center align
if endtag
alignstack.pop
else
alignstack.push(2) alignstack.push(2)
nextline = 1 if x > 0 && nextline == 0
else
alignstack.pop
nextline = 1 if x > 0 && nextline == 0
end end
elsif control == "icon" # Icon nextline = 1 if x > 0 && nextline == 0
when "icon" # Icon
if !endtag if !endtag
param = param.sub(/\s+$/, "") param = param.sub(/\s+$/, "")
graphic = "Graphics/Icons/#{param}" graphic = "Graphics/Icons/#{param}"
controls[i] = nil controls[i] = nil
break break
end end
elsif control == "img" # Icon when "img" # Icon
if !endtag if !endtag
param = param.sub(/\s+$/, "") param = param.sub(/\s+$/, "")
param = param.split("|") param = param.split("|")
@@ -589,11 +587,11 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
controls[i] = nil controls[i] = nil
break break
end end
elsif control == "br" # Line break when "br" # Line break
if !endtag if !endtag
nextline += 1 nextline += 1
end end
elsif control == "r" # Right align this line when "r" # Right align this line
if !endtag if !endtag
x = 0 x = 0
rightalign = 1 rightalign = 1
@@ -679,7 +677,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
havenl = true if !graphic && isWaitChar(textchars[position]) havenl = true if !graphic && isWaitChar(textchars[position])
extraspace = (!graphic && italiccount > 0) ? 2 + (width / 2) : 2 extraspace = (!graphic && italiccount > 0) ? 2 + (width / 2) : 2
characters.push([ characters.push([
graphic ? graphic : textchars[position], graphic || textchars[position],
x + xStart, texty, width + extraspace, lineheight, x + xStart, texty, width + extraspace, lineheight,
graphic ? true : false, graphic ? true : false,
(boldcount > 0), (italiccount > 0), colors[0], colors[1], (boldcount > 0), (italiccount > 0), colors[0], colors[1],
@@ -929,12 +927,11 @@ def getLineBrokenChunks(bitmap, value, width, dims, plain = false)
y += 32 y += 32
next next
end end
textcols = []
if ccheck[/</] && !plain if ccheck[/</] && !plain
textcols = []
ccheck.scan(re) { textcols.push(rgbToColor($1)) } ccheck.scan(re) { textcols.push(rgbToColor($1)) }
words = ccheck.split(reNoMatch) # must have no matches because split can include match words = ccheck.split(reNoMatch) # must have no matches because split can include match
else else
textcols = []
words = [ccheck] words = [ccheck]
end end
for i in 0...words.length for i in 0...words.length
@@ -1161,9 +1158,10 @@ def pbDrawTextPositions(bitmap, textpos)
textsize = bitmap.text_size(i[0]) textsize = bitmap.text_size(i[0])
x = i[1] x = i[1]
y = i[2] + 6 y = i[2] + 6
if i[3] == true || i[3] == 1 # right align case i[3]
when true, 1 # right align
x -= textsize.width x -= textsize.width
elsif i[3] == 2 # centered when 2 # centered
x -= (textsize.width / 2) x -= (textsize.width / 2)
end end
if i[6] == true || i[6] == 1 # outline text if i[6] == true || i[6] == 1 # outline text
@@ -191,15 +191,15 @@ def pbChooseNumber(msgwindow, params)
if Input.trigger?(Input::USE) if Input.trigger?(Input::USE)
ret = cmdwindow.number ret = cmdwindow.number
if ret > maximum if ret > maximum
pbPlayBuzzerSE() pbPlayBuzzerSE
elsif ret < minimum elsif ret < minimum
pbPlayBuzzerSE() pbPlayBuzzerSE
else else
pbPlayDecisionSE() pbPlayDecisionSE
break break
end end
elsif Input.trigger?(Input::BACK) elsif Input.trigger?(Input::BACK)
pbPlayCancelSE() pbPlayCancelSE
ret = cancelNumber ret = cancelNumber
break break
end end
@@ -324,7 +324,7 @@ def pbGetGoldString
end end
def pbDisplayGoldWindow(msgwindow) def pbDisplayGoldWindow(msgwindow)
moneyString = pbGetGoldString() moneyString = pbGetGoldString
goldwindow = Window_AdvancedTextPokemon.new(_INTL("Money:\n<ar>{1}</ar>", moneyString)) goldwindow = Window_AdvancedTextPokemon.new(_INTL("Money:\n<ar>{1}</ar>", moneyString))
goldwindow.setSkin("Graphics/Windowskins/goldskin") goldwindow.setSkin("Graphics/Windowskins/goldskin")
goldwindow.resizeToFit(goldwindow.text, Graphics.width) goldwindow.resizeToFit(goldwindow.text, Graphics.width)
@@ -386,7 +386,7 @@ def pbCreateStatusWindow(viewport = nil)
msgwindow.visible = false msgwindow.visible = false
msgwindow.letterbyletter = false msgwindow.letterbyletter = false
pbBottomLeftLines(msgwindow, 2) pbBottomLeftLines(msgwindow, 2)
skinfile = MessageConfig.pbGetSpeechFrame() skinfile = MessageConfig.pbGetSpeechFrame
msgwindow.setSkin(skinfile) msgwindow.setSkin(skinfile)
return msgwindow return msgwindow
end end
@@ -403,7 +403,7 @@ def pbCreateMessageWindow(viewport = nil, skin = nil)
msgwindow.back_opacity = MessageConfig::WINDOW_OPACITY msgwindow.back_opacity = MessageConfig::WINDOW_OPACITY
pbBottomLeftLines(msgwindow, 2) pbBottomLeftLines(msgwindow, 2)
$game_temp.message_window_showing = true if $game_temp $game_temp.message_window_showing = true if $game_temp
skin = MessageConfig.pbGetSpeechFrame() if !skin skin = MessageConfig.pbGetSpeechFrame if !skin
msgwindow.setSkin(skin) msgwindow.setSkin(skin)
return msgwindow return msgwindow
end end
@@ -562,7 +562,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
if startSE != nil if startSE != nil
pbSEPlay(pbStringToAudioFile(startSE)) pbSEPlay(pbStringToAudioFile(startSE))
elsif signWaitCount == 0 && letterbyletter elsif signWaitCount == 0 && letterbyletter
pbPlayDecisionSE() pbPlayDecisionSE
end end
########## Position message window ############## ########## Position message window ##############
pbRepositionMessageWindow(msgwindow, linecount) pbRepositionMessageWindow(msgwindow, linecount)
@@ -348,7 +348,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
def getLineY(line) def getLineY(line)
textchars = getTextChars textchars = getTextChars
return 0 if textchars.length == 0 return 0 if textchars.length == 0
totallines = getTotalLines() totallines = getTotalLines
line = 0 if line < 0 line = 0 if line < 0
line = totallines - 1 if line >= totallines line = totallines - 1 if line >= totallines
maximumY = 0 maximumY = 0
@@ -364,7 +364,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
def getColumnsInLine(line) def getColumnsInLine(line)
textchars = getTextChars textchars = getTextChars
return 0 if textchars.length == 0 return 0 if textchars.length == 0
totallines = getTotalLines() totallines = getTotalLines
line = 0 if line < 0 line = 0 if line < 0
line = totallines - 1 if line >= totallines line = totallines - 1 if line >= totallines
endpos = 0 endpos = 0
@@ -379,7 +379,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
def getPosFromLineAndColumn(line, column) def getPosFromLineAndColumn(line, column)
textchars = getTextChars textchars = getTextChars
return 0 if textchars.length == 0 return 0 if textchars.length == 0
totallines = getTotalLines() totallines = getTotalLines
line = 0 if line < 0 line = 0 if line < 0
line = totallines - 1 if line >= totallines line = totallines - 1 if line >= totallines
endpos = 0 endpos = 0
@@ -405,7 +405,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
end end
def getLastVisibleLine def getLastVisibleLine
getTextChars() getTextChars
textheight = [1, self.contents.text_size("X").height].max textheight = [1, self.contents.text_size("X").height].max
lastVisible = @firstline + ((self.height - self.borderY) / textheight) - 1 lastVisible = @firstline + ((self.height - self.borderY) / textheight) - 1
return lastVisible return lastVisible
@@ -419,7 +419,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
self.refresh self.refresh
end end
@firstline = @cursorLine if @cursorLine < @firstline @firstline = @cursorLine if @cursorLine < @firstline
lastVisible = getLastVisibleLine() lastVisible = getLastVisibleLine
@firstline += (@cursorLine - lastVisible) if @cursorLine > lastVisible @firstline += (@cursorLine - lastVisible) if @cursorLine > lastVisible
end end
@@ -428,7 +428,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
# can affect line offset) # can affect line offset)
# echoln ["beforemoving",@cursorLine,@cursorColumn] # echoln ["beforemoving",@cursorLine,@cursorColumn]
totalColumns = getColumnsInLine(@cursorLine) # check current line totalColumns = getColumnsInLine(@cursorLine) # check current line
totalLines = getTotalLines() totalLines = getTotalLines
oldCursorLine = @cursorLine oldCursorLine = @cursorLine
oldCursorColumn = @cursorColumn oldCursorColumn = @cursorColumn
@cursorColumn += columnOffset @cursorColumn += columnOffset
@@ -487,7 +487,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
return return
elsif Input.press?(Input::CTRL) && Input.triggerex?(:END) elsif Input.press?(Input::CTRL) && Input.triggerex?(:END)
# Move cursor to end # Move cursor to end
@cursorLine = getTotalLines() - 1 @cursorLine = getTotalLines - 1
@cursorColumn = getColumnsInLine(@cursorLine) @cursorColumn = getColumnsInLine(@cursorLine)
updateCursorPos(true) updateCursorPos(true)
return return
@@ -511,7 +511,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
getTextChars getTextChars
height = self.height - self.borderY height = self.height - self.borderY
cursorcolor = Color.new(0, 0, 0) cursorcolor = Color.new(0, 0, 0)
textchars = getTextChars() textchars = getTextChars
startY = getLineY(@firstline) startY = getLineY(@firstline)
for i in 0...textchars.length for i in 0...textchars.length
thisline = textchars[i][5] thisline = textchars[i][5]
+4 -3
View File
@@ -110,7 +110,8 @@ def getPlayTime2(filename)
File.open(filename, "rb") { |file| File.open(filename, "rb") { |file|
file.pos = 0 file.pos = 0
fdw = fgetdw.call(file) fdw = fgetdw.call(file)
if fdw == 0x46464952 # "RIFF" case fdw
when 0x46464952 # "RIFF"
filesize = fgetdw.call(file) filesize = fgetdw.call(file)
wave = fgetdw.call(file) wave = fgetdw.call(file)
return -1 if wave != 0x45564157 # "WAVE" return -1 if wave != 0x45564157 # "WAVE"
@@ -129,7 +130,7 @@ def getPlayTime2(filename)
datasize = fgetdw.call(file) datasize = fgetdw.call(file)
time = (datasize * 1.0) / bytessec time = (datasize * 1.0) / bytessec
return time return time
elsif fdw == 0x5367674F # "OggS" when 0x5367674F # "OggS"
file.pos = 0 file.pos = 0
time = oggfiletime(file) time = oggfiletime(file)
return time return time
@@ -152,7 +153,7 @@ def getPlayTime2(filename)
break if ateof || !rstr || rstr.length != 3 break if ateof || !rstr || rstr.length != 3
if rstr[0] == 0xFB if rstr[0] == 0xFB
t = rstr[1] >> 4 t = rstr[1] >> 4
next if t == 0 || t == 15 next if [0, 15].include?(t)
freqs = [44100, 22050, 11025, 48000] freqs = [44100, 22050, 11025, 48000]
bitrates = [32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320] bitrates = [32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320]
bitrate = bitrates[t] bitrate = bitrates[t]
+1 -2
View File
@@ -544,7 +544,6 @@ module Transitions
end end
def set_up_timings def set_up_timings
time_between_zooms = (@duration - TIME_TO_ZOOM) * 2 / (TOTAL_SPRITES - 1)
for j in 0...NUM_SPRITES_Y for j in 0...NUM_SPRITES_Y
for i in 0...NUM_SPRITES_X for i in 0...NUM_SPRITES_X
idx_from_start = j * NUM_SPRITES_X + i # Top left -> bottom right idx_from_start = j * NUM_SPRITES_X + i # Top left -> bottom right
@@ -1182,7 +1181,7 @@ module Transitions
for i in 0...4 for i in 0...4
b = [@black_1_bitmap, @black_2_bitmap, @black_3_bitmap, @black_4_bitmap][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, @sprites[i] = new_sprite((i == 1) ? 0 : Graphics.width / 2, (i == 2) ? 0 : Graphics.height / 2, b,
(i % 2 == 0) ? b.width / 2 : 0, (i % 2 == 0) ? 0 : b.height / 2) (i.even?) ? b.width / 2 : 0, (i.even?) ? 0 : b.height / 2)
@sprites[i].zoom_x = 0.0 if i.even? @sprites[i].zoom_x = 0.0 if i.even?
@sprites[i].zoom_y = 0.0 if i.odd? @sprites[i].zoom_y = 0.0 if i.odd?
@sprites[i].visible = false @sprites[i].visible = false
@@ -22,10 +22,3 @@ class PhoneDatabase
@trainers = [] @trainers = []
end end
end end
module PhoneMsgType
Generic = 0
Greeting = 1
Body = 2
BattleRequest = 3
end
@@ -570,9 +570,10 @@ module GameData
when "09D" then new_code = "StartWeakenElectricMoves" when "09D" then new_code = "StartWeakenElectricMoves"
when "09E" then new_code = "StartWeakenFireMoves" when "09E" then new_code = "StartWeakenFireMoves"
when "09F" when "09F"
if data[:id] == :MULTIATTACK case data[:id]
when :MULTIATTACK
new_code = "TypeDependsOnUserMemory" new_code = "TypeDependsOnUserMemory"
elsif data[:id] == :TECHNOBLAST when :TECHNOBLAST
new_code = "TypeDependsOnUserDrive" new_code = "TypeDependsOnUserDrive"
else else
new_code = "TypeDependsOnUserPlate" new_code = "TypeDependsOnUserPlate"
@@ -16,7 +16,7 @@ module GameData
for i in 0...2**factors.length for i in 0...2**factors.length
# Set try_ parameters for this combination # Set try_ parameters for this combination
factors.each_with_index do |factor, index| factors.each_with_index do |factor, index|
value = ((i / (2**index)) % 2 == 0) ? factor[1] : factor[2] value = ((i / (2**index)).even?) ? factor[1] : factor[2]
case factor[0] case factor[0]
when 0 then try_species = value when 0 then try_species = value
when 1 then try_form = value when 1 then try_form = value
@@ -11,8 +11,8 @@ class Battle
when 2 when 2
idxOther = (idxBattler + 2) % 4 idxOther = (idxBattler + 2) % 4
when 3 when 3
return false if idxBattler == 2 || idxBattler == 3 # In middle spot already return false if [2, 3].include?(idxBattler) # In middle spot already
idxOther = ((idxBattler % 2) == 0) ? 2 : 3 idxOther = (idxBattler.even?) ? 2 : 3
end end
return false if pbGetOwnerIndexFromBattlerIndex(idxBattler) != pbGetOwnerIndexFromBattlerIndex(idxOther) return false if pbGetOwnerIndexFromBattlerIndex(idxBattler) != pbGetOwnerIndexFromBattlerIndex(idxOther)
return true return true
@@ -162,8 +162,10 @@ class Battle
allBattlers.each { |b| b.pbCheckFormOnWeatherChange } allBattlers.each { |b| b.pbCheckFormOnWeatherChange }
pbEndPrimordialWeather pbEndPrimordialWeather
allBattlers.each { |b| b.pbAbilityOnTerrainChange } allBattlers.each { |b| b.pbAbilityOnTerrainChange }
allBattlers.each { |b| b.pbCheckFormOnMovesetChange } allBattlers.each do |b|
allBattlers.each { |b| b.pbCheckFormOnStatusChange } b.pbCheckFormOnMovesetChange
b.pbCheckFormOnStatusChange
end
end end
#============================================================================= #=============================================================================
@@ -10,7 +10,6 @@ class Battle::Battler
attr_accessor :ability_id attr_accessor :ability_id
attr_accessor :item_id attr_accessor :item_id
attr_accessor :moves attr_accessor :moves
attr_accessor :gender
attr_accessor :attack attr_accessor :attack
attr_accessor :spatk attr_accessor :spatk
attr_accessor :speed attr_accessor :speed
@@ -739,7 +738,7 @@ class Battle::Battler
# Returns an array containing all unfainted ally Pokémon. # Returns an array containing all unfainted ally Pokémon.
def allAllies def allAllies
return @battle.allSameSideBattlers(@index).select { |b| b.index != @index } return @battle.allSameSideBattlers(@index).reject { |b| b.index == @index }
end end
# Yields each unfainted opposing Pokémon. # Yields each unfainted opposing Pokémon.
@@ -234,12 +234,12 @@ class Battle::Battler
# Darmanitan - Zen Mode # Darmanitan - Zen Mode
if isSpecies?(:DARMANITAN) && self.ability == :ZENMODE if isSpecies?(:DARMANITAN) && self.ability == :ZENMODE
if @hp <= @totalhp / 2 if @hp <= @totalhp / 2
if (@form % 2) == 0 if @form.even?
@battle.pbShowAbilitySplash(self, true) @battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self) @battle.pbHideAbilitySplash(self)
pbChangeForm(@form + 1, _INTL("{1} triggered!", abilityName)) pbChangeForm(@form + 1, _INTL("{1} triggered!", abilityName))
end end
elsif (@form % 2) != 0 elsif @form.odd?
@battle.pbShowAbilitySplash(self, true) @battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self) @battle.pbHideAbilitySplash(self)
pbChangeForm(@form - 1, _INTL("{1} triggered!", abilityName)) pbChangeForm(@form - 1, _INTL("{1} triggered!", abilityName))
@@ -72,7 +72,6 @@ class Battle::Battler
# in and not at any later times, even if a traceable ability turns # in and not at any later times, even if a traceable ability turns
# up later. Essentials ignores this, and allows Trace to trigger # up later. Essentials ignores this, and allows Trace to trigger
# whenever it can even in the old battle mechanics. # whenever it can even in the old battle mechanics.
choices = []
choices = @battle.allOtherSideBattlers(@index).select { |b| choices = @battle.allOtherSideBattlers(@index).select { |b|
next !b.ungainableAbility? && next !b.ungainableAbility? &&
![:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability_id) ![:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability_id)
@@ -22,7 +22,7 @@ class Battle::Battler
idxOther = (@index + 2) % 4 idxOther = (@index + 2) % 4
when 3 when 3
if @index != 2 && @index != 3 # If not in middle spot already if @index != 2 && @index != 3 # If not in middle spot already
idxOther = ((@index % 2) == 0) ? 2 : 3 idxOther = (@index.even?) ? 2 : 3
end end
end end
if idxOther >= 0 if idxOther >= 0
@@ -22,9 +22,10 @@ class Battle::Battler
@battle.scene.pbDamageAnimation(user) @battle.scene.pbDamageAnimation(user)
user.pbReduceHP(user.totalhp / 4, false) user.pbReduceHP(user.totalhp / 4, false)
end end
if target.form == 1 # Gulping Form case target.form
when 1 # Gulping Form
user.pbLowerStatStageByAbility(:DEFENSE, 1, target, false) user.pbLowerStatStageByAbility(:DEFENSE, 1, target, false)
elsif target.form == 2 # Gorging Form when 2 # Gorging Form
target.pbParalyze(user) if target.pbCanParalyze?(user, false) target.pbParalyze(user) if target.pbCanParalyze?(user, false)
end end
@battle.pbHideAbilitySplash(target) @battle.pbHideAbilitySplash(target)
@@ -396,15 +396,17 @@ class Battle::Move
# Weather # Weather
case user.effectiveWeather case user.effectiveWeather
when :Sun, :HarshSun when :Sun, :HarshSun
if type == :FIRE case type
when :FIRE
multipliers[:final_damage_multiplier] *= 1.5 multipliers[:final_damage_multiplier] *= 1.5
elsif type == :WATER when :WATER
multipliers[:final_damage_multiplier] /= 2 multipliers[:final_damage_multiplier] /= 2
end end
when :Rain, :HeavyRain when :Rain, :HeavyRain
if type == :FIRE case type
when :FIRE
multipliers[:final_damage_multiplier] /= 2 multipliers[:final_damage_multiplier] /= 2
elsif type == :WATER when :WATER
multipliers[:final_damage_multiplier] *= 1.5 multipliers[:final_damage_multiplier] *= 1.5
end end
when :Sandstorm when :Sandstorm
@@ -490,9 +490,10 @@ class Battle::Move::CureUserPartyStatus < Battle::Move
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
super super
if @id == :AROMATHERAPY case @id
when :AROMATHERAPY
@battle.pbDisplay(_INTL("A soothing aroma wafted through the area!")) @battle.pbDisplay(_INTL("A soothing aroma wafted through the area!"))
elsif @id == :HEALBELL when :HEALBELL
@battle.pbDisplay(_INTL("A bell chimed!")) @battle.pbDisplay(_INTL("A bell chimed!"))
end end
end end
@@ -200,7 +200,7 @@ class Battle::Scene
# Start Bag screen # Start Bag screen
itemScene = PokemonBag_Scene.new itemScene = PokemonBag_Scene.new
itemScene.pbStartScene($bag, true, itemScene.pbStartScene($bag, true,
Proc.new { |item| proc { |item|
useType = GameData::Item.get(item).battle_use useType = GameData::Item.get(item).battle_use
next useType && useType > 0 next useType && useType > 0
}, false) }, false)
@@ -368,7 +368,7 @@ class Battle::Scene
when :Foe, :Other when :Foe, :Other
indices = @battle.pbGetOpposingIndicesInOrder(idxBattler) indices = @battle.pbGetOpposingIndicesInOrder(idxBattler)
indices.each { |i| return i if !@battle.battlers[i].fainted? } indices.each { |i| return i if !@battle.battlers[i].fainted? }
indices.each { |i| return i } return indices.first if !indices.empty?
end end
return idxBattler # Target the user initially return idxBattler # Target the user initially
end end
@@ -391,7 +391,7 @@ class Battle::Scene
# Update selected command # Update selected command
if mode == 0 # Choosing just one target, can change index if mode == 0 # Choosing just one target, can change index
if Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT) if Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT)
inc = ((cw.index % 2) == 0) ? -2 : 2 inc = (cw.index.even?) ? -2 : 2
inc *= -1 if Input.trigger?(Input::RIGHT) inc *= -1 if Input.trigger?(Input::RIGHT)
indexLength = @battle.sideSizes[cw.index % 2] * 2 indexLength = @battle.sideSizes[cw.index % 2] * 2
newIndex = cw.index newIndex = cw.index
@@ -402,8 +402,8 @@ class Battle::Scene
cw.index = newIndex cw.index = newIndex
break break
end end
elsif (Input.trigger?(Input::UP) && (cw.index % 2) == 0) || elsif (Input.trigger?(Input::UP) && cw.index.even?) ||
(Input.trigger?(Input::DOWN) && (cw.index % 2) == 1) (Input.trigger?(Input::DOWN) && cw.index.odd?)
tryIndex = @battle.pbGetOpposingIndicesInOrder(cw.index) tryIndex = @battle.pbGetOpposingIndicesInOrder(cw.index)
tryIndex.each do |idxBattlerTry| tryIndex.each do |idxBattlerTry|
next if texts[idxBattlerTry].nil? next if texts[idxBattlerTry].nil?
@@ -479,7 +479,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
# NOTE: Battler indexes go from left to right from the perspective of # NOTE: Battler indexes go from left to right from the perspective of
# that side's trainer, so inc is different for each side for the # that side's trainer, so inc is different for each side for the
# same value of i/2. # same value of i/2.
inc = ((i % 2) == 0) ? i / 2 : numButtons - 1 - i / 2 inc = (i.even?) ? i / 2 : numButtons - 1 - i / 2
button = SpriteWrapper.new(viewport) button = SpriteWrapper.new(viewport)
button.bitmap = @buttonBitmap.bitmap button.bitmap = @buttonBitmap.bitmap
button.src_rect.width = (@smallButtons) ? CMD_BUTTON_WIDTH_SMALL : @buttonBitmap.width / 2 button.src_rect.width = (@smallButtons) ? CMD_BUTTON_WIDTH_SMALL : @buttonBitmap.width / 2
@@ -530,7 +530,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
if @texts[i] if @texts[i]
sel ||= (@mode == 0 && i == @index) sel ||= (@mode == 0 && i == @index)
sel ||= (@mode == 1) sel ||= (@mode == 1)
buttonType = ((i % 2) == 0) ? 1 : 2 buttonType = (i.even?) ? 1 : 2
end end
buttonType = 2 * buttonType + ((@smallButtons) ? 1 : 0) buttonType = 2 * buttonType + ((@smallButtons) ? 1 : 0)
button.src_rect.x = (sel) ? @buttonBitmap.width / 2 : 0 button.src_rect.x = (sel) ? @buttonBitmap.width / 2 : 0
@@ -39,7 +39,7 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
end end
def initializeDataBoxGraphic(sideSize) def initializeDataBoxGraphic(sideSize)
onPlayerSide = ((@battler.index % 2) == 0) onPlayerSide = @battler.index.even?
# Get the data box graphic and set whether the HP numbers/Exp bar are shown # Get the data box graphic and set whether the HP numbers/Exp bar are shown
if sideSize == 1 # One Pokémon on side, use the regular dara box BG if sideSize == 1 # One Pokémon on side, use the regular dara box BG
bgFilename = ["Graphics/Pictures/Battle/databox_normal", bgFilename = ["Graphics/Pictures/Battle/databox_normal",
@@ -537,7 +537,7 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
def pbSetPosition def pbSetPosition
return if !@_iconBitmap return if !@_iconBitmap
pbSetOrigin pbSetOrigin
if (@index % 2) == 0 if @index.even?
self.z = 50 + 5 * @index / 2 self.z = 50 + 5 * @index / 2
else else
self.z = 50 - 5 * (@index + 1) / 2 self.z = 50 - 5 * (@index + 1) / 2
@@ -34,7 +34,7 @@ class Battle::Scene::Animation::Intro < Battle::Scene::Animation
end end
# Shadows # Shadows
for i in 0...@battle.battlers.length for i in 0...@battle.battlers.length
makeSlideSprite("shadow_#{i}", ((i % 2) == 0) ? 1 : -1, appearTime, PictureOrigin::Center) makeSlideSprite("shadow_#{i}", (i.even?) ? 1 : -1, appearTime, PictureOrigin::Center)
end end
# Fading blackness over whole screen # Fading blackness over whole screen
blackScreen = addNewSprite(0, 0, "Graphics/Battle animations/black_screen") blackScreen = addNewSprite(0, 0, "Graphics/Battle animations/black_screen")
@@ -196,7 +196,7 @@ class Battle::Scene::Animation::DataBoxAppear < Battle::Scene::Animation
return if !@sprites["dataBox_#{@idxBox}"] return if !@sprites["dataBox_#{@idxBox}"]
box = addSprite(@sprites["dataBox_#{@idxBox}"]) box = addSprite(@sprites["dataBox_#{@idxBox}"])
box.setVisible(0, true) box.setVisible(0, true)
dir = ((@idxBox % 2) == 0) ? 1 : -1 dir = (@idxBox.even?) ? 1 : -1
box.setDelta(0, dir * Graphics.width / 2, 0) box.setDelta(0, dir * Graphics.width / 2, 0)
box.moveDelta(0, 8, -dir * Graphics.width / 2, 0) box.moveDelta(0, 8, -dir * Graphics.width / 2, 0)
end end
@@ -216,7 +216,7 @@ class Battle::Scene::Animation::DataBoxDisappear < Battle::Scene::Animation
def createProcesses def createProcesses
return if !@sprites["dataBox_#{@idxBox}"] || !@sprites["dataBox_#{@idxBox}"].visible return if !@sprites["dataBox_#{@idxBox}"] || !@sprites["dataBox_#{@idxBox}"].visible
box = addSprite(@sprites["dataBox_#{@idxBox}"]) box = addSprite(@sprites["dataBox_#{@idxBox}"])
dir = ((@idxBox % 2) == 0) ? 1 : -1 dir = (@idxBox.even?) ? 1 : -1
box.moveDelta(0, 8, dir * Graphics.width / 2, 0) box.moveDelta(0, 8, dir * Graphics.width / 2, 0)
box.setVisible(8, false) box.setVisible(8, false)
end end
@@ -1689,12 +1689,8 @@ class Battle::AI
when "PowerHigherWithUserHeavierThanTarget" when "PowerHigherWithUserHeavierThanTarget"
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "PowerUpAllyMove" when "PowerUpAllyMove"
hasAlly = false hasAlly = !user.allAllies.empty?
user.allAllies.each do |b| score += 30 if hasAlly
hasAlly = true
score += 30
break
end
score -= 90 if !hasAlly score -= 90 if !hasAlly
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "StartWeakenElectricMoves" when "StartWeakenElectricMoves"
@@ -1826,8 +1822,6 @@ class Battle::AI
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "HitTwoTimes" when "HitTwoTimes"
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "HitTwoTimesPoisonTarget"
#---------------------------------------------------------------------------
when "HitThreeTimesPowersUpWithEachHit" when "HitThreeTimesPowersUpWithEachHit"
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "HitTwoToFiveTimes" when "HitTwoToFiveTimes"
@@ -273,12 +273,11 @@ class Battle::AI
targetTypes = target.pbTypes(true) targetTypes = target.pbTypes(true)
mult = Effectiveness.calculate(:FLYING, mult = Effectiveness.calculate(:FLYING,
targetTypes[0], targetTypes[1], targetTypes[2]) targetTypes[0], targetTypes[1], targetTypes[2])
baseDmg = (baseDmg.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round
else else
mult = Effectiveness.calculate(:FLYING, mult = Effectiveness.calculate(:FLYING,
target.types[0], target.types[1], target.effects[PBEffects::Type3]) target.types[0], target.types[1], target.effects[PBEffects::Type3])
baseDmg = (baseDmg.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round
end end
baseDmg = (baseDmg.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round
end end
baseDmg *= 2 if skill >= PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize] baseDmg *= 2 if skill >= PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize]
when "DoublePowerIfUserLastMoveFailed" # Stomping Tantrum when "DoublePowerIfUserLastMoveFailed" # Stomping Tantrum
@@ -472,15 +471,17 @@ class Battle::AI
if skill >= PBTrainerAI.mediumSkill if skill >= PBTrainerAI.mediumSkill
case user.effectiveWeather case user.effectiveWeather
when :Sun, :HarshSun when :Sun, :HarshSun
if type == :FIRE case type
when :FIRE
multipliers[:final_damage_multiplier] *= 1.5 multipliers[:final_damage_multiplier] *= 1.5
elsif type == :WATER when :WATER
multipliers[:final_damage_multiplier] /= 2 multipliers[:final_damage_multiplier] /= 2
end end
when :Rain, :HeavyRain when :Rain, :HeavyRain
if type == :FIRE case type
when :FIRE
multipliers[:final_damage_multiplier] /= 2 multipliers[:final_damage_multiplier] /= 2
elsif type == :WATER when :WATER
multipliers[:final_damage_multiplier] *= 1.5 multipliers[:final_damage_multiplier] *= 1.5
end end
when :Sandstorm when :Sandstorm
@@ -1582,7 +1582,7 @@ Battle::AbilityEffects::DamageCalcFromTarget.add(:PUNKROCK,
Battle::AbilityEffects::DamageCalcFromTarget.add(:THICKFAT, Battle::AbilityEffects::DamageCalcFromTarget.add(:THICKFAT,
proc { |ability, user, target, move, mults, baseDmg, type| proc { |ability, user, target, move, mults, baseDmg, type|
mults[:base_damage_multiplier] /= 2 if type == :FIRE || type == :ICE mults[:base_damage_multiplier] /= 2 if [:FIRE, :ICE].include?(type)
} }
) )
@@ -726,7 +726,7 @@ Battle::ItemEffects::AccuracyCalcFromTarget.copy(:BRIGHTPOWDER, :LAXINCENSE)
Battle::ItemEffects::DamageCalcFromUser.add(:ADAMANTORB, Battle::ItemEffects::DamageCalcFromUser.add(:ADAMANTORB,
proc { |item, user, target, move, mults, baseDmg, type| proc { |item, user, target, move, mults, baseDmg, type|
if user.isSpecies?(:DIALGA) && (type == :DRAGON || type == :STEEL) if user.isSpecies?(:DIALGA) && [:DRAGON, :STEEL].include?(type)
mults[:base_damage_multiplier] *= 1.2 mults[:base_damage_multiplier] *= 1.2
end end
} }
@@ -854,7 +854,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:GRASSGEM,
Battle::ItemEffects::DamageCalcFromUser.add(:GRISEOUSORB, Battle::ItemEffects::DamageCalcFromUser.add(:GRISEOUSORB,
proc { |item, user, target, move, mults, baseDmg, type| proc { |item, user, target, move, mults, baseDmg, type|
if user.isSpecies?(:GIRATINA) && (type == :DRAGON || type == :GHOST) if user.isSpecies?(:GIRATINA) && [:DRAGON, :GHOST].include?(type)
mults[:base_damage_multiplier] *= 1.2 mults[:base_damage_multiplier] *= 1.2
end end
} }
@@ -898,7 +898,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:LIGHTBALL,
Battle::ItemEffects::DamageCalcFromUser.add(:LUSTROUSORB, Battle::ItemEffects::DamageCalcFromUser.add(:LUSTROUSORB,
proc { |item, user, target, move, mults, baseDmg, type| proc { |item, user, target, move, mults, baseDmg, type|
if user.isSpecies?(:PALKIA) && (type == :DRAGON || type == :WATER) if user.isSpecies?(:PALKIA) && [:DRAGON, :WATER].include?(type)
mults[:base_damage_multiplier] *= 1.2 mults[:base_damage_multiplier] *= 1.2
end end
} }
@@ -1029,7 +1029,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:SOULDEW,
proc { |item, user, target, move, mults, baseDmg, type| proc { |item, user, target, move, mults, baseDmg, type|
next if !user.isSpecies?(:LATIAS) && !user.isSpecies?(:LATIOS) next if !user.isSpecies?(:LATIAS) && !user.isSpecies?(:LATIOS)
if Settings::SOUL_DEW_POWERS_UP_TYPES if Settings::SOUL_DEW_POWERS_UP_TYPES
mults[:final_damage_multiplier] *= 1.2 if type == :PSYCHIC || type == :DRAGON mults[:final_damage_multiplier] *= 1.2 if [:DRAGON, :PSYCHIC].include?(type)
else else
if move.specialMove? && !user.battle.rules["souldewclause"] if move.specialMove? && !user.battle.rules["souldewclause"]
mults[:attack_multiplier] *= 1.5 mults[:attack_multiplier] *= 1.5
@@ -1880,7 +1880,6 @@ Battle::ItemEffects::EndOfRoundEffect.add(:FLAMEORB,
Battle::ItemEffects::EndOfRoundEffect.add(:STICKYBARB, Battle::ItemEffects::EndOfRoundEffect.add(:STICKYBARB,
proc { |item, battler, battle| proc { |item, battler, battle|
next if !battler.takesIndirectDamage? next if !battler.takesIndirectDamage?
oldHP = battler.hp
battle.scene.pbDamageAnimation(battler) battle.scene.pbDamageAnimation(battler)
battler.pbTakeEffectDamage(battler.totalhp / 8, false) { |hp_lost| battler.pbTakeEffectDamage(battler.totalhp / 8, false) { |hp_lost|
battle.pbDisplay(_INTL("{1} is hurt by its {2}!", battler.pbThis, battler.itemName)) battle.pbDisplay(_INTL("{1} is hurt by its {2}!", battler.pbThis, battler.itemName))
@@ -95,17 +95,10 @@ class BattlePalaceBattle < Battle
def pbRegisterMove(idxBattler, idxMove, _showMessages = true) def pbRegisterMove(idxBattler, idxMove, _showMessages = true)
this_battler = @battlers[idxBattler] this_battler = @battlers[idxBattler]
if idxMove == -2 @choices[idxBattler][0] = :UseMove
@choices[idxBattler][0] = :UseMove # "Use move" @choices[idxBattler][1] = idxMove # Index of move to be used (-2="Incapable of using its power...")
@choices[idxBattler][1] = -2 # "Incapable of using its power..." @choices[idxBattler][2] = (idxMove == -2) ? @struggle : this_battler.moves[idxMove] # Battle::Move object
@choices[idxBattler][2] = @struggle @choices[idxBattler][3] = -1 # No target chosen yet
@choices[idxBattler][3] = -1
else
@choices[idxBattler][0] = :UseMove # "Use move"
@choices[idxBattler][1] = idxMove # Index of move to be used
@choices[idxBattler][2] = this_battler.moves[idxMove] # Battle::Move object
@choices[idxBattler][3] = -1 # No target chosen yet
end
end end
def pbAutoFightMenu(idxBattler) def pbAutoFightMenu(idxBattler)
@@ -17,9 +17,10 @@ class Battle::SuccessState
end end
def updateSkill def updateSkill
if @useState == 1 case @useState
when 1
@skill = -2 if !@protected @skill = -2 if !@protected
elsif @useState == 2 when 2
if Effectiveness.super_effective?(@typeMod) if Effectiveness.super_effective?(@typeMod)
@skill = 2 @skill = 2
elsif Effectiveness.normal?(@typeMod) elsif Effectiveness.normal?(@typeMod)
@@ -6,10 +6,10 @@ module RecordedBattleModule
attr_reader :rounds attr_reader :rounds
module Commands module Commands
Fight = 0 FIGHT = 0
Bag = 1 BAG = 1
Pokemon = 2 POKEMON = 2
Run = 3 RUN = 3
end end
def initialize(*arg) def initialize(*arg)
@@ -81,7 +81,7 @@ module RecordedBattleModule
def pbRegisterMove(idxBattler, idxMove, showMessages = true) def pbRegisterMove(idxBattler, idxMove, showMessages = true)
if super if super
@rounds[@roundindex][idxBattler] = [Commands::Fight, idxMove] @rounds[@roundindex][idxBattler] = [Commands::FIGHT, idxMove]
return true return true
end end
return false return false
@@ -94,19 +94,19 @@ module RecordedBattleModule
def pbRun(idxBattler, duringBattle = false) def pbRun(idxBattler, duringBattle = false)
ret = super ret = super
@rounds[@roundindex][idxBattler] = [Commands::Run, @decision] @rounds[@roundindex][idxBattler] = [Commands::RUN, @decision]
return ret return ret
end end
def pbAutoChooseMove(idxBattler, showMessages = true) def pbAutoChooseMove(idxBattler, showMessages = true)
ret = super ret = super
@rounds[@roundindex][idxBattler] = [Commands::Fight, -1] @rounds[@roundindex][idxBattler] = [Commands::FIGHT, -1]
return ret return ret
end end
def pbRegisterSwitch(idxBattler, idxParty) def pbRegisterSwitch(idxBattler, idxParty)
if super if super
@rounds[@roundindex][idxBattler] = [Commands::Pokemon, idxParty] @rounds[@roundindex][idxBattler] = [Commands::POKEMON, idxParty]
return true return true
end end
return false return false
@@ -114,7 +114,7 @@ module RecordedBattleModule
def pbRegisterItem(idxBattler, item, idxTarget = nil, idxMove = nil) def pbRegisterItem(idxBattler, item, idxTarget = nil, idxMove = nil)
if super if super
@rounds[@roundindex][idxBattler] = [Commands::Bag, item, idxTarget, idxMove] @rounds[@roundindex][idxBattler] = [Commands::BAG, item, idxTarget, idxMove]
return true return true
end end
return false return false
@@ -140,10 +140,10 @@ end
#=============================================================================== #===============================================================================
module RecordedBattlePlaybackModule module RecordedBattlePlaybackModule
module Commands module Commands
Fight = 0 FIGHT = 0
Bag = 1 BAG = 1
Pokemon = 2 POKEMON = 2
Run = 3 RUN = 3
end end
def initialize(scene, battle) def initialize(scene, battle)
@@ -206,7 +206,7 @@ module RecordedBattlePlaybackModule
next if @rounds[@roundindex][i].length == 0 next if @rounds[@roundindex][i].length == 0
pbClearChoice(i) pbClearChoice(i)
case @rounds[@roundindex][i][0] case @rounds[@roundindex][i][0]
when Commands::Fight when Commands::FIGHT
if @rounds[@roundindex][i][1] == -1 if @rounds[@roundindex][i][1] == -1
pbAutoChooseMove(i, false) pbAutoChooseMove(i, false)
else else
@@ -215,11 +215,11 @@ module RecordedBattlePlaybackModule
if @rounds[@roundindex][i][2] if @rounds[@roundindex][i][2]
pbRegisterTarget(i, @rounds[@roundindex][i][2]) pbRegisterTarget(i, @rounds[@roundindex][i][2])
end end
when Commands::Bag when Commands::BAG
pbRegisterItem(i, @rounds[@roundindex][i][1], @rounds[@roundindex][i][2], @rounds[@roundindex][i][3]) pbRegisterItem(i, @rounds[@roundindex][i][1], @rounds[@roundindex][i][2], @rounds[@roundindex][i][3])
when Commands::Pokemon when Commands::POKEMON
pbRegisterSwitch(i, @rounds[@roundindex][i][1]) pbRegisterSwitch(i, @rounds[@roundindex][i][1])
when Commands::Run when Commands::RUN
@decision = @rounds[@roundindex][i][1] @decision = @rounds[@roundindex][i][1]
end end
end end
@@ -214,7 +214,7 @@ module RPG
end end
if @weatherTypes[weather_type][0].category == :Rain if @weatherTypes[weather_type][0].category == :Rain
last_index = weatherBitmaps.length - 1 # Last sprite is a splash last_index = weatherBitmaps.length - 1 # Last sprite is a splash
if (index % 2) == 0 if index.even?
sprite.bitmap = weatherBitmaps[index % last_index] sprite.bitmap = weatherBitmaps[index % last_index]
else else
sprite.bitmap = weatherBitmaps[last_index] sprite.bitmap = weatherBitmaps[last_index]
@@ -244,10 +244,10 @@ module RPG
lifetimes[index] = 0 lifetimes[index] = 0
return return
end end
if @weatherTypes[weather_type][0].category == :Rain && (index % 2) != 0 # Splash if @weatherTypes[weather_type][0].category == :Rain && index.odd? # Splash
sprite.x = @ox - sprite.bitmap.width + rand(Graphics.width + sprite.bitmap.width * 2) sprite.x = @ox - sprite.bitmap.width + rand(Graphics.width + sprite.bitmap.width * 2)
sprite.y = @oy - sprite.bitmap.height + rand(Graphics.height + sprite.bitmap.height * 2) sprite.y = @oy - sprite.bitmap.height + rand(Graphics.height + sprite.bitmap.height * 2)
lifetimes[index] = (30 + rand(20)) * 0.01 # 0.3-0.5 seconds lifetimes[index] = (rand(30...50)) * 0.01 # 0.3-0.5 seconds
else else
x_speed = @weatherTypes[weather_type][0].particle_delta_x x_speed = @weatherTypes[weather_type][0].particle_delta_x
y_speed = @weatherTypes[weather_type][0].particle_delta_y y_speed = @weatherTypes[weather_type][0].particle_delta_y
@@ -283,7 +283,7 @@ module RPG
# Determine which weather type this sprite is representing # Determine which weather type this sprite is representing
weather_type = (is_new_sprite) ? @target_type : @type weather_type = (is_new_sprite) ? @target_type : @type
# Update visibility/position/opacity of sprite # Update visibility/position/opacity of sprite
if @weatherTypes[weather_type][0].category == :Rain && (index % 2) != 0 # Splash if @weatherTypes[weather_type][0].category == :Rain && index.odd? # Splash
sprite.opacity = (lifetimes[index] < 0.2) ? 255 : 0 # 0.2 seconds sprite.opacity = (lifetimes[index] < 0.2) ? 255 : 0 # 0.2 seconds
else else
dist_x = @weatherTypes[weather_type][0].particle_delta_x * delta_t dist_x = @weatherTypes[weather_type][0].particle_delta_x * delta_t
@@ -486,11 +486,11 @@ module RPG
if @time_until_flash > 0 if @time_until_flash > 0
@time_until_flash -= Graphics.delta_s @time_until_flash -= Graphics.delta_s
if @time_until_flash <= 0 if @time_until_flash <= 0
@viewport.flash(Color.new(255, 255, 255, 230), (2 + rand(3)) * 20) @viewport.flash(Color.new(255, 255, 255, 230), rand(2..4) * 20)
end end
end end
if @time_until_flash <= 0 if @time_until_flash <= 0
@time_until_flash = (1 + rand(12)) * 0.5 # 0.5-6 seconds @time_until_flash = rand(1..12) * 0.5 # 0.5-6 seconds
end end
end end
@viewport.update @viewport.update
@@ -573,7 +573,7 @@ def pbAfterBattle(decision, canLose)
pkmn.makeUnprimal pkmn.makeUnprimal
end end
end end
if decision == 2 || decision == 5 # if loss or draw if [2, 5].include?(decision) # if loss or draw
if canLose if canLose
$player.party.each { |pkmn| pkmn.heal } $player.party.each { |pkmn| pkmn.heal }
(Graphics.frame_rate / 4).times { Graphics.update } (Graphics.frame_rate / 4).times { Graphics.update }
@@ -180,7 +180,7 @@ end
##### VS. animation, by Luka S.J. ##### ##### VS. animation, by Luka S.J. #####
##### Tweaked by Maruno ##### ##### Tweaked by Maruno #####
SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50 SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50
Proc.new { |battle_type, foe| # Condition proc { |battle_type, foe| # Condition
next false unless [1, 3].include?(battle_type) && foe.length == 1 # Only if a single trainer next false unless [1, 3].include?(battle_type) && foe.length == 1 # Only if a single trainer
tr_type = foe[0].trainer_type tr_type = foe[0].trainer_type
next false if !tr_type next false if !tr_type
@@ -189,7 +189,7 @@ SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50
next pbResolveBitmap("Graphics/Transitions/" + trainer_bar_graphic) && next pbResolveBitmap("Graphics/Transitions/" + trainer_bar_graphic) &&
pbResolveBitmap("Graphics/Transitions/" + trainer_graphic) pbResolveBitmap("Graphics/Transitions/" + trainer_graphic)
}, },
Proc.new { |viewport, battle_type, foe| # Animation proc { |viewport, battle_type, foe| # Animation
# Determine filenames of graphics to be used # Determine filenames of graphics to be used
tr_type = foe[0].trainer_type tr_type = foe[0].trainer_type
trainer_bar_graphic = sprintf("vsBar_%s", tr_type.to_s) rescue nil trainer_bar_graphic = sprintf("vsBar_%s", tr_type.to_s) rescue nil
@@ -208,7 +208,7 @@ def pbRoamingPokemonBattle(species, level)
# Perform the battle # Perform the battle
decision = pbWildBattleCore($PokemonGlobal.roamPokemon[idxRoamer]) decision = pbWildBattleCore($PokemonGlobal.roamPokemon[idxRoamer])
# Update Roaming Pokémon data based on result of battle # Update Roaming Pokémon data based on result of battle
if decision == 1 || decision == 4 # Defeated or caught if [1, 4].include?(decision) # Defeated or caught
$PokemonGlobal.roamPokemon[idxRoamer] = true $PokemonGlobal.roamPokemon[idxRoamer] = true
$PokemonGlobal.roamPokemonCaught[idxRoamer] = (decision == 4) $PokemonGlobal.roamPokemonCaught[idxRoamer] = (decision == 4)
end end
@@ -8,7 +8,7 @@ end
module PBDayNight module PBDayNight
HourlyTones = [ HOURLY_TONES = [
Tone.new(-70, -90, 15, 55), # Night # Midnight Tone.new(-70, -90, 15, 55), # Night # Midnight
Tone.new(-70, -90, 15, 55), # Night Tone.new(-70, -90, 15, 55), # Night
Tone.new(-70, -90, 15, 55), # Night Tone.new(-70, -90, 15, 55), # Night
@@ -93,15 +93,13 @@ module PBDayNight
return (now.hour * 60) + now.min return (now.hour * 60) + now.min
end end
private
def self.getToneInternal def self.getToneInternal
# Calculates the tone for the current frame, used for day/night effects # Calculates the tone for the current frame, used for day/night effects
realMinutes = pbGetDayNightMinutes realMinutes = pbGetDayNightMinutes
hour = realMinutes / 60 hour = realMinutes / 60
minute = realMinutes % 60 minute = realMinutes % 60
tone = PBDayNight::HourlyTones[hour] tone = PBDayNight::HOURLY_TONES[hour]
nexthourtone = PBDayNight::HourlyTones[(hour + 1) % 24] nexthourtone = PBDayNight::HOURLY_TONES[(hour + 1) % 24]
# Calculate current tint according to current and next hour's tint and # Calculate current tint according to current and next hour's tint and
# depending on current minute # depending on current minute
@cachedTone.red = ((nexthourtone.red - tone.red) * minute * @oneOverSixty) + tone.red @cachedTone.red = ((nexthourtone.red - tone.red) * minute * @oneOverSixty) + tone.red
@@ -83,7 +83,7 @@ def pbHiddenMoveAnimation(pokemon)
15.times do |i| 15.times do |i|
strobe = BitmapSprite.new(26 * 2, 8 * 2, viewport) strobe = BitmapSprite.new(26 * 2, 8 * 2, viewport)
strobe.bitmap.blt(0, 0, strobebitmap.bitmap, Rect.new(0, (i % 2) * 8 * 2, 26 * 2, 8 * 2)) strobe.bitmap.blt(0, 0, strobebitmap.bitmap, Rect.new(0, (i % 2) * 8 * 2, 26 * 2, 8 * 2))
strobe.z = ((i % 2) == 0 ? 2 : 0) strobe.z = (i.even? ? 2 : 0)
strobe.visible = false strobe.visible = false
strobes.push(strobe) strobes.push(strobe)
end end
@@ -47,8 +47,8 @@ def pbFishing(hasEncounter, rodType = 1)
msgWindow = pbCreateMessageWindow msgWindow = pbCreateMessageWindow
ret = false ret = false
loop do loop do
time = 5 + rand(6) time = rand(5..10)
time = [time, 5 + rand(6)].min if speedup time = [time, rand(5..10)].min if speedup
message = "" message = ""
time.times { message += ". " } time.times { message += ". " }
if pbWaitMessage(msgWindow, time) if pbWaitMessage(msgWindow, time)
@@ -382,7 +382,7 @@ def pbBerryPlant
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag) screen = PokemonBagScreen.new(scene, $bag)
mulch = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_mulch? }) mulch = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_mulch? })
} }
return if !mulch return if !mulch
mulch_data = GameData::Item.get(mulch) mulch_data = GameData::Item.get(mulch)
@@ -409,7 +409,7 @@ def pbBerryPlant
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag) screen = PokemonBagScreen.new(scene, $bag)
berry = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_berry? }) berry = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_berry? })
} }
if berry if berry
$stats.berries_planted += 1 $stats.berries_planted += 1
@@ -76,10 +76,10 @@ module RandomDungeonGenerator
ROOM_MIN_HEIGHT = 4 ROOM_MIN_HEIGHT = 4
ROOM_MAX_HEIGHT = CELL_HEIGHT - 3 # Should be at most CELL_HEIGHT - 3 ROOM_MAX_HEIGHT = CELL_HEIGHT - 3 # Should be at most CELL_HEIGHT - 3
CORRIDOR_WIDTH = 3 CORRIDOR_WIDTH = 3
None = 0 TURN_NONE = 0
TurnLeft = 1 TURN_LEFT = 1
TurnRight = 2 TURN_RIGHT = 2
Turn180 = 3 TURN_BACK = 3
@@corridor_layouts = nil @@corridor_layouts = nil
module_function module_function
@@ -96,16 +96,16 @@ module RandomDungeonGenerator
for i in 0...CELL_WIDTH * CELL_HEIGHT for i in 0...CELL_WIDTH * CELL_HEIGHT
tiles[combo][i] = DungeonTile::VOID tiles[combo][i] = DungeonTile::VOID
end end
if (combo & EdgeMasks::North) == 0 if (combo & EdgeMasks::NORTH) == 0
paint_corridor(tiles[combo], x_offset, 0, CORRIDOR_WIDTH, y_offset + CORRIDOR_WIDTH) paint_corridor(tiles[combo], x_offset, 0, CORRIDOR_WIDTH, y_offset + CORRIDOR_WIDTH)
end end
if (combo & EdgeMasks::South) == 0 if (combo & EdgeMasks::SOUTH) == 0
paint_corridor(tiles[combo], x_offset, y_offset, CORRIDOR_WIDTH, CELL_HEIGHT - y_offset) paint_corridor(tiles[combo], x_offset, y_offset, CORRIDOR_WIDTH, CELL_HEIGHT - y_offset)
end end
if (combo & EdgeMasks::East) == 0 if (combo & EdgeMasks::EAST) == 0
paint_corridor(tiles[combo], x_offset, y_offset, CELL_WIDTH - x_offset, CORRIDOR_WIDTH) paint_corridor(tiles[combo], x_offset, y_offset, CELL_WIDTH - x_offset, CORRIDOR_WIDTH)
end end
if (combo & EdgeMasks::West) == 0 if (combo & EdgeMasks::WEST) == 0
paint_corridor(tiles[combo], 0, y_offset, x_offset + CORRIDOR_WIDTH, CORRIDOR_WIDTH) paint_corridor(tiles[combo], 0, y_offset, x_offset + CORRIDOR_WIDTH, CORRIDOR_WIDTH)
end end
end end
@@ -126,25 +126,25 @@ module RandomDungeonGenerator
# Used to draw tiles from the given tile_layout and rotation (for corridors). # Used to draw tiles from the given tile_layout and rotation (for corridors).
def paint_tile_layout(dungeon, dstX, dstY, tile_layout, rotation) def paint_tile_layout(dungeon, dstX, dstY, tile_layout, rotation)
case rotation case rotation
when None when TURN_NONE
for y in 0...CELL_HEIGHT for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH for x in 0...CELL_WIDTH
dungeon[x + dstX, y + dstY] = tile_layout[y * CELL_WIDTH + x] dungeon[x + dstX, y + dstY] = tile_layout[y * CELL_WIDTH + x]
end end
end end
when TurnLeft when TURN_LEFT
for y in 0...CELL_HEIGHT for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH for x in 0...CELL_WIDTH
dungeon[y + dstX, CELL_WIDTH - 1 - x + dstY] = tile_layout[y * CELL_WIDTH + x] dungeon[y + dstX, CELL_WIDTH - 1 - x + dstY] = tile_layout[y * CELL_WIDTH + x]
end end
end end
when TurnRight when TURN_RIGHT
for y in 0...CELL_HEIGHT for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH for x in 0...CELL_WIDTH
dungeon[CELL_HEIGHT - 1 - y + dstX, x + dstY] = tile_layout[y * CELL_WIDTH + x] dungeon[CELL_HEIGHT - 1 - y + dstX, x + dstY] = tile_layout[y * CELL_WIDTH + x]
end end
end end
when Turn180 when TURN_BACK
for y in 0...CELL_HEIGHT for y in 0...CELL_HEIGHT
for x in 0...CELL_WIDTH for x in 0...CELL_WIDTH
dungeon[CELL_WIDTH - 1 - x + dstX, CELL_HEIGHT - 1 - y + dstY] = tile_layout[y * CELL_WIDTH + x] dungeon[CELL_WIDTH - 1 - x + dstX, CELL_HEIGHT - 1 - y + dstY] = tile_layout[y * CELL_WIDTH + x]
@@ -180,11 +180,11 @@ module RandomDungeonGenerator
# Bitwise values used to keep track of the generation of node connections. # Bitwise values used to keep track of the generation of node connections.
#============================================================================= #=============================================================================
module EdgeMasks module EdgeMasks
North = 1 NORTH = 1
West = 2 WEST = 2
East = 4 EAST = 4
South = 8 SOUTH = 8
Visited = 16 VISITED = 16
end end
#============================================================================= #=============================================================================
@@ -225,7 +225,7 @@ module RandomDungeonGenerator
class Maze class Maze
attr_accessor :cellWidth, :cellHeight, :nodeWidth, :nodeHeight attr_accessor :cellWidth, :cellHeight, :nodeWidth, :nodeHeight
DIRECTIONS = [EdgeMasks::North, EdgeMasks::South, EdgeMasks::East, EdgeMasks::West] DIRECTIONS = [EdgeMasks::NORTH, EdgeMasks::SOUTH, EdgeMasks::EAST, EdgeMasks::WEST]
def initialize(cw, ch) def initialize(cw, ch)
raise ArgumentError.new if cw == 0 || ch == 0 raise ArgumentError.new if cw == 0 || ch == 0
@@ -244,17 +244,17 @@ module RandomDungeonGenerator
def getVisited(x, y) def getVisited(x, y)
return false if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight return false if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight
return (@cells[y * cellWidth + x] & EdgeMasks::Visited) != 0 return (@cells[y * cellWidth + x] & EdgeMasks::VISITED) != 0
end end
def setVisited(x, y) def setVisited(x, y)
return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight
@cells[y * cellWidth + x] |= EdgeMasks::Visited @cells[y * cellWidth + x] |= EdgeMasks::VISITED
end end
def clearVisited(x, y) def clearVisited(x, y)
return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight
@cells[y * cellWidth + x] &= ~EdgeMasks::Visited @cells[y * cellWidth + x] &= ~EdgeMasks::VISITED
end end
def clearAllCells def clearAllCells
@@ -275,17 +275,17 @@ module RandomDungeonGenerator
nx = x nx = x
ny = y ny = y
case edge case edge
when EdgeMasks::North when EdgeMasks::NORTH
e = EdgeMasks::South e = EdgeMasks::SOUTH
ny = y - 1 ny = y - 1
when EdgeMasks::South when EdgeMasks::SOUTH
e = EdgeMasks::North e = EdgeMasks::NORTH
ny = y + 1 ny = y + 1
when EdgeMasks::East when EdgeMasks::EAST
e = EdgeMasks::West e = EdgeMasks::WEST
nx = x + 1 nx = x + 1
when EdgeMasks::West when EdgeMasks::WEST
e = EdgeMasks::East e = EdgeMasks::EAST
nx = x - 1 nx = x - 1
else else
return return
@@ -307,17 +307,17 @@ module RandomDungeonGenerator
nx = x nx = x
ny = y ny = y
case edge case edge
when EdgeMasks::North when EdgeMasks::NORTH
e = EdgeMasks::South e = EdgeMasks::SOUTH
ny -= 1 ny -= 1
when EdgeMasks::South when EdgeMasks::SOUTH
e = EdgeMasks::North e = EdgeMasks::NORTH
ny += 1 ny += 1
when EdgeMasks::East when EdgeMasks::EAST
e = EdgeMasks::West e = EdgeMasks::WEST
nx += 1 nx += 1
when EdgeMasks::West when EdgeMasks::WEST
e = EdgeMasks::East e = EdgeMasks::EAST
nx -= 1 nx -= 1
else else
raise ArgumentError.new raise ArgumentError.new
@@ -339,10 +339,10 @@ module RandomDungeonGenerator
def getEdgePattern(x, y) def getEdgePattern(x, y)
pattern = 0 pattern = 0
pattern |= EdgeMasks::North if getEdgeNode(x, y, EdgeMasks::North) pattern |= EdgeMasks::NORTH if getEdgeNode(x, y, EdgeMasks::NORTH)
pattern |= EdgeMasks::South if getEdgeNode(x, y, EdgeMasks::South) pattern |= EdgeMasks::SOUTH if getEdgeNode(x, y, EdgeMasks::SOUTH)
pattern |= EdgeMasks::East if getEdgeNode(x, y, EdgeMasks::East) pattern |= EdgeMasks::EAST if getEdgeNode(x, y, EdgeMasks::EAST)
pattern |= EdgeMasks::West if getEdgeNode(x, y, EdgeMasks::West) pattern |= EdgeMasks::WEST if getEdgeNode(x, y, EdgeMasks::WEST)
return pattern return pattern
end end
@@ -354,13 +354,13 @@ module RandomDungeonGenerator
ox = wx ox = wx
oy = wy oy = wy
case dir case dir
when EdgeMasks::North when EdgeMasks::NORTH
wy -= 1 wy -= 1
when EdgeMasks::West when EdgeMasks::WEST
wx -= 1 wx -= 1
when EdgeMasks::East when EdgeMasks::EAST
wx += 1 wx += 1
when EdgeMasks::South when EdgeMasks::SOUTH
wy += 1 wy += 1
end end
if isBlockedNode?(wx, wy) if isBlockedNode?(wx, wy)
@@ -384,10 +384,10 @@ module RandomDungeonGenerator
def generateWallGrowthMaze(minWall = 0, maxWall = nil) def generateWallGrowthMaze(minWall = 0, maxWall = nil)
maxWall = cellWidth if !maxWall maxWall = cellWidth if !maxWall
nlist = buildNodeList() nlist = buildNodeList
return if nlist.length == 0 return if nlist.length == 0
for c in 0...nlist.length for c in 0...nlist.length
d = randomDir() d = randomDir
len = rand(maxWall + 1) len = rand(maxWall + 1)
x = nlist[c].x x = nlist[c].x
y = nlist[c].y y = nlist[c].y
@@ -403,13 +403,13 @@ module RandomDungeonGenerator
cx = x cx = x
cy = y cy = y
case d case d
when EdgeMasks::North when EdgeMasks::NORTH
cy -= 1 cy -= 1
when EdgeMasks::South when EdgeMasks::SOUTH
cy += 1 cy += 1
when EdgeMasks::East when EdgeMasks::EAST
cx += 1 cx += 1
when EdgeMasks::West when EdgeMasks::WEST
cx -= 1 cx -= 1
end end
if cx >= 0 && cy >= 0 && cx < cellWidth && cy < cellHeight if cx >= 0 && cy >= 0 && cx < cellWidth && cy < cellHeight
@@ -568,7 +568,7 @@ module RandomDungeonGenerator
end end
# Generate connections between cells # Generate connections between cells
maze = Maze.new(maxWidth / cellWidth, maxHeight / cellHeight) maze = Maze.new(maxWidth / cellWidth, maxHeight / cellHeight)
maze.generateDepthFirstMaze() maze.generateDepthFirstMaze
# Draw each cell's contents in turn (room and corridors) # Draw each cell's contents in turn (room and corridors)
corridor_patterns = DungeonMaze.generate_corridor_patterns corridor_patterns = DungeonMaze.generate_corridor_patterns
roomcount = 0 roomcount = 0
@@ -577,7 +577,7 @@ module RandomDungeonGenerator
pattern = maze.getEdgePattern(x, y) pattern = maze.getEdgePattern(x, y)
if DungeonMaze.paint_cell_contents( if DungeonMaze.paint_cell_contents(
self, BUFFER_X + x * cellWidth, BUFFER_Y + y * cellHeight, self, BUFFER_X + x * cellWidth, BUFFER_Y + y * cellHeight,
corridor_patterns[pattern], DungeonMaze::None) corridor_patterns[pattern], DungeonMaze::TURN_NONE)
roomcount += 1 roomcount += 1
end end
end end
@@ -622,8 +622,8 @@ module RandomDungeonGenerator
ar1 = AntiRandom.new(dungeon.width) ar1 = AntiRandom.new(dungeon.width)
ar2 = AntiRandom.new(dungeon.height) ar2 = AntiRandom.new(dungeon.height)
((tiles.length + 1) * 1000).times do ((tiles.length + 1) * 1000).times do
x = ar1.get() x = ar1.get
y = ar2.get() y = ar2.get
if dungeon.isRoom?(x, y) && if dungeon.isRoom?(x, y) &&
!tiles.any? { |item| (item[0] - x).abs < 2 && (item[1] - y).abs < 2 } !tiles.any? { |item| (item[0] - x).abs < 2 && (item[1] - y).abs < 2 }
ret = [x, y] ret = [x, y]
+6 -9
View File
@@ -145,10 +145,10 @@ def pbChangeLevel(pkmn, new_level, scene)
old_special_attack = pkmn.spatk old_special_attack = pkmn.spatk
old_special_defense = pkmn.spdef old_special_defense = pkmn.spdef
old_speed = pkmn.speed old_speed = pkmn.speed
if pkmn.level > new_level pkmn.level = new_level
pkmn.level = new_level pkmn.calc_stats
pkmn.calc_stats scene.pbRefresh
scene.pbRefresh if old_level > new_level
if scene.is_a?(PokemonPartyScreen) if scene.is_a?(PokemonPartyScreen)
scene.pbDisplay(_INTL("{1} dropped to Lv. {2}!", pkmn.name, pkmn.level)) scene.pbDisplay(_INTL("{1} dropped to Lv. {2}!", pkmn.name, pkmn.level))
else else
@@ -165,10 +165,7 @@ def pbChangeLevel(pkmn, new_level, scene)
pbTopRightWindow(_INTL("Max. HP<r>{1}\r\nAttack<r>{2}\r\nDefense<r>{3}\r\nSp. Atk<r>{4}\r\nSp. Def<r>{5}\r\nSpeed<r>{6}", pbTopRightWindow(_INTL("Max. HP<r>{1}\r\nAttack<r>{2}\r\nDefense<r>{3}\r\nSp. Atk<r>{4}\r\nSp. Def<r>{5}\r\nSpeed<r>{6}",
pkmn.totalhp, pkmn.attack, pkmn.defense, pkmn.spatk, pkmn.spdef, pkmn.speed), scene) pkmn.totalhp, pkmn.attack, pkmn.defense, pkmn.spatk, pkmn.spdef, pkmn.speed), scene)
else else
pkmn.level = new_level
pkmn.changeHappiness("vitamin") pkmn.changeHappiness("vitamin")
pkmn.calc_stats
scene.pbRefresh
if scene.is_a?(PokemonPartyScreen) if scene.is_a?(PokemonPartyScreen)
scene.pbDisplay(_INTL("{1} grew to Lv. {2}!", pkmn.name, pkmn.level)) scene.pbDisplay(_INTL("{1} grew to Lv. {2}!", pkmn.name, pkmn.level))
else else
@@ -898,7 +895,7 @@ def pbChooseApricorn(var = 0)
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag) screen = PokemonBagScreen.new(scene, $bag)
ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_apricorn? }) ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_apricorn? })
} }
$game_variables[var] = ret || :NONE if var > 0 $game_variables[var] = ret || :NONE if var > 0
return ret return ret
@@ -909,7 +906,7 @@ def pbChooseFossil(var = 0)
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag) screen = PokemonBagScreen.new(scene, $bag)
ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_fossil? }) ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_fossil? })
} }
$game_variables[var] = ret || :NONE if var > 0 $game_variables[var] = ret || :NONE if var > 0
return ret return ret
+1 -1
View File
@@ -127,7 +127,7 @@ Events.onStepTaken += proc {
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag) screen = PokemonBagScreen.new(scene, $bag)
ret = screen.pbChooseItemScreen(Proc.new { |item| ret = screen.pbChooseItemScreen(proc { |item|
[:REPEL, :SUPERREPEL, :MAXREPEL].include?(item) [:REPEL, :SUPERREPEL, :MAXREPEL].include?(item)
}) })
} }
+1 -1
View File
@@ -208,7 +208,7 @@ Events.onWildBattleEnd += proc { |_sender, e|
species = e[0] species = e[0]
level = e[1] level = e[1]
decision = e[2] decision = e[2]
if $game_temp.poke_radar_data && (decision == 1 || decision == 4) # Defeated/caught if $game_temp.poke_radar_data && [1, 4].include?(decision) # Defeated/caught
$game_temp.poke_radar_data[0] = species $game_temp.poke_radar_data[0] = species
$game_temp.poke_radar_data[1] = level $game_temp.poke_radar_data[1] = level
$game_temp.poke_radar_data[2] += 1 $game_temp.poke_radar_data[2] += 1
@@ -515,7 +515,7 @@ MultipleForms.register(:SILVALLY, {
MultipleForms.register(:MINIOR, { MultipleForms.register(:MINIOR, {
"getFormOnCreation" => proc { |pkmn| "getFormOnCreation" => proc { |pkmn|
next 7 + rand(7) # Meteor forms are 0-6, Core forms are 7-13 next rand(7..13) # Meteor forms are 0-6, Core forms are 7-13
}, },
"getFormOnEnteringBattle" => proc { |pkmn, wild| "getFormOnEnteringBattle" => proc { |pkmn, wild|
next pkmn.form - 7 if pkmn.form >= 7 && wild # Wild Minior always appear in Meteor form next pkmn.form - 7 if pkmn.form >= 7 && wild # Wild Minior always appear in Meteor form
@@ -10,7 +10,7 @@ class Pokemon
attr_accessor :shadow_moves attr_accessor :shadow_moves
attr_accessor :heart_gauge_step_counter attr_accessor :heart_gauge_step_counter
alias :__shadow_expeq :exp= alias __shadow_expeq exp=
def exp=(value) def exp=(value)
if shadowPokemon? if shadowPokemon?
@saved_exp += value - @exp @saved_exp += value - @exp
@@ -19,7 +19,7 @@ class Pokemon
end end
end end
alias :__shadow_hpeq :hp= alias __shadow_hpeq hp=
def hp=(value) def hp=(value)
__shadow_hpeq(value) __shadow_hpeq(value)
@hyper_mode = false if @hp <= 0 @hyper_mode = false if @hp <= 0
@@ -212,7 +212,7 @@ class Pokemon
end end
end end
alias :__shadow_clone :clone alias __shadow_clone clone
def clone def clone
ret = __shadow_clone ret = __shadow_clone
if @saved_ev if @saved_ev
@@ -99,7 +99,7 @@ class PokemonEggHatch_Scene
frames = (GameData::Species.cry_length(@pokemon) * Graphics.frame_rate).ceil frames = (GameData::Species.cry_length(@pokemon) * Graphics.frame_rate).ceil
@pokemon.play_cry @pokemon.play_cry
updateScene(frames + 4) updateScene(frames + 4)
pbBGMStop() pbBGMStop
pbMEPlay("Evolution success") pbMEPlay("Evolution success")
@pokemon.name = nil @pokemon.name = nil
pbMessage(_INTL("\\se[]{1} hatched from the Egg!\\wt[80]", @pokemon.name)) { update } pbMessage(_INTL("\\se[]{1} hatched from the Egg!\\wt[80]", @pokemon.name)) { update }
@@ -135,8 +135,8 @@ class PokemonEggHatch_Scene
targets.push(@sprites["pokemon"].x) targets.push(@sprites["pokemon"].x)
targets.each_with_index do |target, i| targets.each_with_index do |target, i|
loop do loop do
break if i % 2 == 0 && @sprites["pokemon"].x >= target break if i.even? && @sprites["pokemon"].x >= target
break if i % 2 == 1 && @sprites["pokemon"].x <= target break if i.odd? && @sprites["pokemon"].x <= target
@sprites["pokemon"].x += speed @sprites["pokemon"].x += speed
@sprites["hatch"].x = @sprites["pokemon"].x @sprites["hatch"].x = @sprites["pokemon"].x
updateScene updateScene
@@ -161,7 +161,7 @@ class HallOfFame_Scene
def xpositionformula(battlernumber) def xpositionformula(battlernumber)
ret = 0 ret = 0
if !SINGLEROW if !SINGLEROW
ret = (battlernumber / 3 % 2 == 0) ? (19 - battlernumber) % 3 : (19 + battlernumber) % 3 ret = (battlernumber / 3).even? ? (19 - battlernumber) % 3 : (19 + battlernumber) % 3
else else
ret = battlernumber % 2 * 2 ret = battlernumber % 2 * 2
end end
+9 -9
View File
@@ -676,7 +676,7 @@ class PokemonPokedex_Scene
end end
end end
# Draw selected option(s) button graphic # Draw selected option(s) button graphic
if mode == 3 || mode == 4 # Height, weight if [3, 4].include?(mode) # Height, weight
xpos1 = xstart + (sel[0] + 1) * xgap xpos1 = xstart + (sel[0] + 1) * xgap
xpos1 = xstart if sel[0] < -1 xpos1 = xstart if sel[0] < -1
xpos2 = xstart + (sel[1] + 1) * xgap xpos2 = xstart + (sel[1] + 1) * xgap
@@ -696,11 +696,10 @@ class PokemonPokedex_Scene
textpos.push([txt2, xpos2 + halfwidth, ypos2, 2, base, nil, 1]) textpos.push([txt2, xpos2 + halfwidth, ypos2, 2, base, nil, 1])
else else
for i in 0...sel.length for i in 0...sel.length
selrect = Rect.new(0, selbuttony, @selbitmap.bitmap.width, selbuttonheight)
if sel[i] >= 0 if sel[i] >= 0
selrect = Rect.new(0, selbuttony, @selbitmap.bitmap.width, selbuttonheight)
overlay.blt(xstart + (sel[i] % cols) * xgap, ystart + (sel[i] / cols).floor * ygap, @selbitmap.bitmap, selrect) overlay.blt(xstart + (sel[i] % cols) * xgap, ystart + (sel[i] / cols).floor * ygap, @selbitmap.bitmap, selrect)
else else
selrect = Rect.new(0, selbuttony, @selbitmap.bitmap.width, selbuttonheight)
overlay.blt(xstart + (cols - 1) * xgap, ystart + (cmds.length / cols).floor * ygap, @selbitmap.bitmap, selrect) overlay.blt(xstart + (cols - 1) * xgap, ystart + (cmds.length / cols).floor * ygap, @selbitmap.bitmap, selrect)
end end
end end
@@ -903,7 +902,7 @@ class PokemonPokedex_Scene
oldindex = index oldindex = index
minmax = 1 minmax = 1
oldminmax = minmax oldminmax = minmax
if mode == 3 || mode == 4 if [3, 4].include?(mode)
index = oldindex = selindex[minmax] index = oldindex = selindex[minmax]
end end
@sprites["searchcursor"].mode = mode @sprites["searchcursor"].mode = mode
@@ -922,7 +921,7 @@ class PokemonPokedex_Scene
end end
Graphics.update Graphics.update
Input.update Input.update
if mode == 3 || mode == 4 if [3, 4].include?(mode)
if Input.trigger?(Input::UP) if Input.trigger?(Input::UP)
if index < -1 # From OK/Cancel if index < -1 # From OK/Cancel
minmax = 0 minmax = 0
@@ -936,10 +935,11 @@ class PokemonPokedex_Scene
pbRefreshDexSearchParam(mode, cmds, selindex, index) pbRefreshDexSearchParam(mode, cmds, selindex, index)
end end
elsif Input.trigger?(Input::DOWN) elsif Input.trigger?(Input::DOWN)
if minmax == 1 case minmax
when 1
minmax = 0 minmax = 0
index = selindex[minmax] index = selindex[minmax]
elsif minmax == 0 when 0
minmax = -1 minmax = -1
index = -2 index = -2
end end
@@ -1131,7 +1131,7 @@ class PokemonPokedex_Scene
end end
pbPlayCursorSE if index != oldindex pbPlayCursorSE if index != oldindex
elsif Input.trigger?(Input::DOWN) elsif Input.trigger?(Input::DOWN)
if index == 4 || index == 6 if [4, 6].include?(index)
index = 8 index = 8
elsif index < 7 elsif index < 7
index += 1 index += 1
@@ -1151,7 +1151,7 @@ class PokemonPokedex_Scene
index = 5 index = 5
elsif index >= 2 && index <= 4 elsif index >= 2 && index <= 4
index = 6 index = 6
elsif index == 7 || index == 8 elsif [7, 8].include?(index)
index += 1 index += 1
end end
pbPlayCursorSE if index != oldindex pbPlayCursorSE if index != oldindex
+5 -4
View File
@@ -383,7 +383,7 @@ class PokemonPokedexInfo_Scene
end end
textpos = [ textpos = [
[GameData::Species.get(@species).name, Graphics.width / 2, Graphics.height - 94, 2, base, shadow], [GameData::Species.get(@species).name, Graphics.width / 2, Graphics.height - 94, 2, base, shadow],
[formname, Graphics.width / 2, Graphics.height - 62, 2, base, shadow], [formname, Graphics.width / 2, Graphics.height - 62, 2, base, shadow]
] ]
# Draw all text # Draw all text
pbDrawTextPositions(overlay, textpos) pbDrawTextPositions(overlay, textpos)
@@ -464,12 +464,13 @@ class PokemonPokedexInfo_Scene
pbPlayCloseMenuSE pbPlayCloseMenuSE
break break
elsif Input.trigger?(Input::USE) elsif Input.trigger?(Input::USE)
if @page == 1 # Info case @page
when 1 # Info
@show_battled_count = !@show_battled_count @show_battled_count = !@show_battled_count
dorefresh = true dorefresh = true
elsif @page == 2 # Area when 2 # Area
# dorefresh = true # dorefresh = true
elsif @page == 3 # Forms when 3 # Forms
if @available.length > 1 if @available.length > 1
pbPlayDecisionSE pbPlayDecisionSE
pbChooseForm pbChooseForm
+2 -4
View File
@@ -679,7 +679,7 @@ class PokemonParty_Scene
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, bag) screen = PokemonBagScreen.new(scene, bag)
ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).can_hold? }) ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).can_hold? })
yield if block_given? yield if block_given?
} }
return ret return ret
@@ -690,7 +690,7 @@ class PokemonParty_Scene
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, bag) screen = PokemonBagScreen.new(scene, bag)
ret = screen.pbChooseItemScreen(Proc.new { |item| ret = screen.pbChooseItemScreen(proc { |item|
itm = GameData::Item.get(item) itm = GameData::Item.get(item)
next false if !pbCanUseOnPokemon?(itm) next false if !pbCanUseOnPokemon?(itm)
if itm.is_machine? if itm.is_machine?
@@ -1023,8 +1023,6 @@ class PokemonPartyScreen
addedEntry = false addedEntry = false
for i in 0...@party.length for i in 0...@party.length
statuses[i] = (ruleset.isPokemonValid?(@party[i])) ? 1 : 2 statuses[i] = (ruleset.isPokemonValid?(@party[i])) ? 1 : 2
end
for i in 0...@party.length
annot[i] = ordinals[statuses[i]] annot[i] = ordinals[statuses[i]]
end end
@scene.pbStartScene(@party, _INTL("Choose Pokémon and confirm."), annot, true) @scene.pbStartScene(@party, _INTL("Choose Pokémon and confirm."), annot, true)
+11 -9
View File
@@ -212,14 +212,14 @@ class PokemonSummary_Scene
def pbDisplay(text) def pbDisplay(text)
@sprites["messagebox"].text = text @sprites["messagebox"].text = text
@sprites["messagebox"].visible = true @sprites["messagebox"].visible = true
pbPlayDecisionSE() pbPlayDecisionSE
loop do loop do
Graphics.update Graphics.update
Input.update Input.update
pbUpdate pbUpdate
if @sprites["messagebox"].busy? if @sprites["messagebox"].busy?
if Input.trigger?(Input::USE) if Input.trigger?(Input::USE)
pbPlayDecisionSE() if @sprites["messagebox"].pausing? pbPlayDecisionSE if @sprites["messagebox"].pausing?
@sprites["messagebox"].resume @sprites["messagebox"].resume
end end
elsif Input.trigger?(Input::USE) || Input.trigger?(Input::BACK) elsif Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
@@ -393,7 +393,7 @@ class PokemonSummary_Scene
[@pokemon.speciesName, 435, 106, 2, Color.new(64, 64, 64), Color.new(176, 176, 176)], [@pokemon.speciesName, 435, 106, 2, Color.new(64, 64, 64), Color.new(176, 176, 176)],
[_INTL("Type"), 238, 138, 0, base, shadow], [_INTL("Type"), 238, 138, 0, base, shadow],
[_INTL("OT"), 238, 170, 0, base, shadow], [_INTL("OT"), 238, 170, 0, base, shadow],
[_INTL("ID No."), 238, 202, 0, base, shadow], [_INTL("ID No."), 238, 202, 0, base, shadow]
] ]
# Write the Regional/National Dex number # Write the Regional/National Dex number
dexnum = 0 dexnum = 0
@@ -836,7 +836,7 @@ class PokemonSummary_Scene
# Write various bits of text # Write various bits of text
textpos = [ textpos = [
[_INTL("No. of Ribbons:"), 234, 326, 0, Color.new(64, 64, 64), Color.new(176, 176, 176)], [_INTL("No. of Ribbons:"), 234, 326, 0, Color.new(64, 64, 64), Color.new(176, 176, 176)],
[@pokemon.numRibbons.to_s, 450, 326, 1, Color.new(64, 64, 64), Color.new(176, 176, 176)], [@pokemon.numRibbons.to_s, 450, 326, 1, Color.new(64, 64, 64), Color.new(176, 176, 176)]
] ]
# Draw all text # Draw all text
pbDrawTextPositions(overlay, textpos) pbDrawTextPositions(overlay, textpos)
@@ -1097,11 +1097,12 @@ class PokemonSummary_Scene
# Reposition the cursor # Reposition the cursor
@sprites["markingsel"].x = 284 + 58 * (index % 3) @sprites["markingsel"].x = 284 + 58 * (index % 3)
@sprites["markingsel"].y = 144 + 50 * (index / 3) @sprites["markingsel"].y = 144 + 50 * (index / 3)
if index == 6 # OK case index
when 6 # OK
@sprites["markingsel"].x = 284 @sprites["markingsel"].x = 284
@sprites["markingsel"].y = 244 @sprites["markingsel"].y = 244
@sprites["markingsel"].src_rect.y = @sprites["markingsel"].bitmap.height / 2 @sprites["markingsel"].src_rect.y = @sprites["markingsel"].bitmap.height / 2
elsif index == 7 # Cancel when 7 # Cancel
@sprites["markingsel"].x = 284 @sprites["markingsel"].x = 284
@sprites["markingsel"].y = 294 @sprites["markingsel"].y = 294
@sprites["markingsel"].src_rect.y = @sprites["markingsel"].bitmap.height / 2 @sprites["markingsel"].src_rect.y = @sprites["markingsel"].bitmap.height / 2
@@ -1116,10 +1117,11 @@ class PokemonSummary_Scene
break break
elsif Input.trigger?(Input::USE) elsif Input.trigger?(Input::USE)
pbPlayDecisionSE pbPlayDecisionSE
if index == 6 # OK case index
when 6 # OK
ret = markings ret = markings
break break
elsif index == 7 # Cancel when 7 # Cancel
break break
else else
markings[index] = ((markings[index] || 0) + 1) % mark_variants markings[index] = ((markings[index] || 0) + 1) % mark_variants
@@ -1197,7 +1199,7 @@ class PokemonSummary_Scene
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag) screen = PokemonBagScreen.new(scene, $bag)
item = screen.pbChooseItemScreen(Proc.new { |itm| GameData::Item.get(itm).can_hold? }) item = screen.pbChooseItemScreen(proc { |itm| GameData::Item.get(itm).can_hold? })
} }
if item if item
dorefresh = pbGiveItemToPokemon(item, @pokemon, self, @partyindex) dorefresh = pbGiveItemToPokemon(item, @pokemon, self, @partyindex)
+1 -1
View File
@@ -42,7 +42,7 @@ class PokegearButton < SpriteWrapper
rect.y = @button.height / 2 if @selected rect.y = @button.height / 2 if @selected
self.bitmap.blt(0, 0, @button.bitmap, rect) self.bitmap.blt(0, 0, @button.bitmap, rect)
textpos = [ textpos = [
[@name, self.bitmap.width / 2, 4, 2, Color.new(248, 248, 248), Color.new(40, 40, 40)], [@name, self.bitmap.width / 2, 4, 2, Color.new(248, 248, 248), Color.new(40, 40, 40)]
] ]
pbDrawTextPositions(self.bitmap, textpos) pbDrawTextPositions(self.bitmap, textpos)
imagepos = [ imagepos = [
+3 -3
View File
@@ -408,13 +408,13 @@ class PokemonOption_Scene
@PokemonOptions[i].set(@sprites["option"][i]) @PokemonOptions[i].set(@sprites["option"][i])
end end
if $PokemonSystem.textskin != oldTextSkin if $PokemonSystem.textskin != oldTextSkin
@sprites["textbox"].setSkin(MessageConfig.pbGetSpeechFrame()) @sprites["textbox"].setSkin(MessageConfig.pbGetSpeechFrame)
@sprites["textbox"].text = _INTL("Speech frame {1}.", 1 + $PokemonSystem.textskin) @sprites["textbox"].text = _INTL("Speech frame {1}.", 1 + $PokemonSystem.textskin)
oldTextSkin = $PokemonSystem.textskin oldTextSkin = $PokemonSystem.textskin
end end
if $PokemonSystem.frame != oldSystemSkin if $PokemonSystem.frame != oldSystemSkin
@sprites["title"].setSkin(MessageConfig.pbGetSystemFrame()) @sprites["title"].setSkin(MessageConfig.pbGetSystemFrame)
@sprites["option"].setSkin(MessageConfig.pbGetSystemFrame()) @sprites["option"].setSkin(MessageConfig.pbGetSystemFrame)
oldSystemSkin = $PokemonSystem.frame oldSystemSkin = $PokemonSystem.frame
end end
end end
+4 -3
View File
@@ -71,7 +71,7 @@ class ReadyMenuButton < SpriteWrapper
self.bitmap.blt(0, 0, @button.bitmap, rect) self.bitmap.blt(0, 0, @button.bitmap, rect)
textx = (@command[2]) ? 164 : (GameData::Item.get(@command[0]).is_important?) ? 146 : 124 textx = (@command[2]) ? 164 : (GameData::Item.get(@command[0]).is_important?) ? 146 : 124
textpos = [ textpos = [
[@command[1], textx, 16, 2, Color.new(248, 248, 248), Color.new(40, 40, 40), 1], [@command[1], textx, 16, 2, Color.new(248, 248, 248), Color.new(40, 40, 40), 1]
] ]
if !@command[2] if !@command[2]
if !GameData::Item.get(@command[0]).is_important? if !GameData::Item.get(@command[0]).is_important?
@@ -206,11 +206,12 @@ class PokemonReadyMenu_Scene
oldindex = @index[@index[2]] oldindex = @index[@index[2]]
@index[@index[2]] = @sprites["cmdwindow"].index @index[@index[2]] = @sprites["cmdwindow"].index
if @index[@index[2]] != oldindex if @index[@index[2]] != oldindex
if @index[2] == 0 case @index[2]
when 0
for i in 0...@commands[0].length for i in 0...@commands[0].length
@sprites["movebutton#{i}"].selected = @index[@index[2]] @sprites["movebutton#{i}"].selected = @index[@index[2]]
end end
elsif @index[2] == 1 when 1
for i in 0...@commands[1].length for i in 0...@commands[1].length
@sprites["itembutton#{i}"].selected = @index[@index[2]] @sprites["itembutton#{i}"].selected = @index[@index[2]]
end end
+27 -22
View File
@@ -617,12 +617,11 @@ class PokemonStorageScene
if command != 2 if command != 2
pbSetArrow(@sprites["arrow"], @selection) pbSetArrow(@sprites["arrow"], @selection)
pbUpdateOverlay(@selection) pbUpdateOverlay(@selection)
pbSetMosaic(@selection)
else else
pbPartySetArrow(@sprites["arrow"], @selection) pbPartySetArrow(@sprites["arrow"], @selection)
pbUpdateOverlay(@selection, @storage.party) pbUpdateOverlay(@selection, @storage.party)
pbSetMosaic(@selection)
end end
pbSetMosaic(@selection)
pbSEPlay("PC access") pbSEPlay("PC access")
pbFadeInAndShow(@sprites) pbFadeInAndShow(@sprites)
end end
@@ -714,22 +713,24 @@ class PokemonStorageScene
def pbChangeSelection(key, selection) def pbChangeSelection(key, selection)
case key case key
when Input::UP when Input::UP
if selection == -1 # Box name case selection
when -1 # Box name
selection = -2 selection = -2
elsif selection == -2 # Party when -2 # Party
selection = PokemonBox::BOX_SIZE - 1 - PokemonBox::BOX_WIDTH * 2 / 3 # 25 selection = PokemonBox::BOX_SIZE - 1 - PokemonBox::BOX_WIDTH * 2 / 3 # 25
elsif selection == -3 # Close Box when -3 # Close Box
selection = PokemonBox::BOX_SIZE - PokemonBox::BOX_WIDTH / 3 # 28 selection = PokemonBox::BOX_SIZE - PokemonBox::BOX_WIDTH / 3 # 28
else else
selection -= PokemonBox::BOX_WIDTH selection -= PokemonBox::BOX_WIDTH
selection = -1 if selection < 0 selection = -1 if selection < 0
end end
when Input::DOWN when Input::DOWN
if selection == -1 # Box name case selection
when -1 # Box name
selection = PokemonBox::BOX_WIDTH / 3 # 2 selection = PokemonBox::BOX_WIDTH / 3 # 2
elsif selection == -2 # Party when -2 # Party
selection = -1 selection = -1
elsif selection == -3 # Close Box when -3 # Close Box
selection = -1 selection = -1
else else
selection += PokemonBox::BOX_WIDTH selection += PokemonBox::BOX_WIDTH
@@ -830,16 +831,17 @@ class PokemonStorageScene
pbPlayCursorSE pbPlayCursorSE
selection = pbChangeSelection(key, selection) selection = pbChangeSelection(key, selection)
pbSetArrow(@sprites["arrow"], selection) pbSetArrow(@sprites["arrow"], selection)
if selection == -4 case selection
when -4
nextbox = (@storage.currentBox + @storage.maxBoxes - 1) % @storage.maxBoxes nextbox = (@storage.currentBox + @storage.maxBoxes - 1) % @storage.maxBoxes
pbSwitchBoxToLeft(nextbox) pbSwitchBoxToLeft(nextbox)
@storage.currentBox = nextbox @storage.currentBox = nextbox
elsif selection == -5 when -5
nextbox = (@storage.currentBox + 1) % @storage.maxBoxes nextbox = (@storage.currentBox + 1) % @storage.maxBoxes
pbSwitchBoxToRight(nextbox) pbSwitchBoxToRight(nextbox)
@storage.currentBox = nextbox @storage.currentBox = nextbox
end end
selection = -1 if selection == -4 || selection == -5 selection = -1 if [-4, -5].include?(selection)
pbUpdateOverlay(selection) pbUpdateOverlay(selection)
pbSetMosaic(selection) pbSetMosaic(selection)
end end
@@ -932,9 +934,10 @@ class PokemonStorageScene
if key >= 0 if key >= 0
pbPlayCursorSE pbPlayCursorSE
newselection = pbPartyChangeSelection(key, selection) newselection = pbPartyChangeSelection(key, selection)
if newselection == -1 case newselection
when -1
return -1 if !depositing return -1 if !depositing
elsif newselection == -2 when -2
selection = lastsel selection = lastsel
else else
selection = newselection selection = newselection
@@ -1217,7 +1220,7 @@ class PokemonStorageScene
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, bag) screen = PokemonBagScreen.new(scene, bag)
ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).can_hold? }) ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).can_hold? })
} }
return ret return ret
end end
@@ -1352,10 +1355,11 @@ class PokemonStorageScene
break break
elsif Input.trigger?(Input::USE) elsif Input.trigger?(Input::USE)
pbPlayDecisionSE pbPlayDecisionSE
if index == 6 # OK case index
when 6 # OK
pokemon.markings = markings pokemon.markings = markings
break break
elsif index == 7 # Cancel when 7 # Cancel
break break
else else
markings[index] = ((markings[index] || 0) + 1) % mark_variants markings[index] = ((markings[index] || 0) + 1) % mark_variants
@@ -1399,7 +1403,7 @@ class PokemonStorageScene
buttonshadow = Color.new(80, 80, 80) buttonshadow = Color.new(80, 80, 80)
pbDrawTextPositions(overlay, [ pbDrawTextPositions(overlay, [
[_INTL("Party: {1}", (@storage.party.length rescue 0)), 270, 326, 2, buttonbase, buttonshadow, 1], [_INTL("Party: {1}", (@storage.party.length rescue 0)), 270, 326, 2, buttonbase, buttonshadow, 1],
[_INTL("Exit"), 446, 326, 2, buttonbase, buttonshadow, 1], [_INTL("Exit"), 446, 326, 2, buttonbase, buttonshadow, 1]
]) ])
pokemon = nil pokemon = nil
if @screen.pbHeldPokemon if @screen.pbHeldPokemon
@@ -1478,7 +1482,8 @@ class PokemonStorageScreen
def pbStartScreen(command) def pbStartScreen(command)
$game_temp.in_storage = true $game_temp.in_storage = true
@heldpkmn = nil @heldpkmn = nil
if command == 0 # Organise case command
when 0 # Organise
@scene.pbStartBox(self, command) @scene.pbStartBox(self, command)
loop do loop do
selected = @scene.pbSelectBox(@storage.party) selected = @scene.pbSelectBox(@storage.party)
@@ -1559,7 +1564,7 @@ class PokemonStorageScreen
end end
end end
@scene.pbCloseBox @scene.pbCloseBox
elsif command == 1 # Withdraw when 1 # Withdraw
@scene.pbStartBox(self, command) @scene.pbStartBox(self, command)
loop do loop do
selected = @scene.pbSelectBox(@storage.party) selected = @scene.pbSelectBox(@storage.party)
@@ -1599,7 +1604,7 @@ class PokemonStorageScreen
end end
end end
@scene.pbCloseBox @scene.pbCloseBox
elsif command == 2 # Deposit when 2 # Deposit
@scene.pbStartBox(self, command) @scene.pbStartBox(self, command)
loop do loop do
selected = @scene.pbSelectParty(@storage.party) selected = @scene.pbSelectParty(@storage.party)
@@ -1631,7 +1636,7 @@ class PokemonStorageScreen
end end
end end
@scene.pbCloseBox @scene.pbCloseBox
elsif command == 3 when 3
@scene.pbStartBox(self, command) @scene.pbStartBox(self, command)
@scene.pbCloseBox @scene.pbCloseBox
end end
@@ -1921,7 +1926,7 @@ class PokemonStorageScreen
_INTL("Jump"), _INTL("Jump"),
_INTL("Wallpaper"), _INTL("Wallpaper"),
_INTL("Name"), _INTL("Name"),
_INTL("Cancel"), _INTL("Cancel")
] ]
command = pbShowCommands( command = pbShowCommands(
_INTL("What do you want to do?"), commands) _INTL("What do you want to do?"), commands)
+3 -2
View File
@@ -47,12 +47,13 @@ class StorageSystemPC
_INTL("Return to the previous menu.")], -1, command _INTL("Return to the previous menu.")], -1, command
) )
if command >= 0 && command < 3 if command >= 0 && command < 3
if command == 1 # Withdraw case command
when 1 # Withdraw
if $PokemonStorage.party_full? if $PokemonStorage.party_full?
pbMessage(_INTL("Your party is full!")) pbMessage(_INTL("Your party is full!"))
next next
end end
elsif command == 2 # Deposit when 2 # Deposit
count = 0 count = 0
for p in $PokemonStorage.party for p in $PokemonStorage.party
count += 1 if p && !p.egg? && p.hp > 0 count += 1 if p && !p.egg? && p.hp > 0
+13 -11
View File
@@ -291,7 +291,7 @@ module PurifyChamberHelper
return chamber.getShadow(set) return chamber.getShadow(set)
elsif position > 0 elsif position > 0
position -= 1 position -= 1
if position % 2 == 0 if position.even?
return chamber[set, position / 2] return chamber[set, position / 2]
else # In between two indices else # In between two indices
return nil return nil
@@ -305,7 +305,7 @@ module PurifyChamberHelper
return chamber.getShadow(chamber.currentSet) return chamber.getShadow(chamber.currentSet)
elsif position > 0 elsif position > 0
position -= 1 position -= 1
if position % 2 == 0 if position.even?
return chamber[chamber.currentSet, position / 2] return chamber[chamber.currentSet, position / 2]
else # In between two indices else # In between two indices
return nil return nil
@@ -318,7 +318,7 @@ module PurifyChamberHelper
if position > 0 if position > 0
position -= 1 position -= 1
oldpos = position / 2 oldpos = position / 2
if position % 2 == 0 if position.even?
return position + 1 return position + 1
else else
return ((oldpos + 1) * 2) + 1 return ((oldpos + 1) * 2) + 1
@@ -332,7 +332,7 @@ module PurifyChamberHelper
chamber.setShadow(chamber.currentSet, value) chamber.setShadow(chamber.currentSet, value)
elsif position > 0 elsif position > 0
position -= 1 position -= 1
if position % 2 == 0 if position.even?
chamber.insertAt(chamber.currentSet, position / 2, value) chamber.insertAt(chamber.currentSet, position / 2, value)
else # In between two indices else # In between two indices
chamber.insertAfter(chamber.currentSet, position / 2, value) chamber.insertAfter(chamber.currentSet, position / 2, value)
@@ -612,11 +612,12 @@ class PurifyChamberScreen
_INTL("What do you want to do?"), _INTL("What do you want to do?"),
[_INTL("EDIT"), _INTL("SWITCH"), _INTL("CANCEL")] [_INTL("EDIT"), _INTL("SWITCH"), _INTL("CANCEL")]
) )
if cmd == 0 # edit case cmd
when 0 # edit
if !pbOpenSetDetail if !pbOpenSetDetail
break break
end end
elsif cmd == 1 # switch when 1 # switch
chamber.currentSet = set chamber.currentSet = set
newSet = @scene.pbSwitch(set) newSet = @scene.pbSwitch(set)
chamber.switch(set, newSet) chamber.switch(set, newSet)
@@ -900,19 +901,20 @@ class PurifyChamberSetView < SpriteWrapper
pos /= 2 pos /= 2
end end
seg = pos * 8 / points seg = pos * 8 / points
if seg == 7 || seg == 0 case seg
when 7, 0
pos -= 1 if button == Input::LEFT pos -= 1 if button == Input::LEFT
pos += 1 if button == Input::RIGHT pos += 1 if button == Input::RIGHT
pos = nil if button == Input::DOWN pos = nil if button == Input::DOWN
elsif seg == 1 || seg == 2 when 1, 2
pos -= 1 if button == Input::UP pos -= 1 if button == Input::UP
pos += 1 if button == Input::DOWN pos += 1 if button == Input::DOWN
pos = nil if button == Input::LEFT pos = nil if button == Input::LEFT
elsif seg == 3 || seg == 4 when 3, 4
pos -= 1 if button == Input::RIGHT pos -= 1 if button == Input::RIGHT
pos += 1 if button == Input::LEFT pos += 1 if button == Input::LEFT
pos = nil if button == Input::UP pos = nil if button == Input::UP
elsif seg == 5 || seg == 6 when 5, 6
pos -= 1 if button == Input::DOWN pos -= 1 if button == Input::DOWN
pos += 1 if button == Input::UP pos += 1 if button == Input::UP
pos = nil if button == Input::RIGHT pos = nil if button == Input::RIGHT
@@ -986,7 +988,7 @@ class PurifyChamberSetView < SpriteWrapper
setList = @chamber.setList(@set) setList = @chamber.setList(@set)
refreshFlows refreshFlows
for i in 0...PurifyChamber::SETSIZE * 2 for i in 0...PurifyChamber::SETSIZE * 2
pkmn = (i % 2 == 1 || i >= points) ? nil : setList[i / 2] pkmn = (i.odd? || i >= points) ? nil : setList[i / 2]
angle = 360 - (i * 360 / points) angle = 360 - (i * 360 / points)
angle += 90 # start at 12 not 3 o'clock angle += 90 # start at 12 not 3 o'clock
if pkmn && @chamber[@set].facing == i / 2 if pkmn && @chamber[@set].facing == i / 2
+8 -12
View File
@@ -182,18 +182,19 @@ def pbManageMysteryGifts
_INTL("Delete"), _INTL("Delete"),
_INTL("Cancel")] _INTL("Cancel")]
cmd = pbMessage("\\ts[]" + commands[command], cmds, -1, nil, cmd) cmd = pbMessage("\\ts[]" + commands[command], cmds, -1, nil, cmd)
if cmd == -1 || cmd == cmds.length - 1 case cmd
when -1, cmds.length - 1
break break
elsif cmd == 0 # Toggle on/offline when 0 # Toggle on/offline
if online.include?(gift[0]) if online.include?(gift[0])
online.delete(gift[0]) online.delete(gift[0])
else else
online.push(gift[0]) online.push(gift[0])
end end
elsif cmd == 1 # Edit when 1 # Edit
newgift = pbEditMysteryGift(gift[1], gift[2], gift[0], gift[3]) newgift = pbEditMysteryGift(gift[1], gift[2], gift[0], gift[3])
master[command] = newgift if newgift master[command] = newgift if newgift
elsif cmd == 2 # Receive when 2 # Receive
if !$player if !$player
pbMessage(_INTL("There is no save file loaded. Cannot receive any gifts.")) pbMessage(_INTL("There is no save file loaded. Cannot receive any gifts."))
next next
@@ -207,7 +208,7 @@ def pbManageMysteryGifts
end end
$player.mystery_gifts.push(gift) if !replaced $player.mystery_gifts.push(gift) if !replaced
pbReceiveMysteryGift(gift[0]) pbReceiveMysteryGift(gift[0])
elsif cmd == 3 # Delete when 3 # Delete
master.delete_at(command) if pbConfirmMessage(_INTL("Are you sure you want to delete this gift?")) master.delete_at(command) if pbConfirmMessage(_INTL("Are you sure you want to delete this gift?"))
break break
end end
@@ -381,13 +382,8 @@ def pbReceiveMysteryGift(id)
gift[2].timeReceived = time.getgm.to_i gift[2].timeReceived = time.getgm.to_i
gift[2].obtain_method = 4 # Fateful encounter gift[2].obtain_method = 4 # Fateful encounter
gift[2].record_first_moves gift[2].record_first_moves
if $game_map gift[2].obtain_level = gift[2].level
gift[2].obtain_map = $game_map.map_id gift[2].obtain_map = $game_map&.map_id || 0
gift[2].obtain_level = gift[2].level
else
gift[2].obtain_map = 0
gift[2].obtain_level = gift[2].level
end
if pbAddPokemonSilent(gift[2]) if pbAddPokemonSilent(gift[2])
pbMessage(_INTL("\\me[Pkmn get]{1} received {2}!", $player.name, gift[2].name)) pbMessage(_INTL("\\me[Pkmn get]{1} received {2}!", $player.name, gift[2].name))
$player.mystery_gifts[index] = [id] $player.mystery_gifts[index] = [id]
+8 -8
View File
@@ -72,7 +72,7 @@ end
class PokemonEntryScene class PokemonEntryScene
@@Characters = [ @@Characters = [
[("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").scan(/./), "[*]"], [("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").scan(/./), "[*]"],
[("0123456789 !@\#$%^&*() ~`-_+={}[] :;'\"<>,.?/ ").scan(/./), "[A]"], [("0123456789 !@\#$%^&*() ~`-_+={}[] :;'\"<>,.?/ ").scan(/./), "[A]"]
] ]
USEKEYBOARD = true USEKEYBOARD = true
@@ -212,28 +212,28 @@ class PokemonEntryScene
if index == -3 # Confirm text if index == -3 # Confirm text
ret = @sprites["entry"].text ret = @sprites["entry"].text
if ret.length < @minlength || ret.length > @maxlength if ret.length < @minlength || ret.length > @maxlength
pbPlayBuzzerSE() pbPlayBuzzerSE
else else
pbPlayDecisionSE() pbPlayDecisionSE
break break
end end
elsif index == -1 # Insert a space elsif index == -1 # Insert a space
if @sprites["entry"].insert(" ") if @sprites["entry"].insert(" ")
pbPlayDecisionSE() pbPlayDecisionSE
else else
pbPlayBuzzerSE() pbPlayBuzzerSE
end end
elsif index == -2 # Change character set elsif index == -2 # Change character set
pbPlayDecisionSE() pbPlayDecisionSE
@symtype += 1 @symtype += 1
@symtype = 0 if @symtype >= @@Characters.length @symtype = 0 if @symtype >= @@Characters.length
@sprites["entry2"].setCharset(@@Characters[@symtype][0]) @sprites["entry2"].setCharset(@@Characters[@symtype][0])
@sprites["entry2"].setOtherCharset(@@Characters[@symtype][1]) @sprites["entry2"].setOtherCharset(@@Characters[@symtype][1])
else # Insert given character else # Insert given character
if @sprites["entry"].insert(@sprites["entry2"].character) if @sprites["entry"].insert(@sprites["entry2"].character)
pbPlayDecisionSE() pbPlayDecisionSE
else else
pbPlayBuzzerSE() pbPlayBuzzerSE
end end
end end
next next
@@ -174,7 +174,7 @@ class PokemonDuel
PBMoveRoute::Forward PBMoveRoute::Forward
]) ])
pbMessage(_INTL("Your attack was evaded!")) pbMessage(_INTL("Your attack was evaded!"))
elsif (action == 0 || action == 1 || action == 2) && command == 3 elsif [0, 1, 2].include?(action) && command == 3
pbMoveRoute($game_player, [ pbMoveRoute($game_player, [
PBMoveRoute::ChangeSpeed, 4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::ScriptAsync, "jumpForward" PBMoveRoute::ScriptAsync, "jumpForward"
@@ -282,7 +282,7 @@ class PokemonDuel
PBMoveRoute::Backward PBMoveRoute::Backward
]) ])
pbMessage(_INTL("You evade the opponent's attack!")) pbMessage(_INTL("You evade the opponent's attack!"))
elsif action == 3 && (command == 0 || command == 1 || command == 2) elsif action == 3 && [0, 1, 2].include?(command)
pbMoveRoute(event, [ pbMoveRoute(event, [
PBMoveRoute::ChangeSpeed, 4, PBMoveRoute::ChangeSpeed, 4,
PBMoveRoute::ScriptAsync, "jumpForward" PBMoveRoute::ScriptAsync, "jumpForward"
@@ -611,7 +611,7 @@ class TriadScreen
def maxCards def maxCards
numcards = @width * @height numcards = @width * @height
if numcards % 2 == 1 if numcards.odd?
numcards = numcards / 2 + 1 numcards = numcards / 2 + 1
else else
numcards = numcards / 2 numcards = numcards / 2
@@ -833,7 +833,7 @@ class TriadScreen
end end
end end
# Sort by number of flips # Sort by number of flips
scores.sort! { |a, b| (b[3] == a[3]) ? rand(3) - 1 : b[3] <=> a[3] } scores.sort! { |a, b| (b[3] == a[3]) ? rand(-1..1) : b[3] <=> a[3] }
scores = scores[0, opponentCards.length] # Get the best results scores = scores[0, opponentCards.length] # Get the best results
if scores.length == 0 if scores.length == 0
@scene.pbDisplay(_INTL("{1} can't move somehow...", @opponentName)) @scene.pbDisplay(_INTL("{1} can't move somehow...", @opponentName))
@@ -193,7 +193,7 @@ class SlotMachineScene
@sprites["light2"].src_rect.set(0, 26 * ((frame / timePerFrame) % 4), 96, 26) @sprites["light2"].src_rect.set(0, 26 * ((frame / timePerFrame) % 4), 96, 26)
for i in 1..5 for i in 1..5
if wonRow[i - 1] if wonRow[i - 1]
@sprites["row#{i}"].visible = ((frame / timePerFrame) % 2) == 0 @sprites["row#{i}"].visible = (frame / timePerFrame).even?
else else
@sprites["row#{i}"].visible = false @sprites["row#{i}"].visible = false
end end
@@ -44,7 +44,7 @@ class VoltorbFlip
voltorbs += 1 voltorbs += 1
# Sets the value randomly to a 2 or 3 if the total is less than the max # Sets the value randomly to a 2 or 3 if the total is less than the max
elsif total < @levelRanges[@level - 1][1] elsif total < @levelRanges[@level - 1][1]
squareValues[i] = rand(2) + 2 squareValues[i] = rand(2..3)
total *= squareValues[i] total *= squareValues[i]
end end
if total > (@levelRanges[@level - 1][1]) if total > (@levelRanges[@level - 1][1])
@@ -387,11 +387,11 @@ class VoltorbFlip
if @level < 8 if @level < 8
@level += 1 @level += 1
pbMessage(_INTL("\\se[Voltorb Flip level up]Advanced to Game Lv. {1}!", @level.to_s)) pbMessage(_INTL("\\se[Voltorb Flip level up]Advanced to Game Lv. {1}!", @level.to_s))
# if @firstRound if @firstRound
# pbMessage(_INTL("Congratulations!")) # pbMessage(_INTL("Congratulations!"))
# pbMessage(_INTL("You can receive even more Coins in the next game!")) # pbMessage(_INTL("You can receive even more Coins in the next game!"))
@firstRound = false @firstRound = false
# end end
end end
pbDisposeSpriteHash(@sprites) pbDisposeSpriteHash(@sprites)
pbNewGame pbNewGame
@@ -78,8 +78,8 @@ class MiningGameCursor < BitmapSprite
attr_accessor :hit attr_accessor :hit
attr_accessor :counter attr_accessor :counter
ToolPositions = [[1, 0], [1, 1], [1, 1], [0, 0], [0, 0], TOOL_POSITIONS = [[1, 0], [1, 1], [1, 1], [0, 0], [0, 0],
[0, 2], [0, 2], [0, 0], [0, 0], [0, 2], [0, 2]] # Graphic, position [0, 2], [0, 2], [0, 0], [0, 0], [0, 2], [0, 2]] # Graphic, position
def initialize(position = 0, mode = 0) # mode: 0=pick, 1=hammer def initialize(position = 0, mode = 0) # mode: 0=pick, 1=hammer
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@@ -106,22 +106,23 @@ class MiningGameCursor < BitmapSprite
def update def update
self.bitmap.clear self.bitmap.clear
x = 32 * (@position % MiningGameScene::BOARDWIDTH) x = 32 * (@position % MiningGameScene::BOARD_WIDTH)
y = 32 * (@position / MiningGameScene::BOARDWIDTH) y = 32 * (@position / MiningGameScene::BOARD_WIDTH)
if @counter > 0 if @counter > 0
@counter -= 1 @counter -= 1
toolx = x toolx = x
tooly = y tooly = y
i = 10 - (@counter / 2).floor i = 10 - (@counter / 2).floor
if ToolPositions[i][1] == 1 case TOOL_POSITIONS[i][1]
when 1
toolx -= 8 toolx -= 8
tooly += 8 tooly += 8
elsif ToolPositions[i][1] == 2 when 2
toolx += 6 toolx += 6
end end
self.bitmap.blt(toolx, tooly, @toolbitmap.bitmap, self.bitmap.blt(toolx, tooly, @toolbitmap.bitmap,
Rect.new(96 * ToolPositions[i][0], 96 * @mode, 96, 96)) Rect.new(96 * TOOL_POSITIONS[i][0], 96 * @mode, 96, 96))
if i < 5 && i % 2 == 0 if i < 5 && i.even?
if @hit == 2 if @hit == 2
self.bitmap.blt(x - 64, y, @hitsbitmap.bitmap, Rect.new(160 * 2, 0, 160, 160)) self.bitmap.blt(x - 64, y, @hitsbitmap.bitmap, Rect.new(160 * 2, 0, 160, 160))
else else
@@ -140,8 +141,8 @@ end
class MiningGameScene class MiningGameScene
BOARDWIDTH = 13 BOARD_WIDTH = 13
BOARDHEIGHT = 10 BOARD_HEIGHT = 10
ITEMS = [ # Item, probability, graphic x, graphic y, width, height, pattern ITEMS = [ # Item, probability, graphic x, graphic y, width, height, pattern
[:DOMEFOSSIL, 20, 0, 3, 5, 4, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0]], [:DOMEFOSSIL, 20, 0, 3, 5, 4, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0]],
[:HELIXFOSSIL, 5, 5, 3, 4, 4, [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]], [:HELIXFOSSIL, 5, 5, 3, 4, 4, [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]],
@@ -238,9 +239,9 @@ class MiningGameScene
@iron = [] @iron = []
pbDistributeItems pbDistributeItems
pbDistributeIron pbDistributeIron
for i in 0...BOARDHEIGHT for i in 0...BOARD_HEIGHT
for j in 0...BOARDWIDTH for j in 0...BOARD_WIDTH
@sprites["tile#{j + i * BOARDWIDTH}"] = MiningGameTile.new(32 * j, 64 + 32 * i) @sprites["tile#{j + i * BOARD_WIDTH}"] = MiningGameTile.new(32 * j, 64 + 32 * i)
end end
end end
@sprites["crack"] = MiningGameCounter.new(0, 4) @sprites["crack"] = MiningGameCounter.new(0, 4)
@@ -258,7 +259,7 @@ class MiningGameScene
for i in ITEMS for i in ITEMS
ptotal += i[1] ptotal += i[1]
end end
numitems = 2 + rand(3) numitems = rand(2..4)
tries = 0 tries = 0
while numitems > 0 while numitems > 0
rnd = rand(ptotal) rnd = rand(ptotal)
@@ -268,8 +269,8 @@ class MiningGameScene
if rnd < 0 if rnd < 0
if pbNoDuplicateItems(ITEMS[i][0]) if pbNoDuplicateItems(ITEMS[i][0])
while !added while !added
provx = rand(BOARDWIDTH - ITEMS[i][4] + 1) provx = rand(BOARD_WIDTH - ITEMS[i][4] + 1)
provy = rand(BOARDHEIGHT - ITEMS[i][5] + 1) provy = rand(BOARD_HEIGHT - ITEMS[i][5] + 1)
if pbCheckOverlaps(false, provx, provy, ITEMS[i][4], ITEMS[i][5], ITEMS[i][6]) if pbCheckOverlaps(false, provx, provy, ITEMS[i][4], ITEMS[i][5], ITEMS[i][6])
@items.push([i, provx, provy]) @items.push([i, provx, provy])
numitems -= 1 numitems -= 1
@@ -298,12 +299,12 @@ class MiningGameScene
def pbDistributeIron def pbDistributeIron
# Set iron to be buried (index in IRON, x coord, y coord) # Set iron to be buried (index in IRON, x coord, y coord)
numitems = 4 + rand(3) numitems = rand(4..6)
tries = 0 tries = 0
while numitems > 0 while numitems > 0
rnd = rand(IRON.length) rnd = rand(IRON.length)
provx = rand(BOARDWIDTH - IRON[rnd][2] + 1) provx = rand(BOARD_WIDTH - IRON[rnd][2] + 1)
provy = rand(BOARDHEIGHT - IRON[rnd][3] + 1) provy = rand(BOARD_HEIGHT - IRON[rnd][3] + 1)
if pbCheckOverlaps(true, provx, provy, IRON[rnd][2], IRON[rnd][3], IRON[rnd][4]) if pbCheckOverlaps(true, provx, provy, IRON[rnd][2], IRON[rnd][3], IRON[rnd][4])
@iron.push([rnd, provx, provy]) @iron.push([rnd, provx, provy])
numitems -= 1 numitems -= 1
@@ -398,12 +399,12 @@ class MiningGameScene
hittype = 2 hittype = 2
else else
for i in 0..2 for i in 0..2
ytile = i - 1 + position / BOARDWIDTH ytile = i - 1 + position / BOARD_WIDTH
next if ytile < 0 || ytile >= BOARDHEIGHT next if ytile < 0 || ytile >= BOARD_HEIGHT
for j in 0..2 for j in 0..2
xtile = j - 1 + position % BOARDWIDTH xtile = j - 1 + position % BOARD_WIDTH
next if xtile < 0 || xtile >= BOARDWIDTH next if xtile < 0 || xtile >= BOARD_WIDTH
@sprites["tile#{xtile + ytile * BOARDWIDTH}"].layer -= pattern[j + i * 3] @sprites["tile#{xtile + ytile * BOARD_WIDTH}"].layer -= pattern[j + i * 3]
end end
end end
if @sprites["cursor"].mode == 1 # Hammer if @sprites["cursor"].mode == 1 # Hammer
@@ -427,8 +428,8 @@ class MiningGameScene
end end
def pbIsItemThere?(position) def pbIsItemThere?(position)
posx = position % BOARDWIDTH posx = position % BOARD_WIDTH
posy = position / BOARDWIDTH posy = position / BOARD_WIDTH
for i in @items for i in @items
index = i[0] index = i[0]
width = ITEMS[index][4] width = ITEMS[index][4]
@@ -444,8 +445,8 @@ class MiningGameScene
end end
def pbIsIronThere?(position) def pbIsIronThere?(position)
posx = position % BOARDWIDTH posx = position % BOARD_WIDTH
posy = position / BOARDWIDTH posy = position / BOARD_WIDTH
for i in @iron for i in @iron
index = i[0] index = i[0]
width = IRON[index][2] width = IRON[index][2]
@@ -471,7 +472,7 @@ class MiningGameScene
pattern = ITEMS[index][6] pattern = ITEMS[index][6]
for j in 0...height for j in 0...height
for k in 0...width for k in 0...width
layer = @sprites["tile#{@items[i][1] + k + (@items[i][2] + j) * BOARDWIDTH}"].layer layer = @sprites["tile#{@items[i][1] + k + (@items[i][2] + j) * BOARD_WIDTH}"].layer
revealed = false if layer > 0 && pattern[k + j * width] > 0 revealed = false if layer > 0 && pattern[k + j * width] > 0
break if !revealed break if !revealed
end end
@@ -550,22 +551,22 @@ class MiningGameScene
end end
# Input # Input
if Input.trigger?(Input::UP) || Input.repeat?(Input::UP) if Input.trigger?(Input::UP) || Input.repeat?(Input::UP)
if @sprites["cursor"].position >= BOARDWIDTH if @sprites["cursor"].position >= BOARD_WIDTH
pbSEPlay("Mining cursor") pbSEPlay("Mining cursor")
@sprites["cursor"].position -= BOARDWIDTH @sprites["cursor"].position -= BOARD_WIDTH
end end
elsif Input.trigger?(Input::DOWN) || Input.repeat?(Input::DOWN) elsif Input.trigger?(Input::DOWN) || Input.repeat?(Input::DOWN)
if @sprites["cursor"].position < (BOARDWIDTH * (BOARDHEIGHT - 1)) if @sprites["cursor"].position < (BOARD_WIDTH * (BOARD_HEIGHT - 1))
pbSEPlay("Mining cursor") pbSEPlay("Mining cursor")
@sprites["cursor"].position += BOARDWIDTH @sprites["cursor"].position += BOARD_WIDTH
end end
elsif Input.trigger?(Input::LEFT) || Input.repeat?(Input::LEFT) elsif Input.trigger?(Input::LEFT) || Input.repeat?(Input::LEFT)
if @sprites["cursor"].position % BOARDWIDTH > 0 if @sprites["cursor"].position % BOARD_WIDTH > 0
pbSEPlay("Mining cursor") pbSEPlay("Mining cursor")
@sprites["cursor"].position -= 1 @sprites["cursor"].position -= 1
end end
elsif Input.trigger?(Input::RIGHT) || Input.repeat?(Input::RIGHT) elsif Input.trigger?(Input::RIGHT) || Input.repeat?(Input::RIGHT)
if @sprites["cursor"].position % BOARDWIDTH < (BOARDWIDTH - 1) if @sprites["cursor"].position % BOARD_WIDTH < (BOARD_WIDTH - 1)
pbSEPlay("Mining cursor") pbSEPlay("Mining cursor")
@sprites["cursor"].position += 1 @sprites["cursor"].position += 1
end end
@@ -190,13 +190,14 @@ class TilePuzzleScene
ret.push(i) ret.push(i)
@angles.push(0) @angles.push(0)
end end
if @game == 6 case @game
when 6
@tiles = ret @tiles = ret
5.times do 5.times do
pbShiftLine([2, 4, 6, 8][rand(4)], rand(@boardwidth * @boardheight), false) pbShiftLine([2, 4, 6, 8][rand(4)], rand(@boardwidth * @boardheight), false)
end end
return @tiles return @tiles
elsif @game == 7 when 7
@tiles = ret @tiles = ret
5.times do 5.times do
pbRotateTile(rand(@boardwidth * @boardheight), false) pbRotateTile(rand(@boardwidth * @boardheight), false)
@@ -213,11 +214,11 @@ class TilePuzzleScene
ret[j] != @boardwidth * @boardheight - 1 ret[j] != @boardwidth * @boardheight - 1
end end
end end
if @boardwidth % 2 == 1 if @boardwidth.odd?
ret = pbShuffleTiles if num % 2 == 1 ret = pbShuffleTiles if num.odd?
else else
ret = pbShuffleTiles if !((num % 2 == 0 && (@boardheight - (blank / @boardwidth)) % 2 == 1) || ret = pbShuffleTiles if !((num.even? && (@boardheight - (blank / @boardwidth)).odd?) ||
(num % 2 == 1 && (@boardheight - (blank / @boardwidth)) % 2 == 0)) (num.odd? && (@boardheight - (blank / @boardwidth)).even?))
end end
end end
if @game == 1 || @game == 2 if @game == 1 || @game == 2
@@ -241,16 +242,15 @@ class TilePuzzleScene
for i in 0...@boardwidth * @boardheight for i in 0...@boardwidth * @boardheight
return i if @tiles[i] == @boardwidth * @boardheight - 1 return i if @tiles[i] == @boardwidth * @boardheight - 1
end end
return 0
else
return 0
end end
return 0
end end
def pbMoveCursor(pos, dir) def pbMoveCursor(pos, dir)
if dir == 2 case dir
when 2
pos += @boardwidth pos += @boardwidth
elsif dir == 4 when 4
if pos >= @boardwidth * @boardheight if pos >= @boardwidth * @boardheight
if pos % @boardwidth == (@boardwidth / 2).ceil if pos % @boardwidth == (@boardwidth / 2).ceil
pos = ((pos % (@boardwidth * @boardheight)) / @boardwidth) * @boardwidth + @boardwidth - 1 pos = ((pos % (@boardwidth * @boardheight)) / @boardwidth) * @boardwidth + @boardwidth - 1
@@ -264,7 +264,7 @@ class TilePuzzleScene
pos -= 1 pos -= 1
end end
end end
elsif dir == 6 when 6
if pos >= @boardwidth * @boardheight if pos >= @boardwidth * @boardheight
if pos % @boardwidth == (@boardwidth / 2).ceil - 1 if pos % @boardwidth == (@boardwidth / 2).ceil - 1
pos = ((pos % (@boardwidth * @boardheight)) / @boardwidth) * @boardwidth pos = ((pos % (@boardwidth * @boardheight)) / @boardwidth) * @boardwidth
@@ -278,7 +278,7 @@ class TilePuzzleScene
pos += 1 pos += 1
end end
end end
elsif dir == 8 when 8
pos -= @boardwidth pos -= @boardwidth
end end
return pos return pos
@@ -286,21 +286,22 @@ class TilePuzzleScene
def pbCanMoveInDir?(pos, dir, swapping) def pbCanMoveInDir?(pos, dir, swapping)
return true if @game == 6 && swapping return true if @game == 6 && swapping
if dir == 2 case dir
when 2
return false if (pos / @boardwidth) % @boardheight >= @boardheight - 1 return false if (pos / @boardwidth) % @boardheight >= @boardheight - 1
elsif dir == 4 when 4
if @game == 1 || @game == 2 if @game == 1 || @game == 2
return false if pos >= @boardwidth * @boardheight && pos % @boardwidth == 0 return false if pos >= @boardwidth * @boardheight && pos % @boardwidth == 0
else else
return false if pos % @boardwidth == 0 return false if pos % @boardwidth == 0
end end
elsif dir == 6 when 6
if @game == 1 || @game == 2 if @game == 1 || @game == 2
return false if pos >= @boardwidth * @boardheight && pos % @boardwidth >= @boardwidth - 1 return false if pos >= @boardwidth * @boardheight && pos % @boardwidth >= @boardwidth - 1
else else
return false if pos % @boardwidth >= @boardwidth - 1 return false if pos % @boardwidth >= @boardwidth - 1
end end
elsif dir == 8 when 8
return false if (pos / @boardwidth) % @boardheight == 0 return false if (pos / @boardwidth) % @boardheight == 0
end end
return true return true
@@ -376,8 +377,8 @@ class TilePuzzleScene
movetile = pbMoveCursor(cursor, dir) movetile = pbMoveCursor(cursor, dir)
@sprites["cursor"].visible = false @sprites["cursor"].visible = false
@sprites["tile#{@tiles[cursor]}"].z = 1 @sprites["tile#{@tiles[cursor]}"].z = 1
if dir == 2 || dir == 8 # Swap vertically swapTime = Graphics.frame_rate * 3 / 10
swapTime = Graphics.frame_rate * 3 / 10 if [2, 8].include?(dir) # Swap vertically
distancePerFrame = (@tileheight.to_f / swapTime).ceil distancePerFrame = (@tileheight.to_f / swapTime).ceil
dist = (dir / 4).floor - 1 dist = (dir / 4).floor - 1
swapTime.times do swapTime.times do
@@ -388,7 +389,6 @@ class TilePuzzleScene
Input.update Input.update
end end
else # Swap horizontally else # Swap horizontally
swapTime = Graphics.frame_rate * 3 / 10
distancePerFrame = (@tilewidth.to_f / swapTime).ceil distancePerFrame = (@tilewidth.to_f / swapTime).ceil
dist = dir - 5 dist = dir - 5
swapTime.times do swapTime.times do
@@ -411,7 +411,7 @@ class TilePuzzleScene
# Get tiles involved # Get tiles involved
tiles = [] tiles = []
dist = 0 dist = 0
if dir == 2 || dir == 8 if [2, 8].include?(dir)
dist = (dir / 4).floor - 1 dist = (dir / 4).floor - 1
while (dist > 0 && cursor < (@boardwidth - 1) * @boardheight) || while (dist > 0 && cursor < (@boardwidth - 1) * @boardheight) ||
(dist < 0 && cursor >= @boardwidth) (dist < 0 && cursor >= @boardwidth)
@@ -441,7 +441,7 @@ class TilePuzzleScene
Input.update Input.update
end end
shiftTime = Graphics.frame_rate * 3 / 10 shiftTime = Graphics.frame_rate * 3 / 10
if dir == 2 || dir == 8 if [2, 8].include?(dir)
distancePerFrame = (@tileheight.to_f / shiftTime).ceil distancePerFrame = (@tileheight.to_f / shiftTime).ceil
shiftTime.times do shiftTime.times do
for i in tiles for i in tiles
@@ -197,12 +197,8 @@ class BattleChallengeData
end end
def setParty(value) def setParty(value)
if @inProgress $player.party = value if @inProgress
$player.party = value @party = value
@party = value
else
@party = value
end
end end
def pbStart(t, numRounds) def pbStart(t, numRounds)
@@ -87,7 +87,7 @@ def pbOrganizedBattleEx(opponent, challengedata, endspeech, endspeechwin)
end end
# Save the record of the battle # Save the record of the battle
$game_temp.last_battle_record = nil $game_temp.last_battle_record = nil
if decision == 1 || decision == 2 || decision == 5 # if win, loss or draw if [1, 2, 5].include?(decision) # if win, loss or draw
$game_temp.last_battle_record = battle.pbDumpRecord $game_temp.last_battle_record = battle.pbDumpRecord
end end
case decision case decision
@@ -104,9 +104,10 @@ class BattleSwapScene
def pbUpdateChoices(choices) def pbUpdateChoices(choices)
commands = pbGetCommands(@rentals, choices) commands = pbGetCommands(@rentals, choices)
@choices = choices @choices = choices
if choices.length == 0 case choices.length
when 0
@sprites["help"].text = _INTL("Choose the first Pokémon.") @sprites["help"].text = _INTL("Choose the first Pokémon.")
elsif choices.length == 1 when 1
@sprites["help"].text = _INTL("Choose the second Pokémon.") @sprites["help"].text = _INTL("Choose the second Pokémon.")
else else
@sprites["help"].text = _INTL("Choose the third Pokémon.") @sprites["help"].text = _INTL("Choose the third Pokémon.")
@@ -162,9 +163,10 @@ class BattleSwapScreen
end end
commands.push(_INTL("OTHERS")) commands.push(_INTL("OTHERS"))
command = @scene.pbShowCommands(commands) command = @scene.pbShowCommands(commands)
if command == 0 case command
when 0
@scene.pbSummary(rentals, index) @scene.pbSummary(rentals, index)
elsif command == 1 when 1
if chosen.include?(index) if chosen.include?(index)
chosen.delete(index) chosen.delete(index)
@scene.pbUpdateChoices(chosen.clone) @scene.pbUpdateChoices(chosen.clone)
@@ -194,9 +196,10 @@ class BattleSwapScreen
if pkmn >= 0 if pkmn >= 0
commands = [_INTL("SUMMARY"), _INTL("SWAP"), _INTL("RECHOOSE")] commands = [_INTL("SUMMARY"), _INTL("SWAP"), _INTL("RECHOOSE")]
command = @scene.pbShowCommands(commands) command = @scene.pbShowCommands(commands)
if command == 0 case command
when 0
@scene.pbSummary(currentPokemon, pkmn) @scene.pbSummary(currentPokemon, pkmn)
elsif command == 1 when 1
@scene.pbSwapChosen(pkmn) @scene.pbSwapChosen(pkmn)
yourPkmn = pkmn yourPkmn = pkmn
loop do loop do
@@ -4,7 +4,7 @@ class BugContestState
attr_accessor :lastPokemon attr_accessor :lastPokemon
attr_reader :timer attr_reader :timer
ContestantNames = [ CONTESTANT_NAMES = [
_INTL("Bug Catcher Ed"), _INTL("Bug Catcher Ed"),
_INTL("Bug Catcher Benny"), _INTL("Bug Catcher Benny"),
_INTL("Bug Catcher Josh"), _INTL("Bug Catcher Josh"),
@@ -14,7 +14,7 @@ class BugContestState
_INTL("Picnicker Cindy"), _INTL("Picnicker Cindy"),
_INTL("Youngster Samuel") _INTL("Youngster Samuel")
] ]
TimerSeconds = Settings::BUG_CONTEST_TIME TIME_ALLOWED = Settings::BUG_CONTEST_TIME
def initialize def initialize
clear clear
@@ -29,8 +29,8 @@ class BugContestState
def expired? def expired?
return false if !undecided? return false if !undecided?
return false if TimerSeconds <= 0 return false if TIME_ALLOWED <= 0
curtime = @timer + TimerSeconds * Graphics.frame_rate curtime = @timer + TIME_ALLOWED * Graphics.frame_rate
curtime = [curtime - Graphics.frame_count, 0].max curtime = [curtime - Graphics.frame_count, 0].max
return (curtime <= 0) return (curtime <= 0)
end end
@@ -65,8 +65,8 @@ class BugContestState
@chosenPokemon = chosenpoke @chosenPokemon = chosenpoke
end end
# Reception map is handled separately from contest map since the reception map # Reception map is handled separately from contest map since the reception map
# can be outdoors, with its own grassy patches. # can be outdoors, with its own grassy patches.
def pbSetReception(*arg) def pbSetReception(*arg)
@reception = [] @reception = []
for i in arg for i in arg
@@ -96,16 +96,6 @@ class BugContestState
if @lastPokemon if @lastPokemon
judgearray.push([-1, @lastPokemon.species, pbBugContestScore(@lastPokemon)]) judgearray.push([-1, @lastPokemon.species, pbBugContestScore(@lastPokemon)])
end end
@contestants = []
[5, ContestantNames.length].min.times do
loop do
value = rand(ContestantNames.length)
if !@contestants.any? { |i| i == value }
@contestants.push(value)
break
end
end
end
enctype = :BugContest enctype = :BugContest
if !$PokemonEncounters.map_has_encounter_type?(@contestMap, enctype) if !$PokemonEncounters.map_has_encounter_type?(@contestMap, enctype)
enctype = :Land enctype = :Land
@@ -134,7 +124,7 @@ class BugContestState
if cont < 0 if cont < 0
$game_variables[1] = $player.name $game_variables[1] = $player.name
else else
$game_variables[1] = ContestantNames[cont] $game_variables[1] = CONTESTANT_NAMES[cont]
end end
$game_variables[2] = GameData::Species.get(@places[place][1]).name $game_variables[2] = GameData::Species.get(@places[place][1]).name
$game_variables[3] = @places[place][2] $game_variables[3] = @places[place][2]
@@ -177,13 +167,12 @@ class BugContestState
@otherparty.push($player.party[i]) if i != @chosenPokemon @otherparty.push($player.party[i]) if i != @chosenPokemon
end end
@contestants = [] @contestants = []
[5, ContestantNames.length].min.times do [5, CONTESTANT_NAMES.length].min.times do
loop do loop do
value = rand(ContestantNames.length) value = rand(CONTESTANT_NAMES.length)
if !@contestants.any? { |i| i == value } next if @contestants.include?(value)
@contestants.push(value) @contestants.push(value)
break break
end
end end
end end
$player.party = [chosenpkmn] $player.party = [chosenpkmn]
@@ -303,10 +292,10 @@ Events.onMapChange += proc { |_sender, _e|
Events.onMapSceneChange += proc { |_sender, e| Events.onMapSceneChange += proc { |_sender, e|
scene = e[0] scene = e[0]
if pbInBugContest? && pbBugContestState.decision == 0 && BugContestState::TimerSeconds > 0 if pbInBugContest? && pbBugContestState.decision == 0 && BugContestState::TIME_ALLOWED > 0
scene.spriteset.addUserSprite(TimerDisplay.new( scene.spriteset.addUserSprite(TimerDisplay.new(
pbBugContestState.timer, pbBugContestState.timer,
BugContestState::TimerSeconds * Graphics.frame_rate)) BugContestState::TIME_ALLOWED * Graphics.frame_rate))
end end
} }
@@ -373,7 +362,7 @@ def pbBugContestBattle(species, level)
pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) { pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) {
decision = battle.pbStartBattle decision = battle.pbStartBattle
pbAfterBattle(decision, true) pbAfterBattle(decision, true)
if decision == 2 || decision == 5 # Lost or drew if [2, 5].include?(decision) # Lost or drew
$game_system.bgm_unpause $game_system.bgm_unpause
$game_system.bgs_unpause $game_system.bgs_unpause
pbBugContestStartOver pbBugContestStartOver
@@ -57,9 +57,10 @@ end
def withRestr(_rule, minbs, maxbs, legendary) def withRestr(_rule, minbs, maxbs, legendary)
ret = PokemonChallengeRules.new.addPokemonRule(BaseStatRestriction.new(minbs, maxbs)) ret = PokemonChallengeRules.new.addPokemonRule(BaseStatRestriction.new(minbs, maxbs))
if legendary == 0 case legendary
when 0
ret.addPokemonRule(NonlegendaryRestriction.new) ret.addPokemonRule(NonlegendaryRestriction.new)
elsif legendary == 1 when 1
ret.addPokemonRule(InverseRestriction.new(NonlegendaryRestriction.new)) ret.addPokemonRule(InverseRestriction.new(NonlegendaryRestriction.new))
end end
return ret return ret
@@ -298,14 +299,16 @@ def pbWriteCup(id, rules)
else else
cmd = pbMessage(_INTL("Generate Pokémon teams for this challenge?"), cmd = pbMessage(_INTL("Generate Pokémon teams for this challenge?"),
[_INTL("YES"), _INTL("NO")], 2) [_INTL("YES"), _INTL("NO")], 2)
if cmd == 0 case cmd
when 0
cmd = 2 cmd = 2
elsif cmd == 1 when 1
cmd = 0 cmd = 0
end end
end end
return if cmd == 0 # No return if cmd == 0 # No
if cmd == 1 # Yes, use existing case cmd
when 1 # Yes, use existing
cmd = pbMessage(_INTL("Choose a challenge."), list, -1) cmd = pbMessage(_INTL("Choose a challenge."), list, -1)
if cmd >= 0 if cmd >= 0
pbMessage(_INTL("This challenge will use the Pokémon list from {1}.", list[cmd])) pbMessage(_INTL("This challenge will use the Pokémon list from {1}.", list[cmd]))
@@ -321,7 +324,7 @@ def pbWriteCup(id, rules)
Compiler.write_trainer_lists Compiler.write_trainer_lists
end end
return return
elsif cmd == 2 # Yes, use new when 2 # Yes, use new
return if !pbConfirmMessage(_INTL("This may take a long time. Are you sure?")) return if !pbConfirmMessage(_INTL("This may take a long time. Are you sure?"))
mw = pbCreateMessageWindow mw = pbCreateMessageWindow
t = Time.now t = Time.now
@@ -159,7 +159,7 @@ def pbRandomPokemonFromRule(rules, trainer)
r = rand(20) r = rand(20)
bst = baseStatTotal(species) bst = baseStatTotal(species)
next if level < minimumLevel(species) next if level < minimumLevel(species)
if iteration % 2 == 0 if iteration.even?
next if r < 16 && bst < 400 next if r < 16 && bst < 400
next if r < 13 && bst < 500 next if r < 13 && bst < 500
else else
@@ -339,7 +339,7 @@ def pbRandomPokemonFromRule(rules, trainer)
break break
end end
end end
if item == :LIGHTCLAY && !moves.any? { |m| m == :LIGHTSCREEN || m == :REFLECT } if item == :LIGHTCLAY && !moves.any? { |m| [:LIGHTSCREEN, :REFLECT].include?(m) }
item = :LEFTOVERS item = :LEFTOVERS
end end
if item == :BLACKSLUDGE if item == :BLACKSLUDGE
@@ -60,7 +60,7 @@ class RuledTeam
def updateRating def updateRating
@totalGames = 0 if !@totalGames @totalGames = 0 if !@totalGames
oldgames = self.games oldgames = self.games
@history.updateAndClear() @history.updateAndClear
newgames = self.games newgames = self.games
@totalGames += (oldgames - newgames) @totalGames += (oldgames - newgames)
end end
@@ -420,10 +420,11 @@ def pbRuledBattle(team1, team2, rule)
p.item = items2[i] p.item = items2[i]
end end
end end
if decision == 1 # Team 1 wins case decision
when 1 # Team 1 wins
team1.addMatch(team2, 1) team1.addMatch(team2, 1)
team2.addMatch(team1, 0) team2.addMatch(team1, 0)
elsif decision == 2 # Team 2 wins when 2 # Team 2 wins
team1.addMatch(team2, 0) team1.addMatch(team2, 0)
team2.addMatch(team1, 1) team2.addMatch(team1, 1)
else else
+2 -2
View File
@@ -49,7 +49,7 @@ def pbEachCombination(array, num)
end end
# Returns a language ID # Returns a language ID
def pbGetLanguage() def pbGetLanguage
case System.user_language[0..1] case System.user_language[0..1]
when "ja" then return 1 # Japanese when "ja" then return 1 # Japanese
when "en" then return 2 # English when "en" then return 2 # English
@@ -242,7 +242,7 @@ def pbTrainerName(name = nil, outfit = 0)
end end
def pbSuggestTrainerName(gender) def pbSuggestTrainerName(gender)
userName = pbGetUserName() userName = pbGetUserName
userName = userName.gsub(/\s+.*$/, "") userName = userName.gsub(/\s+.*$/, "")
if userName.length > 0 && userName.length < Settings::MAX_PLAYER_NAME_SIZE if userName.length > 0 && userName.length < Settings::MAX_PLAYER_NAME_SIZE
userName[0, 1] = userName[0, 1].upcase userName[0, 1] = userName[0, 1].upcase
@@ -356,7 +356,8 @@ def pbTrainerTypeEditor
] ]
pbListScreenBlock(_INTL("Trainer Types"), TrainerTypeLister.new(0, true)) { |button, tr_type| pbListScreenBlock(_INTL("Trainer Types"), TrainerTypeLister.new(0, true)) { |button, tr_type|
if tr_type if tr_type
if button == Input::ACTION case button
when Input::ACTION
if tr_type.is_a?(Symbol) if tr_type.is_a?(Symbol)
if pbConfirmMessageSerious("Delete this trainer type?") if pbConfirmMessageSerious("Delete this trainer type?")
GameData::TrainerType::DATA.delete(tr_type) GameData::TrainerType::DATA.delete(tr_type)
@@ -365,7 +366,7 @@ def pbTrainerTypeEditor
pbMessage(_INTL("The Trainer type was deleted.")) pbMessage(_INTL("The Trainer type was deleted."))
end end
end end
elsif button == Input::USE when Input::USE
if tr_type.is_a?(Symbol) if tr_type.is_a?(Symbol)
t_data = GameData::TrainerType.get(tr_type) t_data = GameData::TrainerType.get(tr_type)
data = [ data = [
@@ -496,7 +497,8 @@ def pbTrainerBattleEditor
modified = false modified = false
pbListScreenBlock(_INTL("Trainer Battles"), TrainerBattleLister.new(0, true)) { |button, trainer_id| pbListScreenBlock(_INTL("Trainer Battles"), TrainerBattleLister.new(0, true)) { |button, trainer_id|
if trainer_id if trainer_id
if button == Input::ACTION case button
when Input::ACTION
if trainer_id.is_a?(Array) if trainer_id.is_a?(Array)
if pbConfirmMessageSerious("Delete this trainer battle?") if pbConfirmMessageSerious("Delete this trainer battle?")
tr_data = GameData::Trainer::DATA[trainer_id] tr_data = GameData::Trainer::DATA[trainer_id]
@@ -505,7 +507,7 @@ def pbTrainerBattleEditor
pbMessage(_INTL("The Trainer battle was deleted.")) pbMessage(_INTL("The Trainer battle was deleted."))
end end
end end
elsif button == Input::USE when Input::USE
if trainer_id.is_a?(Array) # Edit existing trainer if trainer_id.is_a?(Array) # Edit existing trainer
tr_data = GameData::Trainer::DATA[trainer_id] tr_data = GameData::Trainer::DATA[trainer_id]
old_type = tr_data.trainer_type old_type = tr_data.trainer_type
@@ -881,7 +883,8 @@ def pbItemEditor
] ]
pbListScreenBlock(_INTL("Items"), ItemLister.new(0, true)) { |button, item| pbListScreenBlock(_INTL("Items"), ItemLister.new(0, true)) { |button, item|
if item if item
if button == Input::ACTION case button
when Input::ACTION
if item.is_a?(Symbol) if item.is_a?(Symbol)
if pbConfirmMessageSerious("Delete this item?") if pbConfirmMessageSerious("Delete this item?")
GameData::Item::DATA.delete(item) GameData::Item::DATA.delete(item)
@@ -890,7 +893,7 @@ def pbItemEditor
pbMessage(_INTL("The item was deleted.")) pbMessage(_INTL("The item was deleted."))
end end
end end
elsif button == Input::USE when Input::USE
if item.is_a?(Symbol) if item.is_a?(Symbol)
itm = GameData::Item.get(item) itm = GameData::Item.get(item)
data = [ data = [
@@ -1039,7 +1042,8 @@ def pbPokemonEditor
] ]
pbListScreenBlock(_INTL("Pokémon species"), SpeciesLister.new(0, false)) { |button, species| pbListScreenBlock(_INTL("Pokémon species"), SpeciesLister.new(0, false)) { |button, species|
if species if species
if button == Input::ACTION case button
when Input::ACTION
if species.is_a?(Symbol) if species.is_a?(Symbol)
if pbConfirmMessageSerious("Delete this species?") if pbConfirmMessageSerious("Delete this species?")
GameData::Species::DATA.delete(species) GameData::Species::DATA.delete(species)
@@ -1048,7 +1052,7 @@ def pbPokemonEditor
pbMessage(_INTL("The species was deleted.")) pbMessage(_INTL("The species was deleted."))
end end
end end
elsif button == Input::USE when Input::USE
if species.is_a?(Symbol) if species.is_a?(Symbol)
spec = GameData::Species.get(species) spec = GameData::Species.get(species)
moves = [] moves = []
@@ -1448,29 +1452,30 @@ def pbAnimationsOrganiser
refreshlist = false refreshlist = false
oldsel = -1 oldsel = -1
cmd = pbCommands3(cmdwin, commands, -1, cmd[1], true) cmd = pbCommands3(cmdwin, commands, -1, cmd[1], true)
if cmd[0] == 1 # Swap animation up case cmd[0]
when 1 # Swap animation up
if cmd[1] >= 0 && cmd[1] < commands.length - 1 if cmd[1] >= 0 && cmd[1] < commands.length - 1
list[cmd[1] + 1], list[cmd[1]] = list[cmd[1]], list[cmd[1] + 1] list[cmd[1] + 1], list[cmd[1]] = list[cmd[1]], list[cmd[1] + 1]
refreshlist = true refreshlist = true
end end
elsif cmd[0] == 2 # Swap animation down when 2 # Swap animation down
if cmd[1] > 0 if cmd[1] > 0
list[cmd[1] - 1], list[cmd[1]] = list[cmd[1]], list[cmd[1] - 1] list[cmd[1] - 1], list[cmd[1]] = list[cmd[1]], list[cmd[1] - 1]
refreshlist = true refreshlist = true
end end
elsif cmd[0] == 3 # Delete spot when 3 # Delete spot
list.delete_at(cmd[1]) list.delete_at(cmd[1])
cmd[1] = [cmd[1], list.length - 1].min cmd[1] = [cmd[1], list.length - 1].min
refreshlist = true refreshlist = true
pbWait(Graphics.frame_rate * 2 / 10) pbWait(Graphics.frame_rate * 2 / 10)
elsif cmd[0] == 4 # Insert spot when 4 # Insert spot
list.insert(cmd[1], PBAnimation.new) list.insert(cmd[1], PBAnimation.new)
refreshlist = true refreshlist = true
pbWait(Graphics.frame_rate * 2 / 10) pbWait(Graphics.frame_rate * 2 / 10)
elsif cmd[0] == 0 when 0
cmd2 = pbMessage(_INTL("Save changes?"), cmd2 = pbMessage(_INTL("Save changes?"),
[_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3) [_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3)
if cmd2 == 0 || cmd2 == 1 if [0, 1].include?(cmd2)
if cmd2 == 0 if cmd2 == 0
# Save animations here # Save animations here
save_data(list, "Data/PkmnAnimations.rxdata") save_data(list, "Data/PkmnAnimations.rxdata")
@@ -20,7 +20,7 @@ class MapSprite
def getXY def getXY
return nil if !Input.trigger?(Input::MOUSELEFT) return nil if !Input.trigger?(Input::MOUSELEFT)
mouse = Mouse::getMousePos(true) mouse = Mouse.getMousePos(true)
return nil if !mouse return nil if !mouse
if mouse[0] < @sprite.x || mouse[0] >= @sprite.x + @sprite.bitmap.width if mouse[0] < @sprite.x || mouse[0] >= @sprite.x + @sprite.bitmap.width
return nil return nil
@@ -119,7 +119,7 @@ class RegionMapSprite
def getXY def getXY
return nil if !Input.trigger?(Input::MOUSELEFT) return nil if !Input.trigger?(Input::MOUSELEFT)
mouse = Mouse::getMousePos(true) mouse = Mouse.getMousePos(true)
return nil if !mouse return nil if !mouse
if mouse[0] < @sprite.x || mouse[0] >= @sprite.x + @sprite.bitmap.width if mouse[0] < @sprite.x || mouse[0] >= @sprite.x + @sprite.bitmap.width
return nil return nil
@@ -280,7 +280,7 @@ class MapScreenScene
end end
def serializeConnectionData def serializeConnectionData
conndata = generateConnectionData() conndata = generateConnectionData
save_data(conndata, "Data/map_connections.dat") save_data(conndata, "Data/map_connections.dat")
Compiler.write_connections Compiler.write_connections
@mapconns = conndata @mapconns = conndata
@@ -477,7 +477,7 @@ class MapScreenScene
end end
def update def update
mousepos = Mouse::getMousePos mousepos = Mouse.getMousePos
if mousepos if mousepos
hitmap = hittest(mousepos[0], mousepos[1]) hitmap = hittest(mousepos[0], mousepos[1])
if Input.trigger?(Input::MOUSELEFT) if Input.trigger?(Input::MOUSELEFT)
@@ -121,8 +121,6 @@ def pbChooseFromGameDataList(game_data, default = nil)
name = data.real_name name = data.real_name
name = yield(data) if block_given? name = yield(data) if block_given?
next if !name next if !name
index = commands.length + 1
index = data.id_number if data.respond_to?("id_number")
commands.push([commands.length + 1, name, data.id]) commands.push([commands.length + 1, name, data.id])
end end
return pbChooseList(commands, default, nil, -1) return pbChooseList(commands, default, nil, -1)
@@ -344,9 +342,10 @@ def pbChooseList(commands, default = 0, cancelValue = -1, sortType = 1)
sorting = true sorting = true
loop do loop do
if sorting if sorting
if sortMode == 0 case sortMode
when 0
commands.sort! { |a, b| a[0] <=> b[0] } commands.sort! { |a, b| a[0] <=> b[0] }
elsif sortMode == 1 when 1
commands.sort! { |a, b| a[1] <=> b[1] } commands.sort! { |a, b| a[1] <=> b[1] }
end end
if itemID.is_a?(Symbol) if itemID.is_a?(Symbol)
@@ -365,10 +364,11 @@ def pbChooseList(commands, default = 0, cancelValue = -1, sortType = 1)
sorting = false sorting = false
end end
cmd = pbCommandsSortable(cmdwin, realcommands, -1, itemIndex, (sortType < 0)) cmd = pbCommandsSortable(cmdwin, realcommands, -1, itemIndex, (sortType < 0))
if cmd[0] == 0 # Chose an option or cancelled case cmd[0]
when 0 # Chose an option or cancelled
itemID = (cmd[1] < 0) ? cancelValue : (commands[cmd[1]][2] || commands[cmd[1]][0]) itemID = (cmd[1] < 0) ? cancelValue : (commands[cmd[1]][2] || commands[cmd[1]][0])
break break
elsif cmd[0] == 1 # Toggle sorting when 1 # Toggle sorting
itemID = commands[cmd[1]][2] || commands[cmd[1]][0] itemID = commands[cmd[1]][2] || commands[cmd[1]][0]
sortMode = (sortMode + 1) % 2 sortMode = (sortMode + 1) % 2
sorting = true sorting = true
@@ -25,7 +25,7 @@ class Window_Menu < Window_CommandPokemon
end end
def hittest def hittest
mousepos = Mouse::getMousePos mousepos = Mouse.getMousePos
return -1 if !mousepos return -1 if !mousepos
toprow = self.top_row toprow = self.top_row
for i in toprow...toprow + @item_max for i in toprow...toprow + @item_max
@@ -51,7 +51,7 @@ module Clipboard
def self.data def self.data
return nil if !@data return nil if !@data
return Marshal::load(@data) return Marshal.load(@data)
end end
def self.typekey def self.typekey
@@ -131,7 +131,7 @@ def pbSpriteHitTest(sprite, x, y, usealpha = true, wholecanvas = false)
end end
def pbTrackPopupMenu(commands) def pbTrackPopupMenu(commands)
mousepos = Mouse::getMousePos mousepos = Mouse.getMousePos
return -1 if !mousepos return -1 if !mousepos
menuwindow = Window_Menu.new(commands, mousepos[0], mousepos[1]) menuwindow = Window_Menu.new(commands, mousepos[0], mousepos[1])
menuwindow.z = 99999 menuwindow.z = 99999
@@ -250,7 +250,7 @@ class AnimationWindow < SpriteWrapper
end end
def update def update
mousepos = Mouse::getMousePos mousepos = Mouse.getMousePos
@changed = false @changed = false
return if !Input.repeat?(Input::MOUSELEFT) return if !Input.repeat?(Input::MOUSELEFT)
return if !mousepos return if !mousepos
@@ -795,7 +795,7 @@ class AnimationCanvas < Sprite
def updateInput def updateInput
cel = currentCel cel = currentCel
mousepos = Mouse::getMousePos mousepos = Mouse.getMousePos
if mousepos && pbSpriteHitTest(self, mousepos[0], mousepos[1], false, true) if mousepos && pbSpriteHitTest(self, mousepos[0], mousepos[1], false, true)
if Input.trigger?(Input::MOUSELEFT) # Left mouse button if Input.trigger?(Input::MOUSELEFT) # Left mouse button
selectedcel = -1 selectedcel = -1
@@ -1,9 +1,10 @@
module ShadowText module ShadowText
def shadowtext(bitmap, x, y, w, h, t, disabled = false, align = 0) def shadowtext(bitmap, x, y, w, h, t, disabled = false, align = 0)
width = bitmap.text_size(t).width width = bitmap.text_size(t).width
if align == 2 case align
when 2
x += (w - width) x += (w - width)
elsif align == 1 when 1
x += (w / 2) - (width / 2) x += (w / 2) - (width / 2)
end end
pbDrawShadowText(bitmap, x, y, w, h, t, pbDrawShadowText(bitmap, x, y, w, h, t,
@@ -120,7 +121,7 @@ class Button < UIControl
end end
def update def update
mousepos = Mouse::getMousePos mousepos = Mouse.getMousePos
self.changed = false self.changed = false
return if !mousepos return if !mousepos
rect = Rect.new(self.x + 1, self.y + 1, self.width - 2, self.height - 2) rect = Rect.new(self.x + 1, self.y + 1, self.width - 2, self.height - 2)
@@ -385,7 +386,7 @@ class Slider < UIControl
end end
def update def update
mousepos = Mouse::getMousePos mousepos = Mouse.getMousePos
self.changed = false self.changed = false
if self.minvalue < self.maxvalue && self.curvalue < self.minvalue if self.minvalue < self.maxvalue && self.curvalue < self.minvalue
self.curvalue = self.minvalue self.curvalue = self.minvalue
@@ -401,14 +402,12 @@ class Slider < UIControl
if left.contains(mousepos[0], mousepos[1]) if left.contains(mousepos[0], mousepos[1])
if repeattime > 2500 if repeattime > 2500
self.curvalue -= 10 self.curvalue -= 10
self.curvalue = self.curvalue.floor
elsif repeattime > 1250 elsif repeattime > 1250
self.curvalue -= 5 self.curvalue -= 5
self.curvalue = self.curvalue.floor
else else
self.curvalue -= 1 self.curvalue -= 1
self.curvalue = self.curvalue.floor
end end
self.curvalue = self.curvalue.floor
self.changed = (self.curvalue != oldvalue) self.changed = (self.curvalue != oldvalue)
self.invalidate self.invalidate
end end
@@ -416,14 +415,12 @@ class Slider < UIControl
if right.contains(mousepos[0], mousepos[1]) if right.contains(mousepos[0], mousepos[1])
if repeattime > 2500 if repeattime > 2500
self.curvalue += 10 self.curvalue += 10
self.curvalue = self.curvalue.floor
elsif repeattime > 1250 elsif repeattime > 1250
self.curvalue += 5 self.curvalue += 5
self.curvalue = self.curvalue.floor
else else
self.curvalue += 1 self.curvalue += 1
self.curvalue = self.curvalue.floor
end end
self.curvalue = self.curvalue.floor
self.changed = (self.curvalue != oldvalue) self.changed = (self.curvalue != oldvalue)
self.invalidate self.invalidate
end end
@@ -634,7 +631,7 @@ class TextSlider < UIControl
end end
def update def update
mousepos = Mouse::getMousePos mousepos = Mouse.getMousePos
self.changed = false self.changed = false
if self.minvalue < self.maxvalue && self.curvalue < self.minvalue if self.minvalue < self.maxvalue && self.curvalue < self.minvalue
self.curvalue = self.minvalue self.curvalue = self.minvalue
@@ -832,7 +829,7 @@ class ControlWindow < SpriteWindow_Base
end end
def hittest?(i) def hittest?(i)
mousepos = Mouse::getMousePos mousepos = Mouse.getMousePos
return false if !mousepos return false if !mousepos
return false if i < 0 || i >= @controls.length return false if i < 0 || i >= @controls.length
rc = Rect.new( rc = Rect.new(
@@ -24,7 +24,7 @@ class ControlPointSprite < SpriteWrapper
@dragging = false @dragging = false
return return
end end
mouse = Mouse::getMousePos(true) mouse = Mouse.getMousePos(true)
return if !mouse return if !mouse
self.x = [[mouse[0], 0].max, 512].min self.x = [[mouse[0], 0].max, 512].min
self.y = [[mouse[1], 0].max, 384].min self.y = [[mouse[1], 0].max, 384].min
@@ -32,7 +32,7 @@ class ControlPointSprite < SpriteWrapper
def hittest? def hittest?
return true if !self.visible return true if !self.visible
mouse = Mouse::getMousePos(true) mouse = Mouse.getMousePos(true)
return false if !mouse return false if !mouse
return mouse[0] >= self.x && mouse[0] < self.x + 6 && return mouse[0] >= self.x && mouse[0] < self.x + 6 &&
mouse[1] >= self.y && mouse[1] < self.y + 6 mouse[1] >= self.y && mouse[1] < self.y + 6
@@ -294,7 +294,7 @@ def pbDefinePath(canvas)
if Input.trigger?(Input::MOUSELEFT) if Input.trigger?(Input::MOUSELEFT)
for j in 0...4 for j in 0...4
next if !curve[j].hittest? next if !curve[j].hittest?
if j == 1 || j == 2 if [1, 2].include?(j)
next if !curve[0].visible || !curve[3].visible next if !curve[0].visible || !curve[3].visible
end end
curve[j].visible = true curve[j].visible = true
@@ -307,7 +307,7 @@ def pbDefinePath(canvas)
for j in 0...4 for j in 0...4
curve[j].mouseover curve[j].mouseover
end end
mousepos = Mouse::getMousePos(true) mousepos = Mouse.getMousePos(true)
newtext = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)" newtext = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)"
if window.text != newtext if window.text != newtext
window.text = newtext window.text = newtext
@@ -376,11 +376,11 @@ def pbDefinePath(canvas)
if Input.trigger?(Input::MOUSELEFT) if Input.trigger?(Input::MOUSELEFT)
break break
end end
mousepos = Mouse::getMousePos(true) mousepos = Mouse.getMousePos(true)
window.text = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)" window.text = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)"
end end
while !canceled while !canceled
mousepos = Mouse::getMousePos(true) mousepos = Mouse.getMousePos(true)
if mousepos && !pointpath.isEndPoint?(mousepos[0], mousepos[1]) if mousepos && !pointpath.isEndPoint?(mousepos[0], mousepos[1])
pointpath.addPoint(mousepos[0], mousepos[1]) pointpath.addPoint(mousepos[0], mousepos[1])
points.push(PointSprite.new(mousepos[0], mousepos[1], canvas.viewport)) points.push(PointSprite.new(mousepos[0], mousepos[1], canvas.viewport))
@@ -102,11 +102,12 @@ def pbConvertAnimToNewFormat(textdata)
for j in 0...PBAnimation::MAX_SPRITES for j in 0...PBAnimation::MAX_SPRITES
next if !textdata[i][j] next if !textdata[i][j]
textdata[i][j][AnimFrame::PRIORITY] = 1 if textdata[i][j][AnimFrame::PRIORITY] == nil textdata[i][j][AnimFrame::PRIORITY] = 1 if textdata[i][j][AnimFrame::PRIORITY] == nil
if j == 0 # User battler case j
when 0 # User battler
textdata[i][j][AnimFrame::FOCUS] = 2 textdata[i][j][AnimFrame::FOCUS] = 2
textdata[i][j][AnimFrame::X] = Battle::Scene::FOCUSUSER_X textdata[i][j][AnimFrame::X] = Battle::Scene::FOCUSUSER_X
textdata[i][j][AnimFrame::Y] = Battle::Scene::FOCUSUSER_Y textdata[i][j][AnimFrame::Y] = Battle::Scene::FOCUSUSER_Y
elsif j == 1 # Target battler when 1 # Target battler
textdata[i][j][AnimFrame::FOCUS] = 1 textdata[i][j][AnimFrame::FOCUS] = 1
textdata[i][j][AnimFrame::X] = Battle::Scene::FOCUSTARGET_X textdata[i][j][AnimFrame::X] = Battle::Scene::FOCUSTARGET_X
textdata[i][j][AnimFrame::Y] = Battle::Scene::FOCUSTARGET_Y textdata[i][j][AnimFrame::Y] = Battle::Scene::FOCUSTARGET_Y
@@ -158,15 +158,16 @@ def pbAnimList(animations, canvas, animwin)
_INTL("Rename"), _INTL("Rename"),
_INTL("Delete") _INTL("Delete")
], -1) ], -1)
if cmd2 == 0 # Load Animation case cmd2
when 0 # Load Animation
canvas.loadAnimation(animations[cmdwin.index]) canvas.loadAnimation(animations[cmdwin.index])
animwin.animbitmap = canvas.animbitmap animwin.animbitmap = canvas.animbitmap
animations.selected = cmdwin.index animations.selected = cmdwin.index
break break
elsif cmd2 == 1 # Rename when 1 # Rename
pbAnimName(animations[cmdwin.index], cmdwin) pbAnimName(animations[cmdwin.index], cmdwin)
cmdwin.refresh cmdwin.refresh
elsif cmd2 == 2 # Delete when 2 # Delete
if pbConfirmMessage(_INTL("Are you sure you want to delete this animation?")) if pbConfirmMessage(_INTL("Are you sure you want to delete this animation?"))
animations[cmdwin.index] = PBAnimation.new animations[cmdwin.index] = PBAnimation.new
cmdwin.commands[cmdwin.index] = _INTL("{1} {2}", cmdwin.index, animations[cmdwin.index].name) cmdwin.commands[cmdwin.index] = _INTL("{1} {2}", cmdwin.index, animations[cmdwin.index].name)
@@ -683,10 +684,8 @@ def pbEditBG(canvas, timing)
timing.colorBlue = maxsizewindow.value(6) timing.colorBlue = maxsizewindow.value(6)
timing.colorAlpha = maxsizewindow.value(7) timing.colorAlpha = maxsizewindow.value(7)
ret = true ret = true
break
else
break
end end
break
end end
if maxsizewindow.changed?(9) # Cancel if maxsizewindow.changed?(9) # Cancel
break break
@@ -1064,7 +1063,7 @@ def animationEditorMain(animation)
end end
next next
elsif Input.trigger?(Input::MOUSERIGHT) # Right mouse button elsif Input.trigger?(Input::MOUSERIGHT) # Right mouse button
mousepos = Mouse::getMousePos mousepos = Mouse.getMousePos
mousepos = [0, 0] if !mousepos mousepos = [0, 0] if !mousepos
commands = [ commands = [
_INTL("Properties..."), _INTL("Properties..."),
@@ -1187,7 +1186,7 @@ end
# Start # Start
################################################################################ ################################################################################
def pbAnimationEditor def pbAnimationEditor
pbBGMStop() pbBGMStop
animation = pbLoadBattleAnimations animation = pbLoadBattleAnimations
if !animation || !animation[0] if !animation || !animation[0]
animation = PBAnimations.new animation = PBAnimations.new
@@ -668,7 +668,7 @@ module MapSizeProperty
oldsetting = [0, ""] if !oldsetting oldsetting = [0, ""] if !oldsetting
properties = [ properties = [
[_INTL("Width"), NonzeroLimitProperty.new(30), _INTL("The width of this map in Region Map squares.")], [_INTL("Width"), NonzeroLimitProperty.new(30), _INTL("The width of this map in Region Map squares.")],
[_INTL("Valid Squares"), StringProperty, _INTL("A series of 1s and 0s marking which squares are part of this map (1=part, 0=not part).")], [_INTL("Valid Squares"), StringProperty, _INTL("A series of 1s and 0s marking which squares are part of this map (1=part, 0=not part).")]
] ]
pbPropertyList(settingname, oldsetting, properties, false) pbPropertyList(settingname, oldsetting, properties, false)
return oldsetting return oldsetting
@@ -760,10 +760,11 @@ module RegionMapCoordsProperty
def self.set(_settingname, oldsetting) def self.set(_settingname, oldsetting)
regions = self.getMapNameList regions = self.getMapNameList
selregion = -1 selregion = -1
if regions.length == 0 case regions.length
when 0
pbMessage(_INTL("No region maps are defined.")) pbMessage(_INTL("No region maps are defined."))
return oldsetting return oldsetting
elsif regions.length == 1 when 1
selregion = regions[0][0] selregion = regions[0][0]
else else
cmds = [] cmds = []
@@ -1335,17 +1336,18 @@ class EvolutionsProperty
refreshlist = false refreshlist = false
oldsel = -1 oldsel = -1
cmd = pbCommands3(cmdwin, commands, -1, cmd[1], true) cmd = pbCommands3(cmdwin, commands, -1, cmd[1], true)
if cmd[0] == 1 # Swap evolution up case cmd[0]
when 1 # Swap evolution up
if cmd[1] > 0 && cmd[1] < realcmds.length - 1 if cmd[1] > 0 && cmd[1] < realcmds.length - 1
realcmds[cmd[1] + 1][3], realcmds[cmd[1]][3] = realcmds[cmd[1]][3], realcmds[cmd[1] + 1][3] realcmds[cmd[1] + 1][3], realcmds[cmd[1]][3] = realcmds[cmd[1]][3], realcmds[cmd[1] + 1][3]
refreshlist = true refreshlist = true
end end
elsif cmd[0] == 2 # Swap evolution down when 2 # Swap evolution down
if cmd[1] > 1 if cmd[1] > 1
realcmds[cmd[1] - 1][3], realcmds[cmd[1]][3] = realcmds[cmd[1]][3], realcmds[cmd[1] - 1][3] realcmds[cmd[1] - 1][3], realcmds[cmd[1]][3] = realcmds[cmd[1]][3], realcmds[cmd[1] - 1][3]
refreshlist = true refreshlist = true
end end
elsif cmd[0] == 0 when 0
if cmd[1] >= 0 if cmd[1] >= 0
entry = realcmds[cmd[1]] entry = realcmds[cmd[1]]
if entry[3] == -1 # Add new evolution path if entry[3] == -1 # Add new evolution path
@@ -1450,7 +1452,7 @@ class EvolutionsProperty
else else
cmd2 = pbMessage(_INTL("Save changes?"), cmd2 = pbMessage(_INTL("Save changes?"),
[_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3) [_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3)
if cmd2 == 0 || cmd2 == 1 if [0, 1].include?(cmd2)
if cmd2 == 0 if cmd2 == 0
for i in 0...realcmds.length for i in 0...realcmds.length
realcmds[i].pop realcmds[i].pop
@@ -134,11 +134,12 @@ DebugMenuCommands.register("togglewallpapers", {
end end
paperscmd = pbShowCommands(nil, paperscmds, -1, paperscmd) paperscmd = pbShowCommands(nil, paperscmds, -1, paperscmd)
break if paperscmd < 0 break if paperscmd < 0
if paperscmd == 0 # Unlock all case paperscmd
when 0 # Unlock all
for i in PokemonStorage::BASICWALLPAPERQTY...w.length for i in PokemonStorage::BASICWALLPAPERQTY...w.length
unlockarray[i] = true unlockarray[i] = true
end end
elsif paperscmd == 1 # Lock all when 1 # Lock all
for i in PokemonStorage::BASICWALLPAPERQTY...w.length for i in PokemonStorage::BASICWALLPAPERQTY...w.length
unlockarray[i] = false unlockarray[i] = false
end end
@@ -715,9 +716,10 @@ DebugMenuCommands.register("setbadges", {
end end
badgecmd = pbShowCommands(nil, badgecmds, -1, badgecmd) badgecmd = pbShowCommands(nil, badgecmds, -1, badgecmd)
break if badgecmd < 0 break if badgecmd < 0
if badgecmd == 0 # Give all case badgecmd
when 0 # Give all
24.times { |i| $player.badges[i] = true } 24.times { |i| $player.badges[i] = true }
elsif badgecmd == 1 # Remove all when 1 # Remove all
24.times { |i| $player.badges[i] = false } 24.times { |i| $player.badges[i] = false }
else else
$player.badges[badgecmd - 2] = !$player.badges[badgecmd - 2] $player.badges[badgecmd - 2] = !$player.badges[badgecmd - 2]

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