From 13aab8d911cabf06cb405615a9b794244b653e93 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sat, 28 Jan 2023 15:21:12 +0000 Subject: [PATCH] Lots of rubocop --- .rubocop.yml | 31 +++ .../001_Technical/002_Files/001_FileTests.rb | 27 +- .../001_Technical/002_Files/002_FileMixins.rb | 29 +-- .../002_Files/003_HTTP_Utilities.rb | 4 +- .../001_Technical/002_RubyUtilities.rb | 20 +- .../001_Technical/003_Intl_Messages.rb | 148 ++++++----- Data/Scripts/001_Technical/004_Input.rb | 4 +- .../001_Technical/005_PluginManager.rb | 8 +- Data/Scripts/001_Technical/006_RPG_Sprite.rb | 24 +- .../002_Save data/002_SaveData_Value.rb | 2 + .../002_Save data/003_SaveData_Conversion.rb | 2 + .../002_Save data/004_Game_SaveValues.rb | 6 +- .../003_Game processing/001_StartGame.rb | 4 +- .../003_Game processing/002_Scene_Map.rb | 4 +- .../003_Game processing/003_Interpreter.rb | 4 +- .../004_Interpreter_Commands.rb | 4 +- .../004_Game classes/001_Game_Screen.rb | 4 +- .../004_Game classes/003_Game_Picture.rb | 4 +- Data/Scripts/004_Game classes/004_Game_Map.rb | 8 +- .../005_Game_Map_Autoscroll.rb | 125 +++++---- .../004_Game classes/006_Game_MapFactory.rb | 4 +- .../004_Game classes/008_Game_Event.rb | 12 +- .../004_Game classes/010_Game_CommonEvent.rb | 4 +- .../004_Game classes/011_Game_Follower.rb | 8 +- .../012_Game_FollowerFactory.rb | 14 +- .../005_Sprites/004_Sprite_Reflection.rb | 8 +- .../006_Map renderer/001_TilemapRenderer.rb | 4 +- .../006_Map renderer/002_TilesetWrapper.rb | 2 + .../007_Objects and windows/001_RPG_Cache.rb | 4 +- .../002_MessageConfig.rb | 41 +-- .../007_Objects and windows/003_Window.rb | 4 + .../004_SpriteWindow.rb | 35 ++- .../005_SpriteWindow_text.rb | 22 +- .../008_AnimatedBitmap.rb | 4 +- .../007_Objects and windows/009_Planes.rb | 2 + .../007_Objects and windows/010_DrawText.rb | 239 +++++++++--------- .../007_Objects and windows/011_Messages.rb | 50 ++-- .../007_Objects and windows/012_TextEntry.rb | 10 +- Data/Scripts/008_Audio/001_Audio.rb | 20 +- Data/Scripts/009_Scenes/001_Transitions.rb | 48 ++-- Data/Scripts/009_Scenes/002_EventScene.rb | 28 +- Data/Scripts/010_Data/001_GameData.rb | 11 +- .../010_Data/002_PBS data/002_TownMap.rb | 2 +- .../Scripts/010_Data/002_PBS data/003_Type.rb | 2 +- .../010_Data/002_PBS data/004_Ability.rb | 4 +- .../Scripts/010_Data/002_PBS data/005_Move.rb | 4 +- .../Scripts/010_Data/002_PBS data/006_Item.rb | 10 +- .../010_Data/002_PBS data/008_Species.rb | 8 +- .../002_PBS data/010_SpeciesMetrics.rb | 4 +- .../010_Data/002_PBS data/012_Ribbon.rb | 4 +- .../010_Data/002_PBS data/014_TrainerType.rb | 2 +- .../010_Data/002_PBS data/015_Trainer.rb | 4 +- .../010_Data/002_PBS data/016_Metadata.rb | 2 +- .../010_Data/002_PBS data/018_MapMetadata.rb | 2 +- .../003_Battle_ExpAndMoveLearning.rb | 4 +- .../004_Battle_ActionAttacksPriority.rb | 4 +- .../001_Battle/005_Battle_ActionSwitching.rb | 4 +- .../001_Battle/009_Battle_CommandPhase.rb | 8 +- .../001_Battle/010_Battle_AttackPhase.rb | 6 +- .../001_Battle/011_Battle_EndOfRoundPhase.rb | 48 ++-- .../002_Battler/006_Battler_AbilityAndItem.rb | 4 +- .../002_Battler/007_Battler_UseMove.rb | 20 +- .../011_Battle/003_Move/002_Move_Usage.rb | 4 +- .../003_Move/003_Move_UsageCalculations.rb | 12 +- .../003_Move/004_Move_BaseEffects.rb | 6 +- .../008_MoveEffects_MoveAttributes.rb | 8 +- .../011_Battle/004_Scene/001_Battle_Scene.rb | 3 +- .../004_Scene/003_Scene_ChooseCommands.rb | 16 +- .../004_Scene/004_Scene_PlayAnimations.rb | 8 +- .../007_Battle_Scene_BaseAnimation.rb | 44 ++-- .../004_Scene/008_Battle_Scene_Animations.rb | 16 +- .../005_Battle_CatchAndStoreMixin.rb | 8 +- .../008_Battle_AbilityEffects.rb | 20 +- .../009_Battle_ItemEffects.rb | 12 +- .../004_BattleArenaBattle.rb | 28 +- Data/Scripts/012_Overworld/001_Overworld.rb | 112 ++++---- .../001_Overworld_BattleStarting.rb | 16 +- .../012_Overworld/004_Overworld_FieldMoves.rb | 47 ++-- .../012_Overworld/005_Overworld_Fishing.rb | 16 +- .../006_Overworld_BerryPlants.rb | 8 +- .../012_Overworld/007_Overworld_DayCare.rb | 4 +- .../008_Overworld_RandomDungeons.rb | 32 +-- Data/Scripts/013_Items/001_Item_Utilities.rb | 28 +- Data/Scripts/013_Items/002_Item_Effects.rb | 96 ++++--- Data/Scripts/013_Items/004_Item_Phone.rb | 29 +-- .../001_Pokemon-related/001_FormHandlers.rb | 4 +- .../002_ShadowPokemon_Other.rb | 37 ++- .../001_Pokemon-related/004_PokemonStorage.rb | 4 +- Data/Scripts/014_Pokemon/001_Pokemon.rb | 24 +- .../002_Trainer_LoadAndNew.rb | 2 +- .../005_Player_Pokedex.rb | 14 +- .../003_UI_EggHatching.rb | 12 +- .../004_UI_Evolution.rb | 4 +- .../001_Non-interactive UI/005_UI_Trading.rb | 8 +- Data/Scripts/016_UI/001_UI_PauseMenu.rb | 40 +-- Data/Scripts/016_UI/002_UI_Pokedex_Menu.rb | 4 +- Data/Scripts/016_UI/003_UI_Pokedex_Main.rb | 59 ++--- Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb | 14 +- Data/Scripts/016_UI/005_UI_Party.rb | 52 ++-- Data/Scripts/016_UI/006_UI_Summary.rb | 30 +-- Data/Scripts/016_UI/007_UI_Bag.rb | 12 +- Data/Scripts/016_UI/008_UI_Pokegear.rb | 12 +- Data/Scripts/016_UI/009_UI_RegionMap.rb | 8 +- Data/Scripts/016_UI/010_UI_Phone.rb | 4 +- Data/Scripts/016_UI/011_UI_Jukebox.rb | 4 +- Data/Scripts/016_UI/015_UI_Options.rb | 8 +- Data/Scripts/016_UI/016_UI_ReadyMenu.rb | 4 +- Data/Scripts/016_UI/017_UI_PokemonStorage.rb | 40 +-- Data/Scripts/016_UI/018_UI_ItemStorage.rb | 4 +- Data/Scripts/016_UI/019_UI_PC.rb | 32 +-- Data/Scripts/016_UI/020_UI_PokeMart.rb | 6 +- Data/Scripts/016_UI/021_UI_BattlePointShop.rb | 6 +- Data/Scripts/016_UI/022_UI_MoveRelearner.rb | 8 +- Data/Scripts/016_UI/023_UI_PurifyChamber.rb | 76 +++--- Data/Scripts/016_UI/024_UI_MysteryGift.rb | 12 +- Data/Scripts/016_UI/025_UI_TextEntry.rb | 20 +- .../017_Minigames/001_Minigame_Duel.rb | 186 +++++++------- .../017_Minigames/002_Minigame_TripleTriad.rb | 72 ++---- .../017_Minigames/003_Minigame_SlotMachine.rb | 4 +- .../017_Minigames/004_Minigame_VoltorbFlip.rb | 8 +- .../017_Minigames/005_Minigame_Lottery.rb | 4 +- .../017_Minigames/006_Minigame_Mining.rb | 4 +- .../017_Minigames/007_Minigame_TilePuzzles.rb | 4 +- .../001_Challenge_BattleChallenge.rb | 51 ++-- .../001_Battle Frontier/002_Challenge_Data.rb | 22 +- .../003_Challenge_ChooseFoes.rb | 2 +- .../004_Challenge_Battles.rb | 26 +- .../001_Battle Frontier/005_UI_BattleSwap.rb | 4 +- .../001_SafariZone.rb | 12 +- .../001_Challenge_ChallengeRules.rb | 4 +- .../002_Challenge_Rulesets.rb | 8 +- .../004_Challenge_LevelAdjustment.rb | 30 +-- .../002_BugContest.rb | 12 +- .../001_ChallengeGenerator_Data.rb | 34 ++- .../002_ChallengeGenerator_Pokemon.rb | 8 +- .../003_ChallengeGenerator_Trainers.rb | 8 +- .../004_ChallengeGenerator_BattleSim.rb | 6 +- Data/Scripts/019_Utilities/001_Utilities.rb | 129 +++++----- .../019_Utilities/002_Utilities_Pokemon.rb | 12 +- .../003_Utilities_BattleAudio.rb | 12 +- .../001_Editor screens/001_EditorScreens.rb | 16 +- .../002_EditorScreens_TerrainTags.rb | 4 +- .../003_EditorScreens_MapConnections.rb | 8 +- .../Scripts/020_Debug/001_Editor_Utilities.rb | 16 +- .../001_AnimEditor_SceneElements.rb | 11 +- .../002_AnimEditor_ControlsButtons.rb | 28 +- .../003_AnimEditor_Interpolation.rb | 38 +-- .../004_AnimEditor_ExportImport.rb | 8 +- .../005_AnimEditor_Functions.rb | 50 ++-- .../Scripts/020_Debug/002_Editor_DataTypes.rb | 4 +- .../003_Debug menus/002_Debug_MenuCommands.rb | 30 +-- .../003_Debug_MenuExtraCode.rb | 36 ++- .../005_Debug_BattlePkmnCommands.rb | 1 - .../008_Debug_FilenameUpdater.rb | 4 +- Data/Scripts/020_Debug/003_Editor_Listers.rb | 27 +- Data/Scripts/021_Compiler/001_Compiler.rb | 61 ++--- .../021_Compiler/002_Compiler_CompilePBS.rb | 160 ++++++------ .../021_Compiler/003_Compiler_WritePBS.rb | 64 ++--- .../004_Compiler_MapsAndEvents.rb | 63 +++-- 159 files changed, 1679 insertions(+), 1931 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9ad1f5ac4..516658de1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -63,6 +63,24 @@ Naming/ClassAndModuleCamelCase: Naming/FileName: Enabled: false +# Disabled for sanity's sake. While this is a cop we want to obey, fixing all +# this is a gargantuan task that may never be completed, and we don't need +# rubocop telling us about the 4000+ instances of camelCase method names. +Naming/MethodName: + Enabled: false + +# Disabled for sanity's sake. While this is a cop we want to obey, fixing all +# this is a gargantuan task that may never be completed, and we don't need +# rubocop telling us about the 1500+ instances of camelCase parameter names. +Naming/MethodParameterName: + Enabled: false + +# Disabled for sanity's sake. While this is a cop we want to obey, fixing all +# this is a gargantuan task that may never be completed, and we don't need +# rubocop telling us about the 10000+ instances of camelCase variable names. +Naming/VariableName: + Enabled: false + #=============================================================================== # Security #=============================================================================== @@ -85,13 +103,21 @@ Style/AccessorGrouping: # The assign_to_condition style looks awful, indenting loads of lines and # increasing the separation between variable and value being assigned to it. +# Having said that, using "assign_inside_condition" flags every instance of +# conditional assignment using a one-line ternary operator, so this cop has been +# disabled because such assignment is fine. Style/ConditionalAssignment: + Enabled: false EnforcedStyle: assign_inside_condition # Check with yard instead. Style/Documentation: Enabled: false +# This is just shorthand that looks bad due to the lack of an "end" to a "def". +Style/EndlessMethod: + EnforcedStyle: disallow + # It's a choice between format and sprintf. We already make use of sprintf and # the translatable _ISPRINTF, so... Style/FormatString: @@ -110,6 +136,11 @@ Style/GlobalVars: Style/HashSyntax: EnforcedStyle: no_mixed_keys +# Sometimes you want to clearly separate sets of code, one per "paradigm". +Style/IfInsideElse: + Enabled: false + AllowIfModifier: true + # The alernative is ->(x) { x } which is less English than "lambda". This style # makes lambda definitions require the word "lambda". Style/Lambda: diff --git a/Data/Scripts/001_Technical/002_Files/001_FileTests.rb b/Data/Scripts/001_Technical/002_Files/001_FileTests.rb index e657e22c9..2ad061d9a 100644 --- a/Data/Scripts/001_Technical/002_Files/001_FileTests.rb +++ b/Data/Scripts/001_Technical/002_Files/001_FileTests.rb @@ -45,7 +45,7 @@ class Dir # get path tree dirs = path.split("/") full = "" - for dir in dirs + dirs.each do |dir| full += dir + "/" # creates directories self.mkdir(full) if !self.safe?(full) @@ -56,7 +56,7 @@ class Dir def self.all_dirs(dir) # sets variables for starting dirs = [] - for file in self.get(dir, "*", true) + self.get(dir, "*", true).each do |file| # engages in recursion to read the entire folder tree dirs += self.all_dirs(file) if self.safe?(file) end @@ -86,7 +86,6 @@ class File # Checks for existing .rxdata file def self.safeData?(file) - ret = false ret = (load_data(file) ? true : false) rescue false return ret end @@ -121,10 +120,10 @@ def safeGlob(dir, wildcard) ret = [] afterChdir = false begin - Dir.chdir(dir) { + Dir.chdir(dir) do afterChdir = true Dir.glob(wildcard) { |f| ret.push(dir + "/" + f) } - } + end rescue Errno::ENOENT raise if afterChdir end @@ -152,13 +151,13 @@ def pbResolveBitmap(x) # filename = pbTryString(path) if !filename # filename = pbTryString(path + ".gif") if !filename # } - RTP.eachPathFor(noext) { |path| + RTP.eachPathFor(noext) do |path| filename = pbTryString(path + ".png") if !filename filename = pbTryString(path + ".gif") if !filename # filename = pbTryString(path + ".jpg") if !filename # filename = pbTryString(path + ".jpeg") if !filename # filename = pbTryString(path + ".bmp") if !filename - } + end return filename end @@ -211,12 +210,12 @@ module RTP def self.exists?(filename, extensions = []) return false if nil_or_empty?(filename) - eachPathFor(filename) { |path| + eachPathFor(filename) do |path| return true if safeExists?(path) extensions.each do |ext| return true if safeExists?(path + ext) end - } + end return false end @@ -230,13 +229,13 @@ module RTP def self.getPath(filename, extensions = []) return filename if nil_or_empty?(filename) - eachPathFor(filename) { |path| + eachPathFor(filename) do |path| return path if safeExists?(path) extensions.each do |ext| file = path + ext return file if safeExists?(file) end - } + end return filename end @@ -248,13 +247,13 @@ module RTP yield filename else # relative path - RTP.eachPath { |path| + RTP.eachPath do |path| if path == "./" yield filename else yield path + filename end - } + end end end @@ -308,7 +307,7 @@ end # NOTE: pbGetFileChar checks anything added in MKXP's RTP setting, and matching # mount points added through System.mount. def pbRgssExists?(filename) - return pbGetFileChar(filename) != nil if safeExists?("./Game.rgssad") + return !pbGetFileChar(filename).nil? if safeExists?("./Game.rgssad") filename = canonicalize(filename) return safeExists?(filename) end diff --git a/Data/Scripts/001_Technical/002_Files/002_FileMixins.rb b/Data/Scripts/001_Technical/002_Files/002_FileMixins.rb index 79f525993..f283c811f 100644 --- a/Data/Scripts/001_Technical/002_Files/002_FileMixins.rb +++ b/Data/Scripts/001_Technical/002_Files/002_FileMixins.rb @@ -109,22 +109,21 @@ module FileOutputMixin end class File < IO -=begin - unless defined?(debugopen) - class << self - alias debugopen open - end - end +# unless defined?(debugopen) +# class << self +# alias debugopen open +# end +# end + +# def open(f, m = "r") +# debugopen("debug.txt", "ab") { |file| file.write([f, m, Time.now.to_f].inspect + "\r\n") } +# if block_given? +# debugopen(f, m) { |file| yield file } +# else +# return debugopen(f, m) +# end +# end - def open(f, m = "r") - debugopen("debug.txt", "ab") { |file| file.write([f, m, Time.now.to_f].inspect + "\r\n") } - if block_given? - debugopen(f, m) { |file| yield file } - else - return debugopen(f, m) - end - end -=end include FileInputMixin include FileOutputMixin end diff --git a/Data/Scripts/001_Technical/002_Files/003_HTTP_Utilities.rb b/Data/Scripts/001_Technical/002_Files/003_HTTP_Utilities.rb index d989107a0..a402f79f5 100644 --- a/Data/Scripts/001_Technical/002_Files/003_HTTP_Utilities.rb +++ b/Data/Scripts/001_Technical/002_Files/003_HTTP_Utilities.rb @@ -9,13 +9,13 @@ def pbPostData(url, postdata, filename = nil, depth = 0) # path = $2 # 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" - body = postdata.map { |key, value| + body = postdata.map do |key, value| keyString = key.to_s valueString = value.to_s keyString.gsub!(/[^a-zA-Z0-9_\.\-]/n) { |s| sprintf("%%%02x", s[0]) } valueString.gsub!(/[^a-zA-Z0-9_\.\-]/n) { |s| sprintf("%%%02x", s[0]) } next "#{keyString}=#{valueString}" - }.join("&") + end.join("&") ret = HTTPLite.post_body( url, body, diff --git a/Data/Scripts/001_Technical/002_RubyUtilities.rb b/Data/Scripts/001_Technical/002_RubyUtilities.rb index 8d9a911f2..4570a2ccf 100644 --- a/Data/Scripts/001_Technical/002_RubyUtilities.rb +++ b/Data/Scripts/001_Technical/002_RubyUtilities.rb @@ -169,23 +169,25 @@ class Color # New constructor, accepts RGB values as well as a hex number or string value. def initialize(*args) pbPrintException("Wrong number of arguments! At least 1 is needed!") if args.length < 1 - if args.length == 1 - if args.first.is_a?(Fixnum) + case args.length + when 1 + case args.first + when Integer hex = args.first.to_s(16) - elsif args.first.is_a?(String) + when String try_rgb_format = args.first.split(",") - return init_original(*try_rgb_format.map(&:to_i)) if try_rgb_format.length.between?(3, 4) + init_original(*try_rgb_format.map(&:to_i)) if try_rgb_format.length.between?(3, 4) hex = args.first.delete("#") end pbPrintException("Wrong type of argument given!") if !hex r = hex[0...2].to_i(16) g = hex[2...4].to_i(16) b = hex[4...6].to_i(16) - elsif args.length == 3 + when 3 r, g, b = *args end - return init_original(r, g, b) if r && g && b - return init_original(*args) + init_original(r, g, b) if r && g && b + init_original(*args) end def self.new_from_rgb(param) @@ -242,7 +244,9 @@ class Color # @return [String] this color in the format "RRGGBBAA" (or "RRGGBB" if this color's alpha is 255) def to_rgb32(always_include_alpha = false) - return sprintf("%02X%02X%02X", self.red.to_i, self.green.to_i, self.blue.to_i) if self.alpha.to_i == 255 && !always_include_alpha + if self.alpha.to_i == 255 && !always_include_alpha + return sprintf("%02X%02X%02X", self.red.to_i, self.green.to_i, self.blue.to_i) + end return sprintf("%02X%02X%02X%02X", self.red.to_i, self.green.to_i, self.blue.to_i, self.alpha.to_i) end diff --git a/Data/Scripts/001_Technical/003_Intl_Messages.rb b/Data/Scripts/001_Technical/003_Intl_Messages.rb index 0dceb744b..f5e552b36 100644 --- a/Data/Scripts/001_Technical/003_Intl_Messages.rb +++ b/Data/Scripts/001_Technical/003_Intl_Messages.rb @@ -45,7 +45,7 @@ module Translator end end end - MessageTypes.addMessagesAsHash(MessageTypes::ScriptTexts, texts) + MessageTypes.addMessagesAsHash(MessageTypes::SCRIPT_TEXTS, texts) # Find all text in common events and add them to messages commonevents = load_data("Data/CommonEvents.rxdata") items = [] @@ -87,7 +87,7 @@ module Translator elsif list.code == 209 # Set Move Route route = list.parameters[1] route.list.size.times do |k| - if route.list[k].code == PBMoveRoute::Script + if route.list[k].code == PBMoveRoute::SCRIPT find_translatable_text_from_event_script(items, route.list[k].parameters[0]) end end @@ -157,7 +157,7 @@ module Translator elsif list.code == 209 # Set Move Route route = list.parameters[1] route.list.size.times do |k| - if route.list[k].code == PBMoveRoute::Script + if route.list[k].code == PBMoveRoute::SCRIPT find_translatable_text_from_event_script(items, route.list[k].parameters[0]) end end @@ -190,7 +190,7 @@ module Translator def find_translatable_text_from_RGSS_script(items, script) script.force_encoding(Encoding::UTF_8) - script.scan(/(?:_INTL|_ISPRINTF)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) { |s| + script.scan(/(?:_INTL|_ISPRINTF)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) do |s| string = s[0] string.gsub!(/\\r/, "\r") string.gsub!(/\\n/, "\n") @@ -198,17 +198,17 @@ module Translator string.gsub!(/\\\"/, "\"") string.gsub!(/\\\\/, "\\") items.push(string) - } + end end def find_translatable_text_from_event_script(items, script) script.force_encoding(Encoding::UTF_8) - script.scan(/(?:_I)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) { |s| + script.scan(/(?:_I)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) do |s| string = s[0] string.gsub!(/\\\"/, "\"") string.gsub!(/\\\\/, "\\") items.push(string) - } + end end def normalize_value(value) @@ -239,7 +239,7 @@ module Translator return value end - #============================================================================= + #----------------------------------------------------------------------------- def extract_text(language_name = "default", core_text = false, separate_map_files = false) dir_name = sprintf("Text_%s_%s", language_name, (core_text) ? "core" : "game") @@ -296,18 +296,18 @@ module Translator max_section_id.times do |i| section_name = getConstantName(MessageTypes, i, false) next if !section_name - if i == MessageTypes::EventTexts + if i == MessageTypes::EVENT_TEXTS if separate_map_files map_infos = pbLoadMapInfos default_messages[i].each_with_index do |map_msgs, map_id| next if !map_msgs || map_msgs.length == 0 filename = sprintf("Map%03d", map_id) filename += " " + map_infos[map_id].name if map_infos[map_id] - File.open(dir_name + "/" + filename + ".txt", "wb") { |f| + File.open(dir_name + "/" + filename + ".txt", "wb") do |f| write_header.call(f, true) translated_msgs = language_messages[i][map_id] if language_messages && language_messages[i] write_section_texts_to_file(f, sprintf("Map%03d", map_id), translated_msgs, map_msgs) - } + end end else next if !default_messages[i] || default_messages[i].length == 0 @@ -317,7 +317,7 @@ module Translator break if !map_msgs end next if no_difference - File.open(dir_name + "/" + section_name + ".txt", "wb") { |f| + File.open(dir_name + "/" + section_name + ".txt", "wb") do |f| write_header.call(f, false) default_messages[i].each_with_index do |map_msgs, map_id| next if !map_msgs || map_msgs.length == 0 @@ -325,15 +325,15 @@ module Translator translated_msgs = (language_messages && language_messages[i]) ? language_messages[i][map_id] : nil write_section_texts_to_file(f, sprintf("Map%03d", map_id), translated_msgs, map_msgs) end - } + end end else # MessageTypes sections next if !default_messages[i] || default_messages[i].length == 0 - File.open(dir_name + "/" + section_name + ".txt", "wb") { |f| + File.open(dir_name + "/" + section_name + ".txt", "wb") do |f| write_header.call(f, true) translated_msgs = (language_messages) ? language_messages[i] : nil write_section_texts_to_file(f, section_name, translated_msgs, default_messages[i]) - } + end end end msg_window.textspeed = MessageConfig.pbSettingToTextSpeed($PokemonSystem.textspeed) @@ -371,7 +371,7 @@ module Translator end end - #============================================================================= + #----------------------------------------------------------------------------- def compile_text(dir_name, dat_filename) msg_window = pbCreateMessageWindow @@ -452,16 +452,16 @@ module Translator break if i >= contents.length end # Add ordered list/hash (text_hash) to array of all text (all_text) - all_text[MessageTypes::EventTexts] = [] if is_map && !all_text[MessageTypes::EventTexts] - target_section = (is_map) ? all_text[MessageTypes::EventTexts][section_id] : all_text[section_id] + all_text[MessageTypes::EVENT_TEXTS] = [] if is_map && !all_text[MessageTypes::EVENT_TEXTS] + target_section = (is_map) ? all_text[MessageTypes::EVENT_TEXTS][section_id] : all_text[section_id] if target_section if text_hash.is_a?(Hash) - text_hash.keys.each { |key| target_section[key] = text_hash[key] if text_hash[key] } + text_hash.each_key { |key| target_section[key] = text_hash[key] if text_hash[key] } else # text_hash is an array - text_hash.each_with_index { |line, i| target_section[i] = line if line } + text_hash.each_with_index { |line, j| target_section[j] = line if line } end elsif is_map - all_text[MessageTypes::EventTexts][section_id] = text_hash + all_text[MessageTypes::EVENT_TEXTS][section_id] = text_hash else all_text[section_id] = text_hash end @@ -570,16 +570,16 @@ class Translation def setMapMessagesAsHash(map_id, array) load_default_messages - @default_game_messages[MessageTypes::EventTexts] ||= [] - @default_game_messages[MessageTypes::EventTexts][map_id] = priv_add_to_hash(MessageTypes::EventTexts, + @default_game_messages[MessageTypes::EVENT_TEXTS] ||= [] + @default_game_messages[MessageTypes::EVENT_TEXTS][map_id] = priv_add_to_hash(MessageTypes::EVENT_TEXTS, array, nil, map_id) end def addMapMessagesAsHash(map_id, array) load_default_messages - @default_game_messages[MessageTypes::EventTexts] ||= [] - @default_game_messages[MessageTypes::EventTexts][map_id] = priv_add_to_hash(MessageTypes::EventTexts, - array, @default_game_messages[MessageTypes::EventTexts][map_id], map_id) + @default_game_messages[MessageTypes::EVENT_TEXTS] ||= [] + @default_game_messages[MessageTypes::EVENT_TEXTS][map_id] = priv_add_to_hash(MessageTypes::EVENT_TEXTS, + array, @default_game_messages[MessageTypes::EVENT_TEXTS][map_id], map_id) end def get(type, id) @@ -610,23 +610,25 @@ class Translation delayed_load_message_files key = Translation.stringToKey(text) return text if nil_or_empty?(key) - if @game_messages && @game_messages[MessageTypes::EventTexts] - if @game_messages[MessageTypes::EventTexts][map_id] && @game_messages[MessageTypes::EventTexts][map_id][key] - return @game_messages[MessageTypes::EventTexts][map_id][key] - elsif @game_messages[MessageTypes::EventTexts][0] && @game_messages[MessageTypes::EventTexts][0][key] - return @game_messages[MessageTypes::EventTexts][0][key] + if @game_messages && @game_messages[MessageTypes::EVENT_TEXTS] + if @game_messages[MessageTypes::EVENT_TEXTS][map_id] && @game_messages[MessageTypes::EVENT_TEXTS][map_id][key] + return @game_messages[MessageTypes::EVENT_TEXTS][map_id][key] + elsif @game_messages[MessageTypes::EVENT_TEXTS][0] && @game_messages[MessageTypes::EVENT_TEXTS][0][key] + return @game_messages[MessageTypes::EVENT_TEXTS][0][key] end end - if @core_messages && @core_messages[MessageTypes::EventTexts] - if @core_messages[MessageTypes::EventTexts][map_id] && @core_messages[MessageTypes::EventTexts][map_id][key] - return @core_messages[MessageTypes::EventTexts][map_id][key] - elsif @core_messages[MessageTypes::EventTexts][0] && @core_messages[MessageTypes::EventTexts][0][key] - return @core_messages[MessageTypes::EventTexts][0][key] + if @core_messages && @core_messages[MessageTypes::EVENT_TEXTS] + if @core_messages[MessageTypes::EVENT_TEXTS][map_id] && @core_messages[MessageTypes::EVENT_TEXTS][map_id][key] + return @core_messages[MessageTypes::EVENT_TEXTS][map_id][key] + elsif @core_messages[MessageTypes::EVENT_TEXTS][0] && @core_messages[MessageTypes::EVENT_TEXTS][0][key] + return @core_messages[MessageTypes::EVENT_TEXTS][0][key] end end return text end + #----------------------------------------------------------------------------- + private def delayed_load_message_files @@ -645,7 +647,7 @@ class Translation end def priv_add_to_hash(type, array, ret, map_id = 0) - if type == MessageTypes::EventTexts + if type == MessageTypes::EVENT_TEXTS @default_core_messages[type] ||= [] @default_core_messages[type][map_id] ||= {} default_keys = @default_core_messages[type][map_id].keys @@ -670,36 +672,36 @@ module MessageTypes # NOTE: These constants aren't numbered in any particular order, but these # numbers are retained for backwards compatibility with older extracted # text files. - EventTexts = 0 # Used for text in both common events and map events - Species = 1 - SpeciesCategories = 2 - PokedexEntries = 3 - SpeciesForms = 4 - Moves = 5 - MoveDescriptions = 6 - Items = 7 - ItemPlurals = 8 - ItemDescriptions = 9 - Abilities = 10 - AbilityDescriptions = 11 - Types = 12 - TrainerTypes = 13 - TrainerNames = 14 - FrontierIntroSpeeches = 15 - FrontierEndSpeechesWin = 16 - FrontierEndSpeechesLose = 17 - Regions = 18 - RegionLocations = 19 - RegionDescriptions = 20 - MapNames = 21 - PhoneMessages = 22 - TrainerLoseTexts = 23 - ScriptTexts = 24 - RibbonNames = 25 - RibbonDescriptions = 26 - StorageCreator = 27 - ItemPortions = 28 - ItemPortionPlurals = 29 + EVENT_TEXTS = 0 # Used for text in both common events and map events + SPECIES_NAMES = 1 + SPECIES_CATEGORIES = 2 + POKEDEX_ENTRIES = 3 + SPECIES_FORM_NAMES = 4 + MOVE_NAMES = 5 + MOVE_DESCRIPTIONS = 6 + ITEM_NAMES = 7 + ITEM_NAME_PLURALS = 8 + ITEM_DESCRIPTIONS = 9 + ABILITY_NAMES = 10 + ABILITY_DESCRIPTIONS = 11 + TYPE_NAMES = 12 + TRAINER_TYPE_NAMES = 13 + TRAINER_NAMES = 14 + FRONTIER_INTRO_SPEECHES = 15 + FRONTIER_END_SPEECHES_WIN = 16 + FRONTIER_END_SPEECHES_LOSE = 17 + REGION_NAMES = 18 + REGION_LOCATION_NAMES = 19 + REGION_LOCATION_DESCRIPTIONS = 20 + MAP_NAMES = 21 + PHONE_MESSAGES = 22 + TRAINER_SPEECHES_LOSE = 23 + SCRIPT_TEXTS = 24 + RIBBON_NAMES = 25 + RIBBON_DESCRIPTIONS = 26 + STORAGE_CREATOR_NAME = 27 + ITEM_PORTION_NAMES = 28 + ITEM_PORTION_NAME_PLURALS = 29 @@messages = Translation.new def self.load_default_messages @@ -766,7 +768,7 @@ end # parameters by replacing {1}, {2}, etc. with those placeholders. def _INTL(*arg) begin - string = MessageTypes.getFromHash(MessageTypes::ScriptTexts, arg[0]) + string = MessageTypes.getFromHash(MessageTypes::SCRIPT_TEXTS, arg[0]) rescue string = arg[0] end @@ -782,15 +784,13 @@ end # This version acts more like sprintf, supports e.g. {1:d} or {2:s} def _ISPRINTF(*arg) begin - string = MessageTypes.getFromHash(MessageTypes::ScriptTexts, arg[0]) + string = MessageTypes.getFromHash(MessageTypes::SCRIPT_TEXTS, arg[0]) rescue string = arg[0] end string = string.clone (1...arg.length).each do |i| - string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| - next sprintf("%" + $1, arg[i]) - } + string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| next sprintf("%" + $1, arg[i]) } end return string end @@ -812,9 +812,7 @@ def _MAPISPRINTF(mapid, *arg) string = MessageTypes.getFromMapHash(mapid, arg[0]) string = string.clone (1...arg.length).each do |i| - string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| - next sprintf("%" + $1, arg[i]) - } + string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| next sprintf("%" + $1, arg[i]) } end return string end diff --git a/Data/Scripts/001_Technical/004_Input.rb b/Data/Scripts/001_Technical/004_Input.rb index a86ea1cc3..87a162343 100644 --- a/Data/Scripts/001_Technical/004_Input.rb +++ b/Data/Scripts/001_Technical/004_Input.rb @@ -16,9 +16,7 @@ module Input def self.update update_KGC_ScreenCapture - if trigger?(Input::F8) - pbScreenCapture - end + pbScreenCapture if trigger?(Input::F8) end end diff --git a/Data/Scripts/001_Technical/005_PluginManager.rb b/Data/Scripts/001_Technical/005_PluginManager.rb index 5852c390e..0a616989f 100644 --- a/Data/Scripts/001_Technical/005_PluginManager.rb +++ b/Data/Scripts/001_Technical/005_PluginManager.rb @@ -136,9 +136,7 @@ module PluginManager end name = value when :version # Plugin version - if nil_or_empty?(value) - self.error("Plugin version must be a string.") - end + self.error("Plugin version must be a string.") if nil_or_empty?(value) version = value when :essentials essentials = value @@ -412,7 +410,7 @@ module PluginManager filename = "#{dir}/#{file}" meta = {} # read file - Compiler.pbCompilerEachPreppedLine(filename) { |line, line_no| + Compiler.pbCompilerEachPreppedLine(filename) do |line, line_no| # split line up into property name and values if !line[/^\s*(\w+)\s*=\s*(.*)$/] raise _INTL("Bad line syntax (expected syntax like XXX=YYY)\r\n{1}", FileLineData.linereport) @@ -456,7 +454,7 @@ module PluginManager else meta[property.downcase.to_sym] = data[0] end - } + end # generate a list of all script files to be loaded, in the order they are to # be loaded (files listed in the meta file are loaded first) meta[:scripts] = [] if !meta[:scripts] diff --git a/Data/Scripts/001_Technical/006_RPG_Sprite.rb b/Data/Scripts/001_Technical/006_RPG_Sprite.rb index edfd0dd64..932b60408 100644 --- a/Data/Scripts/001_Technical/006_RPG_Sprite.rb +++ b/Data/Scripts/001_Technical/006_RPG_Sprite.rb @@ -56,9 +56,7 @@ class SpriteAnimation sprite.visible = false @_animation_sprites.push(sprite) end - unless @@_animations.include?(animation) - @@_animations.push(animation) - end + @@_animations.push(animation) unless @@_animations.include?(animation) end update_animation end @@ -97,13 +95,9 @@ class SpriteAnimation sprite = @_animation_sprites[0] if sprite @@_reference_count[sprite.bitmap] -= 1 - if @@_reference_count[sprite.bitmap] == 0 - sprite.bitmap.dispose - end - end - @_animation_sprites.each do |sprite| - sprite.dispose + sprite.bitmap.dispose if @@_reference_count[sprite.bitmap] == 0 end + @_animation_sprites.each { |s| s.dispose } @_animation_sprites = nil @_animation = nil end @@ -113,13 +107,9 @@ class SpriteAnimation sprite = @_loop_animation_sprites[0] if sprite @@_reference_count[sprite.bitmap] -= 1 - if @@_reference_count[sprite.bitmap] == 0 - sprite.bitmap.dispose - end - end - @_loop_animation_sprites.each do |sprite| - sprite.dispose + sprite.bitmap.dispose if @@_reference_count[sprite.bitmap] == 0 end + @_loop_animation_sprites.each { |s| s.dispose } @_loop_animation_sprites = nil @_loop_animation = nil end @@ -469,9 +459,7 @@ module RPG @_damage_sprite.y += 4 end @_damage_sprite.opacity = 256 - ((12 - @_damage_duration) * 32) - if @_damage_duration == 0 - dispose_damage - end + dispose_damage if @_damage_duration == 0 end @animations.each do |a| a.update diff --git a/Data/Scripts/002_Save data/002_SaveData_Value.rb b/Data/Scripts/002_Save data/002_SaveData_Value.rb index 8871a878a..e4391327e 100644 --- a/Data/Scripts/002_Save data/002_SaveData_Value.rb +++ b/Data/Scripts/002_Save data/002_SaveData_Value.rb @@ -99,6 +99,8 @@ module SaveData return @old_format_get_proc.call(old_format) end + #--------------------------------------------------------------------------- + private # Raises an {InvalidValueError} if the given value is invalid. diff --git a/Data/Scripts/002_Save data/003_SaveData_Conversion.rb b/Data/Scripts/002_Save data/003_SaveData_Conversion.rb index 40a6e70c0..73a0431ab 100644 --- a/Data/Scripts/002_Save data/003_SaveData_Conversion.rb +++ b/Data/Scripts/002_Save data/003_SaveData_Conversion.rb @@ -71,6 +71,8 @@ module SaveData @value_procs[key].call(object) if @value_procs[key].is_a?(Proc) end + #--------------------------------------------------------------------------- + private # @!group Configuration diff --git a/Data/Scripts/002_Save data/004_Game_SaveValues.rb b/Data/Scripts/002_Save data/004_Game_SaveValues.rb index 856c00303..0922a453d 100644 --- a/Data/Scripts/002_Save data/004_Game_SaveValues.rb +++ b/Data/Scripts/002_Save data/004_Game_SaveValues.rb @@ -4,11 +4,7 @@ SaveData.register(:player) do ensure_class :Player save_value { $player } load_value { |value| $player = $Trainer = value } - new_game_value { - # Get the first defined trainer type as a placeholder - trainer_type = GameData::TrainerType.keys.first - Player.new("Unnamed", trainer_type) - } + new_game_value { Player.new("Unnamed", GameData::TrainerType.keys.first) } from_old_format { |old_format| old_format[0] } end diff --git a/Data/Scripts/003_Game processing/001_StartGame.rb b/Data/Scripts/003_Game processing/001_StartGame.rb index 05f51a011..2d7aa1496 100644 --- a/Data/Scripts/003_Game processing/001_StartGame.rb +++ b/Data/Scripts/003_Game processing/001_StartGame.rb @@ -75,9 +75,7 @@ module Game $game_map = $map_factory.map magic_number_matches = ($game_system.magic_number == $data_system.magic_number) if !magic_number_matches || $PokemonGlobal.safesave - if pbMapInterpreterRunning? - pbMapInterpreter.setup(nil, 0) - end + pbMapInterpreter.setup(nil, 0) if pbMapInterpreterRunning? begin $map_factory.setup($game_map.map_id) rescue Errno::ENOENT diff --git a/Data/Scripts/003_Game processing/002_Scene_Map.rb b/Data/Scripts/003_Game processing/002_Scene_Map.rb index ad261d02e..eedb8d0d3 100644 --- a/Data/Scripts/003_Game processing/002_Scene_Map.rb +++ b/Data/Scripts/003_Game processing/002_Scene_Map.rb @@ -197,9 +197,7 @@ class Scene_Map $game_temp.menu_beep = true end elsif Input.trigger?(Input::SPECIAL) - unless $game_player.moving? - $game_temp.ready_menu_calling = true - end + $game_temp.ready_menu_calling = true if !$game_player.moving? elsif Input.press?(Input::F9) $game_temp.debug_calling = true if $DEBUG end diff --git a/Data/Scripts/003_Game processing/003_Interpreter.rb b/Data/Scripts/003_Game processing/003_Interpreter.rb index 07858f00e..890c74651 100644 --- a/Data/Scripts/003_Game processing/003_Interpreter.rb +++ b/Data/Scripts/003_Game processing/003_Interpreter.rb @@ -143,13 +143,13 @@ class Interpreter message = pbGetExceptionMessage(e) backtrace_text = "" if e.is_a?(SyntaxError) - script.each_line { |line| + script.each_line do |line| line.gsub!(/\s+$/, "") if line[/^\s*\(/] message += "\r\n***Line '#{line}' shouldn't begin with '('. Try putting the '('\r\n" message += "at the end of the previous line instead, or using 'extendtext.exe'." end - } + end else backtrace_text += "\r\n" backtrace_text += "Backtrace:" diff --git a/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb b/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb index 923611962..03b1c054b 100644 --- a/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb +++ b/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb @@ -1081,14 +1081,14 @@ class Interpreter end if $game_actors && $data_actors && $data_actors[@parameters[0]] $game_temp.battle_abort = true - pbFadeOutIn { + pbFadeOutIn do sscene = PokemonEntryScene.new sscreen = PokemonEntry.new(sscene) $game_actors[@parameters[0]].name = sscreen.pbStartScreen( _INTL("Enter {1}'s name.", $game_actors[@parameters[0]].name), 1, @parameters[1], $game_actors[@parameters[0]].name ) - } + end end return true end diff --git a/Data/Scripts/004_Game classes/001_Game_Screen.rb b/Data/Scripts/004_Game classes/001_Game_Screen.rb index 641644a22..20fb1e485 100644 --- a/Data/Scripts/004_Game classes/001_Game_Screen.rb +++ b/Data/Scripts/004_Game classes/001_Game_Screen.rb @@ -40,9 +40,7 @@ class Game_Screen def start_tone_change(tone, duration) @tone_target = tone.clone @tone_duration = duration - if @tone_duration == 0 - @tone = @tone_target.clone - end + @tone = @tone_target.clone if @tone_duration == 0 end def start_flash(color, duration) diff --git a/Data/Scripts/004_Game classes/003_Game_Picture.rb b/Data/Scripts/004_Game classes/003_Game_Picture.rb index eda83d545..721cac8f1 100644 --- a/Data/Scripts/004_Game classes/003_Game_Picture.rb +++ b/Data/Scripts/004_Game classes/003_Game_Picture.rb @@ -103,9 +103,7 @@ class Game_Picture def start_tone_change(tone, duration) @tone_target = tone.clone @tone_duration = duration - if @tone_duration == 0 - @tone = @tone_target.clone - end + @tone = @tone_target.clone if @tone_duration == 0 end # Erase Picture diff --git a/Data/Scripts/004_Game classes/004_Game_Map.rb b/Data/Scripts/004_Game classes/004_Game_Map.rb index 304bc61ab..0cd19eb24 100644 --- a/Data/Scripts/004_Game classes/004_Game_Map.rb +++ b/Data/Scripts/004_Game classes/004_Game_Map.rb @@ -371,17 +371,13 @@ class Game_Map def start_fog_tone_change(tone, duration) @fog_tone_target = tone.clone @fog_tone_duration = duration - if @fog_tone_duration == 0 - @fog_tone = @fog_tone_target.clone - end + @fog_tone = @fog_tone_target.clone if @fog_tone_duration == 0 end def start_fog_opacity_change(opacity, duration) @fog_opacity_target = opacity.to_f @fog_opacity_duration = duration - if @fog_opacity_duration == 0 - @fog_opacity = @fog_opacity_target - end + @fog_opacity = @fog_opacity_target if @fog_opacity_duration == 0 end def set_tile(x, y, layer, id = 0) diff --git a/Data/Scripts/004_Game classes/005_Game_Map_Autoscroll.rb b/Data/Scripts/004_Game classes/005_Game_Map_Autoscroll.rb index a1c274945..0d89a53ad 100644 --- a/Data/Scripts/004_Game classes/005_Game_Map_Autoscroll.rb +++ b/Data/Scripts/004_Game classes/005_Game_Map_Autoscroll.rb @@ -5,69 +5,68 @@ # Version 1.02 # 2005-12-18 #=============================================================================== -=begin - - This script supplements the built-in "Scroll Map" event command with the - aim of simplifying cutscenes (and map scrolling in general). Whereas the - normal event command requires a direction and number of tiles to scroll, - Map Autoscroll scrolls the map to center on the tile whose x and y - coordinates are given. - - FEATURES - - automatic map scrolling to given x,y coordinate (or player) - - destination is fixed, so it's possible to scroll to same place even if - origin is variable (e.g. moving NPC) - - variable speed (just like "Scroll Map" event command) - - diagonal scrolling supported - - SETUP - Instead of a "Scroll Map" event command, use the "Call Script" command - and enter on the following on the first line: - - autoscroll(x,y) - - (replacing "x" and "y" with the x and y coordinates of the tile to scroll to) - - To specify a scroll speed other than the default (4), use: - - autoscroll(x,y,speed) - - (now also replacing "speed" with the scroll speed from 1-6) - - Diagonal scrolling happens automatically when the destination is diagonal - relative to the starting point (i.e., not directly up, down, left or right). - - To scroll to the player, instead use the following: - - autoscroll_player(speed) - - Note: because of how the interpreter and the "Call Script" event command - are setup, the call to autoscroll(...) can only be on the first line of - the "Call Script" event command (and not flowing down to subsequent lines). - - For example, the following call may not work as expected: - - autoscroll($game_variables[1], - $game_variables[2]) - - (since the long argument names require dropping down to a second line) - A work-around is to setup new variables with shorter names in a preceding - (separate) "Call Script" event command: - - @x = $game_variables[1] - @y = $game_variables[2] - - and then use those as arguments: - - autoscroll(@x,@y) - - The renaming must be in a separate "Call Script" because otherwise - the call to autoscroll(...) isn't on the first line. - - Originally requested by militantmilo80: - http://www.rmxp.net/forums/index.php?showtopic=29519 - -=end +# +# This script supplements the built-in "Scroll Map" event command with the +# aim of simplifying cutscenes (and map scrolling in general). Whereas the +# normal event command requires a direction and number of tiles to scroll, +# Map Autoscroll scrolls the map to center on the tile whose x and y +# coordinates are given. +# +# FEATURES +# - automatic map scrolling to given x,y coordinate (or player) +# - destination is fixed, so it's possible to scroll to same place even if +# origin is variable (e.g. moving NPC) +# - variable speed (just like "Scroll Map" event command) +# - diagonal scrolling supported +# +# SETUP +# Instead of a "Scroll Map" event command, use the "Call Script" command +# and enter on the following on the first line: +# +# autoscroll(x,y) +# +# (replacing "x" and "y" with the x and y coordinates of the tile to scroll to) +# +# To specify a scroll speed other than the default (4), use: +# +# autoscroll(x,y,speed) +# +# (now also replacing "speed" with the scroll speed from 1-6) +# +# Diagonal scrolling happens automatically when the destination is diagonal +# relative to the starting point (i.e., not directly up, down, left or right). +# +# To scroll to the player, instead use the following: +# +# autoscroll_player(speed) +# +# Note: because of how the interpreter and the "Call Script" event command +# are setup, the call to autoscroll(...) can only be on the first line of +# the "Call Script" event command (and not flowing down to subsequent lines). +# +# For example, the following call may not work as expected: +# +# autoscroll($game_variables[1], +# $game_variables[2]) +# +# (since the long argument names require dropping down to a second line) +# A work-around is to setup new variables with shorter names in a preceding +# (separate) "Call Script" event command: +# +# @x = $game_variables[1] +# @y = $game_variables[2] +# +# and then use those as arguments: +# +# autoscroll(@x,@y) +# +# The renaming must be in a separate "Call Script" because otherwise +# the call to autoscroll(...) isn't on the first line. +# +# Originally requested by militantmilo80: +# http://www.rmxp.net/forums/index.php?showtopic=29519 +# +#=============================================================================== #=============================================================================== # diff --git a/Data/Scripts/004_Game classes/006_Game_MapFactory.rb b/Data/Scripts/004_Game classes/006_Game_MapFactory.rb index d879568db..0657b0f2d 100644 --- a/Data/Scripts/004_Game classes/006_Game_MapFactory.rb +++ b/Data/Scripts/004_Game classes/006_Game_MapFactory.rb @@ -433,9 +433,9 @@ module MapFactoryHelper end def self.mapsConnected?(id1, id2) - MapFactoryHelper.eachConnectionForMap(id1) { |conn| + MapFactoryHelper.eachConnectionForMap(id1) do |conn| return true if conn[0] == id2 || conn[3] == id2 - } + end return false end diff --git a/Data/Scripts/004_Game classes/008_Game_Event.rb b/Data/Scripts/004_Game classes/008_Game_Event.rb index bf9510a10..1f64074f3 100644 --- a/Data/Scripts/004_Game classes/008_Game_Event.rb +++ b/Data/Scripts/004_Game classes/008_Game_Event.rb @@ -237,9 +237,7 @@ class Game_Event < Game_Character @trigger = @page.trigger @list = @page.list @interpreter = nil - if @trigger == 4 # Parallel Process - @interpreter = Interpreter.new - end + @interpreter = Interpreter.new if @trigger == 4 # Parallel Process check_event_trigger_auto end @@ -262,18 +260,14 @@ class Game_Event < Game_Character @moveto_happened = false last_moving = moving? super - if !moving? && last_moving - $game_player.pbCheckEventTriggerFromDistance([2]) - end + $game_player.pbCheckEventTriggerFromDistance([2]) if !moving? && last_moving if @need_refresh @need_refresh = false refresh end check_event_trigger_auto if @interpreter - unless @interpreter.running? - @interpreter.setup(@list, @event.id, @map_id) - end + @interpreter.setup(@list, @event.id, @map_id) if !@interpreter.running? @interpreter.update end end diff --git a/Data/Scripts/004_Game classes/010_Game_CommonEvent.rb b/Data/Scripts/004_Game classes/010_Game_CommonEvent.rb index dfa5e21b8..0cfc66ce4 100644 --- a/Data/Scripts/004_Game classes/010_Game_CommonEvent.rb +++ b/Data/Scripts/004_Game classes/010_Game_CommonEvent.rb @@ -40,9 +40,7 @@ class Game_CommonEvent def refresh # Create an interpreter for parallel process if necessary if self.trigger == 2 && switchIsOn?(self.switch_id) - if @interpreter.nil? - @interpreter = Interpreter.new - end + @interpreter = Interpreter.new if @interpreter.nil? else @interpreter = nil end diff --git a/Data/Scripts/004_Game classes/011_Game_Follower.rb b/Data/Scripts/004_Game classes/011_Game_Follower.rb index 6b209e999..17c3bd899 100644 --- a/Data/Scripts/004_Game classes/011_Game_Follower.rb +++ b/Data/Scripts/004_Game classes/011_Game_Follower.rb @@ -27,7 +27,7 @@ class Game_Follower < Game_Event end end - #============================================================================= + #----------------------------------------------------------------------------- def move_through(direction) old_through = @through @@ -105,7 +105,7 @@ class Game_Follower < Game_Event end end - #============================================================================= + #----------------------------------------------------------------------------- def turn_towards_leader(leader) pbTurnTowardEvent(self, leader) @@ -146,7 +146,7 @@ class Game_Follower < Game_Event end end - #============================================================================= + #----------------------------------------------------------------------------- def update_move was_jumping = jumping? @@ -157,7 +157,7 @@ class Game_Follower < Game_Event end end - #============================================================================= + #----------------------------------------------------------------------------- private diff --git a/Data/Scripts/004_Game classes/012_Game_FollowerFactory.rb b/Data/Scripts/004_Game classes/012_Game_FollowerFactory.rb index 176770a8a..9fcab0f59 100644 --- a/Data/Scripts/004_Game classes/012_Game_FollowerFactory.rb +++ b/Data/Scripts/004_Game classes/012_Game_FollowerFactory.rb @@ -84,7 +84,7 @@ class Game_FollowerFactory @last_update = -1 end - #============================================================================= + #----------------------------------------------------------------------------- def add_follower(event, name = nil, common_event_id = nil) return if !event @@ -150,7 +150,7 @@ class Game_FollowerFactory $PokemonGlobal.followers.each_with_index { |follower, i| yield @events[i], follower } end - #============================================================================= + #----------------------------------------------------------------------------- def turn_followers leader = $game_player @@ -208,11 +208,11 @@ class Game_FollowerFactory vector = $map_factory.getRelativePos(event.map.map_id, event.x, event.y, leader[0], leader[1], leader[2]) if vector[0] != 0 - move_route.prepend((vector[0] > 0) ? PBMoveRoute::Right : PBMoveRoute::Left) + move_route.prepend((vector[0] > 0) ? PBMoveRoute::RIGHT : PBMoveRoute::LEFT) elsif vector[1] != 0 - move_route.prepend((vector[1] > 0) ? PBMoveRoute::Down : PBMoveRoute::Up) + move_route.prepend((vector[1] > 0) ? PBMoveRoute::DOWN : PBMoveRoute::UP) end - pbMoveRoute(event, move_route + [PBMoveRoute::Opacity, 0]) + pbMoveRoute(event, move_route + [PBMoveRoute::OPACITY, 0]) end end @@ -237,7 +237,7 @@ class Game_FollowerFactory end end - #============================================================================= + #----------------------------------------------------------------------------- def update followers = $PokemonGlobal.followers @@ -286,7 +286,7 @@ class Game_FollowerFactory end end - #============================================================================= + #----------------------------------------------------------------------------- private diff --git a/Data/Scripts/005_Sprites/004_Sprite_Reflection.rb b/Data/Scripts/005_Sprites/004_Sprite_Reflection.rb index 8ae3ec550..71f638a2b 100644 --- a/Data/Scripts/005_Sprites/004_Sprite_Reflection.rb +++ b/Data/Scripts/005_Sprites/004_Sprite_Reflection.rb @@ -48,15 +48,15 @@ class Sprite_Reflection # Just-in-time creation of sprite @sprite = Sprite.new(@viewport) if !@sprite if @sprite - x = @rsprite.x - @rsprite.ox * TilemapRenderer::ZOOM_X - y = @rsprite.y - @rsprite.oy * TilemapRenderer::ZOOM_Y + x = @rsprite.x - (@rsprite.ox * TilemapRenderer::ZOOM_X) + y = @rsprite.y - (@rsprite.oy * TilemapRenderer::ZOOM_Y) y -= Game_Map::TILE_HEIGHT * TilemapRenderer::ZOOM_Y if @rsprite.character.character_name[/offset/i] @height = $PokemonGlobal.bridge if !@fixedheight y += @height * TilemapRenderer::ZOOM_Y * Game_Map::TILE_HEIGHT / 2 width = @rsprite.src_rect.width height = @rsprite.src_rect.height - @sprite.x = x + (width / 2) * TilemapRenderer::ZOOM_X - @sprite.y = y + (height + (height / 2)) * TilemapRenderer::ZOOM_Y + @sprite.x = x + ((width / 2) * TilemapRenderer::ZOOM_X) + @sprite.y = y + ((height + (height / 2)) * TilemapRenderer::ZOOM_Y) @sprite.ox = width / 2 @sprite.oy = (height / 2) - 2 # Hard-coded 2 pixel shift up @sprite.oy -= @rsprite.character.bob_height * 2 diff --git a/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb b/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb index a2a8bb5c1..c9cb798dc 100644 --- a/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb +++ b/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb @@ -184,9 +184,7 @@ class TilemapRenderer end def current_frame(filename) - if !@current_frames[filename] - set_current_frame(filename) - end + set_current_frame(filename) if !@current_frames[filename] return @current_frames[filename] end diff --git a/Data/Scripts/006_Map renderer/002_TilesetWrapper.rb b/Data/Scripts/006_Map renderer/002_TilesetWrapper.rb index 3a15224a8..ed243fd4b 100644 --- a/Data/Scripts/006_Map renderer/002_TilesetWrapper.rb +++ b/Data/Scripts/006_Map renderer/002_TilesetWrapper.rb @@ -56,6 +56,8 @@ class TilemapRenderer return ret end + #--------------------------------------------------------------------------- + private def blitWrappedPixels(destX, destY, dest, src, srcrect) diff --git a/Data/Scripts/007_Objects and windows/001_RPG_Cache.rb b/Data/Scripts/007_Objects and windows/001_RPG_Cache.rb index 3da5779d0..8cf7f91eb 100644 --- a/Data/Scripts/007_Objects and windows/001_RPG_Cache.rb +++ b/Data/Scripts/007_Objects and windows/001_RPG_Cache.rb @@ -11,7 +11,7 @@ module RPG def self.debug t = Time.now filename = t.strftime("%H %M %S.%L.txt") - File.open("cache_" + filename, "wb") { |f| + File.open("cache_" + filename, "wb") do |f| @cache.each do |key, value| if !value f.write("#{key} (nil)\r\n") @@ -21,7 +21,7 @@ module RPG f.write("#{key} (#{value.refcount}, #{value.width}x#{value.height})\r\n") end end - } + end end def self.setKey(key, obj) diff --git a/Data/Scripts/007_Objects and windows/002_MessageConfig.rb b/Data/Scripts/007_Objects and windows/002_MessageConfig.rb index c33a4db8e..77f9d6b77 100644 --- a/Data/Scripts/007_Objects and windows/002_MessageConfig.rb +++ b/Data/Scripts/007_Objects and windows/002_MessageConfig.rb @@ -208,9 +208,7 @@ def pbPositionNearMsgWindow(cmdwindow, msgwindow, side) return if !cmdwindow if msgwindow height = [cmdwindow.height, Graphics.height - msgwindow.height].min - if cmdwindow.height != height - cmdwindow.height = height - end + cmdwindow.height = height if cmdwindow.height != height cmdwindow.y = msgwindow.y - cmdwindow.height if cmdwindow.y < 0 cmdwindow.y = msgwindow.y + msgwindow.height @@ -257,9 +255,7 @@ def pbUpdateMsgWindowPos(msgwindow, event, eventChanged = false) msgwindow.resizeToFit2(msgwindow.text, Graphics.width * 2 / 3, msgwindow.height) end msgwindow.y = event.screen_y - 48 - msgwindow.height - if msgwindow.y < 0 - msgwindow.y = event.screen_y + 24 - end + msgwindow.y = event.screen_y + 24 if msgwindow.y < 0 msgwindow.x = event.screen_x - (msgwindow.width / 2) msgwindow.x = 0 if msgwindow.x < 0 if msgwindow.x > Graphics.width - msgwindow.width @@ -623,24 +619,24 @@ def pbFadeOutInWithMusic(zViewport = 99999) $game_system.bgm_pause(1.0) $game_system.bgs_pause(1.0) pos = $game_system.bgm_position - pbFadeOutIn(zViewport) { + pbFadeOutIn(zViewport) do yield $game_system.bgm_position = pos $game_system.bgm_resume(playingBGM) $game_system.bgs_resume(playingBGS) - } + end end def pbFadeOutAndHide(sprites) visiblesprites = {} numFrames = (Graphics.frame_rate * 0.4).floor alphaDiff = (255.0 / numFrames).ceil - pbDeactivateWindows(sprites) { + pbDeactivateWindows(sprites) do (0..numFrames).each do |j| pbSetSpritesToColor(sprites, Color.new(0, 0, 0, j * alphaDiff)) (block_given?) ? yield : pbUpdateSpriteHash(sprites) end - } + end sprites.each do |i| next if !i[1] next if pbDisposed?(i[1]) @@ -660,12 +656,12 @@ def pbFadeInAndShow(sprites, visiblesprites = nil) end numFrames = (Graphics.frame_rate * 0.4).floor alphaDiff = (255.0 / numFrames).ceil - pbDeactivateWindows(sprites) { + pbDeactivateWindows(sprites) do (0..numFrames).each do |j| pbSetSpritesToColor(sprites, Color.new(0, 0, 0, ((numFrames - j) * alphaDiff))) (block_given?) ? yield : pbUpdateSpriteHash(sprites) end - } + end end # Restores which windows are active for the given sprite hash. @@ -731,9 +727,7 @@ def addBackgroundPlane(sprites, planename, background, viewport = nil) else sprites[planename].setBitmap(bitmapName) sprites.each_value do |spr| - if spr.is_a?(Window) - spr.windowskin = nil - end + spr.windowskin = nil if spr.is_a?(Window) end end end @@ -753,9 +747,7 @@ def addBackgroundOrColoredPlane(sprites, planename, background, color, viewport sprites[planename] = AnimatedPlane.new(viewport) sprites[planename].setBitmap(bitmapName) sprites.each_value do |spr| - if spr.is_a?(Window) - spr.windowskin = nil - end + spr.windowskin = nil if spr.is_a?(Window) end end end @@ -767,6 +759,7 @@ module Graphics if !self.respond_to?("width") def self.width; return 640; end end + if !self.respond_to?("height") def self.height; return 480; end end @@ -778,9 +771,7 @@ end if !defined?(_INTL) def _INTL(*args) string = args[0].clone - (1...args.length).each do |i| - string.gsub!(/\{#{i}\}/, args[i].to_s) - end + (1...args.length).each { |i| string.gsub!(/\{#{i}\}/, args[i].to_s) } return string end end @@ -789,9 +780,7 @@ if !defined?(_ISPRINTF) def _ISPRINTF(*args) string = args[0].clone (1...args.length).each do |i| - string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| - next sprintf("%" + $1, args[i]) - } + string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| next sprintf("%" + $1, args[i]) } end return string end @@ -800,9 +789,7 @@ end if !defined?(_MAPINTL) def _MAPINTL(*args) string = args[1].clone - (2...args.length).each do |i| - string.gsub!(/\{#{i}\}/, args[i + 1].to_s) - end + (2...args.length).each { |i| string.gsub!(/\{#{i}\}/, args[i + 1].to_s) } return string end end diff --git a/Data/Scripts/007_Objects and windows/003_Window.rb b/Data/Scripts/007_Objects and windows/003_Window.rb index 3a20b9d7c..720c9deeb 100644 --- a/Data/Scripts/007_Objects and windows/003_Window.rb +++ b/Data/Scripts/007_Objects and windows/003_Window.rb @@ -42,6 +42,8 @@ class WindowCursorRect < Rect @window.width = @window.width end + #----------------------------------------------------------------------------- + private def needs_update?(x, y, width, height) @@ -323,6 +325,8 @@ class Window end end + #----------------------------------------------------------------------------- + private def ensureBitmap(bitmap, dwidth, dheight) diff --git a/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb b/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb index e726b3613..588f5c7c3 100644 --- a/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb +++ b/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb @@ -34,15 +34,14 @@ class SpriteWindow < Window @_windowskin end - # Flags used to preserve compatibility - # with RGSS/RGSS2's version of Window + # Flags used to preserve compatibility with RGSS/RGSS2's version of Window module CompatBits - CorrectZ = 1 - ExpandBack = 2 - ShowScrollArrows = 4 - StretchSides = 8 - ShowPause = 16 - ShowCursor = 32 + CORRECT_Z = 1 + EXPAND_BACK = 2 + SHOW_SCROLL_ARROWS = 4 + STRETCH_SIDES = 8 + SHOW_PAUSE = 16 + SHOW_CURSOR = 32 end attr_reader :compat @@ -78,7 +77,7 @@ class SpriteWindow < Window @contents = @blankcontents @_windowskin = nil @rpgvx = false - @compat = CompatBits::ExpandBack | CompatBits::StretchSides + @compat = CompatBits::EXPAND_BACK | CompatBits::STRETCH_SIDES @x = 0 @y = 0 @width = 0 @@ -435,7 +434,7 @@ class SpriteWindow < Window privRefresh end - #=============================================================================== + #----------------------------------------------------------------------------- private @@ -515,9 +514,9 @@ class SpriteWindow < Window @sprites["back"].visible = @visible @sprites["contents"].visible = @visible && @openness == 255 @sprites["pause"].visible = supported && @visible && @pause && - (@combat & CompatBits::ShowPause) + (@combat & CompatBits::SHOW_PAUSE) @sprites["cursor"].visible = supported && @visible && @openness == 255 && - (@combat & CompatBits::ShowCursor) + (@combat & CompatBits::SHOW_CURSOR) @sprites["scroll0"].visible = false @sprites["scroll1"].visible = false @sprites["scroll2"].visible = false @@ -540,7 +539,7 @@ class SpriteWindow < Window @spritekeys.each do |i| @sprites[i].z = @z end - if (@compat & CompatBits::CorrectZ) > 0 && @skinformat == 0 && !@rpgvx + if (@compat & CompatBits::CORRECT_Z) > 0 && @skinformat == 0 && !@rpgvx # Compatibility Mode: Cursor, pause, and contents have higher Z @sprites["cursor"].z = @z + 1 @sprites["contents"].z = @z + 2 @@ -630,7 +629,7 @@ class SpriteWindow < Window end @sprites["contents"].x = @x + trimStartX @sprites["contents"].y = @y + trimStartY - if (@compat & CompatBits::ShowScrollArrows) > 0 && @skinformat == 0 && + if (@compat & CompatBits::SHOW_SCROLL_ARROWS) > 0 && @skinformat == 0 && @_windowskin && !@_windowskin.disposed? && @contents && !@contents.disposed? @sprites["scroll0"].visible = @visible && hascontents && @oy > 0 @@ -667,7 +666,7 @@ class SpriteWindow < Window @sprites["scroll3"].y = @y + @height - 16 @sprites["cursor"].x = @x + startX + @cursor_rect.x @sprites["cursor"].y = @y + startY + @cursor_rect.y - if (@compat & CompatBits::ExpandBack) > 0 && @skinformat == 0 + if (@compat & CompatBits::EXPAND_BACK) > 0 && @skinformat == 0 # Compatibility mode: Expand background @sprites["back"].x = @x + 2 @sprites["back"].y = @y + 2 @@ -742,7 +741,7 @@ class SpriteWindow < Window @sprites["side#{i}"].src_rect.set(0, 0, dwidth, dheight) @sidebitmaps[i].clear if sideRects[i].width > 0 && sideRects[i].height > 0 - if (@compat & CompatBits::StretchSides) > 0 && @skinformat == 0 + if (@compat & CompatBits::STRETCH_SIDES) > 0 && @skinformat == 0 # Compatibility mode: Stretch sides @sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect, @_windowskin, sideRects[i]) @@ -752,7 +751,7 @@ class SpriteWindow < Window end end end - if (@compat & CompatBits::ExpandBack) > 0 && @skinformat == 0 + if (@compat & CompatBits::EXPAND_BACK) > 0 && @skinformat == 0 # Compatibility mode: Expand background backwidth = @width - 4 backheight = @height - 4 @@ -816,7 +815,7 @@ end # #=============================================================================== class SpriteWindow_Base < SpriteWindow - TEXTPADDING = 4 # In pixels + TEXT_PADDING = 4 # In pixels def initialize(x, y, width, height) super() diff --git a/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb b/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb index 9859c8843..15e70cb31 100644 --- a/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb +++ b/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb @@ -51,7 +51,7 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base dims = [0, 0] cwidth = maxwidth < 0 ? Graphics.width : maxwidth getLineBrokenChunks(self.contents, text, - cwidth - self.borderX - SpriteWindow_Base::TEXTPADDING, dims, true) + cwidth - self.borderX - SpriteWindow_Base::TEXT_PADDING, dims, true) return dims end @@ -62,7 +62,7 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base def resizeToFit(text, maxwidth = -1) # maxwidth is maximum acceptable window width dims = resizeToFitInternal(text, maxwidth) - self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING + self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXT_PADDING self.height = dims[1] + self.borderY refresh end @@ -211,7 +211,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base dims = resizeToFitInternal(text, maxwidth) oldstarting = @starting @starting = true - self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING + self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXT_PADDING self.height = dims[1] + self.borderY @starting = oldstarting redrawText @@ -221,7 +221,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base dims = resizeToFitInternal(text, maxwidth) oldstarting = @starting @starting = true - self.width = [dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING, maxwidth].min + self.width = [dims[0] + self.borderX + SpriteWindow_Base::TEXT_PADDING, maxwidth].min self.height = [dims[1] + self.borderY, maxheight].min @starting = oldstarting redrawText @@ -306,7 +306,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base if @letterbyletter @fmtchars = [] fmt = getFormattedText(self.contents, 0, 0, - self.width - self.borderX - SpriteWindow_Base::TEXTPADDING, -1, + self.width - self.borderX - SpriteWindow_Base::TEXT_PADDING, -1, shadowctag(@baseColor, @shadowColor) + value, 32, true) @oldfont = self.contents.font.clone fmt.each do |ch| @@ -333,7 +333,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base fmt.clear else @fmtchars = getFormattedText(self.contents, 0, 0, - self.width - self.borderX - SpriteWindow_Base::TEXTPADDING, -1, + self.width - self.borderX - SpriteWindow_Base::TEXT_PADDING, -1, shadowctag(@baseColor, @shadowColor) + value, 32, true) @oldfont = self.contents.font.clone @fmtchars.each do |ch| @@ -586,6 +586,8 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base @frameskipChanged = false end + #----------------------------------------------------------------------------- + private def curcharSkip(skip) @@ -704,6 +706,8 @@ class Window_InputNumberPokemon < SpriteWindow_Base @frame = (@frame + 1) % 30 end + #----------------------------------------------------------------------------- + private def textHelper(x, y, text, i) @@ -895,6 +899,8 @@ class SpriteWindow_Selectable < SpriteWindow_Base end end + #----------------------------------------------------------------------------- + private def priv_page_row_max @@ -1074,7 +1080,7 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx width = [width, tmpbitmap.text_size(i).width].max end # one 16 to allow cursor - width += 16 + 16 + SpriteWindow_Base::TEXTPADDING + width += 16 + 16 + SpriteWindow_Base::TEXT_PADDING tmpbitmap.dispose end # Store suggested width and height of window @@ -1229,7 +1235,7 @@ class Window_AdvancedCommandPokemon < Window_DrawableCommand def textWidth(bitmap, text) dims = [nil, 0] chars = getFormattedText(bitmap, 0, 0, - Graphics.width - self.borderX - SpriteWindow_Base::TEXTPADDING - 16, + Graphics.width - self.borderX - SpriteWindow_Base::TEXT_PADDING - 16, -1, text, self.rowHeight, true, true) chars.each do |ch| dims[0] = dims[0] ? [dims[0], ch[1]].min : ch[1] diff --git a/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb b/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb index 0a5aea4ee..7dd2081a1 100644 --- a/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb +++ b/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb @@ -218,9 +218,9 @@ end # #=============================================================================== def pbGetTileBitmap(filename, tile_id, hue, width = 1, height = 1) - return RPG::Cache.tileEx(filename, tile_id, hue, width, height) { |f| + return RPG::Cache.tileEx(filename, tile_id, hue, width, height) do |f| AnimatedBitmap.new("Graphics/Tilesets/" + filename).deanimate - } + end end def pbGetTileset(name, hue = 0) diff --git a/Data/Scripts/007_Objects and windows/009_Planes.rb b/Data/Scripts/007_Objects and windows/009_Planes.rb index 2a94b5307..bacd66b57 100644 --- a/Data/Scripts/007_Objects and windows/009_Planes.rb +++ b/Data/Scripts/007_Objects and windows/009_Planes.rb @@ -64,6 +64,8 @@ class AnimatedPlane < Plane end end + #----------------------------------------------------------------------------- + private def clear_bitmap diff --git a/Data/Scripts/007_Objects and windows/010_DrawText.rb b/Data/Scripts/007_Objects and windows/010_DrawText.rb index b3e217c26..a71b69252 100644 --- a/Data/Scripts/007_Objects and windows/010_DrawText.rb +++ b/Data/Scripts/007_Objects and windows/010_DrawText.rb @@ -97,9 +97,7 @@ end def getFormattedTextForDims(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight, newlineBreaks = true, explicitBreaksOnly = false) text2 = text.gsub(/<(\/?)(c|c2|c3|o|u|s)(\s*\=\s*([^>]*))?>/i, "") - if newlineBreaks - text2.gsub!(/<(\/?)(br)(\s*\=\s*([^>]*))?>/i, "\n") - end + text2.gsub!(/<(\/?)(br)(\s*\=\s*([^>]*))?>/i, "\n") if newlineBreaks return getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text2, lineheight, newlineBreaks, explicitBreaksOnly, true) @@ -249,70 +247,79 @@ end #=============================================================================== # Formats a string of text and returns an array containing a list of formatted # characters. +# +# Parameters: +# bitmap: Source bitmap. Will be used to determine the default font of +# the text. +# xDst: X coordinate of the text's top left corner. +# yDst: Y coordinate of the text's top left corner. +# widthDst: Width of the text. Used to determine line breaks. +# heightDst: Height of the text. If -1, there is no height restriction. +# If 1 or greater, any characters exceeding the height are +# removed from the returned list. +# newLineBreaks: If true, newline characters will be treated as line breaks. +# The default is true. +# +# Return Values: +# A list of formatted characters. Returns an empty array if _bitmap_ is nil +# or disposed, or if _widthDst_ is 0 or less or _heightDst_ is 0. +# +# Formatting Specification: +# This function uses the following syntax when formatting the text. +# +# ... - Formats the text in bold. +# ... - Formats the text in italics. +# ... - Underlines the text. +# ... - Draws a strikeout line over the text. +# ... - Left-aligns the text. Causes line breaks before and +# after the text. +# - Right-aligns the text until the next line break. +# ... - Right-aligns the text. Causes line breaks before and +# after the text. +# ... - Centers the text. Causes line breaks before and after +# the text. +#
- Causes a line break. +# ... - Color specification. A total of four formats are +# supported: RRGGBBAA, RRGGBB, 16-bit RGB, and +# Window_Base color numbers. +# ... - Color specification where the first half is the base +# color and the second half is the shadow color. 16-bit +# RGB is supported. +# +# Added 2009-10-20 +# +# ... - Color specification where B is the base color and S is +# the shadow color. B and/or S can be omitted. A total of +# four formats are supported: RRGGBBAA, RRGGBB, 16-bit +# RGB, and Window_Base color numbers. +# +# Added 2009-9-12 +# +# - Displays the text in the given opacity (0-255) +# +# Added 2009-10-19 +# +# - Displays the text in outline format. +# +# Added 2010-05-12 +# +# - Displays the text in outline format (outlines more +# exaggerated. +# ... - Formats the text in the specified font, or Arial if the +# font doesn't exist. +# ... - Changes the font size to X. +# - Displays the icon X (in Graphics/Icons/). +# +# In addition, the syntax supports the following: +# ' - Converted to "'". +# < - Converted to "<". +# > - Converted to ">". +# & - Converted to "&". +# " - Converted to double quotation mark. +# +# To draw the characters, pass the returned array to the +# _drawFormattedChars_ function. #=============================================================================== -=begin -Parameters: -bitmap: Source bitmap. Will be used to determine the default font of - the text. -xDst: X coordinate of the text's top left corner. -yDst: Y coordinate of the text's top left corner. -widthDst: Width of the text. Used to determine line breaks. -heightDst: Height of the text. If -1, there is no height restriction. If - 1 or greater, any characters exceeding the height are removed - from the returned list. -newLineBreaks: If true, newline characters will be treated as line breaks. The - default is true. - -Return Values: -A list of formatted characters. Returns an empty array if _bitmap_ is nil -or disposed, or if _widthDst_ is 0 or less or _heightDst_ is 0. - -Formatting Specification: -This function uses the following syntax when formatting the text. - ... - Formats the text in bold. - ... - Formats the text in italics. - ... - Underlines the text. - ... - Draws a strikeout line over the text. - ... - Left-aligns the text. Causes line breaks before and after - the text. - - Right-aligns the text until the next line break. - ... - Right-aligns the text. Causes line breaks before and after - the text. - ... - Centers the text. Causes line breaks before and after the - text. -
- Causes a line break. - ... - Color specification. A total of four formats are supported: - RRGGBBAA, RRGGBB, 16-bit RGB, and Window_Base color numbers. - ... - Color specification where the first half is the base color - and the second half is the shadow color. 16-bit RGB is - supported. -Added 2009-10-20 - ... - Color specification where B is the base color and S is the - shadow color. B and/or S can be omitted. A total of four - formats are supported: - RRGGBBAA, RRGGBB, 16-bit RGB, and Window_Base color numbers. -Added 2009-9-12 - - Displays the text in the given opacity (0-255) -Added 2009-10-19 - - Displays the text in outline format. -Added 2010-05-12 - - Displays the text in outline format (outlines more - exaggerated. - ... - Formats the text in the specified font, or Arial if the - font doesn't exist. - ... - Changes the font size to X. - - Displays the icon X (in Graphics/Icons/). - -In addition, the syntax supports the following: -' - Converted to "'". -< - Converted to "<". -> - Converted to ">". -& - Converted to "&". -" - Converted to double quotation mark. - -To draw the characters, pass the returned array to the -_drawFormattedChars_ function. -=end def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = 32, newlineBreaks = true, explicitBreaksOnly = false, collapseAlignments = false) @@ -515,9 +522,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = break end when "br" # Line break - if !endtag - nextline += 1 - end + nextline += 1 if !endtag when "r" # Right align this line if !endtag x = 0 @@ -639,49 +644,47 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = end # This code looks at whether the text occupies exactly two lines when # displayed. If it does, it balances the length of each line. -=begin - # Count total number of lines - numlines = (x==0 && y>0) ? y : y+1 - if numlines==2 && realtext && !realtext[/\n/] && realtext.length>=50 - # Set half to middle of text (known to contain no formatting) - half = realtext.length/2 - leftSearch = 0 - rightSearch = 0 - # Search left for a space - i = half - while i>=0 - break if realtext[i,1][/\s/]||isWaitChar(realtext[i,1]) # found a space - leftSearch += 1 - i -= 1 - end - # Search right for a space - i = half - while i0) ? y : y+1 +# if numlines==2 && realtext && !realtext[/\n/] && realtext.length>=50 +# # Set half to middle of text (known to contain no formatting) +# half = realtext.length/2 +# leftSearch = 0 +# rightSearch = 0 +# # Search left for a space +# i = half +# while i>=0 +# break if realtext[i,1][/\s/]||isWaitChar(realtext[i,1]) # found a space +# leftSearch += 1 +# i -= 1 +# end +# # Search right for a space +# i = half +# while i 400) ? 3 : 2 ### Text replacement - text.gsub!(/\\sign\[([^\]]*)\]/i) { # \sign[something] gets turned into + text.gsub!(/\\sign\[([^\]]*)\]/i) do # \sign[something] gets turned into next "\\op\\cl\\ts[]\\w[" + $1 + "]" # \op\cl\ts[]\w[something] - } + end text.gsub!(/\\\\/, "\5") text.gsub!(/\\1/, "\1") if $game_actors - text.gsub!(/\\n\[([1-8])\]/i) { - m = $1.to_i - next $game_actors[m].name - } + text.gsub!(/\\n\[([1-8])\]/i) { next $game_actors[$1.to_i].name } end text.gsub!(/\\pn/i, $player.name) if $player text.gsub!(/\\pm/i, _INTL("${1}", $player.money.to_s_formatted)) if $player @@ -445,7 +444,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni text.gsub!(/\\pog/i, "") text.gsub!(/\\b/i, "") text.gsub!(/\\r/i, "") - text.gsub!(/\\[Ww]\[([^\]]*)\]/) { + text.gsub!(/\\[Ww]\[([^\]]*)\]/) do w = $1.to_s if w == "" msgwindow.windowskin = nil @@ -453,12 +452,11 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni msgwindow.setSkin("Graphics/Windowskins/#{w}", false) end next "" - } + end isDarkSkin = isDarkWindowskin(msgwindow.windowskin) - text.gsub!(/\\c\[([0-9]+)\]/i) { - m = $1.to_i - next getSkinColor(msgwindow.windowskin, m, isDarkSkin) - } + text.gsub!(/\\c\[([0-9]+)\]/i) do + next getSkinColor(msgwindow.windowskin, $1.to_i, isDarkSkin) + end loop do last_text = text.clone text.gsub!(/\\v\[([0-9]+)\]/i) { $game_variables[$1.to_i] } @@ -466,10 +464,10 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni end loop do last_text = text.clone - text.gsub!(/\\l\[([0-9]+)\]/i) { + text.gsub!(/\\l\[([0-9]+)\]/i) do linecount = [1, $1.to_i].max next "" - } + end break if text == last_text end colortag = "" @@ -664,9 +662,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni $game_variables[cmdvariable] = pbShowCommands(msgwindow, commands, cmdIfCancel) $game_map.need_refresh = true if $game_map end - if commandProc - ret = commandProc.call(msgwindow) - end + ret = commandProc.call(msgwindow) if commandProc msgback&.dispose goldwindow&.dispose coinwindow&.dispose @@ -698,8 +694,8 @@ def pbMessage(message, commands = nil, cmdIfCancel = 0, skin = nil, defaultCmd = msgwindow = pbCreateMessageWindow(nil, skin) if commands ret = pbMessageDisplay(msgwindow, message, true, - proc { |msgwindow| - next Kernel.pbShowCommands(msgwindow, commands, cmdIfCancel, defaultCmd, &block) + proc { |msgwndw| + next Kernel.pbShowCommands(msgwndw, commands, cmdIfCancel, defaultCmd, &block) }, &block) else pbMessageDisplay(msgwindow, message, &block) @@ -720,8 +716,8 @@ end def pbMessageChooseNumber(message, params, &block) msgwindow = pbCreateMessageWindow(nil, params.messageSkin) ret = pbMessageDisplay(msgwindow, message, true, - proc { |msgwindow| - next pbChooseNumber(msgwindow, params, &block) + proc { |msgwndw| + next pbChooseNumber(msgwndw, params, &block) }, &block) pbDisposeMessageWindow(msgwindow) return ret @@ -783,9 +779,7 @@ def pbShowCommandsWithHelp(msgwindow, commands, help, cmdIfCancel = 0, defaultCm Input.update oldindex = cmdwindow.index cmdwindow.update - if oldindex != cmdwindow.index - msgwin.text = help[cmdwindow.index] - end + msgwin.text = help[cmdwindow.index] if oldindex != cmdwindow.index msgwin.update yield if block_given? if Input.trigger?(Input::BACK) @@ -822,9 +816,7 @@ def pbMessageWaitForInput(msgwindow, frames, showPause = false) Input.update msgwindow&.update pbUpdateSceneMap - if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK) - break - end + break if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK) yield if block_given? end msgwindow.stopPause if msgwindow && showPause @@ -863,8 +855,8 @@ end def pbMessageFreeText(message, currenttext, passwordbox, maxlength, width = 240, &block) msgwindow = pbCreateMessageWindow retval = pbMessageDisplay(msgwindow, message, true, - proc { |msgwindow| - next pbFreeText(msgwindow, currenttext, passwordbox, maxlength, width, &block) + proc { |msgwndw| + next pbFreeText(msgwndw, currenttext, passwordbox, maxlength, width, &block) }, &block) pbDisposeMessageWindow(msgwindow) return retval diff --git a/Data/Scripts/007_Objects and windows/012_TextEntry.rb b/Data/Scripts/007_Objects and windows/012_TextEntry.rb index 2d8699cfa..076dca94e 100644 --- a/Data/Scripts/007_Objects and windows/012_TextEntry.rb +++ b/Data/Scripts/007_Objects and windows/012_TextEntry.rb @@ -41,9 +41,7 @@ class CharacterEntryHelper return false if @maxlength >= 0 && chars.length >= @maxlength chars.insert(@cursor, ch) @text = "" - chars.each do |ch| - @text += ch if ch - end + chars.each { |char| @text += char if char } @cursor += 1 return true end @@ -66,14 +64,14 @@ class CharacterEntryHelper return true end + #----------------------------------------------------------------------------- + private def ensure return if @maxlength < 0 chars = self.text.scan(/./m) - if chars.length > @maxlength && @maxlength >= 0 - chars = chars[0, @maxlength] - end + chars = chars[0, @maxlength] if chars.length > @maxlength && @maxlength >= 0 @text = "" chars.each do |ch| @text += ch if ch diff --git a/Data/Scripts/008_Audio/001_Audio.rb b/Data/Scripts/008_Audio/001_Audio.rb index 23b578651..1b8b7309c 100644 --- a/Data/Scripts/008_Audio/001_Audio.rb +++ b/Data/Scripts/008_Audio/001_Audio.rb @@ -18,8 +18,8 @@ end # Methods that determine the duration of an audio file. #=============================================================================== def getOggPage(file) - fgetdw = proc { |file| - (file.eof? ? 0 : (file.read(4).unpack("V")[0] || 0)) + fgetdw = proc { |f| + (f.eof? ? 0 : (f.read(4).unpack("V")[0] || 0)) } dw = fgetdw.call(file) return nil if dw != 0x5367674F @@ -35,8 +35,8 @@ end # internal function def oggfiletime(file) - fgetdw = proc { |file| - (file.eof? ? 0 : (file.read(4).unpack("V")[0] || 0)) + fgetdw = proc { |f| + (f.eof? ? 0 : (f.read(4).unpack("V")[0] || 0)) } pages = [] page = nil @@ -51,8 +51,8 @@ def oggfiletime(file) i = -1 pcmlengths = [] rates = [] - pages.each do |page| - header = page[0] + pages.each do |pg| + header = pg[0] serial = header[10, 4].unpack("V") frame = header[2, 8].unpack("C*") frameno = frame[7] @@ -65,7 +65,7 @@ def oggfiletime(file) frameno = (frameno << 8) | frame[0] if serial != curserial curserial = serial - file.pos = page[1] + file.pos = pg[1] packtype = (file.read(1)[0].ord rescue 0) string = file.read(6) return -1 if string != "vorbis" @@ -78,7 +78,7 @@ def oggfiletime(file) pcmlengths[i] = frameno end ret = 0.0 - pcmlengths.each_with_index { |length, i| ret += length.to_f / rates[i] } + pcmlengths.each_with_index { |length, j| ret += length.to_f / rates[j] } return ret * 256.0 end @@ -105,7 +105,7 @@ def getPlayTime2(filename) fgetw = proc { |file| (file.eof? ? 0 : (file.read(2).unpack("v")[0] || 0)) } - File.open(filename, "rb") { |file| + File.open(filename, "rb") do |file| file.pos = 0 fdw = fgetdw.call(file) case fdw @@ -165,6 +165,6 @@ def getPlayTime2(filename) break end end - } + end return time end diff --git a/Data/Scripts/009_Scenes/001_Transitions.rb b/Data/Scripts/009_Scenes/001_Transitions.rb index 4f7244573..25f4e0e44 100644 --- a/Data/Scripts/009_Scenes/001_Transitions.rb +++ b/Data/Scripts/009_Scenes/001_Transitions.rb @@ -306,6 +306,8 @@ module Transitions end end + #--------------------------------------------------------------------------- + private def rand_sign @@ -1382,29 +1384,29 @@ module Transitions # Foe sprite appears proportion = (@timer - @foe_appear_start) / (@foe_appear_end - @foe_appear_start) start_x = Graphics.width + (@foe_bitmap.width / 2) - @foe_sprite.x = start_x + (FOE_SPRITE_X_LIMIT - start_x) * proportion + @foe_sprite.x = start_x + ((FOE_SPRITE_X_LIMIT - start_x) * proportion) elsif @timer >= @vs_appear_final @vs_1_sprite.visible = false elsif @timer >= @vs_appear_start_2 # Temp VS sprites enlarge and shrink again if @vs_2_sprite.visible - @vs_2_sprite.zoom_x = 1.6 - 0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time + @vs_2_sprite.zoom_x = 1.6 - (0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time) @vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x if @vs_2_sprite.zoom_x <= 1.2 @vs_2_sprite.visible = false @vs_main_sprite.visible = true end end - @vs_1_sprite.zoom_x = 2.0 - 0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time + @vs_1_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time) @vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x elsif @timer >= @vs_appear_start # Temp VS sprites appear and start shrinking @vs_2_sprite.visible = true - @vs_2_sprite.zoom_x = 2.0 - 0.8 * (@timer - @vs_appear_start) / @vs_shrink_time + @vs_2_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start) / @vs_shrink_time) @vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x if @vs_1_sprite.visible || @vs_2_sprite.zoom_x <= 1.6 # Halfway between 2.0 and 1.2 @vs_1_sprite.visible = true - @vs_1_sprite.zoom_x = 2.0 - 0.8 * (@timer - @vs_appear_start - (@vs_shrink_time / 2)) / @vs_shrink_time + @vs_1_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start - (@vs_shrink_time / 2)) / @vs_shrink_time) @vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x end elsif @timer >= @bar_appear_end @@ -1413,7 +1415,7 @@ module Transitions start_x = Graphics.width * (1 - (@timer / @bar_appear_end)) color = Color.new(0, 0, 0, 0) # Transparent (@sprites[0].height / 2).times do |i| - x = start_x - BAR_MASK[i % BAR_MASK.length] * 4 + x = start_x - (BAR_MASK[i % BAR_MASK.length] * 4) @bar_mask_sprite.bitmap.fill_rect(x, BAR_Y + (i * 2), @bar_mask_sprite.width - x, 2, color) end end @@ -1572,14 +1574,14 @@ module Transitions # Bars/trainer sprites slide in proportion = (@timer - @bar_appear_start) / (@bar_appear_end - @bar_appear_start) sqrt_proportion = Math.sqrt(proportion) - @player_bar_sprite.x = @player_bar_start_x + (@player_bar_x + BAR_OVERSHOOT - @player_bar_start_x) * sqrt_proportion + @player_bar_sprite.x = @player_bar_start_x + ((@player_bar_x + BAR_OVERSHOOT - @player_bar_start_x) * sqrt_proportion) @player_sprite.x = @player_bar_sprite.x + TRAINER_X_OFFSET - @foe_bar_sprite.x = @foe_bar_start_x + (@foe_bar_x - BAR_OVERSHOOT - @foe_bar_start_x) * sqrt_proportion + @foe_bar_sprite.x = @foe_bar_start_x + ((@foe_bar_x - BAR_OVERSHOOT - @foe_bar_start_x) * sqrt_proportion) @foe_sprite.x = @foe_bar_sprite.x + (@bar_bitmap.width / 2) - TRAINER_X_OFFSET @text_sprite.x = @foe_bar_sprite.x end # Animate bars - if @timer >= @flash_start + 0.33 * @flash_duration + if @timer >= @flash_start + (0.33 * @flash_duration) bar_phase = (@timer * 30).to_i % @num_bar_frames @player_bar_sprite.src_rect.y = bar_phase * BAR_HEIGHT @foe_bar_sprite.src_rect.y = bar_phase * BAR_HEIGHT @@ -1594,23 +1596,23 @@ module Transitions elsif @timer >= @vs_appear_start_2 # Temp VS sprites enlarge and shrink again if @vs_2_sprite.visible - @vs_2_sprite.zoom_x = 1.6 - 0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time + @vs_2_sprite.zoom_x = 1.6 - (0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time) @vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x if @vs_2_sprite.zoom_x <= 1.2 @vs_2_sprite.visible = false @vs_main_sprite.visible = true end end - @vs_1_sprite.zoom_x = 2.0 - 0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time + @vs_1_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time) @vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x elsif @timer >= @vs_appear_start # Temp VS sprites appear and start shrinking @vs_2_sprite.visible = true - @vs_2_sprite.zoom_x = 2.0 - 0.8 * (@timer - @vs_appear_start) / @vs_shrink_time + @vs_2_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start) / @vs_shrink_time) @vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x if @vs_1_sprite.visible || @vs_2_sprite.zoom_x <= 1.6 # Halfway between 2.0 and 1.2 @vs_1_sprite.visible = true - @vs_1_sprite.zoom_x = 2.0 - 0.8 * (@timer - @vs_appear_start - (@vs_shrink_time / 2)) / @vs_shrink_time + @vs_1_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start - (@vs_shrink_time / 2)) / @vs_shrink_time) @vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x end end @@ -1652,12 +1654,12 @@ module Transitions @flash_viewport.color.alpha = 255 * proportion # Move bars and trainer sprites off-screen dist = BAR_Y_INDENT + BAR_HEIGHT - @player_bar_sprite.x = @player_bar_x - dist * proportion - @player_bar_sprite.y = @player_bar_y - dist * proportion + @player_bar_sprite.x = @player_bar_x - (dist * proportion) + @player_bar_sprite.y = @player_bar_y - (dist * proportion) @player_sprite.x = @player_bar_sprite.x + TRAINER_X_OFFSET @player_sprite.y = @player_bar_sprite.y + BAR_HEIGHT - TRAINER_Y_OFFSET - @foe_bar_sprite.x = @foe_bar_x + dist * proportion - @foe_bar_sprite.y = @foe_bar_y + dist * proportion + @foe_bar_sprite.x = @foe_bar_x + (dist * proportion) + @foe_bar_sprite.y = @foe_bar_y + (dist * proportion) @foe_sprite.x = @foe_bar_sprite.x + (@bar_bitmap.width / 2) - TRAINER_X_OFFSET @foe_sprite.y = @foe_bar_sprite.y + @foe_bitmap.height - TRAINER_Y_OFFSET end @@ -1731,8 +1733,8 @@ module Transitions next if proportion < start_time single_proportion = (proportion - start_time) / @rocket_appear_time sqrt_single_proportion = Math.sqrt(single_proportion) - sprite.x = (ROCKET_X[i] + (0.5 - ROCKET_X[i]) * sqrt_single_proportion) * Graphics.width - sprite.y = (ROCKET_Y[i] + (0.5 - ROCKET_Y[i]) * sqrt_single_proportion) * Graphics.height + sprite.x = (ROCKET_X[i] + ((0.5 - ROCKET_X[i]) * sqrt_single_proportion)) * Graphics.width + sprite.y = (ROCKET_Y[i] + ((0.5 - ROCKET_Y[i]) * sqrt_single_proportion)) * Graphics.height sprite.zoom_x = 2.5 * (1 - single_proportion) sprite.zoom_y = sprite.zoom_x sprite.angle = sprite.zoom_x * ROCKET_ANGLE[i] * 360 @@ -1867,8 +1869,8 @@ module Transitions # Slide foe sprite/name off-screen proportion = (@timer - @foe_disappear_start) / (@foe_disappear_end - @foe_disappear_start) start_x = Graphics.width / 2 - @foe_sprite.x = start_x - (@foe_bitmap.width + start_x) * proportion * proportion - @text_sprite.x = @foe_sprite.x - Graphics.width / 2 + @foe_sprite.x = start_x - ((@foe_bitmap.width + start_x) * proportion * proportion) + @text_sprite.x = @foe_sprite.x - (Graphics.width / 2) elsif @timer >= @flash_end @flash_viewport.color.alpha = 0 # Ensure flash has ended elsif @timer >= @bg_2_appear_end @@ -1884,8 +1886,8 @@ module Transitions @bg_2_sprite.opacity = 255 * proportion # Foe sprite/name appear start_x = Graphics.width + (@foe_bitmap.width / 2) - @foe_sprite.x = start_x + ((Graphics.width / 2) - start_x) * Math.sqrt(proportion) - @text_sprite.x = @foe_sprite.x - Graphics.width / 2 + @foe_sprite.x = start_x + (((Graphics.width / 2) - start_x) * Math.sqrt(proportion)) + @text_sprite.x = @foe_sprite.x - (Graphics.width / 2) @text_sprite.visible = true elsif @timer >= @bg_1_appear_end @bg_1_sprite.oy = Graphics.height / 2 diff --git a/Data/Scripts/009_Scenes/002_EventScene.rb b/Data/Scripts/009_Scenes/002_EventScene.rb index a50c12906..58f3ff78d 100644 --- a/Data/Scripts/009_Scenes/002_EventScene.rb +++ b/Data/Scripts/009_Scenes/002_EventScene.rb @@ -79,12 +79,8 @@ class EventScene def dispose return if disposed? - @picturesprites.each do |sprite| - sprite.dispose - end - @usersprites.each do |sprite| - sprite.dispose - end + @picturesprites.each { |sprite| sprite.dispose } + @usersprites.each { |sprite| sprite.dispose } @onCTrigger.clear @onBTrigger.clear @onUpdate.clear @@ -142,9 +138,7 @@ class EventScene def pictureWait(extraframes = 0) loop do hasRunning = false - @pictures.each do |pic| - hasRunning = true if pic.running? - end + @pictures.each { |pic| hasRunning = true if pic.running? } break if !hasRunning update end @@ -155,12 +149,8 @@ class EventScene return if disposed? Graphics.update Input.update - @pictures.each do |picture| - picture.update - end - @picturesprites.each do |sprite| - sprite.update - end + @pictures.each { |picture| picture.update } + @picturesprites.each { |sprite| sprite.update } @usersprites.each do |sprite| next if !sprite || sprite.disposed? || !sprite.is_a?(Sprite) sprite.update @@ -184,12 +174,10 @@ end # #=============================================================================== def pbEventScreen(cls) - pbFadeOutIn { + pbFadeOutIn do viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport.z = 99999 - PBDebug.logonerr { - cls.new(viewport).main - } + PBDebug.logonerr { cls.new(viewport).main } viewport.dispose - } + end end diff --git a/Data/Scripts/010_Data/001_GameData.rb b/Data/Scripts/010_Data/001_GameData.rb index 209cec07c..83263509c 100644 --- a/Data/Scripts/010_Data/001_GameData.rb +++ b/Data/Scripts/010_Data/001_GameData.rb @@ -266,13 +266,12 @@ module GameData self.constants.each do |c| next if !self.const_get(c).is_a?(Class) ret[c] = self.const_get(c)::PBS_BASE_FILENAME if self.const_get(c).const_defined?(:PBS_BASE_FILENAME) - if ret[c].is_a?(Array) - ret[c].length.times do |i| - next if i == 0 - ret[(c.to_s + i.to_s).to_sym] = ret[c][i] # :Species1 => "pokemon_forms" - end - ret[c] = ret[c][0] # :Species => "pokemon" + next if !ret[c].is_a?(Array) + ret[c].length.times do |i| + next if i == 0 + ret[(c.to_s + i.to_s).to_sym] = ret[c][i] # :Species1 => "pokemon_forms" end + ret[c] = ret[c][0] # :Species => "pokemon" end return ret end diff --git a/Data/Scripts/010_Data/002_PBS data/002_TownMap.rb b/Data/Scripts/010_Data/002_PBS data/002_TownMap.rb index bf161e340..a9b3d4c7a 100644 --- a/Data/Scripts/010_Data/002_PBS data/002_TownMap.rb +++ b/Data/Scripts/010_Data/002_PBS data/002_TownMap.rb @@ -33,7 +33,7 @@ module GameData # @return [String] the translated name of this region def name - return pbGetMessageFromHash(MessageTypes::Regions, @real_name) + return pbGetMessageFromHash(MessageTypes::REGION_NAMES, @real_name) end def has_flag?(flag) diff --git a/Data/Scripts/010_Data/002_PBS data/003_Type.rb b/Data/Scripts/010_Data/002_PBS data/003_Type.rb index 95fde1829..8688f6376 100644 --- a/Data/Scripts/010_Data/002_PBS data/003_Type.rb +++ b/Data/Scripts/010_Data/002_PBS data/003_Type.rb @@ -48,7 +48,7 @@ module GameData # @return [String] the translated name of this item def name - return pbGetMessageFromHash(MessageTypes::Types, @real_name) + return pbGetMessageFromHash(MessageTypes::TYPE_NAMES, @real_name) end def physical?; return !@special_type; end diff --git a/Data/Scripts/010_Data/002_PBS data/004_Ability.rb b/Data/Scripts/010_Data/002_PBS data/004_Ability.rb index d21feb70a..9c7e58b1e 100644 --- a/Data/Scripts/010_Data/002_PBS data/004_Ability.rb +++ b/Data/Scripts/010_Data/002_PBS data/004_Ability.rb @@ -30,12 +30,12 @@ module GameData # @return [String] the translated name of this ability def name - return pbGetMessageFromHash(MessageTypes::Abilities, @real_name) + return pbGetMessageFromHash(MessageTypes::ABILITY_NAMES, @real_name) end # @return [String] the translated description of this ability def description - return pbGetMessageFromHash(MessageTypes::AbilityDescriptions, @real_description) + return pbGetMessageFromHash(MessageTypes::ABILITY_DESCRIPTIONS, @real_description) end def has_flag?(flag) diff --git a/Data/Scripts/010_Data/002_PBS data/005_Move.rb b/Data/Scripts/010_Data/002_PBS data/005_Move.rb index 5a79f4e0a..eeb0cf4d9 100644 --- a/Data/Scripts/010_Data/002_PBS data/005_Move.rb +++ b/Data/Scripts/010_Data/002_PBS data/005_Move.rb @@ -60,12 +60,12 @@ module GameData # @return [String] the translated name of this move def name - return pbGetMessageFromHash(MessageTypes::Moves, @real_name) + return pbGetMessageFromHash(MessageTypes::MOVE_NAMES, @real_name) end # @return [String] the translated description of this move def description - return pbGetMessageFromHash(MessageTypes::MoveDescriptions, @real_description) + return pbGetMessageFromHash(MessageTypes::MOVE_DESCRIPTIONS, @real_description) end def has_flag?(flag) diff --git a/Data/Scripts/010_Data/002_PBS data/006_Item.rb b/Data/Scripts/010_Data/002_PBS data/006_Item.rb index 8a1094b08..dff99bfdc 100644 --- a/Data/Scripts/010_Data/002_PBS data/006_Item.rb +++ b/Data/Scripts/010_Data/002_PBS data/006_Item.rb @@ -133,29 +133,29 @@ module GameData # @return [String] the translated name of this item def name - return pbGetMessageFromHash(MessageTypes::Items, @real_name) + return pbGetMessageFromHash(MessageTypes::ITEM_NAMES, @real_name) end # @return [String] the translated plural version of the name of this item def name_plural - return pbGetMessageFromHash(MessageTypes::ItemPlurals, @real_name_plural) + return pbGetMessageFromHash(MessageTypes::ITEM_NAME_PLURALS, @real_name_plural) end # @return [String] the translated portion name of this item def portion_name - return pbGetMessageFromHash(MessageTypes::ItemPortions, @real_portion_name) if @real_portion_name + return pbGetMessageFromHash(MessageTypes::ITEM_PORTION_NAMES, @real_portion_name) if @real_portion_name return name end # @return [String] the translated plural version of the portion name of this item def portion_name_plural - return pbGetMessageFromHash(MessageTypes::ItemPortionPlurals, @real_portion_name_plural) if @real_portion_name_plural + return pbGetMessageFromHash(MessageTypes::ITEM_PORTION_NAME_PLURALS, @real_portion_name_plural) if @real_portion_name_plural return name_plural end # @return [String] the translated description of this item def description - return pbGetMessageFromHash(MessageTypes::ItemDescriptions, @real_description) + return pbGetMessageFromHash(MessageTypes::ITEM_DESCRIPTIONS, @real_description) end def has_flag?(flag) diff --git a/Data/Scripts/010_Data/002_PBS data/008_Species.rb b/Data/Scripts/010_Data/002_PBS data/008_Species.rb index 8e5aacef5..71d59f161 100644 --- a/Data/Scripts/010_Data/002_PBS data/008_Species.rb +++ b/Data/Scripts/010_Data/002_PBS data/008_Species.rb @@ -220,22 +220,22 @@ module GameData # @return [String] the translated name of this species def name - return pbGetMessageFromHash(MessageTypes::Species, @real_name) + return pbGetMessageFromHash(MessageTypes::SPECIES_NAMES, @real_name) end # @return [String] the translated name of this form of this species def form_name - return pbGetMessageFromHash(MessageTypes::SpeciesForms, @real_form_name) + return pbGetMessageFromHash(MessageTypes::SPECIES_FORM_NAMES, @real_form_name) end # @return [String] the translated Pokédex category of this species def category - return pbGetMessageFromHash(MessageTypes::SpeciesCategories, @real_category) + return pbGetMessageFromHash(MessageTypes::SPECIES_CATEGORIES, @real_category) end # @return [String] the translated Pokédex entry of this species def pokedex_entry - return pbGetMessageFromHash(MessageTypes::PokedexEntries, @real_pokedex_entry) + return pbGetMessageFromHash(MessageTypes::POKEDEX_ENTRIES, @real_pokedex_entry) end def default_form diff --git a/Data/Scripts/010_Data/002_PBS data/010_SpeciesMetrics.rb b/Data/Scripts/010_Data/002_PBS data/010_SpeciesMetrics.rb index 79b882a40..a0fc44319 100644 --- a/Data/Scripts/010_Data/002_PBS data/010_SpeciesMetrics.rb +++ b/Data/Scripts/010_Data/002_PBS data/010_SpeciesMetrics.rb @@ -70,9 +70,7 @@ module GameData def apply_metrics_to_sprite(sprite, index, shadow = false) if shadow - if (index & 1) == 1 # Foe Pokémon - sprite.x += @shadow_x * 2 - end + sprite.x += @shadow_x * 2 if (index & 1) == 1 # Foe Pokémon elsif (index & 1) == 0 # Player's Pokémon sprite.x += @back_sprite[0] * 2 sprite.y += @back_sprite[1] * 2 diff --git a/Data/Scripts/010_Data/002_PBS data/012_Ribbon.rb b/Data/Scripts/010_Data/002_PBS data/012_Ribbon.rb index 90c0f058c..5f0f707ba 100644 --- a/Data/Scripts/010_Data/002_PBS data/012_Ribbon.rb +++ b/Data/Scripts/010_Data/002_PBS data/012_Ribbon.rb @@ -33,12 +33,12 @@ module GameData # @return [String] the translated name of this ribbon def name - return pbGetMessageFromHash(MessageTypes::RibbonNames, @real_name) + return pbGetMessageFromHash(MessageTypes::RIBBON_NAMES, @real_name) end # @return [String] the translated description of this ribbon def description - return pbGetMessageFromHash(MessageTypes::RibbonDescriptions, @real_description) + return pbGetMessageFromHash(MessageTypes::RIBBON_DESCRIPTIONS, @real_description) end def has_flag?(flag) diff --git a/Data/Scripts/010_Data/002_PBS data/014_TrainerType.rb b/Data/Scripts/010_Data/002_PBS data/014_TrainerType.rb index 7b12c201a..ec3ac2a15 100644 --- a/Data/Scripts/010_Data/002_PBS data/014_TrainerType.rb +++ b/Data/Scripts/010_Data/002_PBS data/014_TrainerType.rb @@ -113,7 +113,7 @@ module GameData # @return [String] the translated name of this trainer type def name - return pbGetMessageFromHash(MessageTypes::TrainerTypes, @real_name) + return pbGetMessageFromHash(MessageTypes::TRAINER_TYPE_NAMES, @real_name) end def male?; return @gender == 0; end diff --git a/Data/Scripts/010_Data/002_PBS data/015_Trainer.rb b/Data/Scripts/010_Data/002_PBS data/015_Trainer.rb index 083eaf750..df301b5de 100644 --- a/Data/Scripts/010_Data/002_PBS data/015_Trainer.rb +++ b/Data/Scripts/010_Data/002_PBS data/015_Trainer.rb @@ -102,12 +102,12 @@ module GameData # @return [String] the translated name of this trainer def name - return pbGetMessageFromHash(MessageTypes::TrainerNames, @real_name) + return pbGetMessageFromHash(MessageTypes::TRAINER_NAMES, @real_name) end # @return [String] the translated in-battle lose message of this trainer def lose_text - return pbGetMessageFromHash(MessageTypes::TrainerLoseTexts, @real_lose_text) + return pbGetMessageFromHash(MessageTypes::TRAINER_SPEECHES_LOSE, @real_lose_text) end # Creates a battle-ready version of a trainer's data. diff --git a/Data/Scripts/010_Data/002_PBS data/016_Metadata.rb b/Data/Scripts/010_Data/002_PBS data/016_Metadata.rb index 80adbb0a7..8e8dbd285 100644 --- a/Data/Scripts/010_Data/002_PBS data/016_Metadata.rb +++ b/Data/Scripts/010_Data/002_PBS data/016_Metadata.rb @@ -74,7 +74,7 @@ module GameData # @return [String] the translated name of the Pokémon Storage creator def storage_creator - ret = pbGetMessageFromHash(MessageTypes::StorageCreator, @real_storage_creator) + ret = pbGetMessageFromHash(MessageTypes::STORAGE_CREATOR_NAME, @real_storage_creator) return nil_or_empty?(ret) ? _INTL("Bill") : ret end end diff --git a/Data/Scripts/010_Data/002_PBS data/018_MapMetadata.rb b/Data/Scripts/010_Data/002_PBS data/018_MapMetadata.rb index 8068d96ad..706719e48 100644 --- a/Data/Scripts/010_Data/002_PBS data/018_MapMetadata.rb +++ b/Data/Scripts/010_Data/002_PBS data/018_MapMetadata.rb @@ -115,7 +115,7 @@ module GameData # @return [String] the translated name of this map def name - ret = pbGetMessageFromHash(MessageTypes::MapNames, @real_name) + ret = pbGetMessageFromHash(MessageTypes::MAP_NAMES, @real_name) ret = pbGetBasicMapNameFromId(@id) if nil_or_empty?(ret) ret.gsub!(/\\PN/, $player.name) if $player return ret diff --git a/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb b/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb index b2b6ca12e..b950d71f5 100644 --- a/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb +++ b/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb @@ -211,9 +211,7 @@ class Battle oldSpAtk = pkmn.spatk oldSpDef = pkmn.spdef oldSpeed = pkmn.speed - if battler&.pokemon - battler.pokemon.changeHappiness("levelup") - end + battler.pokemon.changeHappiness("levelup") if battler&.pokemon pkmn.calc_stats battler&.pbUpdate(false) @scene.pbRefreshOne(battler.index) if battler diff --git a/Data/Scripts/011_Battle/001_Battle/004_Battle_ActionAttacksPriority.rb b/Data/Scripts/011_Battle/001_Battle/004_Battle_ActionAttacksPriority.rb index 938284f7d..43b4f3f9e 100644 --- a/Data/Scripts/011_Battle/001_Battle/004_Battle_ActionAttacksPriority.rb +++ b/Data/Scripts/011_Battle/001_Battle/004_Battle_ActionAttacksPriority.rb @@ -227,7 +227,7 @@ class Battle end # Reorder the priority array if needRearranging - @priority.sort! { |a, b| + @priority.sort! do |a, b| if a[5] != b[5] # Sort by priority (highest value first) b[5] <=> a[5] @@ -241,7 +241,7 @@ class Battle # Sort by speed (highest first), and use tie-breaker if necessary (a[1] == b[1]) ? b[6] <=> a[6] : b[1] <=> a[1] end - } + end # Write the priority order to the debug log logMsg = (fullCalc) ? "[Round order] " : "[Round order recalculated] " comma = false diff --git a/Data/Scripts/011_Battle/001_Battle/005_Battle_ActionSwitching.rb b/Data/Scripts/011_Battle/001_Battle/005_Battle_ActionSwitching.rb index 7a80aba15..6c7a93b46 100644 --- a/Data/Scripts/011_Battle/001_Battle/005_Battle_ActionSwitching.rb +++ b/Data/Scripts/011_Battle/001_Battle/005_Battle_ActionSwitching.rb @@ -111,7 +111,7 @@ class Battle # all instances where the party screen is opened. def pbPartyScreen(idxBattler, checkLaxOnly = false, canCancel = false, shouldRegister = false) ret = -1 - @scene.pbPartyScreen(idxBattler, canCancel) { |idxParty, partyScene| + @scene.pbPartyScreen(idxBattler, canCancel) do |idxParty, partyScene| if checkLaxOnly next false if !pbCanSwitchLax?(idxBattler, idxParty, partyScene) elsif !pbCanSwitch?(idxBattler, idxParty, partyScene) @@ -122,7 +122,7 @@ class Battle end ret = idxParty next true - } + end return ret end diff --git a/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb b/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb index fbbd876bb..c260330d2 100644 --- a/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb +++ b/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb @@ -64,7 +64,7 @@ class Battle return true if pbAutoFightMenu(idxBattler) # Regular move selection ret = false - @scene.pbFightMenu(idxBattler, pbCanMegaEvolve?(idxBattler)) { |cmd| + @scene.pbFightMenu(idxBattler, pbCanMegaEvolve?(idxBattler)) do |cmd| case cmd when -1 # Cancel when -2 # Toggle Mega Evolution @@ -83,7 +83,7 @@ class Battle ret = true end next true - } + end return ret end @@ -103,7 +103,7 @@ class Battle return false end ret = false - @scene.pbItemMenu(idxBattler, firstAction) { |item, useType, idxPkmn, idxMove, itemScene| + @scene.pbItemMenu(idxBattler, firstAction) do |item, useType, idxPkmn, idxMove, itemScene| next false if !item battler = pkmn = nil case useType @@ -133,7 +133,7 @@ class Battle next false if !pbRegisterItem(idxBattler, item, idxPkmn, idxMove) ret = true next true - } + end return ret end diff --git a/Data/Scripts/011_Battle/001_Battle/010_Battle_AttackPhase.rb b/Data/Scripts/011_Battle/001_Battle/010_Battle_AttackPhase.rb index e76b6dbb5..f4717ff21 100644 --- a/Data/Scripts/011_Battle/001_Battle/010_Battle_AttackPhase.rb +++ b/Data/Scripts/011_Battle/001_Battle/010_Battle_AttackPhase.rb @@ -57,9 +57,9 @@ class Battle pbPursuit(b.index) return if @decision > 0 # Switch Pokémon - allBattlers.each do |b| - b.droppedBelowHalfHP = false - b.statsDropped = false + allBattlers.each do |b2| + b2.droppedBelowHalfHP = false + b2.statsDropped = false end pbRecallAndReplace(b.index, idxNewPkmn) pbOnBattlerEnteringBattle(b.index, true) diff --git a/Data/Scripts/011_Battle/001_Battle/011_Battle_EndOfRoundPhase.rb b/Data/Scripts/011_Battle/001_Battle/011_Battle_EndOfRoundPhase.rb index 6a03f5145..5d1392d46 100644 --- a/Data/Scripts/011_Battle/001_Battle/011_Battle_EndOfRoundPhase.rb +++ b/Data/Scripts/011_Battle/001_Battle/011_Battle_EndOfRoundPhase.rb @@ -141,9 +141,9 @@ class Battle next if battler.opposes?(side) next if !battler.takesIndirectDamage? || battler.pbHasType?(:FIRE) @scene.pbDamageAnimation(battler) - battler.pbTakeEffectDamage(battler.totalhp / 8, false) { |hp_lost| + battler.pbTakeEffectDamage(battler.totalhp / 8, false) do |hp_lost| pbDisplay(_INTL("{1} is hurt by the sea of fire!", battler.pbThis)) - } + end end end end @@ -190,11 +190,11 @@ class Battle recipient = @battlers[battler.effects[PBEffects::LeechSeed]] next if !recipient || recipient.fainted? pbCommonAnimation("LeechSeed", recipient, battler) - battler.pbTakeEffectDamage(battler.totalhp / 8) { |hp_lost| + battler.pbTakeEffectDamage(battler.totalhp / 8) do |hp_lost| recipient.pbRecoverHPFromDrain(hp_lost, battler, _INTL("{1}'s health is sapped by Leech Seed!", battler.pbThis)) recipient.pbAbilitiesOnDamageTaken - } + end recipient.pbFaint if recipient.fainted? end end @@ -257,16 +257,16 @@ class Battle priority.each do |battler| battler.effects[PBEffects::Nightmare] = false if !battler.asleep? next if !battler.effects[PBEffects::Nightmare] || !battler.takesIndirectDamage? - battler.pbTakeEffectDamage(battler.totalhp / 4) { |hp_lost| + battler.pbTakeEffectDamage(battler.totalhp / 4) do |hp_lost| pbDisplay(_INTL("{1} is locked in a nightmare!", battler.pbThis)) - } + end end # Curse priority.each do |battler| next if !battler.effects[PBEffects::Curse] || !battler.takesIndirectDamage? - battler.pbTakeEffectDamage(battler.totalhp / 4) { |hp_lost| + battler.pbTakeEffectDamage(battler.totalhp / 4) do |hp_lost| pbDisplay(_INTL("{1} is afflicted by the curse!", battler.pbThis)) - } + end end end @@ -299,9 +299,9 @@ class Battle hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? battler.totalhp / 6 : battler.totalhp / 8 end @scene.pbDamageAnimation(battler) - battler.pbTakeEffectDamage(hpLoss, false) { |hp_lost| + battler.pbTakeEffectDamage(hpLoss, false) do |hp_lost| pbDisplay(_INTL("{1} is hurt by {2}!", battler.pbThis, move_name)) - } + end end #============================================================================= @@ -317,9 +317,9 @@ class Battle def pbEOREndBattlerEffects(priority) # Taunt - pbEORCountDownBattlerEffect(priority, PBEffects::Taunt) { |battler| + pbEORCountDownBattlerEffect(priority, PBEffects::Taunt) do |battler| pbDisplay(_INTL("{1}'s taunt wore off!", battler.pbThis)) - } + end # Encore priority.each do |battler| next if battler.fainted? || battler.effects[PBEffects::Encore] == 0 @@ -337,34 +337,34 @@ class Battle end end # Disable/Cursed Body - pbEORCountDownBattlerEffect(priority, PBEffects::Disable) { |battler| + pbEORCountDownBattlerEffect(priority, PBEffects::Disable) do |battler| battler.effects[PBEffects::DisableMove] = nil pbDisplay(_INTL("{1} is no longer disabled!", battler.pbThis)) - } + end # Magnet Rise - pbEORCountDownBattlerEffect(priority, PBEffects::MagnetRise) { |battler| + pbEORCountDownBattlerEffect(priority, PBEffects::MagnetRise) do |battler| pbDisplay(_INTL("{1}'s electromagnetism wore off!", battler.pbThis)) - } + end # Telekinesis - pbEORCountDownBattlerEffect(priority, PBEffects::Telekinesis) { |battler| + pbEORCountDownBattlerEffect(priority, PBEffects::Telekinesis) do |battler| pbDisplay(_INTL("{1} was freed from the telekinesis!", battler.pbThis)) - } + end # Heal Block - pbEORCountDownBattlerEffect(priority, PBEffects::HealBlock) { |battler| + pbEORCountDownBattlerEffect(priority, PBEffects::HealBlock) do |battler| pbDisplay(_INTL("{1}'s Heal Block wore off!", battler.pbThis)) - } + end # Embargo - pbEORCountDownBattlerEffect(priority, PBEffects::Embargo) { |battler| + pbEORCountDownBattlerEffect(priority, PBEffects::Embargo) do |battler| pbDisplay(_INTL("{1} can use items again!", battler.pbThis)) battler.pbItemTerrainStatBoostCheck - } + end # Yawn - pbEORCountDownBattlerEffect(priority, PBEffects::Yawn) { |battler| + pbEORCountDownBattlerEffect(priority, PBEffects::Yawn) do |battler| if battler.pbCanSleepYawn? PBDebug.log("[Lingering effect] #{battler.pbThis} fell asleep because of Yawn") battler.pbSleep end - } + end # Perish Song perishSongUsers = [] priority.each do |battler| diff --git a/Data/Scripts/011_Battle/002_Battler/006_Battler_AbilityAndItem.rb b/Data/Scripts/011_Battle/002_Battler/006_Battler_AbilityAndItem.rb index 02fa3e9fa..69989790f 100644 --- a/Data/Scripts/011_Battle/002_Battler/006_Battler_AbilityAndItem.rb +++ b/Data/Scripts/011_Battle/002_Battler/006_Battler_AbilityAndItem.rb @@ -72,10 +72,10 @@ class Battle::Battler # in and not at any later times, even if a traceable ability turns # up later. Essentials ignores this, and allows Trace to trigger # whenever it can even in Gen 5 battle mechanics. - choices = @battle.allOtherSideBattlers(@index).select { |b| + choices = @battle.allOtherSideBattlers(@index).select do |b| next !b.ungainableAbility? && ![:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability_id) - } + end if choices.length > 0 choice = choices[@battle.pbRandom(choices.length)] @battle.pbShowAbilitySplash(self) diff --git a/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb b/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb index f340b5f18..710103a1b 100644 --- a/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb +++ b/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb @@ -48,9 +48,7 @@ class Battle::Battler end # Use the move PBDebug.log("[Move usage] #{pbThis} started using #{choice[2].name}") - PBDebug.logonerr { - pbUseMove(choice, choice[2] == @battle.struggle) - } + PBDebug.logonerr { pbUseMove(choice, choice[2] == @battle.struggle) } @battle.pbJudge # Update priority order @battle.pbCalculatePriority if Settings::RECALCULATE_TURN_ORDER_AFTER_SPEED_CHANGES @@ -315,9 +313,9 @@ class Battle::Battler @battle.pbDisplay(_INTL("When the flame touched the powder on the Pokémon, it exploded!")) user.lastMoveFailed = true if ![:Rain, :HeavyRain].include?(user.effectiveWeather) && user.takesIndirectDamage? - user.pbTakeEffectDamage((user.totalhp / 4.0).round, false) { |hp_lost| + user.pbTakeEffectDamage((user.totalhp / 4.0).round, false) do |hp_lost| @battle.pbDisplay(_INTL("{1} is hurt by its {2}!", battler.pbThis, battler.itemName)) - } + end @battle.pbGainExp # In case user is KO'd by this end pbCancelMoves @@ -531,9 +529,9 @@ class Battle::Battler @battle.pbDisplay(_INTL("{1} used the move instructed by {2}!", b.pbThis, user.pbThis(true))) b.effects[PBEffects::Instructed] = true if b.pbCanChooseMove?(@moves[idxMove], false) - PBDebug.logonerr { + PBDebug.logonerr do b.pbUseMoveSimple(b.lastMoveUsed, b.lastRegularMoveTarget, idxMove, false) - } + end b.lastRoundMoved = oldLastRoundMoved @battle.pbJudge return if @battle.decision > 0 @@ -567,9 +565,7 @@ class Battle::Battler end nextUser.effects[PBEffects::Dancer] = true if nextUser.pbCanChooseMove?(move, false) - PBDebug.logonerr { - nextUser.pbUseMoveSimple(move.id, preTarget) - } + PBDebug.logonerr { nextUser.pbUseMoveSimple(move.id, preTarget) } nextUser.lastRoundMoved = oldLastRoundMoved nextUser.effects[PBEffects::Outrage] = oldOutrage nextUser.currentMove = oldCurrentMove @@ -716,9 +712,7 @@ class Battle::Battler next if b.damageState.calcDamage == 0 chance = move.pbAdditionalEffectChance(user, b) next if chance <= 0 - if @battle.pbRandom(100) < chance - move.pbAdditionalEffect(user, b) - end + move.pbAdditionalEffect(user, b) if @battle.pbRandom(100) < chance end end # Make the target flinch (because of an item/ability) diff --git a/Data/Scripts/011_Battle/003_Move/002_Move_Usage.rb b/Data/Scripts/011_Battle/003_Move/002_Move_Usage.rb index 466aa30dd..02836d7f0 100644 --- a/Data/Scripts/011_Battle/003_Move/002_Move_Usage.rb +++ b/Data/Scripts/011_Battle/003_Move/002_Move_Usage.rb @@ -104,11 +104,11 @@ class Battle::Move def pbFailsAgainstTarget?(user, target, show_message); return false; end def pbMoveFailedLastInRound?(user, showMessage = true) - unmoved = @battle.allBattlers.any? { |b| + unmoved = @battle.allBattlers.any? do |b| next b.index != user.index && [:UseMove, :Shift].include?(@battle.choices[b.index][0]) && !b.movedThisRound? - } + end if !unmoved @battle.pbDisplay(_INTL("But it failed!")) if showMessage return true diff --git a/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb b/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb index bab8fff14..f3bbaafbb 100644 --- a/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb +++ b/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb @@ -226,16 +226,12 @@ class Battle::Move def pbModifyDamage(damageMult, user, target); return damageMult; end def pbGetAttackStats(user, target) - if specialMove? - return user.spatk, user.stages[:SPECIAL_ATTACK] + 6 - end + return user.spatk, user.stages[:SPECIAL_ATTACK] + 6 if specialMove? return user.attack, user.stages[:ATTACK] + 6 end def pbGetDefenseStats(user, target) - if specialMove? - return target.spdef, target.stages[:SPECIAL_DEFENSE] + 6 - end + return target.spdef, target.stages[:SPECIAL_DEFENSE] + 6 if specialMove? return target.defense, target.stages[:DEFENSE] + 6 end @@ -396,9 +392,7 @@ class Battle::Move end end # Multi-targeting attacks - if numTargets > 1 - multipliers[:final_damage_multiplier] *= 0.75 - end + multipliers[:final_damage_multiplier] *= 0.75 if numTargets > 1 # Weather case user.effectiveWeather when :Sun, :HarshSun diff --git a/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb b/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb index 1bdc45386..d7081a9a6 100644 --- a/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb +++ b/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb @@ -356,8 +356,7 @@ class Battle::Move::TwoTurnMove < Battle::Move @battle.pbDisplay(_INTL("{1} began charging up!", user.pbThis)) end - def pbAttackingTurnMessage(user, targets) - end + def pbAttackingTurnMessage(user, targets); end def pbEffectAgainstTarget(user, target) if @damagingTurn @@ -372,8 +371,7 @@ class Battle::Move::TwoTurnMove < Battle::Move # the latter just records the target is being Sky Dropped end - def pbAttackingTurnEffect(user, target) - end + def pbAttackingTurnEffect(user, target); end def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) hitNum = 1 if @chargingTurn && !@damagingTurn # Charging anim diff --git a/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb b/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb index 1afa61381..500667125 100644 --- a/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb +++ b/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb @@ -100,9 +100,7 @@ class Battle::Move::OHKO < Battle::Move::FixedDamageMove def pbHitEffectivenessMessages(user, target, numTargets = 1) super - if target.fainted? - @battle.pbDisplay(_INTL("It's a one-hit KO!")) - end + @battle.pbDisplay(_INTL("It's a one-hit KO!")) if target.fainted? end end @@ -1211,9 +1209,7 @@ end #=============================================================================== class Battle::Move::UseTargetAttackInsteadOfUserAttack < Battle::Move def pbGetAttackStats(user, target) - if specialMove? - return target.spatk, target.stages[:SPECIAL_ATTACK] + 6 - end + return target.spatk, target.stages[:SPECIAL_ATTACK] + 6 if specialMove? return target.attack, target.stages[:ATTACK] + 6 end end diff --git a/Data/Scripts/011_Battle/004_Scene/001_Battle_Scene.rb b/Data/Scripts/011_Battle/004_Scene/001_Battle_Scene.rb index 6d2c93921..339c016a0 100644 --- a/Data/Scripts/011_Battle/004_Scene/001_Battle_Scene.rb +++ b/Data/Scripts/011_Battle/004_Scene/001_Battle_Scene.rb @@ -363,8 +363,7 @@ class Battle::Scene pbShowWindow(MESSAGE_BOX) end - def pbBeginEndOfRoundPhase - end + def pbBeginEndOfRoundPhase; end def pbEndBattle(_result) @abortable = false diff --git a/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb b/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb index cb6eeb4b4..fce6e46c5 100644 --- a/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb +++ b/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb @@ -98,15 +98,11 @@ class Battle::Scene if Input.trigger?(Input::LEFT) cw.index -= 1 if (cw.index & 1) == 1 elsif Input.trigger?(Input::RIGHT) - if battler.moves[cw.index + 1]&.id && (cw.index & 1) == 0 - cw.index += 1 - end + cw.index += 1 if battler.moves[cw.index + 1]&.id && (cw.index & 1) == 0 elsif Input.trigger?(Input::UP) cw.index -= 2 if (cw.index & 2) == 2 elsif Input.trigger?(Input::DOWN) - if battler.moves[cw.index + 2]&.id && (cw.index & 2) == 0 - cw.index += 2 - end + cw.index += 2 if battler.moves[cw.index + 2]&.id && (cw.index & 2) == 0 end pbPlayCursorSE if cw.index != oldIndex # Actions @@ -449,11 +445,11 @@ class Battle::Scene # not allow HM moves to be forgotten. def pbForgetMove(pkmn, moveToLearn) ret = -1 - pbFadeOutIn { + pbFadeOutIn do scene = PokemonSummary_Scene.new screen = PokemonSummaryScreen.new(scene) ret = screen.pbStartForgetScreen([pkmn], 0, moveToLearn) - } + end return ret end @@ -468,10 +464,10 @@ class Battle::Scene # Shows the Pokédex entry screen for a newly caught Pokémon #============================================================================= def pbShowPokedex(species) - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokedexInfo_Scene.new screen = PokemonPokedexInfoScreen.new(scene) screen.pbDexEntry(species) - } + end end end diff --git a/Data/Scripts/011_Battle/004_Scene/004_Scene_PlayAnimations.rb b/Data/Scripts/011_Battle/004_Scene/004_Scene_PlayAnimations.rb index 97090b220..d54f40f5c 100644 --- a/Data/Scripts/011_Battle/004_Scene/004_Scene_PlayAnimations.rb +++ b/Data/Scripts/011_Battle/004_Scene/004_Scene_PlayAnimations.rb @@ -137,9 +137,7 @@ class Battle::Scene a[2] = true if a[1].animDone? end pbUpdate - if !inPartyAnimation? && sendOutAnims.none? { |a| !a[2] } - break - end + break if !inPartyAnimation? && sendOutAnims.none? { |a| !a[2] } end fadeAnim.dispose sendOutAnims.each do |a| @@ -498,13 +496,13 @@ class Battle::Scene target = (targets.is_a?(Array)) ? targets[0] : targets animations = pbLoadBattleAnimations return if !animations - pbSaveShadows { + pbSaveShadows do if animID[1] # On opposing side and using OppMove animation pbAnimationCore(animations[anim], target, user, true) else # On player's side, and/or using Move animation pbAnimationCore(animations[anim], user, target) end - } + end end # Plays a common animation. diff --git a/Data/Scripts/011_Battle/004_Scene/007_Battle_Scene_BaseAnimation.rb b/Data/Scripts/011_Battle/004_Scene/007_Battle_Scene_BaseAnimation.rb index 48acfed5f..1f60f42c2 100644 --- a/Data/Scripts/011_Battle/004_Scene/007_Battle_Scene_BaseAnimation.rb +++ b/Data/Scripts/011_Battle/004_Scene/007_Battle_Scene_BaseAnimation.rb @@ -401,8 +401,8 @@ module Battle::Scene::Animation::BallAnimationMixin angle = rand(360) radian = (angle + 90) * Math::PI / 180 start_zoom = rand(50...100) - ray = addNewSprite(ballX + ray_min_radius * Math.cos(radian), - ballY - ray_min_radius * Math.sin(radian), + ray = addNewSprite(ballX + (ray_min_radius * Math.cos(radian)), + ballY - (ray_min_radius * Math.sin(radian)), "Graphics/Battle animations/ballBurst_ray", PictureOrigin::BOTTOM) ray.setZ(0, 100) ray.setZoomXY(0, 200, start_zoom) @@ -411,7 +411,7 @@ module Battle::Scene::Animation::BallAnimationMixin ray.setVisible(0, false) ray.setAngle(0, angle) # Animate ray - start = delay + i / 2 + start = delay + (i / 2) ray.setVisible(start, true) ray.moveZoomXY(start, ray_lifetime, 200, start_zoom * 6) ray.moveOpacity(start, 2, 255) # Quickly fade in @@ -437,7 +437,7 @@ module Battle::Scene::Animation::BallAnimationMixin particle.setVisible(0, false) end # Animate particles - start = delay + i / 4 + start = delay + (i / 4) max_radius = rand(256...384) angle = rand(360) radian = angle * Math::PI / 180 @@ -596,7 +596,7 @@ module Battle::Scene::Animation::BallAnimationMixin else glare1.moveZoom(delay, particle_duration, 600) end - glare1.moveOpacity(delay + particle_duration / 2, particle_duration / 2, 0) + glare1.moveOpacity(delay + (particle_duration / 2), particle_duration / 2, 0) [glare1, glare2, glare3].each_with_index do |particle, num| particle.moveTone(delay, particle_duration, variances[8 - (3 * num)]) end @@ -604,13 +604,13 @@ module Battle::Scene::Animation::BallAnimationMixin glare2.moveZoom(delay, particle_duration, 350) glare3.moveZoom(delay, particle_duration, 500) [glare2, glare3].each_with_index do |particle, num| - particle.moveOpacity(delay + particle_duration / 2, particle_duration / 2, 0) + particle.moveOpacity(delay + (particle_duration / 2), particle_duration / 2, 0) end else glare2.moveZoom(delay, particle_duration, (poke_ball == :MASTERBALL) ? 400 : 250) - glare2.moveOpacity(delay + particle_duration / 2, particle_duration / 3, 0) + glare2.moveOpacity(delay + (particle_duration / 2), particle_duration / 3, 0) glare3.moveZoom(delay, particle_duration, (poke_ball == :MASTERBALL) ? 800 : 500) - glare3.moveOpacity(delay + particle_duration / 2, particle_duration / 3, 0) + glare3.moveOpacity(delay + (particle_duration / 2), particle_duration / 3, 0) end [glare1, glare2, glare3].each { |p| p.setVisible(delay + particle_duration, false) } # Burst particles @@ -647,12 +647,12 @@ module Battle::Scene::Animation::BallAnimationMixin prop = 2 - prop if index > particle_duration / 2 radius *= prop particle1.moveXY(delay + j, 1, - ballX + p1_x_offset * index * 2 / particle_duration, - ballY - p1_y_offset * index * 2 / particle_duration) + ballX + (p1_x_offset * index * 2 / particle_duration), + ballY - (p1_y_offset * index * 2 / particle_duration)) [particle2, particle3].each do |particle| particle.moveXY(delay + j, 1, - ballX + radius * Math.cos(radian), - ballY - radius * Math.sin(radian)) + ballX + (radius * Math.cos(radian)), + ballY - (radius * Math.sin(radian))) end end particle1.moveZoom(delay, particle_duration, 0) @@ -674,14 +674,14 @@ module Battle::Scene::Animation::BallAnimationMixin end # Zoom out if ["particle", "dazzle", "ring3", "ring4", "diamond"].include?(variances[12 - (3 * num)]) - particle.moveZoom(delay + particle_duration * 2 / 3, particle_duration / 3, 10) + particle.moveZoom(delay + (particle_duration * 2 / 3), particle_duration / 3, 10) else - particle.moveZoom(delay + particle_duration * 2 / 3, particle_duration / 3, 25) + particle.moveZoom(delay + (particle_duration * 2 / 3), particle_duration / 3, 25) end # Rotate (for Premier Ball) particle.moveAngle(delay, particle_duration, -180) if poke_ball == :PREMIERBALL # Change tone, fade out - particle.moveTone(delay + particle_duration / 3, (particle_duration.to_f / 3).ceil, variances[14 - (3 * num)]) + particle.moveTone(delay + (particle_duration / 3), (particle_duration.to_f / 3).ceil, variances[14 - (3 * num)]) particle.moveOpacity(delay + particle_duration - 3, 3, 128) # Fade out at end end [particle1, particle2, particle3].each { |p| p.setVisible(delay + particle_duration, false) } @@ -702,7 +702,7 @@ module Battle::Scene::Animation::BallAnimationMixin web.moveZoom(delay + start + (i * 4), 2, 150) web.moveZoom(delay + start + (i * 4) + 2, 2, 120) end - now = start + (web_duration / 4) * 4 + now = start + ((web_duration / 4) * 4) web.moveZoom(delay + now, particle_duration + ring_duration - now, 150) web.moveOpacity(delay + particle_duration, ring_duration, 0) web.setVisible(delay + particle_duration + ring_duration, false) @@ -747,10 +747,10 @@ module Battle::Scene::Animation::BallAnimationMixin index = j + 1 x = 72 * index / star_duration proportion = index.to_f / star_duration - a = (2 * y_pos[2]) - 4 * y_pos[1] + a = (2 * y_pos[2]) - (4 * y_pos[1]) b = y_pos[2] - a y = ((a * proportion) + b) * proportion - star.moveXY(delay + j, 1, ballX + [-1, 0, 1][i] * x, ballY - y) + star.moveXY(delay + j, 1, ballX + ([-1, 0, 1][i] * x), ballY - y) end star.moveAngle(delay, star_duration, start_angle + [144, 0, 45][i]) if i.even? star.moveOpacity(delay, 4, 255) # Fade in @@ -789,17 +789,17 @@ module Battle::Scene::Animation::BallAnimationMixin prop = j.to_f / (color_duration / 3) radius *= 0.75 + (prop / 4) elsif j >= burst_duration / 2 - prop = (j.to_f - burst_duration / 2) / (burst_duration / 2) + prop = (j.to_f - (burst_duration / 2)) / (burst_duration / 2) radius *= 1 - prop end if j == 0 - particle.setXY(delay + j, ballX + radius * Math.cos(radian), ballY - radius * Math.sin(radian)) + particle.setXY(delay + j, ballX + (radius * Math.cos(radian)), ballY - (radius * Math.sin(radian))) else - particle.moveXY(delay + j, 1, ballX + radius * Math.cos(radian), ballY - radius * Math.sin(radian)) + particle.moveXY(delay + j, 1, ballX + (radius * Math.cos(radian)), ballY - (radius * Math.sin(radian))) end end particle.moveZoom(delay, burst_duration, 0) - particle.moveTone(delay + color_duration / 2, color_duration / 2, Tone.new(0, 0, -192)) # Yellow + particle.moveTone(delay + (color_duration / 2), color_duration / 2, Tone.new(0, 0, -192)) # Yellow particle.moveTone(delay + color_duration, shrink_duration, Tone.new(0, -128, -248)) # Dark orange particle.moveOpacity(delay + color_duration, shrink_duration, 0) # Fade out at end particle.setVisible(delay + burst_duration, false) diff --git a/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb b/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb index aa2c13f8d..4d8fb4927 100644 --- a/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb +++ b/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb @@ -323,10 +323,10 @@ class Battle::Scene::Animation::PlayerFade < Battle::Scene::Animation partyBar.setVisible(delay + 12, false) partyBar.setOpacity(delay + 12, 255) end - Battle::Scene::NUM_BALLS.times do |i| - next if !@sprites["partyBall_0_#{i}"] || !@sprites["partyBall_0_#{i}"].visible - partyBall = addSprite(@sprites["partyBall_0_#{i}"]) - partyBall.moveDelta(delay + (2 * i), 16, -Graphics.width, 0) if @fullAnim + Battle::Scene::NUM_BALLS.times do |j| + next if !@sprites["partyBall_0_#{j}"] || !@sprites["partyBall_0_#{j}"].visible + partyBall = addSprite(@sprites["partyBall_0_#{j}"]) + partyBall.moveDelta(delay + (2 * j), 16, -Graphics.width, 0) if @fullAnim partyBall.moveOpacity(delay, 12, 0) partyBall.setVisible(delay + 12, false) partyBall.setOpacity(delay + 12, 255) @@ -366,10 +366,10 @@ class Battle::Scene::Animation::TrainerFade < Battle::Scene::Animation partyBar.setVisible(delay + 12, false) partyBar.setOpacity(delay + 12, 255) end - Battle::Scene::NUM_BALLS.times do |i| - next if !@sprites["partyBall_1_#{i}"] || !@sprites["partyBall_1_#{i}"].visible - partyBall = addSprite(@sprites["partyBall_1_#{i}"]) - partyBall.moveDelta(delay + (2 * i), 16, Graphics.width, 0) if @fullAnim + Battle::Scene::NUM_BALLS.times do |j| + next if !@sprites["partyBall_1_#{j}"] || !@sprites["partyBall_1_#{j}"].visible + partyBall = addSprite(@sprites["partyBall_1_#{j}"]) + partyBall.moveDelta(delay + (2 * j), 16, Graphics.width, 0) if @fullAnim partyBall.moveOpacity(delay, 12, 0) partyBall.setVisible(delay + 12, false) partyBall.setOpacity(delay + 12, 255) diff --git a/Data/Scripts/011_Battle/006_Other battle code/005_Battle_CatchAndStoreMixin.rb b/Data/Scripts/011_Battle/006_Other battle code/005_Battle_CatchAndStoreMixin.rb index 058899ab5..22e3febce 100644 --- a/Data/Scripts/011_Battle/006_Other battle code/005_Battle_CatchAndStoreMixin.rb +++ b/Data/Scripts/011_Battle/006_Other battle code/005_Battle_CatchAndStoreMixin.rb @@ -26,10 +26,10 @@ module Battle::CatchAndStoreMixin when 0 # Add to your party pbDisplay(_INTL("Choose a Pokémon in your party to send to your Boxes.")) party_index = -1 - @scene.pbPartyScreen(0, (@sendToBoxes != 2), 1) { |idxParty, _partyScene| + @scene.pbPartyScreen(0, (@sendToBoxes != 2), 1) do |idxParty, _partyScene| party_index = idxParty next true - } + end next if party_index < 0 # Cancelled party_size = pbPlayer.party.length # Send chosen Pokémon to storage @@ -56,11 +56,11 @@ module Battle::CatchAndStoreMixin when 1 # Send to a Box break when 2 # See X's summary - pbFadeOutIn { + pbFadeOutIn do summary_scene = PokemonSummary_Scene.new summary_screen = PokemonSummaryScreen.new(summary_scene, true) summary_screen.pbStartScreen([pkmn], 0) - } + end when 3 # Check party @scene.pbPartyScreen(0, true, 2) end diff --git a/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb b/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb index 5b0d8443c..46009bde7 100644 --- a/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb +++ b/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb @@ -1240,9 +1240,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:DRAGONSMAW, Battle::AbilityEffects::DamageCalcFromUser.add(:FLAREBOOST, proc { |ability, user, target, move, mults, baseDmg, type| - if user.burned? && move.specialMove? - mults[:base_damage_multiplier] *= 1.5 - end + mults[:base_damage_multiplier] *= 1.5 if user.burned? && move.specialMove? } ) @@ -1384,9 +1382,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:SOLARPOWER, Battle::AbilityEffects::DamageCalcFromUser.add(:SNIPER, proc { |ability, user, target, move, mults, baseDmg, type| - if target.damageState.critical - mults[:final_damage_multiplier] *= 1.5 - end + mults[:final_damage_multiplier] *= 1.5 if target.damageState.critical } ) @@ -1546,9 +1542,7 @@ Battle::AbilityEffects::DamageCalcFromTarget.add(:FURCOAT, Battle::AbilityEffects::DamageCalcFromTarget.add(:GRASSPELT, proc { |ability, user, target, move, mults, baseDmg, type| - if user.battle.field.terrain == :Grassy - mults[:defense_multiplier] *= 1.5 - end + mults[:defense_multiplier] *= 1.5 if user.battle.field.terrain == :Grassy } ) @@ -1610,9 +1604,7 @@ Battle::AbilityEffects::DamageCalcFromTargetNonIgnorable.add(:PRISMARMOR, Battle::AbilityEffects::DamageCalcFromTargetNonIgnorable.add(:SHADOWSHIELD, proc { |ability, user, target, move, mults, baseDmg, type| - if target.hp == target.totalhp - mults[:final_damage_multiplier] /= 2 - end + mults[:final_damage_multiplier] /= 2 if target.hp == target.totalhp } ) @@ -2425,7 +2417,7 @@ Battle::AbilityEffects::EndOfRoundEffect.add(:BADDREAMS, next if !b.near?(battler) || !b.asleep? battle.pbShowAbilitySplash(battler) next if !b.takesIndirectDamage?(Battle::Scene::USE_ABILITY_SPLASH) - b.pbTakeEffectDamage(b.totalhp / 8) { |hp_lost| + b.pbTakeEffectDamage(b.totalhp / 8) do |hp_lost| if Battle::Scene::USE_ABILITY_SPLASH battle.pbDisplay(_INTL("{1} is tormented!", b.pbThis)) else @@ -2433,7 +2425,7 @@ Battle::AbilityEffects::EndOfRoundEffect.add(:BADDREAMS, b.pbThis, battler.pbThis(true), battler.abilityName)) end battle.pbHideAbilitySplash(battler) - } + end end } ) diff --git a/Data/Scripts/011_Battle/006_Other battle code/009_Battle_ItemEffects.rb b/Data/Scripts/011_Battle/006_Other battle code/009_Battle_ItemEffects.rb index 203cb30f5..9ae62a8ab 100644 --- a/Data/Scripts/011_Battle/006_Other battle code/009_Battle_ItemEffects.rb +++ b/Data/Scripts/011_Battle/006_Other battle code/009_Battle_ItemEffects.rb @@ -889,9 +889,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:LIFEORB, Battle::ItemEffects::DamageCalcFromUser.add(:LIGHTBALL, proc { |item, user, target, move, mults, baseDmg, type| - if user.isSpecies?(:PIKACHU) - mults[:attack_multiplier] *= 2 - end + mults[:attack_multiplier] *= 2 if user.isSpecies?(:PIKACHU) } ) @@ -1844,9 +1842,9 @@ Battle::ItemEffects::EndOfRoundHealing.add(:BLACKSLUDGE, battler.pbThis, battler.itemName)) elsif battler.takesIndirectDamage? battle.pbCommonAnimation("UseItem", battler) - battler.pbTakeEffectDamage(battler.totalhp / 8) { |hp_lost| + battler.pbTakeEffectDamage(battler.totalhp / 8) do |hp_lost| battle.pbDisplay(_INTL("{1} is hurt by its {2}!", battler.pbThis, battler.itemName)) - } + end end } ) @@ -1876,9 +1874,9 @@ Battle::ItemEffects::EndOfRoundEffect.add(:STICKYBARB, proc { |item, battler, battle| next if !battler.takesIndirectDamage? battle.scene.pbDamageAnimation(battler) - battler.pbTakeEffectDamage(battler.totalhp / 8, false) { |hp_lost| + battler.pbTakeEffectDamage(battler.totalhp / 8, false) do |hp_lost| battle.pbDisplay(_INTL("{1} is hurt by its {2}!", battler.pbThis, battler.itemName)) - } + end } ) diff --git a/Data/Scripts/011_Battle/007_Other battle types/004_BattleArenaBattle.rb b/Data/Scripts/011_Battle/007_Other battle types/004_BattleArenaBattle.rb index 98e2bf78a..4d166dfdc 100644 --- a/Data/Scripts/011_Battle/007_Other battle types/004_BattleArenaBattle.rb +++ b/Data/Scripts/011_Battle/007_Other battle types/004_BattleArenaBattle.rb @@ -271,10 +271,10 @@ class Battle::Scene msgwindow = pbCreateMessageWindow dimmingvp = Viewport.new(0, 0, Graphics.width, Graphics.height - msgwindow.height) pbMessageDisplay(msgwindow, - _INTL("REFEREE: That's it! We will now go to judging to determine the winner!\\wtnp[20]")) { + _INTL("REFEREE: That's it! We will now go to judging to determine the winner!\\wtnp[20]")) do pbBattleArenaUpdate dimmingvp.update - } + end dimmingvp.z = 99999 infowindow = SpriteWindow_Base.new(80, 0, 320, 224) infowindow.contents = Bitmap.new(infowindow.width - infowindow.borderX, @@ -299,25 +299,25 @@ class Battle::Scene end updateJudgment(infowindow, 1, battler1, battler2, ratings1, ratings2) pbMessageDisplay(msgwindow, - _INTL("REFEREE: Judging category 1, Mind!\nThe Pokémon showing the most guts!\\wtnp[40]")) { + _INTL("REFEREE: Judging category 1, Mind!\nThe Pokémon showing the most guts!\\wtnp[40]")) do pbBattleArenaUpdate dimmingvp.update infowindow.update - } + end updateJudgment(infowindow, 2, battler1, battler2, ratings1, ratings2) pbMessageDisplay(msgwindow, - _INTL("REFEREE: Judging category 2, Skill!\nThe Pokémon using moves the best!\\wtnp[40]")) { + _INTL("REFEREE: Judging category 2, Skill!\nThe Pokémon using moves the best!\\wtnp[40]")) do pbBattleArenaUpdate dimmingvp.update infowindow.update - } + end updateJudgment(infowindow, 3, battler1, battler2, ratings1, ratings2) pbMessageDisplay(msgwindow, - _INTL("REFEREE: Judging category 3, Body!\nThe Pokémon with the most vitality!\\wtnp[40]")) { + _INTL("REFEREE: Judging category 3, Body!\nThe Pokémon with the most vitality!\\wtnp[40]")) do pbBattleArenaUpdate dimmingvp.update infowindow.update - } + end total1 = 0 total2 = 0 3.times do |i| @@ -326,27 +326,27 @@ class Battle::Scene end if total1 == total2 pbMessageDisplay(msgwindow, - _INTL("REFEREE: Judgment: {1} to {2}!\nWe have a draw!\\wtnp[40]", total1, total2)) { + _INTL("REFEREE: Judgment: {1} to {2}!\nWe have a draw!\\wtnp[40]", total1, total2)) do pbBattleArenaUpdate dimmingvp.update infowindow.update - } + end elsif total1 > total2 pbMessageDisplay(msgwindow, _INTL("REFEREE: Judgment: {1} to {2}!\nThe winner is {3}'s {4}!\\wtnp[40]", - total1, total2, @battle.pbGetOwnerName(battler1.index), battler1.name)) { + total1, total2, @battle.pbGetOwnerName(battler1.index), battler1.name)) do pbBattleArenaUpdate dimmingvp.update infowindow.update - } + end else pbMessageDisplay(msgwindow, _INTL("REFEREE: Judgment: {1} to {2}!\nThe winner is {3}!\\wtnp[40]", - total1, total2, battler2.name)) { + total1, total2, battler2.name)) do pbBattleArenaUpdate dimmingvp.update infowindow.update - } + end end infowindow.visible = false msgwindow.visible = false diff --git a/Data/Scripts/012_Overworld/001_Overworld.rb b/Data/Scripts/012_Overworld/001_Overworld.rb index ebf6ce1cc..eb11ed113 100644 --- a/Data/Scripts/012_Overworld/001_Overworld.rb +++ b/Data/Scripts/012_Overworld/001_Overworld.rb @@ -448,52 +448,52 @@ end # Event movement #=============================================================================== module PBMoveRoute - Down = 1 - Left = 2 - Right = 3 - Up = 4 - LowerLeft = 5 - LowerRight = 6 - UpperLeft = 7 - UpperRight = 8 - Random = 9 - TowardPlayer = 10 - AwayFromPlayer = 11 - Forward = 12 - Backward = 13 - Jump = 14 # xoffset, yoffset - Wait = 15 # frames - TurnDown = 16 - TurnLeft = 17 - TurnRight = 18 - TurnUp = 19 - TurnRight90 = 20 - TurnLeft90 = 21 - Turn180 = 22 - TurnRightOrLeft90 = 23 - TurnRandom = 24 - TurnTowardPlayer = 25 - TurnAwayFromPlayer = 26 - SwitchOn = 27 # 1 param - SwitchOff = 28 # 1 param - ChangeSpeed = 29 # 1 param - ChangeFreq = 30 # 1 param - WalkAnimeOn = 31 - WalkAnimeOff = 32 - StepAnimeOn = 33 - StepAnimeOff = 34 - DirectionFixOn = 35 - DirectionFixOff = 36 - ThroughOn = 37 - ThroughOff = 38 - AlwaysOnTopOn = 39 - AlwaysOnTopOff = 40 - Graphic = 41 # Name, hue, direction, pattern - Opacity = 42 # 1 param - Blending = 43 # 1 param - PlaySE = 44 # 1 param - Script = 45 # 1 param - ScriptAsync = 101 # 1 param + DOWN = 1 + LEFT = 2 + RRIGHT = 3 + UP = 4 + LOWER_LEFT = 5 + LOWER_RIGHT = 6 + UPPER_LEFT = 7 + UPPER_RIGHT = 8 + RANDOM = 9 + TOWARD_PLAYER = 10 + AWAY_FROM_PLAYER = 11 + FORWARD = 12 + BACKWARD = 13 + JUMP = 14 # xoffset, yoffset + WAIT = 15 # frames + TURN_DOWN = 16 + TURN_LEFT = 17 + TURN_RIGHT = 18 + TURN_UP = 19 + TURN_RIGHT90 = 20 + TURN_LEFT90 = 21 + TURN180 = 22 + TURN_RIGHT_OR_LEFT90 = 23 + TURN_RANDOM = 24 + TURN_TOWARD_PLAYER = 25 + TURN_AWAY_FROM_PLAYER = 26 + SWITCH_ON = 27 # 1 param + SWITCH_OFF = 28 # 1 param + CHANGE_SPEED = 29 # 1 param + CHANGE_FREQUENCY = 30 # 1 param + WALK_ANIME_ON = 31 + WALK_ANIME_OFF = 32 + STEP_ANIME_ON = 33 + STEP_ANIME_OFF = 34 + DIRECTION_FIX_ON = 35 + DIRECTION_FIX_OFF = 36 + THROUGH_ON = 37 + THROUGH_OFF = 38 + ALWAYS_ON_TOP_ON = 39 + ALWAYS_ON_TOP_OFF = 40 + GRAPHIC = 41 # Name, hue, direction, pattern + OPACITY = 42 # 1 param + BLENDING = 43 # 1 param + PLAY_SE = 44 # 1 param + SCRIPT = 45 # 1 param + SCRIPT_ASYNC = 101 # 1 param end def pbMoveRoute(event, commands, waitComplete = false) @@ -501,23 +501,23 @@ def pbMoveRoute(event, commands, waitComplete = false) route.repeat = false route.skippable = true route.list.clear - route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOn)) + route.list.push(RPG::MoveCommand.new(PBMoveRoute::THROUGH_ON)) i = 0 while i < commands.length case commands[i] - when PBMoveRoute::Wait, PBMoveRoute::SwitchOn, PBMoveRoute::SwitchOff, - PBMoveRoute::ChangeSpeed, PBMoveRoute::ChangeFreq, PBMoveRoute::Opacity, - PBMoveRoute::Blending, PBMoveRoute::PlaySE, PBMoveRoute::Script + when PBMoveRoute::WAIT, PBMoveRoute::SWITCH_ON, PBMoveRoute::SWITCH_OFF, + PBMoveRoute::CHANGE_SPEED, PBMoveRoute::CHANGE_FREQUENCY, PBMoveRoute::OPACITY, + PBMoveRoute::BLENDING, PBMoveRoute::PLAY_SE, PBMoveRoute::SCRIPT route.list.push(RPG::MoveCommand.new(commands[i], [commands[i + 1]])) i += 1 - when PBMoveRoute::ScriptAsync - route.list.push(RPG::MoveCommand.new(PBMoveRoute::Script, [commands[i + 1]])) - route.list.push(RPG::MoveCommand.new(PBMoveRoute::Wait, [0])) + when PBMoveRoute::SCRIPT_ASYNC + route.list.push(RPG::MoveCommand.new(PBMoveRoute::SCRIPT, [commands[i + 1]])) + route.list.push(RPG::MoveCommand.new(PBMoveRoute::WAIT, [0])) i += 1 - when PBMoveRoute::Jump + when PBMoveRoute::JUMP route.list.push(RPG::MoveCommand.new(commands[i], [commands[i + 1], commands[i + 2]])) i += 2 - when PBMoveRoute::Graphic + when PBMoveRoute::GRAPHIC route.list.push(RPG::MoveCommand.new(commands[i], [commands[i + 1], commands[i + 2], commands[i + 3], commands[i + 4]])) @@ -527,7 +527,7 @@ def pbMoveRoute(event, commands, waitComplete = false) end i += 1 end - route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOff)) + route.list.push(RPG::MoveCommand.new(PBMoveRoute::THROUGH_OFF)) route.list.push(RPG::MoveCommand.new(0)) event&.force_move_route(route) return route diff --git a/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb b/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb index 5a5ef0494..cc2b265be 100644 --- a/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb +++ b/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb @@ -390,12 +390,10 @@ class WildBattle $game_temp.clear_battle_rules # Perform the battle itself outcome = 0 - pbBattleAnimation(pbGetWildBattleBGM(foe_party), (foe_party.length == 1) ? 0 : 2, foe_party) { - pbSceneStandby { - outcome = battle.pbStartBattle - } + pbBattleAnimation(pbGetWildBattleBGM(foe_party), (foe_party.length == 1) ? 0 : 2, foe_party) do + pbSceneStandby { outcome = battle.pbStartBattle } BattleCreationHelperMethods.after_battle(outcome, can_lose) - } + end Input.update # Save the result of the battle in a Game Variable (1 by default) BattleCreationHelperMethods.set_outcome(outcome, outcome_variable) @@ -512,12 +510,10 @@ class TrainerBattle $game_temp.clear_battle_rules # Perform the battle itself outcome = 0 - pbBattleAnimation(pbGetTrainerBattleBGM(foe_trainers), (battle.singleBattle?) ? 1 : 3, foe_trainers) { - pbSceneStandby { - outcome = battle.pbStartBattle - } + pbBattleAnimation(pbGetTrainerBattleBGM(foe_trainers), (battle.singleBattle?) ? 1 : 3, foe_trainers) do + pbSceneStandby { outcome = battle.pbStartBattle } BattleCreationHelperMethods.after_battle(outcome, can_lose) - } + end Input.update # Save the result of the battle in a Game Variable (1 by default) BattleCreationHelperMethods.set_outcome(outcome, outcome_variable, true) diff --git a/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb b/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb index ac854f642..07aa9e7cc 100644 --- a/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb +++ b/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb @@ -219,9 +219,7 @@ HiddenMoveHandlers::UseMove.add(:CUT, proc { |move, pokemon| end $stats.cut_count += 1 facingEvent = $game_player.pbFacingEvent - if facingEvent - pbSmashEvent(facingEvent) - end + pbSmashEvent(facingEvent) if facingEvent next true }) @@ -232,13 +230,10 @@ def pbSmashEvent(event) elsif event.name[/smashrock/i] pbSEPlay("Rock Smash", 80) end - pbMoveRoute(event, [PBMoveRoute::Wait, 2, - PBMoveRoute::TurnLeft, - PBMoveRoute::Wait, 2, - PBMoveRoute::TurnRight, - PBMoveRoute::Wait, 2, - PBMoveRoute::TurnUp, - PBMoveRoute::Wait, 2]) + pbMoveRoute(event, [PBMoveRoute::WAIT, 2, + PBMoveRoute::TURN_LEFT, PBMoveRoute::WAIT, 2, + PBMoveRoute::TURN_RIGHT, PBMoveRoute::WAIT, 2, + PBMoveRoute::TURN_UP, PBMoveRoute::WAIT, 2]) pbWait(Graphics.frame_rate * 4 / 10) event.erase $PokemonMap&.addErasedEvent(event.id) @@ -273,7 +268,7 @@ HiddenMoveHandlers::UseMove.add(:DIG, proc { |move, pokemon| if !pbHiddenMoveAnimation(pokemon) pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name)) end - pbFadeOutIn { + pbFadeOutIn do $game_temp.player_new_map_id = escape[0] $game_temp.player_new_x = escape[1] $game_temp.player_new_y = escape[2] @@ -282,7 +277,7 @@ HiddenMoveHandlers::UseMove.add(:DIG, proc { |move, pokemon| $scene.transfer_player $game_map.autoplay $game_map.refresh - } + end pbEraseEscapePoint next true end @@ -306,7 +301,7 @@ def pbDive speciesname = (movefinder) ? movefinder.name : $player.name pbMessage(_INTL("{1} used {2}!", speciesname, GameData::Move.get(move).name)) pbHiddenMoveAnimation(movefinder) - pbFadeOutIn { + pbFadeOutIn do $game_temp.player_new_map_id = map_metadata.dive_map_id $game_temp.player_new_x = $game_player.x $game_temp.player_new_y = $game_player.y @@ -318,7 +313,7 @@ def pbDive $scene.transfer_player(false) $game_map.autoplay $game_map.refresh - } + end return true end return false @@ -344,7 +339,7 @@ def pbSurfacing speciesname = (movefinder) ? movefinder.name : $player.name pbMessage(_INTL("{1} used {2}!", speciesname, GameData::Move.get(move).name)) pbHiddenMoveAnimation(movefinder) - pbFadeOutIn { + pbFadeOutIn do $game_temp.player_new_map_id = surface_map_id $game_temp.player_new_x = $game_player.x $game_temp.player_new_y = $game_player.y @@ -356,7 +351,7 @@ def pbSurfacing surfbgm = GameData::Metadata.get.surf_BGM (surfbgm) ? pbBGMPlay(surfbgm) : $game_map.autoplayAsCue $game_map.refresh - } + end return true end return false @@ -365,7 +360,7 @@ end # @deprecated This method is slated to be removed in v21. def pbTransferUnderwater(mapid, x, y, direction = $game_player.direction) Deprecation.warn_method("pbTransferUnderwater", "v21", '"Transfer Player" event command') - pbFadeOutIn { + pbFadeOutIn do $game_temp.player_new_map_id = mapid $game_temp.player_new_x = x $game_temp.player_new_y = y @@ -373,7 +368,7 @@ def pbTransferUnderwater(mapid, x, y, direction = $game_player.direction) $scene.transfer_player(false) $game_map.autoplay $game_map.refresh - } + end end EventHandlers.add(:on_player_interact, :diving, @@ -438,7 +433,7 @@ HiddenMoveHandlers::UseMove.add(:DIVE, proc { |move, pokemon| if !pbHiddenMoveAnimation(pokemon) pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name)) end - pbFadeOutIn { + pbFadeOutIn do $game_temp.player_new_map_id = dive_map_id $game_temp.player_new_x = $game_player.x $game_temp.player_new_y = $game_player.y @@ -449,7 +444,7 @@ HiddenMoveHandlers::UseMove.add(:DIVE, proc { |move, pokemon| $scene.transfer_player(false) $game_map.autoplay $game_map.refresh - } + end next true }) @@ -518,7 +513,7 @@ def pbFlyToNewLocation(pkmn = nil, move = :FLY) pbMessage(_INTL("{1} used {2}!", name, GameData::Move.get(move).name)) end $stats.fly_count += 1 - pbFadeOutIn { + pbFadeOutIn do pbSEPlay("Fly") $game_temp.player_new_map_id = $game_temp.fly_destination[0] $game_temp.player_new_x = $game_temp.fly_destination[1] @@ -531,7 +526,7 @@ def pbFlyToNewLocation(pkmn = nil, move = :FLY) $game_map.refresh yield if block_given? pbWait(Graphics.frame_rate / 4) - } + end pbEraseEscapePoint return true end @@ -763,7 +758,7 @@ end # @deprecated This method is slated to be removed in v21. def pbTransferSurfing(mapid, xcoord, ycoord, direction = $game_player.direction) Deprecation.warn_method("pbTransferSurfing", "v21", '"Transfer Player" event command') - pbFadeOutIn { + pbFadeOutIn do $game_temp.player_new_map_id = mapid $game_temp.player_new_x = xcoord $game_temp.player_new_y = ycoord @@ -771,7 +766,7 @@ def pbTransferSurfing(mapid, xcoord, ycoord, direction = $game_player.direction) $scene.transfer_player(false) $game_map.autoplay $game_map.refresh - } + end end EventHandlers.add(:on_player_interact, :start_surfing, @@ -923,7 +918,7 @@ HiddenMoveHandlers::UseMove.add(:TELEPORT, proc { |move, pokemon| if !pbHiddenMoveAnimation(pokemon) pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name)) end - pbFadeOutIn { + pbFadeOutIn do $game_temp.player_new_map_id = healing[0] $game_temp.player_new_x = healing[1] $game_temp.player_new_y = healing[2] @@ -932,7 +927,7 @@ HiddenMoveHandlers::UseMove.add(:TELEPORT, proc { |move, pokemon| $scene.transfer_player $game_map.autoplay $game_map.refresh - } + end pbEraseEscapePoint next true }) diff --git a/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb b/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb index 189a4b250..cdbea7723 100644 --- a/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb +++ b/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb @@ -50,33 +50,27 @@ def pbFishing(hasEncounter, rodType = 1) message = "" time.times { message += ". " } if pbWaitMessage(msgWindow, time) - pbFishingEnd { - pbMessageDisplay(msgWindow, _INTL("Not even a nibble...")) - } + pbFishingEnd { pbMessageDisplay(msgWindow, _INTL("Not even a nibble...")) } break end if hasEncounter && rand(100) < biteChance $scene.spriteset.addUserAnimation(Settings::EXCLAMATION_ANIMATION_ID, $game_player.x, $game_player.y, true, 3) frames = Graphics.frame_rate - rand(Graphics.frame_rate / 2) # 0.5-1 second if !pbWaitForInput(msgWindow, message + _INTL("\r\nOh! A bite!"), frames) - pbFishingEnd { - pbMessageDisplay(msgWindow, _INTL("The Pokémon got away...")) - } + pbFishingEnd { pbMessageDisplay(msgWindow, _INTL("The Pokémon got away...")) } break end if Settings::FISHING_AUTO_HOOK || rand(100) < hookChance - pbFishingEnd { + pbFishingEnd do pbMessageDisplay(msgWindow, _INTL("Landed a Pokémon!")) if !Settings::FISHING_AUTO_HOOK - } + end ret = true break end # biteChance += 15 # hookChance += 15 else - pbFishingEnd { - pbMessageDisplay(msgWindow, _INTL("Not even a nibble...")) - } + pbFishingEnd { pbMessageDisplay(msgWindow, _INTL("Not even a nibble...")) } break end end diff --git a/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb b/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb index a5e9570df..8b9c1175e 100644 --- a/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb +++ b/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb @@ -381,11 +381,11 @@ def pbBerryPlant [_INTL("Fertilize"), _INTL("Plant Berry"), _INTL("Exit")], -1) when 0 # Fertilize mulch = nil - pbFadeOutIn { + pbFadeOutIn do scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) mulch = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_mulch? }) - } + end return if !mulch mulch_data = GameData::Item.get(mulch) if mulch_data.is_mulch? @@ -408,11 +408,11 @@ def pbBerryPlant ask_to_plant = false end if !ask_to_plant || pbConfirmMessage(_INTL("Want to plant a Berry?")) - pbFadeOutIn { + pbFadeOutIn do scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) berry = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_berry? }) - } + end if berry $stats.berries_planted += 1 berry_plant.plant(berry) diff --git a/Data/Scripts/012_Overworld/007_Overworld_DayCare.rb b/Data/Scripts/012_Overworld/007_Overworld_DayCare.rb index f41bd5e29..f4ddbddc6 100644 --- a/Data/Scripts/012_Overworld/007_Overworld_DayCare.rb +++ b/Data/Scripts/012_Overworld/007_Overworld_DayCare.rb @@ -404,7 +404,7 @@ class DayCare end end - #============================================================================= + #----------------------------------------------------------------------------- def self.count return $PokemonGlobal.day_care.count @@ -494,7 +494,7 @@ class DayCare day_care.reset_egg_counters end - #============================================================================= + #----------------------------------------------------------------------------- private diff --git a/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb b/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb index ebd0a470a..a790200a4 100644 --- a/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb +++ b/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb @@ -512,8 +512,8 @@ module RandomDungeon start = nil maxWidth = @usable_width - (@buffer_x * 2) maxHeight = @usable_height - (@buffer_y * 2) - for y in 0...maxHeight - for x in 0...maxWidth + maxHeight.times do |y| + maxWidth.times do |x| next if !tile_is_ground?(@map_data[x + @buffer_x, y + @buffer_y, 0]) start = [x, y] break @@ -535,10 +535,10 @@ module RandomDungeon checking = to_check.shift x1, x2, y, dy = checking x = x1 - if !visited[y * maxWidth + x] && tile_is_ground?(@map_data[x + @buffer_x, y + @buffer_y, 0]) + if !visited[(y * maxWidth) + x] && tile_is_ground?(@map_data[x + @buffer_x, y + @buffer_y, 0]) loop do - break if visited[y * maxWidth + x - 1] || !tile_is_ground?(@map_data[x - 1 + @buffer_x, y + @buffer_y, 0]) - visited[y * maxWidth + x - 1] = true + break if visited[(y * maxWidth) + x - 1] || !tile_is_ground?(@map_data[x - 1 + @buffer_x, y + @buffer_y, 0]) + visited[(y * maxWidth) + x - 1] = true x -= 1 end end @@ -546,8 +546,8 @@ module RandomDungeon loop do break if x1 > x2 loop do - break if visited[y * maxWidth + x1] || !tile_is_ground?(@map_data[x1 + @buffer_x, y + @buffer_y, 0]) - visited[y * maxWidth + x1] = true + break if visited[(y * maxWidth) + x1] || !tile_is_ground?(@map_data[x1 + @buffer_x, y + @buffer_y, 0]) + visited[(y * maxWidth) + x1] = true to_check.push([x, x1, y + dy, dy]) to_check.push([x2 + 1, x1, y - dy, -dy]) if x1 > x2 x1 += 1 @@ -555,16 +555,16 @@ module RandomDungeon x1 += 1 loop do break if x1 >= x2 - break if !visited[y * maxWidth + x1] && tile_is_ground?(@map_data[x1 + @buffer_x, y + @buffer_y, 0]) + break if !visited[(y * maxWidth) + x1] && tile_is_ground?(@map_data[x1 + @buffer_x, y + @buffer_y, 0]) x1 += 1 end x = x1 end end # Check for unflooded floor tiles - for y in 0...maxHeight - for x in 0...maxWidth - next if visited[y * maxWidth + x] || !tile_is_ground?(@map_data[x + @buffer_x, y + @buffer_y, 0]) + maxHeight.times do |y| + maxWidth.times do |x| + next if visited[(y * maxWidth) + x] || !tile_is_ground?(@map_data[x + @buffer_x, y + @buffer_y, 0]) @need_redraw = true break end @@ -824,9 +824,9 @@ module RandomDungeon def get_wall_tile_for_coord(x, y, layer = 0) if layer == 0 - is_neighbour = lambda { |x, y| return tile_is_ground?(@map_data.value(x, y)) } + is_neighbour = lambda { |x2, y2| return tile_is_ground?(@map_data.value(x2, y2)) } else - is_neighbour = lambda { |x, y| return tile_is_wall?(@map_data[x, y, 1]) } + is_neighbour = lambda { |x2, y2| return tile_is_wall?(@map_data[x2, y2, 1]) } end neighbours = 0 neighbours |= 0x01 if is_neighbour.call(x, y - 1) # N @@ -863,8 +863,8 @@ module RandomDungeon (maxWidth / @parameters.cell_width).times do |i| next if rand(100) >= @parameters.floor_patch_chance # Random placing of floor patch tiles - mid_x = i * @parameters.cell_width + rand(@parameters.cell_width) - mid_y = j * @parameters.cell_height + rand(@parameters.cell_height) + mid_x = (i * @parameters.cell_width) + rand(@parameters.cell_width) + mid_y = (j * @parameters.cell_height) + rand(@parameters.cell_height) ((mid_y - @parameters.floor_patch_radius)..(mid_y + @parameters.floor_patch_radius)).each do |y| ((mid_x - @parameters.floor_patch_radius)..(mid_x + @parameters.floor_patch_radius)).each do |x| if @tileset.floor_patch_under_walls @@ -989,7 +989,7 @@ module RandomDungeon when :void_decoration_large, :floor_decoration_large 4.times do |c| tile = @tileset.get_random_tile_of_type(tile_type, self, i, j, layer) - tile += (c % 2) + 8 * (c / 2) if tile >= 384 # Regular tile + tile += (c % 2) + (8 * (c / 2)) if tile >= 384 # Regular tile map.data[i + (c % 2), j + (c / 2), layer] = tile end else diff --git a/Data/Scripts/013_Items/001_Item_Utilities.rb b/Data/Scripts/013_Items/001_Item_Utilities.rb index 3448011e7..df70d1125 100644 --- a/Data/Scripts/013_Items/001_Item_Utilities.rb +++ b/Data/Scripts/013_Items/001_Item_Utilities.rb @@ -190,13 +190,13 @@ def pbChangeLevel(pkmn, new_level, scene) # Check for evolution new_species = pkmn.check_evolution_on_level_up if new_species - pbFadeOutInWithMusic { + pbFadeOutInWithMusic do evo = PokemonEvolutionScene.new evo.pbStartScreen(pkmn, new_species) evo.pbEvolution evo.pbEndScreen scene.pbRefresh if scene.is_a?(PokemonPartyScreen) - } + end end end end @@ -299,13 +299,13 @@ def pbChangeExp(pkmn, new_exp, scene) # Check for evolution new_species = pkmn.check_evolution_on_level_up if new_species - pbFadeOutInWithMusic { + pbFadeOutInWithMusic do evo = PokemonEvolutionScene.new evo.pbStartScreen(pkmn, new_species) evo.pbEvolution evo.pbEndScreen scene.pbRefresh if scene.is_a?(PokemonPartyScreen) - } + end end end end @@ -624,11 +624,11 @@ end def pbForgetMove(pkmn, moveToLearn) ret = -1 - pbFadeOutIn { + pbFadeOutIn do scene = PokemonSummary_Scene.new screen = PokemonSummaryScreen.new(scene) ret = screen.pbStartForgetScreen([pkmn], 0, moveToLearn) - } + end return ret end @@ -653,7 +653,7 @@ def pbUseItem(bag, item, bagscene = nil) annot.push((elig) ? _INTL("ABLE") : _INTL("NOT ABLE")) end end - pbFadeOutIn { + pbFadeOutIn do scene = PokemonParty_Scene.new screen = PokemonPartyScreen.new(scene, $player.party) screen.pbStartScene(_INTL("Use on which Pokémon?"), false, annot) @@ -685,7 +685,7 @@ def pbUseItem(bag, item, bagscene = nil) end screen.pbEndScene bagscene&.pbRefresh - } + end return (ret) ? 1 : 0 elsif useType == 2 || itm.is_machine? # Item is usable from Bag or teaches a move intret = ItemHandlers.triggerUseFromBag(item) @@ -853,33 +853,33 @@ end #=============================================================================== def pbChooseItem(var = 0, *args) ret = nil - pbFadeOutIn { + pbFadeOutIn do scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) ret = screen.pbChooseItemScreen - } + end $game_variables[var] = ret || :NONE if var > 0 return ret end def pbChooseApricorn(var = 0) ret = nil - pbFadeOutIn { + pbFadeOutIn do scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_apricorn? }) - } + end $game_variables[var] = ret || :NONE if var > 0 return ret end def pbChooseFossil(var = 0) ret = nil - pbFadeOutIn { + pbFadeOutIn do scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_fossil? }) - } + end $game_variables[var] = ret || :NONE if var > 0 return ret end diff --git a/Data/Scripts/013_Items/002_Item_Effects.rb b/Data/Scripts/013_Items/002_Item_Effects.rb index a5323836f..2d7becaf5 100644 --- a/Data/Scripts/013_Items/002_Item_Effects.rb +++ b/Data/Scripts/013_Items/002_Item_Effects.rb @@ -54,13 +54,13 @@ ItemHandlers::UseFromBag.add(:ITEMFINDER, proc { |item| ItemHandlers::UseFromBag.copy(:ITEMFINDER, :DOWSINGMCHN, :DOWSINGMACHINE) ItemHandlers::UseFromBag.add(:TOWNMAP, proc { |item| - pbFadeOutIn { + pbFadeOutIn do scene = PokemonRegionMap_Scene.new(-1, false) screen = PokemonRegionMapScreen.new(scene) ret = screen.pbStartScreen $game_temp.fly_destination = ret if ret next 99999 if ret # Ugly hack to make Bag scene not reappear if flying - } + end next ($game_temp.fly_destination) ? 2 : 0 }) @@ -148,11 +148,11 @@ EventHandlers.add(:on_player_step_taken, :repel_counter, end next if !pbConfirmMessage(_INTL("The repellent's effect wore off! Would you like to use another one?")) ret = nil - pbFadeOutIn { + pbFadeOutIn do scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) ret = screen.pbChooseItemScreen(proc { |item| repels.include?(item) }) - } + end pbUseItem($bag, ret) if ret } ) @@ -190,7 +190,7 @@ ItemHandlers::UseInField.add(:ESCAPEROPE, proc { |item| next false end pbUseItemMessage(item) - pbFadeOutIn { + pbFadeOutIn do $game_temp.player_new_map_id = escape[0] $game_temp.player_new_x = escape[1] $game_temp.player_new_y = escape[2] @@ -199,7 +199,7 @@ ItemHandlers::UseInField.add(:ESCAPEROPE, proc { |item| $scene.transfer_player $game_map.autoplay $game_map.refresh - } + end pbEraseEscapePoint next true }) @@ -220,7 +220,7 @@ ItemHandlers::UseInField.add(:SACREDASH, proc { |item| next false end revived = 0 - pbFadeOutIn { + pbFadeOutIn do scene = PokemonParty_Scene.new screen = PokemonPartyScreen.new(scene, $player.party) screen.pbStartScene(_INTL("Using item..."), false) @@ -231,11 +231,9 @@ ItemHandlers::UseInField.add(:SACREDASH, proc { |item| screen.pbRefreshSingle(i) screen.pbDisplay(_INTL("{1}'s HP was restored.", pkmn.name)) end - if revived == 0 - screen.pbDisplay(_INTL("It won't have any effect.")) - end + screen.pbDisplay(_INTL("It won't have any effect.")) if revived == 0 screen.pbEndScene - } + end next (revived > 0) }) @@ -371,7 +369,7 @@ ItemHandlers::UseOnPokemon.addIf(:evolution_stones, end newspecies = pkmn.check_evolution_on_use_item(item) if newspecies - pbFadeOutInWithMusic { + pbFadeOutInWithMusic do evo = PokemonEvolutionScene.new evo.pbStartScreen(pkmn, newspecies) evo.pbEvolution(false) @@ -380,7 +378,7 @@ ItemHandlers::UseOnPokemon.addIf(:evolution_stones, scene.pbRefreshAnnotations(proc { |p| !p.check_evolution_on_use_item(item).nil? }) scene.pbRefresh end - } + end next true end scene.pbDisplay(_INTL("It won't have any effect.")) @@ -896,13 +894,13 @@ ItemHandlers::UseOnPokemon.add(:RARECANDY, proc { |item, qty, pkmn, scene| next false end # Check for evolution - pbFadeOutInWithMusic { + pbFadeOutInWithMusic do evo = PokemonEvolutionScene.new evo.pbStartScreen(pkmn, new_species) evo.pbEvolution evo.pbEndScreen scene.pbRefresh if scene.is_a?(PokemonPartyScreen) - } + end next true end # Level up @@ -1093,10 +1091,10 @@ ItemHandlers::UseOnPokemon.add(:GRACIDEA, proc { |item, qty, pkmn, scene| scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) next false end - pkmn.setForm(1) { + pkmn.setForm(1) do scene.pbRefresh scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) - } + end next true }) @@ -1108,10 +1106,10 @@ ItemHandlers::UseOnPokemon.add(:REDNECTAR, proc { |item, qty, pkmn, scene| scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) next false end - pkmn.setForm(0) { + pkmn.setForm(0) do scene.pbRefresh scene.pbDisplay(_INTL("{1} changed form!", pkmn.name)) - } + end next true }) @@ -1123,10 +1121,10 @@ ItemHandlers::UseOnPokemon.add(:YELLOWNECTAR, proc { |item, qty, pkmn, scene| scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) next false end - pkmn.setForm(1) { + pkmn.setForm(1) do scene.pbRefresh scene.pbDisplay(_INTL("{1} changed form!", pkmn.name)) - } + end next true }) @@ -1138,10 +1136,10 @@ ItemHandlers::UseOnPokemon.add(:PINKNECTAR, proc { |item, qty, pkmn, scene| scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) next false end - pkmn.setForm(2) { + pkmn.setForm(2) do scene.pbRefresh scene.pbDisplay(_INTL("{1} changed form!", pkmn.name)) - } + end next true }) @@ -1153,10 +1151,10 @@ ItemHandlers::UseOnPokemon.add(:PURPLENECTAR, proc { |item, qty, pkmn, scene| scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) next false end - pkmn.setForm(3) { + pkmn.setForm(3) do scene.pbRefresh scene.pbDisplay(_INTL("{1} changed form!", pkmn.name)) - } + end next true }) @@ -1171,10 +1169,10 @@ ItemHandlers::UseOnPokemon.add(:REVEALGLASS, proc { |item, qty, pkmn, scene| next false end newForm = (pkmn.form == 0) ? 1 : 0 - pkmn.setForm(newForm) { + pkmn.setForm(newForm) do scene.pbRefresh scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) - } + end next true }) @@ -1187,10 +1185,10 @@ ItemHandlers::UseOnPokemon.add(:PRISONBOTTLE, proc { |item, qty, pkmn, scene| next false end newForm = (pkmn.form == 0) ? 1 : 0 - pkmn.setForm(newForm) { + pkmn.setForm(newForm) do scene.pbRefresh scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) - } + end next true }) @@ -1217,10 +1215,10 @@ ItemHandlers::UseOnPokemon.add(:ROTOMCATALOG, proc { |item, qty, pkmn, scene| scene.pbDisplay(_INTL("It won't have any effect.")) next false elsif new_form > 0 && new_form < choices.length - 1 - pkmn.setForm(new_form) { + pkmn.setForm(new_form) do scene.pbRefresh scene.pbDisplay(_INTL("{1} transformed!", pkmn.name)) - } + end next true end next false @@ -1238,10 +1236,10 @@ ItemHandlers::UseOnPokemon.add(:ZYGARDECUBE, proc { |item, qty, pkmn, scene| [_INTL("Change form"), _INTL("Change Ability"), _INTL("Cancel")]) when 0 # Change form newForm = (pkmn.form == 0) ? 1 : 0 - pkmn.setForm(newForm) { + pkmn.setForm(newForm) do scene.pbRefresh scene.pbDisplay(_INTL("{1} transformed!", pkmn.name)) - } + end next true when 1 # Change ability new_abil = (pkmn.ability_index + 1) % 2 @@ -1282,12 +1280,12 @@ ItemHandlers::UseOnPokemon.add(:DNASPLICERS, proc { |item, qty, pkmn, scene| newForm = 0 newForm = 1 if other_pkmn.isSpecies?(:RESHIRAM) newForm = 2 if other_pkmn.isSpecies?(:ZEKROM) - pkmn.setForm(newForm) { + pkmn.setForm(newForm) do pkmn.fused = other_pkmn $player.remove_pokemon_at_index(chosen) scene.pbHardRefresh scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) - } + end $bag.replace_item(:DNASPLICERS, :DNASPLICERSUSED) next true }) @@ -1304,12 +1302,12 @@ ItemHandlers::UseOnPokemon.add(:DNASPLICERSUSED, proc { |item, qty, pkmn, scene| next false end # Unfusing - pkmn.setForm(0) { + pkmn.setForm(0) do $player.party[$player.party.length] = pkmn.fused pkmn.fused = nil scene.pbHardRefresh scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) - } + end $bag.replace_item(:DNASPLICERSUSED, :DNASPLICERS) next true }) @@ -1339,12 +1337,12 @@ ItemHandlers::UseOnPokemon.add(:NSOLARIZER, proc { |item, qty, pkmn, scene| scene.pbDisplay(_INTL("It cannot be fused with that Pokémon.")) next false end - pkmn.setForm(1) { + pkmn.setForm(1) do pkmn.fused = other_pkmn $player.remove_pokemon_at_index(chosen) scene.pbHardRefresh scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) - } + end $bag.replace_item(:NSOLARIZER, :NSOLARIZERUSED) next true }) @@ -1361,12 +1359,12 @@ ItemHandlers::UseOnPokemon.add(:NSOLARIZERUSED, proc { |item, qty, pkmn, scene| next false end # Unfusing - pkmn.setForm(0) { + pkmn.setForm(0) do $player.party[$player.party.length] = pkmn.fused pkmn.fused = nil scene.pbHardRefresh scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) - } + end $bag.replace_item(:NSOLARIZERUSED, :NSOLARIZER) next true }) @@ -1396,12 +1394,12 @@ ItemHandlers::UseOnPokemon.add(:NLUNARIZER, proc { |item, qty, pkmn, scene| scene.pbDisplay(_INTL("It cannot be fused with that Pokémon.")) next false end - pkmn.setForm(2) { + pkmn.setForm(2) do pkmn.fused = other_pkmn $player.remove_pokemon_at_index(chosen) scene.pbHardRefresh scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) - } + end $bag.replace_item(:NLUNARIZER, :NLUNARIZERUSED) next true }) @@ -1418,12 +1416,12 @@ ItemHandlers::UseOnPokemon.add(:NLUNARIZERUSED, proc { |item, qty, pkmn, scene| next false end # Unfusing - pkmn.setForm(0) { + pkmn.setForm(0) do $player.party[$player.party.length] = pkmn.fused pkmn.fused = nil scene.pbHardRefresh scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) - } + end $bag.replace_item(:NLUNARIZERUSED, :NLUNARIZER) next true }) @@ -1457,12 +1455,12 @@ ItemHandlers::UseOnPokemon.add(:REINSOFUNITY, proc { |item, qty, pkmn, scene| newForm = 0 newForm = 1 if other_pkmn.isSpecies?(:GLASTRIER) newForm = 2 if other_pkmn.isSpecies?(:SPECTRIER) - pkmn.setForm(newForm) { + pkmn.setForm(newForm) do pkmn.fused = other_pkmn $player.remove_pokemon_at_index(chosen) scene.pbHardRefresh scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) - } + end $bag.replace_item(:REINSOFUNITY, :REINSOFUNITYUSED) next true }) @@ -1479,12 +1477,12 @@ ItemHandlers::UseOnPokemon.add(:REINSOFUNITYUSED, proc { |item, qty, pkmn, scene next false end # Unfusing - pkmn.setForm(0) { + pkmn.setForm(0) do $player.party[$player.party.length] = pkmn.fused pkmn.fused = nil scene.pbHardRefresh scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) - } + end $bag.replace_item(:REINSOFUNITYUSED, :REINSOFUNITY) next true }) diff --git a/Data/Scripts/013_Items/004_Item_Phone.rb b/Data/Scripts/013_Items/004_Item_Phone.rb index 306536de8..df72cca7b 100644 --- a/Data/Scripts/013_Items/004_Item_Phone.rb +++ b/Data/Scripts/013_Items/004_Item_Phone.rb @@ -88,12 +88,10 @@ class Phone if contact contact.visible = true @contacts.delete(contact) - @contacts.push(contact) else contact = Contact.new(true, args[0].map_id, args[0].id, trainer_type, name, args[3], args[4], args[5]) contact.increment_version - @contacts.push(contact) end elsif args[1].is_a?(Numeric) # Trainer @@ -104,12 +102,10 @@ class Phone if contact contact.visible = true @contacts.delete(contact) - @contacts.push(contact) else contact = Contact.new(true, args[0], args[1], trainer_type, name, args[4], args[5], args[6]) contact.increment_version - @contacts.push(contact) end else # Non-trainer @@ -118,12 +114,11 @@ class Phone if contact contact.visible = true @contacts.delete(contact) - @contacts.push(contact) else contact = Contact.new(false, *args) - @contacts.push(contact) end end + @contacts.push(contact) sort_contacts return true end @@ -264,9 +259,9 @@ class Phone # Map ID, name, common event ID def initialize(trainer, *args) @trainer = trainer + @map_id = args[0] if @trainer # Trainer - @map_id = args[0] @event_id = args[1] @trainer_type = args[2] @name = args[3] @@ -279,7 +274,6 @@ class Phone @common_event_id = args[6] || 0 else # Non-trainer - @map_id = args[0] @name = args[1] @common_event_id = args[2] || 0 end @@ -320,7 +314,7 @@ class Phone def display_name if trainer? return sprintf("%s %s", GameData::TrainerType.get(@trainer_type).name, - pbGetMessageFromHash(MessageTypes::TrainerNames, @name)) + pbGetMessageFromHash(MessageTypes::TRAINER_NAMES, @name)) end return _INTL(@name) end @@ -482,11 +476,11 @@ class Phone messages = GameData::PhoneMessage.try_get(contact.trainer_type, contact.name, contact.start_version) if !messages messages = GameData::PhoneMessage::DATA["default"] if !messages # Create lambda for choosing a random message and translating it - get_random_message = lambda do |messages| - return "" if !messages - msg = messages.sample + get_random_message = lambda do |msgs| + return "" if !msgs + msg = msgs.sample return "" if !msg - return pbGetMessageFromHash(MessageTypes::PhoneMessages, msg) + return pbGetMessageFromHash(MessageTypes::PHONE_MESSAGES, msg) end # Choose random greeting depending on time of day ret = get_random_message.call(messages.intro) @@ -505,10 +499,11 @@ class Phone # Choose main message set if Phone.rematches_enabled && contact.rematch_flag > 0 # Trainer is ready for a rematch, so tell/remind the player - if contact.rematch_flag == 1 # Tell the player + case contact.rematch_flag + when 1 # Tell the player ret += get_random_message.call(messages.battle_request) contact.rematch_flag = 2 # Ready for rematch and told player - elsif contact.rematch_flag == 2 # Remind the player + when 2 # Remind the player if messages.battle_remind ret += get_random_message.call(messages.battle_remind) else @@ -555,9 +550,7 @@ class Phone species = get_species_from_table.call(enc_tables[:Land]) if !species species = get_species_from_table.call(enc_tables[:Cave]) - if !species - species = get_species_from_table.call(enc_tables[:Water]) - end + species = get_species_from_table.call(enc_tables[:Water]) if !species end return "" if !species return GameData::Species.get(species).name diff --git a/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb b/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb index 6ded890f4..9078bbf50 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb @@ -264,9 +264,7 @@ MultipleForms.register(:ROTOM, { MultipleForms.register(:GIRATINA, { "getForm" => proc { |pkmn| next 1 if pkmn.hasItem?(:GRISEOUSORB) - if $game_map && $game_map.metadata&.has_flag?("DistortionWorld") - next 1 - end + next 1 if $game_map&.metadata&.has_flag?("DistortionWorld") next 0 } }) diff --git a/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb b/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb index d5abc64d0..df046d5cf 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb @@ -1,17 +1,15 @@ -=begin -All types except Shadow have Shadow as a weakness. -Shadow has Shadow as a resistance. -On a side note, the Shadow moves in Colosseum will not be affected by Weaknesses -or Resistances, while in XD the Shadow-type is Super-Effective against all other -types. -2/5 - display nature - -XD - Shadow Rush -- 55, 100 - Deals damage. -Colosseum - Shadow Rush -- 90, 100 -If this attack is successful, user loses half of HP lost by opponent due to this -attack (recoil). If user is in Hyper Mode, this attack has a good chance for a -critical hit. -=end +# All types except Shadow have Shadow as a weakness. +# Shadow has Shadow as a resistance. +# On a side note, the Shadow moves in Colosseum will not be affected by +# Weaknesses or Resistances, while in XD the Shadow-type is Super-Effective +# against all other types. +# 2/5 - display nature +# +# XD - Shadow Rush -- 55, 100 - Deals damage. +# Colosseum - Shadow Rush -- 90, 100 +# If this attack is successful, user loses half of HP lost by opponent due to +# this attack (recoil). If user is in Hyper Mode, this attack has a good chance +# for a critical hit. #=============================================================================== # Purify a Shadow Pokémon. @@ -63,8 +61,7 @@ end # Relic Stone scene. #=============================================================================== class RelicStoneScene - def pbPurify - end + def pbPurify; end def pbUpdate pbUpdateSpriteHash(@sprites) @@ -136,11 +133,11 @@ end #=============================================================================== def pbRelicStoneScreen(pkmn) retval = true - pbFadeOutIn { + pbFadeOutIn do scene = RelicStoneScene.new screen = RelicStoneScreen.new(scene) retval = screen.pbStartScreen(pkmn) - } + end return retval end @@ -187,9 +184,7 @@ class Battle::Battler alias __shadow__pbInitPokemon pbInitPokemon unless method_defined?(:__shadow__pbInitPokemon) def pbInitPokemon(*arg) - if self.pokemonIndex > 0 && inHyperMode? - self.pokemon.hyper_mode = false - end + self.pokemon.hyper_mode = false if self.pokemonIndex > 0 && inHyperMode? __shadow__pbInitPokemon(*arg) # Called into battle if shadowPokemon? diff --git a/Data/Scripts/014_Pokemon/001_Pokemon-related/004_PokemonStorage.rb b/Data/Scripts/014_Pokemon/001_Pokemon-related/004_PokemonStorage.rb index 9f05b6f8a..9866d3a21 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/004_PokemonStorage.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/004_PokemonStorage.rb @@ -284,9 +284,7 @@ class RegionalStorage if @rgnmap < 0 raise _INTL("The current map has no region set. Please set the MapPosition metadata setting for this map.") end - if !@storages[@rgnmap] - @storages[@rgnmap] = PokemonStorage.new - end + @storages[@rgnmap] = PokemonStorage.new if !@storages[@rgnmap] return @storages[@rgnmap] end diff --git a/Data/Scripts/014_Pokemon/001_Pokemon.rb b/Data/Scripts/014_Pokemon/001_Pokemon.rb index 186bf4250..23d9364f7 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon.rb @@ -974,49 +974,49 @@ class Pokemon # Checks whether this Pokemon can evolve because of levelling up. # @return [Symbol, nil] the ID of the species to evolve into def check_evolution_on_level_up - return check_evolution_internal { |pkmn, new_species, method, parameter| + return check_evolution_internal do |pkmn, new_species, method, parameter| success = GameData::Evolution.get(method).call_level_up(pkmn, parameter) next (success) ? new_species : nil - } + end end # Checks whether this Pokemon can evolve because of using an item on it. # @param item_used [Symbol, GameData::Item, nil] the item being used # @return [Symbol, nil] the ID of the species to evolve into def check_evolution_on_use_item(item_used) - return check_evolution_internal { |pkmn, new_species, method, parameter| + return check_evolution_internal do |pkmn, new_species, method, parameter| success = GameData::Evolution.get(method).call_use_item(pkmn, parameter, item_used) next (success) ? new_species : nil - } + end end # Checks whether this Pokemon can evolve because of being traded. # @param other_pkmn [Pokemon] the other Pokémon involved in the trade # @return [Symbol, nil] the ID of the species to evolve into def check_evolution_on_trade(other_pkmn) - return check_evolution_internal { |pkmn, new_species, method, parameter| + return check_evolution_internal do |pkmn, new_species, method, parameter| success = GameData::Evolution.get(method).call_on_trade(pkmn, parameter, other_pkmn) next (success) ? new_species : nil - } + end end # Checks whether this Pokemon can evolve after a battle. # @return [Symbol, nil] the ID of the species to evolve into def check_evolution_after_battle(party_index) - return check_evolution_internal { |pkmn, new_species, method, parameter| + return check_evolution_internal do |pkmn, new_species, method, parameter| success = GameData::Evolution.get(method).call_after_battle(pkmn, party_index, parameter) next (success) ? new_species : nil - } + end end # Checks whether this Pokemon can evolve by a triggered event. # @param value [Integer] a value that may be used by the evolution method # @return [Symbol, nil] the ID of the species to evolve into def check_evolution_by_event(value = 0) - return check_evolution_internal { |pkmn, new_species, method, parameter| + return check_evolution_internal do |pkmn, new_species, method, parameter| success = GameData::Evolution.get(method).call_event(pkmn, parameter, value) next (success) ? new_species : nil - } + end end # Called after this Pokémon evolves, to remove its held item (if the evolution @@ -1047,12 +1047,12 @@ class Pokemon def trigger_event_evolution(number) new_species = check_evolution_by_event(number) if new_species - pbFadeOutInWithMusic { + pbFadeOutInWithMusic do evo = PokemonEvolutionScene.new evo.pbStartScreen(self, new_species) evo.pbEvolution evo.pbEndScreen - } + end return true end return false diff --git a/Data/Scripts/015_Trainers and player/002_Trainer_LoadAndNew.rb b/Data/Scripts/015_Trainers and player/002_Trainer_LoadAndNew.rb index 3e1911c66..c41df0829 100644 --- a/Data/Scripts/015_Trainers and player/002_Trainer_LoadAndNew.rb +++ b/Data/Scripts/015_Trainers and player/002_Trainer_LoadAndNew.rb @@ -62,7 +62,7 @@ end def pbConvertTrainerData tr_type_names = [] GameData::TrainerType.each { |t| tr_type_names.push(t.real_name) } - MessageTypes.setMessagesAsHash(MessageTypes::TrainerTypes, tr_type_names) + MessageTypes.setMessagesAsHash(MessageTypes::TRAINER_TYPE_NAMES, tr_type_names) Compiler.write_trainer_types Compiler.write_trainers end diff --git a/Data/Scripts/015_Trainers and player/005_Player_Pokedex.rb b/Data/Scripts/015_Trainers and player/005_Player_Pokedex.rb index aa9919ae7..020f04ab5 100644 --- a/Data/Scripts/015_Trainers and player/005_Player_Pokedex.rb +++ b/Data/Scripts/015_Trainers and player/005_Player_Pokedex.rb @@ -139,7 +139,7 @@ class Player < Trainer @last_seen_forms[species] = [gender, form, shiny] end - #=========================================================================== + #--------------------------------------------------------------------------- # Sets the given species as owned in the Pokédex. # @param species [Symbol, GameData::Species] species to set as owned @@ -185,7 +185,7 @@ class Player < Trainer return self.count_species(@owned, dex) end - #=========================================================================== + #--------------------------------------------------------------------------- # @param species [Pokemon, Symbol, GameData::Species] Pokemon to register as seen # @param gender [Integer] gender to register (0=male, 1=female, 2=genderless) @@ -227,7 +227,7 @@ class Player < Trainer @last_seen_forms[pkmn.species] = [pkmn.gender, form, pkmn.shiny?] end - #=========================================================================== + #--------------------------------------------------------------------------- # @param species [Symbol, GameData::Species] species to check # @return [Integer] the number of Pokémon of the given species that have @@ -272,7 +272,7 @@ class Player < Trainer @defeated_counts[species_id] += 1 end - #=========================================================================== + #--------------------------------------------------------------------------- # Unlocks the given Dex, -1 being the National Dex. # @param dex [Integer] Dex ID (-1 is the National Dex) @@ -321,9 +321,7 @@ class Player < Trainer return end if dexes_count == 1 # Only National Dex is defined - if self.unlocked?(0) && self.seen_any? - @accessible_dexes.push(-1) - end + @accessible_dexes.push(-1) if self.unlocked?(0) && self.seen_any? else # Regional Dexes + National Dex dexes_count.times do |i| dex_list_to_check = (i == dexes_count - 1) ? -1 : i @@ -334,7 +332,7 @@ class Player < Trainer end end - #=========================================================================== + #--------------------------------------------------------------------------- private diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb index 2b8e75af5..eebf4a48d 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb @@ -109,11 +109,11 @@ class PokemonEggHatch_Scene if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex pbMessage(_INTL("{1}'s data was added to the Pokédex.", @pokemon.name)) { update } $player.pokedex.register_last_seen(@pokemon) - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokedexInfo_Scene.new screen = PokemonPokedexInfoScreen.new(scene) screen.pbDexEntry(@pokemon.species) - } + end end # Nickname the Pokémon if $PokemonSystem.givenicknames == 0 && @@ -195,11 +195,11 @@ end #=============================================================================== def pbHatchAnimation(pokemon) pbMessage(_INTL("Huh?\1")) - pbFadeOutInWithMusic { + pbFadeOutInWithMusic do scene = PokemonEggHatch_Scene.new screen = PokemonEggHatchScreen.new(scene) screen.pbStartScreen(pokemon) - } + end return true end @@ -226,11 +226,11 @@ def pbHatch(pokemon) if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex pbMessage(_INTL("{1}'s data was added to the Pokédex.", speciesname)) $player.pokedex.register_last_seen(pokemon) - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokedexInfo_Scene.new screen = PokemonPokedexInfoScreen.new(scene) screen.pbDexEntry(pokemon.species) - } + end end # Nickname the Pokémon if $PokemonSystem.givenicknames == 0 && diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb b/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb index 1efc28f79..87e2dd73d 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb @@ -617,13 +617,13 @@ class PokemonEvolutionScene pbMessageDisplay(@sprites["msgwindow"], _INTL("{1}'s data was added to the Pokédex.", newspeciesname)) { pbUpdate } $player.pokedex.register_last_seen(@pokemon) - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokedexInfo_Scene.new screen = PokemonPokedexInfoScreen.new(scene) screen.pbDexEntry(@pokemon.species) @sprites["msgwindow"].text = "" if moves_to_learn.length > 0 pbEndScreen(false) if moves_to_learn.length == 0 - } + end end # Learn moves upon evolution for evolved species moves_to_learn.each do |move| diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb b/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb index 2782def27..dfbcc0a85 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb @@ -195,12 +195,12 @@ class PokemonTrade_Scene pbMessageDisplay(@sprites["msgwindow"], _INTL("{1}'s data was added to the Pokédex.", speciesname2)) { pbUpdate } $player.pokedex.register_last_seen(@pokemon2) - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokedexInfo_Scene.new screen = PokemonPokedexInfoScreen.new(scene) screen.pbDexEntry(@pokemon2.species) pbEndScreen(false) - } + end end end end @@ -227,11 +227,11 @@ def pbStartTrade(pokemonIndex, newpoke, nickname, trainerName, trainerGender = 0 yourPokemon.obtain_method = 2 # traded yourPokemon.reset_moves if resetmoves yourPokemon.record_first_moves - pbFadeOutInWithMusic { + pbFadeOutInWithMusic do evo = PokemonTrade_Scene.new evo.pbStartScreen(myPokemon, yourPokemon, $player.name, trainerName) evo.pbTrade evo.pbEndScreen - } + end $player.party[pokemonIndex] = yourPokemon end diff --git a/Data/Scripts/016_UI/001_UI_PauseMenu.rb b/Data/Scripts/016_UI/001_UI_PauseMenu.rb index c5a530a0b..1d16f0242 100644 --- a/Data/Scripts/016_UI/001_UI_PauseMenu.rb +++ b/Data/Scripts/016_UI/001_UI_PauseMenu.rb @@ -137,27 +137,27 @@ MenuHandlers.add(:pause_menu, :pokedex, { "effect" => proc { |menu| pbPlayDecisionSE if Settings::USE_CURRENT_REGION_DEX - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokedex_Scene.new screen = PokemonPokedexScreen.new(scene) screen.pbStartScreen menu.pbRefresh - } + end elsif $player.pokedex.accessible_dexes.length == 1 $PokemonGlobal.pokedexDex = $player.pokedex.accessible_dexes[0] - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokedex_Scene.new screen = PokemonPokedexScreen.new(scene) screen.pbStartScreen menu.pbRefresh - } + end else - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokedexMenu_Scene.new screen = PokemonPokedexMenuScreen.new(scene) screen.pbStartScreen menu.pbRefresh - } + end end next false } @@ -170,12 +170,12 @@ MenuHandlers.add(:pause_menu, :party, { "effect" => proc { |menu| pbPlayDecisionSE hidden_move = nil - pbFadeOutIn { + pbFadeOutIn do sscene = PokemonParty_Scene.new sscreen = PokemonPartyScreen.new(sscene, $player.party) hidden_move = sscreen.pbPokemonScreen (hidden_move) ? menu.pbEndScene : menu.pbRefresh - } + end next false if !hidden_move $game_temp.in_menu = false pbUseHiddenMove(hidden_move[0], hidden_move[1]) @@ -190,12 +190,12 @@ MenuHandlers.add(:pause_menu, :bag, { "effect" => proc { |menu| pbPlayDecisionSE item = nil - pbFadeOutIn { + pbFadeOutIn do scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) item = screen.pbStartScreen (item) ? menu.pbEndScene : menu.pbRefresh - } + end next false if !item $game_temp.in_menu = false pbUseKeyItemInField(item) @@ -209,12 +209,12 @@ MenuHandlers.add(:pause_menu, :pokegear, { "condition" => proc { next $player.has_pokegear }, "effect" => proc { |menu| pbPlayDecisionSE - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokegear_Scene.new screen = PokemonPokegearScreen.new(scene) screen.pbStartScreen ($game_temp.fly_destination) ? menu.pbEndScene : menu.pbRefresh - } + end next pbFlyToNewLocation } }) @@ -225,13 +225,13 @@ MenuHandlers.add(:pause_menu, :town_map, { "condition" => proc { next !$player.has_pokegear && $bag.has?(:TOWNMAP) }, "effect" => proc { |menu| pbPlayDecisionSE - pbFadeOutIn { + pbFadeOutIn do scene = PokemonRegionMap_Scene.new(-1, false) screen = PokemonRegionMapScreen.new(scene) ret = screen.pbStartScreen $game_temp.fly_destination = ret if ret ($game_temp.fly_destination) ? menu.pbEndScene : menu.pbRefresh - } + end next pbFlyToNewLocation } }) @@ -241,12 +241,12 @@ MenuHandlers.add(:pause_menu, :trainer_card, { "order" => 50, "effect" => proc { |menu| pbPlayDecisionSE - pbFadeOutIn { + pbFadeOutIn do scene = PokemonTrainerCard_Scene.new screen = PokemonTrainerCardScreen.new(scene) screen.pbStartScreen menu.pbRefresh - } + end next false } }) @@ -276,13 +276,13 @@ MenuHandlers.add(:pause_menu, :options, { "order" => 70, "effect" => proc { |menu| pbPlayDecisionSE - pbFadeOutIn { + pbFadeOutIn do scene = PokemonOption_Scene.new screen = PokemonOptionScreen.new(scene) screen.pbStartScreen pbUpdateSceneMap menu.pbRefresh - } + end next false } }) @@ -293,10 +293,10 @@ MenuHandlers.add(:pause_menu, :debug, { "condition" => proc { next $DEBUG }, "effect" => proc { |menu| pbPlayDecisionSE - pbFadeOutIn { + pbFadeOutIn do pbDebugMenu menu.pbRefresh - } + end next false } }) diff --git a/Data/Scripts/016_UI/002_UI_Pokedex_Menu.rb b/Data/Scripts/016_UI/002_UI_Pokedex_Menu.rb index 4b02e6be9..72328430d 100644 --- a/Data/Scripts/016_UI/002_UI_Pokedex_Menu.rb +++ b/Data/Scripts/016_UI/002_UI_Pokedex_Menu.rb @@ -114,11 +114,11 @@ class PokemonPokedexMenuScreen cmd = @scene.pbScene break if cmd < 0 || cmd >= commands2.length # Cancel/Exit $PokemonGlobal.pokedexDex = $player.pokedex.accessible_dexes[cmd] - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokedex_Scene.new screen = PokemonPokedexScreen.new(scene) screen.pbStartScreen - } + end end @scene.pbEndScene end diff --git a/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb b/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb index abf66b3b6..f0c1428f9 100644 --- a/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb +++ b/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb @@ -272,15 +272,13 @@ class PokemonPokedex_Scene @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 addBackgroundPlane(@sprites, "background", "Pokedex/bg_list", @viewport) -=begin - # Suggestion for changing the background depending on region. You can change - # the line above with the following: - if pbGetPokedexRegion==-1 # Using national Pokédex - addBackgroundPlane(@sprites,"background","Pokedex/bg_national",@viewport) - elsif pbGetPokedexRegion==0 # Using first regional Pokédex - addBackgroundPlane(@sprites,"background","Pokedex/bg_regional",@viewport) - end -=end + # Suggestion for changing the background depending on region. You can + # comment out the line above and uncomment the following lines: +# if pbGetPokedexRegion == -1 # Using national Pokédex +# addBackgroundPlane(@sprites, "background", "Pokedex/bg_national", @viewport) +# elsif pbGetPokedexRegion == 0 # Using first regional Pokédex +# addBackgroundPlane(@sprites, "background", "Pokedex/bg_regional", @viewport) +# end addBackgroundPlane(@sprites, "searchbg", "Pokedex/bg_search", @viewport) @sprites["searchbg"].visible = false @sprites["pokedex"] = Window_Pokedex.new(206, 30, 276, 364, @viewport) @@ -766,9 +764,8 @@ class PokemonPokedex_Scene end def setIconBitmap(species) - gender, form, shiny = $player.pokedex.last_form_seen(species) - shiny = false - @sprites["icon"].setSpeciesBitmap(species, gender, form, shiny) + gender, form, _shiny = $player.pokedex.last_form_seen(species) + @sprites["icon"].setSpeciesBitmap(species, gender, form, false) end def pbSearchDexList(params) @@ -777,17 +774,17 @@ class PokemonPokedex_Scene # Filter by name if params[1] >= 0 scanNameCommand = @nameCommands[params[1]].scan(/./) - dexlist = dexlist.find_all { |item| + dexlist = dexlist.find_all do |item| next false if !$player.seen?(item[:species]) firstChar = item[:name][0, 1] next scanNameCommand.any? { |v| v == firstChar } - } + end end # Filter by type if params[2] >= 0 || params[3] >= 0 stype1 = (params[2] >= 0) ? @typeCommands[params[2]].id : nil stype2 = (params[3] >= 0) ? @typeCommands[params[3]].id : nil - dexlist = dexlist.find_all { |item| + dexlist = dexlist.find_all do |item| next false if !$player.owned?(item[:species]) types = item[:types] if stype1 && stype2 @@ -802,43 +799,41 @@ class PokemonPokedex_Scene else next false end - } + end end # Filter by height range if params[4] >= 0 || params[5] >= 0 minh = (params[4] < 0) ? 0 : (params[4] >= @heightCommands.length) ? 999 : @heightCommands[params[4]] maxh = (params[5] < 0) ? 999 : (params[5] >= @heightCommands.length) ? 0 : @heightCommands[params[5]] - dexlist = dexlist.find_all { |item| + dexlist = dexlist.find_all do |item| next false if !$player.owned?(item[:species]) height = item[:height] next height >= minh && height <= maxh - } + end end # Filter by weight range if params[6] >= 0 || params[7] >= 0 minw = (params[6] < 0) ? 0 : (params[6] >= @weightCommands.length) ? 9999 : @weightCommands[params[6]] maxw = (params[7] < 0) ? 9999 : (params[7] >= @weightCommands.length) ? 0 : @weightCommands[params[7]] - dexlist = dexlist.find_all { |item| + dexlist = dexlist.find_all do |item| next false if !$player.owned?(item[:species]) weight = item[:weight] next weight >= minw && weight <= maxw - } + end end # Filter by color if params[8] >= 0 scolor = @colorCommands[params[8]].id - dexlist = dexlist.find_all { |item| - next false if !$player.seen?(item[:species]) - next item[:color] == scolor - } + dexlist = dexlist.find_all do |item| + next $player.seen?(item[:species]) && item[:color] == scolor + end end # Filter by shape if params[9] >= 0 sshape = @shapeCommands[params[9]].id - dexlist = dexlist.find_all { |item| - next false if !$player.seen?(item[:species]) - next item[:shape] == sshape - } + dexlist = dexlist.find_all do |item| + next $player.seen?(item[:species]) && item[:shape] == sshape + end end # Remove all unseen species from the results dexlist = dexlist.find_all { |item| next $player.seen?(item[:species]) } @@ -924,9 +919,7 @@ class PokemonPokedex_Scene oldindex = index minmax = 1 oldminmax = minmax - if [3, 4].include?(mode) - index = oldindex = selindex[minmax] - end + index = oldindex = selindex[minmax] if [3, 4].include?(mode) @sprites["searchcursor"].mode = mode @sprites["searchcursor"].cmds = cmds.length @sprites["searchcursor"].minmax = minmax @@ -1260,7 +1253,7 @@ class PokemonPokedex_Scene end def pbPokedex - pbActivateWindow(@sprites, "pokedex") { + pbActivateWindow(@sprites, "pokedex") do loop do Graphics.update Input.update @@ -1290,7 +1283,7 @@ class PokemonPokedex_Scene end end end - } + end end end diff --git a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb index 2b43f9525..7f9afac2a 100644 --- a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb +++ b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb @@ -161,9 +161,9 @@ class PokemonPokedexInfo_Scene real_gender = 2 if sp.gender_ratio == :Genderless ret.push([sp.form_name, real_gender, sp.form]) else # Both male and female - 2.times do |real_gender| - next if !$player.pokedex.seen_form?(@species, real_gender, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS - ret.push([sp.form_name, real_gender, sp.form]) + 2.times do |real_gndr| + next if !$player.pokedex.seen_form?(@species, real_gndr, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS + ret.push([sp.form_name, real_gndr, sp.form]) break if sp.form_name && !sp.form_name.empty? # Only show 1 entry for each non-0 form end end @@ -210,9 +210,7 @@ class PokemonPokedexInfo_Scene base = Color.new(88, 88, 80) shadow = Color.new(168, 184, 184) imagepos = [] - if @brief - imagepos.push([_INTL("Graphics/UI/Pokedex/overlay_info"), 0, 0]) - end + imagepos.push([_INTL("Graphics/UI/Pokedex/overlay_info"), 0, 0]) if @brief species_data = GameData::Species.get_species_form(@species, @form) # Write various bits of text indexText = "???" @@ -536,9 +534,7 @@ class PokemonPokedexInfo_Scene dorefresh = true end end - if dorefresh - drawPage(@page) - end + drawPage(@page) if dorefresh end return @index end diff --git a/Data/Scripts/016_UI/005_UI_Party.rb b/Data/Scripts/016_UI/005_UI_Party.rb index 25b4fe661..2ec9da17a 100644 --- a/Data/Scripts/016_UI/005_UI_Party.rb +++ b/Data/Scripts/016_UI/005_UI_Party.rb @@ -559,7 +559,7 @@ class PokemonParty_Scene @sprites["messagebox"].text = text @sprites["messagebox"].visible = true @sprites["helpwindow"].visible = false - using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) { + using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) do cmdwindow.visible = false pbBottomRight(cmdwindow) cmdwindow.y -= @sprites["messagebox"].height @@ -580,7 +580,7 @@ class PokemonParty_Scene end end end - } + end @sprites["messagebox"].visible = false @sprites["helpwindow"].visible = true return ret @@ -590,7 +590,7 @@ class PokemonParty_Scene ret = -1 helpwindow = @sprites["helpwindow"] helpwindow.visible = true - using(cmdwindow = Window_CommandPokemonColor.new(commands)) { + using(cmdwindow = Window_CommandPokemonColor.new(commands)) do cmdwindow.z = @viewport.z + 1 cmdwindow.index = index pbBottomRight(cmdwindow) @@ -612,7 +612,7 @@ class PokemonParty_Scene break end end - } + end return ret end @@ -705,18 +705,18 @@ class PokemonParty_Scene def pbChooseItem(bag) ret = nil - pbFadeOutIn { + pbFadeOutIn do scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, bag) ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).can_hold? }) yield if block_given? - } + end return ret end def pbUseItem(bag, pokemon) ret = nil - pbFadeOutIn { + pbFadeOutIn do scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, bag) ret = screen.pbChooseItemScreen(proc { |item| @@ -730,7 +730,7 @@ class PokemonParty_Scene next true }) yield if block_given? - } + end return ret end @@ -764,12 +764,12 @@ class PokemonParty_Scene cancelsprite = Settings::MAX_PARTY_SIZE + ((@multiselect) ? 1 : 0) if Input.trigger?(Input::SPECIAL) && @can_access_storage && canswitch != 2 pbPlayDecisionSE - pbFadeOutIn { + pbFadeOutIn do scene = PokemonStorageScene.new screen = PokemonStorageScreen.new(scene, $PokemonStorage) screen.pbStartScreen(0) pbHardRefresh - } + end elsif Input.trigger?(Input::ACTION) && canswitch == 1 && @activecmd != cancelsprite pbPlayDecisionSE return [1, @activecmd] @@ -1121,9 +1121,9 @@ class PokemonPartyScreen statuses[pkmnid] = 1 pbRefreshSingle(pkmnid) elsif cmdSummary >= 0 && command == cmdSummary - @scene.pbSummary(pkmnid) { + @scene.pbSummary(pkmnid) do @scene.pbSetHelpText((@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) - } + end end end @scene.pbEndScene @@ -1314,9 +1314,9 @@ MenuHandlers.add(:party_menu, :summary, { "name" => _INTL("Summary"), "order" => 10, "effect" => proc { |screen, party, party_idx| - screen.scene.pbSummary(party_idx) { + screen.scene.pbSummary(party_idx) do screen.scene.pbSetHelpText((party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) - } + end } }) @@ -1351,10 +1351,10 @@ MenuHandlers.add(:party_menu, :mail, { [_INTL("Read"), _INTL("Take"), _INTL("Cancel")]) case command when 0 # Read - pbFadeOutIn { + pbFadeOutIn do pbDisplayMail(pkmn.mail, pkmn) screen.scene.pbSetHelpText((party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) - } + end when 1 # Take if pbTakeItemFromPokemon(pkmn, screen) screen.pbRefreshSingle(party_idx) @@ -1388,9 +1388,9 @@ MenuHandlers.add(:party_menu_item, :use, { "order" => 10, "effect" => proc { |screen, party, party_idx| pkmn = party[party_idx] - item = screen.scene.pbUseItem($bag, pkmn) { + item = screen.scene.pbUseItem($bag, pkmn) do screen.scene.pbSetHelpText((party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) - } + end next if !item pbUseItemOnPokemon(item, pkmn, screen) screen.pbRefreshSingle(party_idx) @@ -1402,9 +1402,9 @@ MenuHandlers.add(:party_menu_item, :give, { "order" => 20, "effect" => proc { |screen, party, party_idx| pkmn = party[party_idx] - item = screen.scene.pbChooseItem($bag) { + item = screen.scene.pbChooseItem($bag) do screen.scene.pbSetHelpText((party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) - } + end next if !item || !pbGiveItemToPokemon(item, pkmn, screen, party_idx) screen.pbRefreshSingle(party_idx) } @@ -1480,11 +1480,11 @@ MenuHandlers.add(:party_menu_item, :move, { # Open the party screen #=============================================================================== def pbPokemonScreen - pbFadeOutIn { + pbFadeOutIn do sscene = PokemonParty_Scene.new sscreen = PokemonPartyScreen.new(sscene, $player.party) sscreen.pbPokemonScreen - } + end end #=============================================================================== @@ -1495,7 +1495,7 @@ end # variable _nameVarNumber_; result is -1 if no Pokémon was chosen def pbChoosePokemon(variableNumber, nameVarNumber, ableProc = nil, allowIneligible = false) chosen = 0 - pbFadeOutIn { + pbFadeOutIn do scene = PokemonParty_Scene.new screen = PokemonPartyScreen.new(scene, $player.party) if ableProc @@ -1505,7 +1505,7 @@ def pbChoosePokemon(variableNumber, nameVarNumber, ableProc = nil, allowIneligib chosen = screen.pbChoosePokemon screen.pbEndScene end - } + end pbSet(variableNumber, chosen) if chosen >= 0 pbSet(nameVarNumber, $player.party[chosen].name) @@ -1525,7 +1525,7 @@ end # Same as pbChoosePokemon, but prevents choosing an egg or a Shadow Pokémon. def pbChooseTradablePokemon(variableNumber, nameVarNumber, ableProc = nil, allowIneligible = false) chosen = 0 - pbFadeOutIn { + pbFadeOutIn do scene = PokemonParty_Scene.new screen = PokemonPartyScreen.new(scene, $player.party) if ableProc @@ -1535,7 +1535,7 @@ def pbChooseTradablePokemon(variableNumber, nameVarNumber, ableProc = nil, allow chosen = screen.pbChoosePokemon screen.pbEndScene end - } + end pbSet(variableNumber, chosen) if chosen >= 0 pbSet(nameVarNumber, $player.party[chosen].name) diff --git a/Data/Scripts/016_UI/006_UI_Summary.rb b/Data/Scripts/016_UI/006_UI_Summary.rb index 403c30498..6c79f1fad 100644 --- a/Data/Scripts/016_UI/006_UI_Summary.rb +++ b/Data/Scripts/016_UI/006_UI_Summary.rb @@ -233,7 +233,7 @@ class PokemonSummary_Scene ret = -1 @sprites["messagebox"].text = text @sprites["messagebox"].visible = true - using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) { + using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) do cmdwindow.z = @viewport.z + 1 cmdwindow.visible = false pbBottomRight(cmdwindow) @@ -254,14 +254,14 @@ class PokemonSummary_Scene end end end - } + end @sprites["messagebox"].visible = false return ret end def pbShowCommands(commands, index = 0) ret = -1 - using(cmdwindow = Window_CommandPokemon.new(commands)) { + using(cmdwindow = Window_CommandPokemon.new(commands)) do cmdwindow.z = @viewport.z + 1 cmdwindow.index = index pbBottomRight(cmdwindow) @@ -280,7 +280,7 @@ class PokemonSummary_Scene break end end - } + end return ret end @@ -328,9 +328,7 @@ class PokemonSummary_Scene imagepos.push([sprintf("Graphics/UI/Summary/icon_pokerus"), 176, 100]) end # Show shininess star - if @pokemon.shiny? - imagepos.push([sprintf("Graphics/UI/shiny"), 2, 134]) - end + imagepos.push([sprintf("Graphics/UI/shiny"), 2, 134]) if @pokemon.shiny? # Draw all images pbDrawImagePositions(overlay, imagepos) # Write various bits of text @@ -1193,23 +1191,21 @@ class PokemonSummary_Scene command = pbShowCommands(commands) if cmdGiveItem >= 0 && command == cmdGiveItem item = nil - pbFadeOutIn { + pbFadeOutIn do scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) item = screen.pbChooseItemScreen(proc { |itm| GameData::Item.get(itm).can_hold? }) - } - if item - dorefresh = pbGiveItemToPokemon(item, @pokemon, self, @partyindex) end + dorefresh = pbGiveItemToPokemon(item, @pokemon, self, @partyindex) if item elsif cmdTakeItem >= 0 && command == cmdTakeItem dorefresh = pbTakeItemFromPokemon(@pokemon, self) elsif cmdPokedex >= 0 && command == cmdPokedex $player.pokedex.register_last_seen(@pokemon) - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokedexInfo_Scene.new screen = PokemonPokedexInfoScreen.new(scene) screen.pbStartSceneSingle(@pokemon.species) - } + end dorefresh = true elsif cmdMark >= 0 && command == cmdMark dorefresh = pbMarking(@pokemon) @@ -1318,9 +1314,7 @@ class PokemonSummary_Scene dorefresh = true end end - if dorefresh - drawPage(@page) - end + drawPage(@page) if dorefresh end return @partyindex end @@ -1375,11 +1369,11 @@ end def pbChooseMove(pokemon, variableNumber, nameVarNumber) return if !pokemon ret = -1 - pbFadeOutIn { + pbFadeOutIn do scene = PokemonSummary_Scene.new screen = PokemonSummaryScreen.new(scene) ret = screen.pbStartForgetScreen([pokemon], 0, nil) - } + end $game_variables[variableNumber] = ret if ret >= 0 $game_variables[nameVarNumber] = pokemon.moves[ret].name diff --git a/Data/Scripts/016_UI/007_UI_Bag.rb b/Data/Scripts/016_UI/007_UI_Bag.rb index ab8c5196b..fc3d110c5 100644 --- a/Data/Scripts/016_UI/007_UI_Bag.rb +++ b/Data/Scripts/016_UI/007_UI_Bag.rb @@ -348,7 +348,7 @@ class PokemonBag_Scene itemwindow = @sprites["itemlist"] thispocket = @bag.pockets[itemwindow.pocket] swapinitialpos = -1 - pbActivateWindow(@sprites, "itemlist") { + pbActivateWindow(@sprites, "itemlist") do loop do oldindex = itemwindow.index Graphics.update @@ -443,7 +443,7 @@ class PokemonBag_Scene end end end - } + end end end @@ -492,9 +492,9 @@ class PokemonBagScreen itemname = itm.name command = @scene.pbShowCommands(_INTL("{1} is selected.", itemname), commands) if cmdRead >= 0 && command == cmdRead # Read mail - pbFadeOutIn { + pbFadeOutIn do pbDisplayMail(Mail.new(item, "", "")) - } + end elsif cmdUse >= 0 && command == cmdUse # Use item ret = pbUseItem(@bag, item, @scene) # ret: 0=Item wasn't used; 1=Item used; 2=Close Bag to use in field @@ -507,12 +507,12 @@ class PokemonBagScreen elsif itm.is_important? @scene.pbDisplay(_INTL("The {1} can't be held.", itm.portion_name)) else - pbFadeOutIn { + pbFadeOutIn do sscene = PokemonParty_Scene.new sscreen = PokemonPartyScreen.new(sscene, $player.party) sscreen.pbPokemonGiveScreen(item) @scene.pbRefresh - } + end end elsif cmdToss >= 0 && command == cmdToss # Toss item qty = @bag.quantity(item) diff --git a/Data/Scripts/016_UI/008_UI_Pokegear.rb b/Data/Scripts/016_UI/008_UI_Pokegear.rb index 4a362dff5..07950eaea 100644 --- a/Data/Scripts/016_UI/008_UI_Pokegear.rb +++ b/Data/Scripts/016_UI/008_UI_Pokegear.rb @@ -162,7 +162,7 @@ MenuHandlers.add(:pokegear_menu, :map, { "icon_name" => "map", "order" => 10, "effect" => proc { |menu| - pbFadeOutIn { + pbFadeOutIn do scene = PokemonRegionMap_Scene.new(-1, false) screen = PokemonRegionMapScreen.new(scene) ret = screen.pbStartScreen @@ -171,7 +171,7 @@ MenuHandlers.add(:pokegear_menu, :map, { menu.dispose next 99999 end - } + end next $game_temp.fly_destination } }) @@ -182,11 +182,11 @@ MenuHandlers.add(:pokegear_menu, :phone, { "order" => 20, # "condition" => proc { next $PokemonGlobal.phone && $PokemonGlobal.phone.contacts.length > 0 }, "effect" => proc { |menu| - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPhone_Scene.new screen = PokemonPhoneScreen.new(scene) screen.pbStartScreen - } + end next false } }) @@ -196,11 +196,11 @@ MenuHandlers.add(:pokegear_menu, :jukebox, { "icon_name" => "jukebox", "order" => 30, "effect" => proc { |menu| - pbFadeOutIn { + pbFadeOutIn do scene = PokemonJukebox_Scene.new screen = PokemonJukeboxScreen.new(scene) screen.pbStartScreen - } + end next false } }) diff --git a/Data/Scripts/016_UI/009_UI_RegionMap.rb b/Data/Scripts/016_UI/009_UI_RegionMap.rb index 5303936a6..b9d12bbb6 100644 --- a/Data/Scripts/016_UI/009_UI_RegionMap.rb +++ b/Data/Scripts/016_UI/009_UI_RegionMap.rb @@ -185,7 +185,7 @@ class PokemonRegionMap_Scene @map.point.each do |point| next if point[0] != x || point[1] != y return "" if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]]) - name = pbGetMessageFromHash(MessageTypes::RegionLocations, point[2]) + name = pbGetMessageFromHash(MessageTypes::REGION_LOCATION_NAMES, point[2]) return (@editor) ? point[2] : name end return "" @@ -214,7 +214,7 @@ class PokemonRegionMap_Scene next if point[0] != x || point[1] != y return "" if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]]) return "" if !point[3] - mapdesc = pbGetMessageFromHash(MessageTypes::RegionDescriptions, point[3]) + mapdesc = pbGetMessageFromHash(MessageTypes::REGION_LOCATION_DESCRIPTIONS, point[3]) return (@editor) ? point[3] : mapdesc end return "" @@ -341,10 +341,10 @@ end # #=============================================================================== def pbShowMap(region = -1, wallmap = true) - pbFadeOutIn { + pbFadeOutIn do scene = PokemonRegionMap_Scene.new(region, wallmap) screen = PokemonRegionMapScreen.new(scene) ret = screen.pbStartScreen $game_temp.fly_destination = ret if ret && !wallmap - } + end end diff --git a/Data/Scripts/016_UI/010_UI_Phone.rb b/Data/Scripts/016_UI/010_UI_Phone.rb index 0cafb4783..4452b2765 100644 --- a/Data/Scripts/016_UI/010_UI_Phone.rb +++ b/Data/Scripts/016_UI/010_UI_Phone.rb @@ -138,7 +138,7 @@ class PokemonPhone_Scene end def pbChooseContact - pbActivateWindow(@sprites, "list") { + pbActivateWindow(@sprites, "list") do index = -1 switch_index = -1 loop do @@ -186,7 +186,7 @@ class PokemonPhone_Scene end end end - } + end end def pbEndScene diff --git a/Data/Scripts/016_UI/011_UI_Jukebox.rb b/Data/Scripts/016_UI/011_UI_Jukebox.rb index 633620660..c92bd49cc 100644 --- a/Data/Scripts/016_UI/011_UI_Jukebox.rb +++ b/Data/Scripts/016_UI/011_UI_Jukebox.rb @@ -99,12 +99,12 @@ class PokemonJukeboxScreen elsif cmdCustom >= 0 && cmd == cmdCustom pbPlayDecisionSE files = [] - Dir.chdir("Audio/BGM/") { + Dir.chdir("Audio/BGM/") do Dir.glob("*.ogg") { |f| files.push(f) } Dir.glob("*.wav") { |f| files.push(f) } Dir.glob("*.mid") { |f| files.push(f) } Dir.glob("*.midi") { |f| files.push(f) } - } + end files.map! { |f| File.basename(f, ".*") } files.uniq! files.sort! { |a, b| a.downcase <=> b.downcase } diff --git a/Data/Scripts/016_UI/015_UI_Options.rb b/Data/Scripts/016_UI/015_UI_Options.rb index bb15862c4..8abc46c1b 100644 --- a/Data/Scripts/016_UI/015_UI_Options.rb +++ b/Data/Scripts/016_UI/015_UI_Options.rb @@ -195,14 +195,14 @@ class Window_PokemonOption < Window_DrawableCommand when EnumOption if @options[index].values.length > 1 totalwidth = 0 - @options[index].values.each do |value| + @options[index].each_value do |value| totalwidth += self.contents.text_size(value).width end spacing = (rect.width - rect.x - optionwidth - totalwidth) / (@options[index].values.length - 1) spacing = 0 if spacing < 0 xpos = optionwidth + rect.x ivalue = 0 - @options[index].values.each do |value| + @options[index].each_value do |value| pbDrawShadowText(self.contents, xpos, rect.y, optionwidth, rect.height, value, (ivalue == self[index]) ? SEL_VALUE_BASE_COLOR : self.baseColor, (ivalue == self[index]) ? SEL_VALUE_SHADOW_COLOR : self.shadowColor) @@ -325,7 +325,7 @@ class PokemonOption_Scene end def pbOptions - pbActivateWindow(@sprites, "option") { + pbActivateWindow(@sprites, "option") do index = -1 loop do Graphics.update @@ -342,7 +342,7 @@ class PokemonOption_Scene break if @sprites["option"].index == @options.length end end - } + end end def pbEndScene diff --git a/Data/Scripts/016_UI/016_UI_ReadyMenu.rb b/Data/Scripts/016_UI/016_UI_ReadyMenu.rb index 253f5f0f6..c4cf9db94 100644 --- a/Data/Scripts/016_UI/016_UI_ReadyMenu.rb +++ b/Data/Scripts/016_UI/016_UI_ReadyMenu.rb @@ -258,13 +258,13 @@ class PokemonReadyMenu user = $player.party[commands[0][command[1]][3]] if move == :FLY ret = nil - pbFadeOutInWithUpdate(99999, @scene.sprites) { + pbFadeOutInWithUpdate(99999, @scene.sprites) do pbHideMenu scene = PokemonRegionMap_Scene.new(-1, false) screen = PokemonRegionMapScreen.new(scene) ret = screen.pbStartFlyScreen pbShowMenu if !ret - } + end if ret $game_temp.fly_destination = ret $game_temp.in_menu = false diff --git a/Data/Scripts/016_UI/017_UI_PokemonStorage.rb b/Data/Scripts/016_UI/017_UI_PokemonStorage.rb index 311b83003..2fc8b96be 100644 --- a/Data/Scripts/016_UI/017_UI_PokemonStorage.rb +++ b/Data/Scripts/016_UI/017_UI_PokemonStorage.rb @@ -452,9 +452,7 @@ class PokemonBoxPartySprite < Sprite Settings::MAX_PARTY_SIZE.times do |i| @pokemonsprites[i] = nil pokemon = @party[i] - if pokemon - @pokemonsprites[i] = PokemonBoxIcon.new(pokemon, viewport) - end + @pokemonsprites[i] = PokemonBoxIcon.new(pokemon, viewport) if pokemon end @contents = BitmapWrapper.new(172, 352) self.bitmap = @contents @@ -895,9 +893,7 @@ class PokemonStorageScene return pbSelectBoxInternal(party) if @command == 1 # Withdraw ret = nil loop do - if !@choseFromParty - ret = pbSelectBoxInternal(party) - end + ret = pbSelectBoxInternal(party) if !@choseFromParty if @choseFromParty || (ret && ret[0] == -2) # Party Pokémon if !@choseFromParty pbShowPartyTab @@ -1206,9 +1202,7 @@ class PokemonStorageScene def pbBoxName(helptext, minchars, maxchars) oldsprites = pbFadeOutAndHide(@sprites) ret = pbEnterBoxName(helptext, minchars, maxchars) - if ret.length > 0 - @storage[@storage.currentBox].name = ret - end + @storage[@storage.currentBox].name = ret if ret.length > 0 @sprites["box"].refreshBox = true pbRefresh pbFadeInAndShow(@sprites, oldsprites) @@ -1216,11 +1210,11 @@ class PokemonStorageScene def pbChooseItem(bag) ret = nil - pbFadeOutIn { + pbFadeOutIn do scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, bag) ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).can_hold? }) - } + end return ret end @@ -1443,9 +1437,7 @@ class PokemonStorageScene else textstrings.push([_INTL("No item"), 86, 348, 2, nonbase, nonshadow]) end - if pokemon.shiny? - imagepos.push(["Graphics/UI/shiny", 156, 198]) - end + imagepos.push(["Graphics/UI/shiny", 156, 198]) if pokemon.shiny? typebitmap = AnimatedBitmap.new(_INTL("Graphics/UI/types")) pokemon.types.each_with_index do |type, i| type_number = GameData::Type.get(type).icon_position @@ -1684,9 +1676,7 @@ class PokemonStorageScreen def pbWithdraw(selected, heldpoke) box = selected[0] index = selected[1] - if box == -1 - raise _INTL("Can't withdraw from party...") - end + raise _INTL("Can't withdraw from party...") if box == -1 if @storage.party_full? pbDisplay(_INTL("Your party's full!")) return false @@ -1705,9 +1695,7 @@ class PokemonStorageScreen def pbStore(selected, heldpoke) box = selected[0] index = selected[1] - if box != -1 - raise _INTL("Can't deposit from box...") - end + raise _INTL("Can't deposit from box...") if box != -1 if pbAbleCount <= 1 && pbAble?(@storage[box, index]) && !heldpoke pbPlayBuzzerSE pbDisplay(_INTL("That's your last Pokémon!")) @@ -1788,9 +1776,7 @@ class PokemonStorageScreen end @scene.pbPlace(selected, @heldpkmn) @storage[box, index] = @heldpkmn - if box == -1 - @storage.party.compact! - end + @storage.party.compact! if box == -1 @scene.pbRefresh @heldpkmn = nil end @@ -1929,9 +1915,7 @@ class PokemonStorageScreen case command when 0 destbox = @scene.pbChooseBox(_INTL("Jump to which Box?")) - if destbox >= 0 - @scene.pbJumpToBox(destbox) - end + @scene.pbJumpToBox(destbox) if destbox >= 0 when 1 papers = @storage.availableWallpapers index = 0 @@ -1942,9 +1926,7 @@ class PokemonStorageScreen end end wpaper = pbShowCommands(_INTL("Pick the wallpaper."), papers[0], index) - if wpaper >= 0 - @scene.pbChangeBackground(papers[1][wpaper]) - end + @scene.pbChangeBackground(papers[1][wpaper]) if wpaper >= 0 when 2 @scene.pbBoxName(_INTL("Box name?"), 0, 12) end diff --git a/Data/Scripts/016_UI/018_UI_ItemStorage.rb b/Data/Scripts/016_UI/018_UI_ItemStorage.rb index 391c43036..532e703fc 100644 --- a/Data/Scripts/016_UI/018_UI_ItemStorage.rb +++ b/Data/Scripts/016_UI/018_UI_ItemStorage.rb @@ -150,7 +150,7 @@ class ItemStorage_Scene @sprites["helpwindow"].visible = false itemwindow = @sprites["itemwindow"] itemwindow.refresh - pbActivateWindow(@sprites, "itemwindow") { + pbActivateWindow(@sprites, "itemwindow") do loop do Graphics.update Input.update @@ -168,7 +168,7 @@ class ItemStorage_Scene end end end - } + end end end diff --git a/Data/Scripts/016_UI/019_UI_PC.rb b/Data/Scripts/016_UI/019_UI_PC.rb index aadc6d1f7..87a83d7fb 100644 --- a/Data/Scripts/016_UI/019_UI_PC.rb +++ b/Data/Scripts/016_UI/019_UI_PC.rb @@ -21,18 +21,18 @@ def pbPCItemStorage if $PokemonGlobal.pcItemStorage.empty? pbMessage(_INTL("There are no items.")) else - pbFadeOutIn { + pbFadeOutIn do scene = WithdrawItemScene.new screen = PokemonBagScreen.new(scene, $bag) screen.pbWithdrawItemScreen - } + end end when 1 # Deposit Item - pbFadeOutIn { + pbFadeOutIn do scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) screen.pbDepositItemScreen - } + end when 2 # Toss Item if !$PokemonGlobal.pcItemStorage $PokemonGlobal.pcItemStorage = PCItemStorage.new @@ -40,11 +40,11 @@ def pbPCItemStorage if $PokemonGlobal.pcItemStorage.empty? pbMessage(_INTL("There are no items.")) else - pbFadeOutIn { + pbFadeOutIn do scene = TossItemScene.new screen = PokemonBagScreen.new(scene, $bag) screen.pbTossItemScreen - } + end end else break @@ -78,9 +78,9 @@ def pbPCMailbox ) case commandMail when 0 # Read - pbFadeOutIn { + pbFadeOutIn do pbDisplayMail($PokemonGlobal.mailbox[mailIndex]) - } + end when 1 # Move to Bag if pbConfirmMessage(_INTL("The message will be lost. Is that OK?")) if $bag.add($PokemonGlobal.mailbox[mailIndex].item) @@ -91,11 +91,11 @@ def pbPCMailbox end end when 2 # Give - pbFadeOutIn { + pbFadeOutIn do sscene = PokemonParty_Scene.new sscreen = PokemonPartyScreen.new(sscene, $player.party) sscreen.pbPokemonGiveMailScreen(mailIndex) - } + end end else break @@ -181,21 +181,21 @@ MenuHandlers.add(:pc_menu, :pokemon_storage, { break if command < 0 case command when 0 # Organize - pbFadeOutIn { + pbFadeOutIn do scene = PokemonStorageScene.new screen = PokemonStorageScreen.new(scene, $PokemonStorage) screen.pbStartScreen(0) - } + end when 1 # Withdraw if $PokemonStorage.party_full? pbMessage(_INTL("Your party is full!")) next end - pbFadeOutIn { + pbFadeOutIn do scene = PokemonStorageScene.new screen = PokemonStorageScreen.new(scene, $PokemonStorage) screen.pbStartScreen(1) - } + end when 2 # Deposit count = 0 $PokemonStorage.party.each do |p| @@ -205,11 +205,11 @@ MenuHandlers.add(:pc_menu, :pokemon_storage, { pbMessage(_INTL("Can't deposit the last Pokémon!")) next end - pbFadeOutIn { + pbFadeOutIn do scene = PokemonStorageScene.new screen = PokemonStorageScreen.new(scene, $PokemonStorage) screen.pbStartScreen(2) - } + end else break end diff --git a/Data/Scripts/016_UI/020_UI_PokeMart.rb b/Data/Scripts/016_UI/020_UI_PokeMart.rb index e33d6a75b..73fc2a828 100644 --- a/Data/Scripts/016_UI/020_UI_PokeMart.rb +++ b/Data/Scripts/016_UI/020_UI_PokeMart.rb @@ -546,7 +546,7 @@ class PokemonMart_Scene def pbChooseBuyItem itemwindow = @sprites["itemwindow"] @sprites["helpwindow"].visible = false - pbActivateWindow(@sprites, "itemwindow") { + pbActivateWindow(@sprites, "itemwindow") do pbRefresh loop do Graphics.update @@ -566,7 +566,7 @@ class PokemonMart_Scene end end end - } + end end def pbChooseSellItem @@ -647,7 +647,7 @@ class PokemonMartScreen $stats.money_spent_at_marts += price $stats.mart_items_bought += quantity @adapter.setMoney(@adapter.getMoney - price) - @stock.delete_if { |item| GameData::Item.get(item).is_important? && $bag.has?(item) } + @stock.delete_if { |itm| GameData::Item.get(itm).is_important? && $bag.has?(itm) } pbDisplayPaused(_INTL("Here you are! Thank you!")) { pbSEPlay("Mart buy item") } if quantity >= 10 && GameData::Item.exists?(:PREMIERBALL) if Settings::MORE_BONUS_PREMIER_BALLS && GameData::Item.get(item).is_poke_ball? diff --git a/Data/Scripts/016_UI/021_UI_BattlePointShop.rb b/Data/Scripts/016_UI/021_UI_BattlePointShop.rb index 64d90e26c..3d5d51c82 100644 --- a/Data/Scripts/016_UI/021_UI_BattlePointShop.rb +++ b/Data/Scripts/016_UI/021_UI_BattlePointShop.rb @@ -393,7 +393,7 @@ class BattlePointShop_Scene def pbChooseItem itemwindow = @sprites["itemwindow"] @sprites["helpwindow"].visible = false - pbActivateWindow(@sprites, "itemwindow") { + pbActivateWindow(@sprites, "itemwindow") do pbRefresh loop do Graphics.update @@ -413,7 +413,7 @@ class BattlePointShop_Scene end end end - } + end end end @@ -487,7 +487,7 @@ class BattlePointShopScreen # TODO: Add bpshop_items_bought to $stats? # $stats.bpshop_items_bought += quantity @adapter.setBP(@adapter.getBP - price) - @stock.delete_if { |item| GameData::Item.get(item).is_important? && $bag.has?(item) } + @stock.delete_if { |itm| GameData::Item.get(itm).is_important? && $bag.has?(itm) } pbDisplayPaused(_INTL("Here you are! Thank you!")) { pbSEPlay("Mart buy item") } else added.times do diff --git a/Data/Scripts/016_UI/022_UI_MoveRelearner.rb b/Data/Scripts/016_UI/022_UI_MoveRelearner.rb index 7a9817bd2..5bc1ca067 100644 --- a/Data/Scripts/016_UI/022_UI_MoveRelearner.rb +++ b/Data/Scripts/016_UI/022_UI_MoveRelearner.rb @@ -110,7 +110,7 @@ class MoveRelearner_Scene # Processes the scene def pbChooseMove oldcmd = -1 - pbActivateWindow(@sprites, "commands") { + pbActivateWindow(@sprites, "commands") do loop do oldcmd = @sprites["commands"].index Graphics.update @@ -127,7 +127,7 @@ class MoveRelearner_Scene return @moves[@sprites["commands"].index] end end - } + end end # End the scene here @@ -190,10 +190,10 @@ end #=============================================================================== def pbRelearnMoveScreen(pkmn) retval = true - pbFadeOutIn { + pbFadeOutIn do scene = MoveRelearner_Scene.new screen = MoveRelearnerScreen.new(scene) retval = screen.pbStartScreen(pkmn) - } + end return retval end diff --git a/Data/Scripts/016_UI/023_UI_PurifyChamber.rb b/Data/Scripts/016_UI/023_UI_PurifyChamber.rb index 23cf8ad20..fd7bd2db3 100644 --- a/Data/Scripts/016_UI/023_UI_PurifyChamber.rb +++ b/Data/Scripts/016_UI/023_UI_PurifyChamber.rb @@ -66,15 +66,11 @@ class PurifyChamberSet end def facing=(value) - if value >= 0 && value < @list.length - @facing = value - end + @facing = value if value >= 0 && value < @list.length end def shadow=(value) - if value.nil? || value.shadowPokemon? - @shadow = value - end + @shadow = value if value.nil? || value.shadowPokemon? end # Main component is tempo @@ -225,9 +221,7 @@ class PurifyChamber end def [](chamber, slot = nil) - if slot.nil? - return @sets[chamber] - end + return @sets[chamber] if slot.nil? return nil if chamber < 0 || chamber >= NUMSETS return nil if slot < 0 || slot >= SETSIZE return @sets[chamber][slot] @@ -430,8 +424,8 @@ class PurifyChamberScreen # array[0]==1 - a new set was chosen # array[0]==2 - choose Pokemon command cmd = @scene.pbSetScreen - if cmd[0] == 0 - # Place Pokemon in the set + case cmd[0] + when 0 # Place Pokemon in the set curpkmn = PurifyChamberHelper.pbGetPokemon(@chamber, cmd[1]) if curpkmn || heldpkmn commands = [_INTL("MOVE"), _INTL("SUMMARY"), _INTL("WITHDRAW")] @@ -475,7 +469,7 @@ class PurifyChamberScreen @scene.pbSummary(cmd[1], heldpkmn) elsif choice == 2 if pbBoxesFull? - @scene.pbDisplay("All boxes are full.") + @scene.pbDisplay(_INTL("All boxes are full.")) elsif heldpkmn @scene.pbWithdraw(cmd[1], heldpkmn) $PokemonStorage.pbStoreCaught(heldpkmn) @@ -513,7 +507,7 @@ class PurifyChamberScreen end end end - else # No current Pokemon + else # No current Pokemon pos = @scene.pbChoosePokemon if pbPlacePokemon(pos, cmd[1]) curpkmn = PurifyChamberHelper.pbGetPokemon(@chamber, cmd[1]) @@ -521,20 +515,18 @@ class PurifyChamberScreen @scene.pbPositionHint(PurifyChamberHelper.adjustOnInsert(cmd[1])) end end - elsif cmd[0] == 1 # Change the active set + when 1 # Change the active set @scene.pbChangeSet(cmd[1]) chamber.currentSet = cmd[1] - elsif cmd[0] == 2 # Choose a Pokemon + when 2 # Choose a Pokemon pos = @scene.pbChoosePokemon pkmn = pos ? $PokemonStorage[pos[0], pos[1]] : nil heldpkmn = pkmn if pkmn - else # cancel + else # cancel if heldpkmn - @scene.pbDisplay("You're holding a Pokémon!") + @scene.pbDisplay(_INTL("You're holding a Pokémon!")) else - if !@scene.pbConfirm("Continue editing sets?") - break - end + break if !@scene.pbConfirm(_INTL("Continue editing sets?")) end end end @@ -588,7 +580,7 @@ class PurifyChamberScreen @chamber.setShadow(set, nil) # Remove shadow Pokemon from set if (i + 1) != purifiables.length @scene.pbDisplay(_INTL("There is another Pokémon that is ready to open its heart!")) - if !@scene.pbConfirm("Would you like to switch sets?") + if !@scene.pbConfirm(_INTL("Would you like to switch sets?")) @scene.pbCloseSet break end @@ -609,18 +601,14 @@ class PurifyChamberScreen loop do set = @scene.pbChooseSet if set < 0 - if !@scene.pbConfirm("Continue viewing holograms?") - break - end + break if !@scene.pbConfirm(_INTL("Continue viewing holograms?")) else chamber.currentSet = set cmd = @scene.pbShowCommands(_INTL("What do you want to do?"), [_INTL("EDIT"), _INTL("SWITCH"), _INTL("CANCEL")]) case cmd when 0 # edit - if !pbOpenSetDetail - break - end + break if !pbOpenSetDetail when 1 # switch chamber.currentSet = set newSet = @scene.pbSwitch(set) @@ -880,9 +868,7 @@ class PurifyChamberSetView < Sprite end setcount = @chamber.setCount(@set) setcount.times do |i| - if !@flows[i] - @flows[i] = FlowDiagram.new(self.viewport) - end + @flows[i] = FlowDiagram.new(self.viewport) if !@flows[i] angle = 360 - (i * 360 / setcount) angle += 90 # start at 12 not 3 o'clock endAngle = angle - (360 / setcount) @@ -932,15 +918,13 @@ class PurifyChamberSetView < Sprite @cursor = pos + 1 end end - if @cursor != oldcursor - refresh - end + refresh if @cursor != oldcursor end def checkCursor(index) if @cursor == index - @view.x = @__sprites[index].x - @view.bitmap.width / 2 - @view.y = @__sprites[index].y - @view.bitmap.height / 2 + @view.x = @__sprites[index].x - (@view.bitmap.width / 2) + @view.y = @__sprites[index].y - (@view.bitmap.height / 2) @view.visible = true end end @@ -1005,8 +989,8 @@ class PurifyChamberSetView < Sprite end @__sprites[1 + (PurifyChamber::SETSIZE * 2)].pokemon = @heldpkmn @__sprites[1 + (PurifyChamber::SETSIZE * 2)].visible = @view.visible - @__sprites[1 + (PurifyChamber::SETSIZE * 2)].x = @view.x + @view.bitmap.width / 2 - @__sprites[1 + (PurifyChamber::SETSIZE * 2)].y = @view.y + @view.bitmap.height / 2 + @__sprites[1 + (PurifyChamber::SETSIZE * 2)].x = @view.x + (@view.bitmap.width / 2) + @__sprites[1 + (PurifyChamber::SETSIZE * 2)].y = @view.y + (@view.bitmap.height / 2) @__sprites[1 + (PurifyChamber::SETSIZE * 2)].z = 3 end @@ -1102,8 +1086,7 @@ class PurifyChamberScene @chamber = chamber end - def pbEnd - end + def pbEnd; end def pbOpenSet(set) @sprites = {} @@ -1138,8 +1121,7 @@ class PurifyChamberScene @sprites["setview"].cursor = 0 end - def pbCloseSetDetail - end + def pbCloseSetDetail; end def pbPurify pbRefresh @@ -1185,7 +1167,7 @@ class PurifyChamberScene end def pbSetScreen - pbDeactivateWindows(@sprites) { + pbDeactivateWindows(@sprites) do loop do Graphics.update Input.update @@ -1215,11 +1197,11 @@ class PurifyChamberScene return [3, 0] end end - } + end end def pbChooseSet - pbActivateWindow(@sprites, "setwindow") { + pbActivateWindow(@sprites, "setwindow") do oldindex = @sprites["setwindow"].index loop do if oldindex != @sprites["setwindow"].index @@ -1238,7 +1220,7 @@ class PurifyChamberScene return -1 end end - } + end end def pbSwitch(set) @@ -1305,11 +1287,11 @@ end #=============================================================================== def pbPurifyChamber $player.seen_purify_chamber = true - pbFadeOutIn { + pbFadeOutIn do scene = PurifyChamberScene.new screen = PurifyChamberScreen.new(scene) screen.pbStartPurify - } + end end #=============================================================================== diff --git a/Data/Scripts/016_UI/024_UI_MysteryGift.rb b/Data/Scripts/016_UI/024_UI_MysteryGift.rb index e819a0e56..2a5432cee 100644 --- a/Data/Scripts/016_UI/024_UI_MysteryGift.rb +++ b/Data/Scripts/016_UI/024_UI_MysteryGift.rb @@ -341,11 +341,11 @@ def pbMysteryGiftDecrypt(gift) return [] if nil_or_empty?(gift) ret = Marshal.restore(Zlib::Inflate.inflate(gift.unpack("m")[0])) if ret - ret.each do |gift| - if gift[1] == 0 # Pokémon - gift[2] = gift[2] + ret.each do |gft| + if gft[1] == 0 # Pokémon + gft[2] = gft[2] else # Item - gift[2] = GameData::Item.get(gift[2]).id + gft[2] = GameData::Item.get(gft[2]).id end end end @@ -392,11 +392,11 @@ def pbReceiveMysteryGift(id) if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex pbMessage(_INTL("{1}'s data was added to the Pokédex.", gift[2].name)) $player.pokedex.register_last_seen(gift[2]) - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokedexInfo_Scene.new screen = PokemonPokedexInfoScreen.new(scene) screen.pbDexEntry(gift[2].species) - } + end end return true end diff --git a/Data/Scripts/016_UI/025_UI_TextEntry.rb b/Data/Scripts/016_UI/025_UI_TextEntry.rb index 227c150f2..4ec0aa715 100644 --- a/Data/Scripts/016_UI/025_UI_TextEntry.rb +++ b/Data/Scripts/016_UI/025_UI_TextEntry.rb @@ -461,12 +461,12 @@ class PokemonEntryScene2 @mode = 0 @minlength = minlength @maxlength = maxlength - @maxlength.times { |i| + @maxlength.times do |i| @sprites["blank#{i}"] = Sprite.new(@viewport) @sprites["blank#{i}"].x = 160 + (24 * i) @sprites["blank#{i}"].bitmap = @bitmaps[@bitmaps.length - 1] @blanks[i] = 0 - } + end @sprites["bottomtab"] = Sprite.new(@viewport) # Current tab @sprites["bottomtab"].x = 22 @sprites["bottomtab"].y = 162 @@ -568,10 +568,10 @@ class PokemonEntryScene2 cursorpos = @helper.cursor cursorpos = @maxlength - 1 if cursorpos >= @maxlength cursorpos = 0 if cursorpos < 0 - @maxlength.times { |i| + @maxlength.times do |i| @blanks[i] = (i == cursorpos) ? 1 : 0 @sprites["blank#{i}"].y = [78, 82][@blanks[i]] - } + end end pbDoUpdateOverlay pbUpdateSpriteHash(@sprites) @@ -715,9 +715,7 @@ class PokemonEntryScene2 cursordiv = @cursorpos / ROWS charpos = (cursordiv * ROWS) + cursormod chset = @@Characters[@mode][0] - if @helper.length >= @maxlength - @helper.delete - end + @helper.delete if @helper.length >= @maxlength @helper.insert(chset[charpos]) pbPlayCursorSE if @helper.length >= @maxlength @@ -767,17 +765,17 @@ end def pbEnterText(helptext, minlength, maxlength, initialText = "", mode = 0, pokemon = nil, nofadeout = false) ret = "" if ($PokemonSystem.textinput == 1 rescue false) # Keyboard - pbFadeOutIn(99999, nofadeout) { + pbFadeOutIn(99999, nofadeout) do sscene = PokemonEntryScene.new sscreen = PokemonEntry.new(sscene) ret = sscreen.pbStartScreen(helptext, minlength, maxlength, initialText, mode, pokemon) - } + end else # Cursor - pbFadeOutIn(99999, nofadeout) { + pbFadeOutIn(99999, nofadeout) do sscene = PokemonEntryScene2.new sscreen = PokemonEntry.new(sscene) ret = sscreen.pbStartScreen(helptext, minlength, maxlength, initialText, mode, pokemon) - } + end end return ret end diff --git a/Data/Scripts/017_Minigames/001_Minigame_Duel.rb b/Data/Scripts/017_Minigames/001_Minigame_Duel.rb index 8951878ff..71fd9c80e 100644 --- a/Data/Scripts/017_Minigames/001_Minigame_Duel.rb +++ b/Data/Scripts/017_Minigames/001_Minigame_Duel.rb @@ -72,11 +72,11 @@ class PokemonDuel @oldmovespeed = $game_player.move_speed @oldeventspeed = event.move_speed pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 2, - PBMoveRoute::DirectionFixOn]) + [PBMoveRoute::CHANGE_SPEED, 2, + PBMoveRoute::DIRECTION_FIX_ON]) pbMoveRoute(event, - [PBMoveRoute::ChangeSpeed, 2, - PBMoveRoute::DirectionFixOn]) + [PBMoveRoute::CHANGE_SPEED, 2, + PBMoveRoute::DIRECTION_FIX_ON]) pbWait(Graphics.frame_rate * 3 / 4) end @@ -126,177 +126,177 @@ class PokemonDuel @special[0] = true if command == 3 if action == 0 && command == 0 pbMoveRoute($game_player, - [PBMoveRoute::ScriptAsync, "moveRight90", - PBMoveRoute::ScriptAsync, "moveLeft90", - PBMoveRoute::ScriptAsync, "moveLeft90", - PBMoveRoute::ScriptAsync, "moveRight90"]) + [PBMoveRoute::SCRIPT_ASYNC, "moveRight90", + PBMoveRoute::SCRIPT_ASYNC, "moveLeft90", + PBMoveRoute::SCRIPT_ASYNC, "moveLeft90", + PBMoveRoute::SCRIPT_ASYNC, "moveRight90"]) pbMoveRoute(event, - [PBMoveRoute::ScriptAsync, "moveLeft90", - PBMoveRoute::ScriptAsync, "moveRight90", - PBMoveRoute::ScriptAsync, "moveRight90", - PBMoveRoute::ScriptAsync, "moveLeft90"]) + [PBMoveRoute::SCRIPT_ASYNC, "moveLeft90", + PBMoveRoute::SCRIPT_ASYNC, "moveRight90", + PBMoveRoute::SCRIPT_ASYNC, "moveRight90", + PBMoveRoute::SCRIPT_ASYNC, "moveLeft90"]) pbWait(Graphics.frame_rate / 2) pbMessage(_INTL("You study each other's movements...")) elsif action == 0 && command == 1 pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 4, - PBMoveRoute::Forward]) + [PBMoveRoute::CHANGE_SPEED, 4, + PBMoveRoute::FORWARD]) pbWait(Graphics.frame_rate * 4 / 10) pbShake(9, 9, 8) pbFlashScreens(false, true) pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 2, - PBMoveRoute::Backward]) + [PBMoveRoute::CHANGE_SPEED, 2, + PBMoveRoute::BACKWARD]) @hp[1] -= 1 pbMessage(_INTL("Your attack was not blocked!")) elsif action == 0 && command == 2 pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 4, - PBMoveRoute::ScriptAsync, "jumpForward"]) + [PBMoveRoute::CHANGE_SPEED, 4, + PBMoveRoute::SCRIPT_ASYNC, "jumpForward"]) pbMoveRoute(event, - [PBMoveRoute::ChangeSpeed, 4, - PBMoveRoute::Backward]) + [PBMoveRoute::CHANGE_SPEED, 4, + PBMoveRoute::BACKWARD]) pbWait(Graphics.frame_rate) pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 2, - PBMoveRoute::Backward]) + [PBMoveRoute::CHANGE_SPEED, 2, + PBMoveRoute::BACKWARD]) pbMoveRoute(event, - [PBMoveRoute::ChangeSpeed, 2, - PBMoveRoute::Forward]) + [PBMoveRoute::CHANGE_SPEED, 2, + PBMoveRoute::FORWARD]) pbMessage(_INTL("Your attack was evaded!")) elsif [0, 1, 2].include?(action) && command == 3 pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 4, - PBMoveRoute::ScriptAsync, "jumpForward"]) + [PBMoveRoute::CHANGE_SPEED, 4, + PBMoveRoute::SCRIPT_ASYNC, "jumpForward"]) pbWait(Graphics.frame_rate * 4 / 10) pbMoveRoute(event, - [PBMoveRoute::ChangeSpeed, 5, - PBMoveRoute::Backward, - PBMoveRoute::ChangeSpeed, 2]) + [PBMoveRoute::CHANGE_SPEED, 5, + PBMoveRoute::BACKWARD, + PBMoveRoute::CHANGE_SPEED, 2]) pbWait(Graphics.frame_rate / 2) pbShake(9, 9, 8) pbFlashScreens(false, true) pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 2, - PBMoveRoute::Backward]) + [PBMoveRoute::CHANGE_SPEED, 2, + PBMoveRoute::BACKWARD]) pbMoveRoute(event, - [PBMoveRoute::ChangeSpeed, 2, - PBMoveRoute::Forward]) + [PBMoveRoute::CHANGE_SPEED, 2, + PBMoveRoute::FORWARD]) @hp[1] -= 3 pbMessage(_INTL("You pierce through the opponent's defenses!")) elsif action == 1 && command == 0 pbMoveRoute(event, - [PBMoveRoute::ChangeSpeed, 4, - PBMoveRoute::Forward]) + [PBMoveRoute::CHANGE_SPEED, 4, + PBMoveRoute::FORWARD]) pbWait(Graphics.frame_rate * 4 / 10) pbShake(9, 9, 8) pbFlashScreens(true, false) pbMoveRoute(event, - [PBMoveRoute::ChangeSpeed, 2, - PBMoveRoute::Backward]) + [PBMoveRoute::CHANGE_SPEED, 2, + PBMoveRoute::BACKWARD]) @hp[0] -= 1 pbMessage(_INTL("You fail to block the opponent's attack!")) elsif action == 1 && command == 1 pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 4, - PBMoveRoute::Forward]) + [PBMoveRoute::CHANGE_SPEED, 4, + PBMoveRoute::FORWARD]) pbWait(Graphics.frame_rate * 6 / 10) pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 2, - PBMoveRoute::Backward]) + [PBMoveRoute::CHANGE_SPEED, 2, + PBMoveRoute::BACKWARD]) pbMoveRoute(event, - [PBMoveRoute::ChangeSpeed, 2, - PBMoveRoute::Forward]) + [PBMoveRoute::CHANGE_SPEED, 2, + PBMoveRoute::FORWARD]) pbWait(Graphics.frame_rate * 6 / 10) - pbMoveRoute(event, [PBMoveRoute::Backward]) - pbMoveRoute($game_player, [PBMoveRoute::Forward]) + pbMoveRoute(event, [PBMoveRoute::BACKWARD]) + pbMoveRoute($game_player, [PBMoveRoute::FORWARD]) pbWait(Graphics.frame_rate * 6 / 10) - pbMoveRoute($game_player, [PBMoveRoute::Backward]) + pbMoveRoute($game_player, [PBMoveRoute::BACKWARD]) pbMessage(_INTL("You cross blades with the opponent!")) elsif (action == 1 && command == 2) || (action == 2 && command == 1) || (action == 2 && command == 2) pbMoveRoute($game_player, - [PBMoveRoute::Backward, - PBMoveRoute::ChangeSpeed, 4, - PBMoveRoute::ScriptAsync, "jumpForward"]) + [PBMoveRoute::BACKWARD, + PBMoveRoute::CHANGE_SPEED, 4, + PBMoveRoute::SCRIPT_ASYNC, "jumpForward"]) pbWait(Graphics.frame_rate * 8 / 10) pbMoveRoute(event, - [PBMoveRoute::ChangeSpeed, 4, - PBMoveRoute::Forward]) + [PBMoveRoute::CHANGE_SPEED, 4, + PBMoveRoute::FORWARD]) pbWait(Graphics.frame_rate * 9 / 10) pbShake(9, 9, 8) pbFlashScreens(true, true) pbMoveRoute($game_player, - [PBMoveRoute::Backward, - PBMoveRoute::ChangeSpeed, 2]) + [PBMoveRoute::BACKWARD, + PBMoveRoute::CHANGE_SPEED, 2]) pbMoveRoute(event, - [PBMoveRoute::Backward, - PBMoveRoute::Backward, - PBMoveRoute::ChangeSpeed, 2]) + [PBMoveRoute::BACKWARD, + PBMoveRoute::BACKWARD, + PBMoveRoute::CHANGE_SPEED, 2]) pbWait(Graphics.frame_rate) - pbMoveRoute(event, [PBMoveRoute::Forward]) - pbMoveRoute($game_player, [PBMoveRoute::Forward]) + pbMoveRoute(event, [PBMoveRoute::FORWARD]) + pbMoveRoute($game_player, [PBMoveRoute::FORWARD]) @hp[0] -= action # Enemy action @hp[1] -= command # Player command pbMessage(_INTL("You hit each other!")) elsif action == 2 && command == 0 pbMoveRoute(event, - [PBMoveRoute::ChangeSpeed, 4, - PBMoveRoute::Forward]) + [PBMoveRoute::CHANGE_SPEED, 4, + PBMoveRoute::FORWARD]) pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 4, - PBMoveRoute::ScriptAsync, "jumpBackward"]) + [PBMoveRoute::CHANGE_SPEED, 4, + PBMoveRoute::SCRIPT_ASYNC, "jumpBackward"]) pbWait(Graphics.frame_rate) pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 2, - PBMoveRoute::Forward]) + [PBMoveRoute::CHANGE_SPEED, 2, + PBMoveRoute::FORWARD]) pbMoveRoute(event, - [PBMoveRoute::ChangeSpeed, 2, - PBMoveRoute::Backward]) + [PBMoveRoute::CHANGE_SPEED, 2, + PBMoveRoute::BACKWARD]) pbMessage(_INTL("You evade the opponent's attack!")) elsif action == 3 && [0, 1, 2].include?(command) pbMoveRoute(event, - [PBMoveRoute::ChangeSpeed, 4, - PBMoveRoute::ScriptAsync, "jumpForward"]) + [PBMoveRoute::CHANGE_SPEED, 4, + PBMoveRoute::SCRIPT_ASYNC, "jumpForward"]) pbWait(Graphics.frame_rate * 4 / 10) pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 5, - PBMoveRoute::Backward, - PBMoveRoute::ChangeSpeed, 2]) + [PBMoveRoute::CHANGE_SPEED, 5, + PBMoveRoute::BACKWARD, + PBMoveRoute::CHANGE_SPEED, 2]) pbWait(Graphics.frame_rate / 2) pbShake(9, 9, 8) pbFlashScreens(true, false) pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 2, - PBMoveRoute::Forward]) + [PBMoveRoute::CHANGE_SPEED, 2, + PBMoveRoute::FORWARD]) pbMoveRoute(event, - [PBMoveRoute::ChangeSpeed, 2, - PBMoveRoute::Backward]) + [PBMoveRoute::CHANGE_SPEED, 2, + PBMoveRoute::BACKWARD]) @hp[0] -= 3 pbMessage(_INTL("The opponent pierces through your defenses!")) elsif action == 3 && command == 3 - pbMoveRoute($game_player, [PBMoveRoute::Backward]) + pbMoveRoute($game_player, [PBMoveRoute::BACKWARD]) pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 4, - PBMoveRoute::ScriptAsync, "jumpForward"]) + [PBMoveRoute::CHANGE_SPEED, 4, + PBMoveRoute::SCRIPT_ASYNC, "jumpForward"]) pbMoveRoute(event, - [PBMoveRoute::Wait, 15, - PBMoveRoute::ChangeSpeed, 4, - PBMoveRoute::ScriptAsync, "jumpForward"]) + [PBMoveRoute::WAIT, 15, + PBMoveRoute::CHANGE_SPEED, 4, + PBMoveRoute::SCRIPT_ASYNC, "jumpForward"]) pbWait(Graphics.frame_rate) pbMoveRoute(event, - [PBMoveRoute::ChangeSpeed, 5, - PBMoveRoute::Backward, - PBMoveRoute::ChangeSpeed, 2]) + [PBMoveRoute::CHANGE_SPEED, 5, + PBMoveRoute::BACKWARD, + PBMoveRoute::CHANGE_SPEED, 2]) pbMoveRoute($game_player, - [PBMoveRoute::ChangeSpeed, 5, - PBMoveRoute::Backward, - PBMoveRoute::ChangeSpeed, 2]) + [PBMoveRoute::CHANGE_SPEED, 5, + PBMoveRoute::BACKWARD, + PBMoveRoute::CHANGE_SPEED, 2]) pbShake(9, 9, 8) pbFlash(Color.new(255, 255, 255, 255), 20) pbFlashScreens(true, true) - pbMoveRoute($game_player, [PBMoveRoute::Forward]) + pbMoveRoute($game_player, [PBMoveRoute::FORWARD]) @hp[0] -= 4 @hp[1] -= 4 pbMessage(_INTL("Your special attacks collide!")) @@ -309,11 +309,11 @@ class PokemonDuel def pbEndDuel pbWait(Graphics.frame_rate * 3 / 4) pbMoveRoute($game_player, - [PBMoveRoute::DirectionFixOff, - PBMoveRoute::ChangeSpeed, @oldmovespeed]) + [PBMoveRoute::DIRECTION_FIX_OFF, + PBMoveRoute::CHANGE_SPEED, @oldmovespeed]) pbMoveRoute(@event, - [PBMoveRoute::DirectionFixOff, - PBMoveRoute::ChangeSpeed, @oldeventspeed]) + [PBMoveRoute::DIRECTION_FIX_OFF, + PBMoveRoute::CHANGE_SPEED, @oldeventspeed]) fade_time = Graphics.frame_rate * 4 / 10 alpha_diff = (255.0 / fade_time).ceil fade_time.times do @@ -382,7 +382,7 @@ def pbDuel(trainer_id, trainer_name, event, speeches) trainer_id = GameData::TrainerType.get(trainer_id).id duel = PokemonDuel.new opponent = NPCTrainer.new( - pbGetMessageFromHash(MessageTypes::TrainerNames, trainer_name), trainer_id + pbGetMessageFromHash(MessageTypes::TRAINER_NAMES, trainer_name), trainer_id ) speech_texts = [] 12.times do |i| diff --git a/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb b/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb index 45a5fdb83..5ab7eecff 100644 --- a/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb +++ b/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb @@ -293,8 +293,8 @@ class TriadScene item = chosenCards.pop @battle.pbAdd(cardStorage, item) commands = [] - cardStorage.each do |item| - commands.push(_INTL("{1} x{2}", GameData::Species.get(item[0]).name, item[1])) + cardStorage.each do |itm| + commands.push(_INTL("{1} x{2}", GameData::Species.get(itm[0]).name, itm[1])) end command.commands = commands index = -1 @@ -315,8 +315,8 @@ class TriadScene chosenCards.push(item[0]) @battle.pbSubtract(cardStorage, item[0]) commands = [] - cardStorage.each do |item| - commands.push(_INTL("{1} x{2}", GameData::Species.get(item[0]).name, item[1])) + cardStorage.each do |itm| + commands.push(_INTL("{1} x{2}", GameData::Species.get(itm[0]).name, itm[1])) end command.commands = commands command.index = commands.length - 1 if command.index >= commands.length @@ -762,10 +762,10 @@ class TriadScreen # Set the opponent's cards. if oppdeck.is_a?(Array) && oppdeck.length == self.maxCards # Preset opponentCards = [] - oppdeck.each do |i| - species_data = GameData::Species.try_get(i) + oppdeck.each do |species| + species_data = GameData::Species.try_get(species) if !species_data - @scene.pbDisplayPaused(_INTL("Opponent has an illegal card, \"{1}\".", i)) + @scene.pbDisplayPaused(_INTL("Opponent has an illegal card, \"{1}\".", species)) @scene.pbEndScene return 0 end @@ -819,16 +819,16 @@ class TriadScreen # Opponent's turn @scene.pbDisplay(_INTL("{1} is making a move...", @opponentName)) scores = [] - opponentCards.length.times do |cardIndex| + opponentCards.length.times do |cardIdx| square = TriadSquare.new - square.card = TriadCard.new(opponentCards[cardIndex]) + square.card = TriadCard.new(opponentCards[cardIdx]) square.owner = 2 - (@width * @height).times do |i| - x = i % @width - y = i / @width - square.type = @board[i].type + (@width * @height).times do |j| + x = j % @width + y = j / @width + square.type = @board[j].type flips = flipBoard(x, y, square) - scores.push([cardIndex, x, y, flips.length]) if flips + scores.push([cardIdx, x, y, flips.length]) if flips end end # Sort by number of flips @@ -875,16 +875,12 @@ class TriadScreen result = 3 if @trade == 1 # Keep only cards of your color - originalCards.each do |card| - $PokemonGlobal.triads.remove(card) - end - cards.each do |i| - $PokemonGlobal.triads.add(i) - end + originalCards.each { |crd| $PokemonGlobal.triads.remove(crd) } + cards.each { |crd| $PokemonGlobal.triads.add(crd) } (@width * @height).times do |i| if board[i].owner == 1 - card = GameData::Species.get_species_form(board[i].card.species, board[i].card.form).id - $PokemonGlobal.triads.add(card) + crd = GameData::Species.get_species_form(board[i].card.species, board[i].card.form).id + $PokemonGlobal.triads.add(crd) end end @scene.pbDisplayPaused(_INTL("Kept all cards of your color.")) @@ -906,12 +902,8 @@ class TriadScreen @scene.pbDisplayPaused(_INTL("Got opponent's {1} card.", cardname)) end when 1 # Keep only cards of your color - originalCards.each do |card| - $PokemonGlobal.triads.remove(card) - end - cards.each do |i| - $PokemonGlobal.triads.add(i) - end + originalCards.each { |crd| $PokemonGlobal.triads.remove(crd) } + cards.each { |crd| $PokemonGlobal.triads.add(crd) } (@width * @height).times do |i| if board[i].owner == 1 card = GameData::Species.get_species_form(board[i].card.species, board[i].card.form).id @@ -920,9 +912,7 @@ class TriadScreen end @scene.pbDisplayPaused(_INTL("Kept all cards of your color.")) when 2 # Gain all opponent's cards - originalOpponentCards.each do |card| - $PokemonGlobal.triads.add(card) - end + originalOpponentCards.each { |crd| $PokemonGlobal.triads.add(crd) } @scene.pbDisplayPaused(_INTL("Got all opponent's cards.")) end end @@ -936,12 +926,8 @@ class TriadScreen cardname = GameData::Species.get(card).name @scene.pbDisplayPaused(_INTL("Opponent won your {1} card.", cardname)) when 1 # Keep only cards of your color - originalCards.each do |card| - $PokemonGlobal.triads.remove(card) - end - cards.each do |i| - $PokemonGlobal.triads.add(i) - end + originalCards.each { |crd| $PokemonGlobal.triads.remove(card) } + cards.each { |crd| $PokemonGlobal.triads.add(crd) } (@width * @height).times do |i| if board[i].owner == 1 card = GameData::Species.get_species_form(board[i].card.species, board[i].card.form).id @@ -950,9 +936,7 @@ class TriadScreen end @scene.pbDisplayPaused(_INTL("Kept all cards of your color.", cardname)) when 2 # Lose all your cards - originalCards.each do |card| - $PokemonGlobal.triads.remove(card) - end + originalCards.each { |crd| $PokemonGlobal.triads.remove(crd) } @scene.pbDisplayPaused(_INTL("Opponent won all your cards.")) end end @@ -971,11 +955,11 @@ end def pbTriadDuel(name, minLevel, maxLevel, rules = nil, oppdeck = nil, prize = nil) ret = 0 - pbFadeOutInWithMusic { + pbFadeOutInWithMusic do scene = TriadScene.new screen = TriadScreen.new(scene) ret = screen.pbStartScreen(name, minLevel, maxLevel, rules, oppdeck, prize) - } + end return ret end @@ -1198,9 +1182,7 @@ def pbSellTriads item = $PokemonGlobal.triads.get_item(cmdwindow.index) if olditem != item preview.bitmap&.dispose - if item - preview.bitmap = TriadCard.new(item).createBitmap(1) - end + preview.bitmap = TriadCard.new(item).createBitmap(1) if item olditem = item end if Input.trigger?(Input::BACK) diff --git a/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb b/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb index 12bba4ec9..8fe14e725 100644 --- a/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb +++ b/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb @@ -404,10 +404,10 @@ def pbSlotMachine(difficulty = 1) elsif $player.coins == Settings::MAX_COINS pbMessage(_INTL("Your Coin Case is full!")) else - pbFadeOutIn { + pbFadeOutIn do scene = SlotMachineScene.new screen = SlotMachine.new(scene) screen.pbStartScreen(difficulty) - } + end end end diff --git a/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb b/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb index c4560e80c..54bd775ac 100644 --- a/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb +++ b/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb @@ -351,9 +351,7 @@ class VoltorbFlip end count = 0 @squares.length.times do |i| - if @squares[i][3] == false && @squares[i][2] > 1 - count += 1 - end + count += 1 if @squares[i][3] == false && @squares[i][2] > 1 end pbUpdateCoins # Game cleared @@ -561,9 +559,7 @@ class VoltorbFlip Graphics.update Input.update update - if @sprites["curtainL"].angle >= -90 - break - end + break if @sprites["curtainL"].angle >= -90 end pbFadeOutAndHide(@sprites) { update } pbDisposeSpriteHash(@sprites) diff --git a/Data/Scripts/017_Minigames/005_Minigame_Lottery.rb b/Data/Scripts/017_Minigames/005_Minigame_Lottery.rb index 8851790cc..cdd322725 100644 --- a/Data/Scripts/017_Minigames/005_Minigame_Lottery.rb +++ b/Data/Scripts/017_Minigames/005_Minigame_Lottery.rb @@ -28,7 +28,7 @@ def pbLottery(winnum, nameVar = 2, positionVar = 3, matchedVar = 4) winpos = 1 # Party winmatched = thismatched end - pbEachPokemon { |poke, _box| + pbEachPokemon do |poke, _box| thismatched = 0 id = poke.owner.public_id 5.times do |j| @@ -39,7 +39,7 @@ def pbLottery(winnum, nameVar = 2, positionVar = 3, matchedVar = 4) winpoke = poke.name winpos = 2 # Storage winmatched = thismatched - } + end $game_variables[nameVar] = winpoke $game_variables[positionVar] = winpos $game_variables[matchedVar] = winmatched diff --git a/Data/Scripts/017_Minigames/006_Minigame_Mining.rb b/Data/Scripts/017_Minigames/006_Minigame_Mining.rb index cde5b3350..94fe573f4 100644 --- a/Data/Scripts/017_Minigames/006_Minigame_Mining.rb +++ b/Data/Scripts/017_Minigames/006_Minigame_Mining.rb @@ -628,9 +628,9 @@ end # #=============================================================================== def pbMiningGame - pbFadeOutIn { + pbFadeOutIn do scene = MiningGameScene.new screen = MiningGame.new(scene) screen.pbStartScreen - } + end end diff --git a/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb b/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb index 41fc9f203..5d31c946c 100644 --- a/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb +++ b/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb @@ -585,10 +585,10 @@ end #=============================================================================== def pbTilePuzzle(game, board, width = 0, height = 0) ret = false - pbFadeOutIn { + pbFadeOutIn do scene = TilePuzzleScene.new(game, board, width, height) screen = TilePuzzle.new(scene) ret = screen.pbStartScreen - } + end return ret end diff --git a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/001_Challenge_BattleChallenge.rb b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/001_Challenge_BattleChallenge.rb index d5241c15b..36aa3fbfb 100644 --- a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/001_Challenge_BattleChallenge.rb +++ b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/001_Challenge_BattleChallenge.rb @@ -4,10 +4,10 @@ class BattleChallenge attr_reader :currentChallenge - BattleTowerID = 0 - BattlePalaceID = 1 - BattleArenaID = 2 - BattleFactoryID = 3 + BATTLE_TOWER_ID = 0 + BATTLE_PALACE_ID = 1 + BATTLE_ARENA_ID = 2 + BATTLE_FACTORY_ID = 3 def initialize @bc = BattleChallengeData.new @@ -20,17 +20,17 @@ class BattleChallenge @numRounds = numrounds @rules = rules register(id, id[/double/], 3, - id[/^factory/] ? BattleFactoryID : BattleTowerID, + id[/^factory/] ? BATTLE_FACTORY_ID : BATTLE_TOWER_ID, id[/open$/] ? 1 : 0) pbWriteCup(id, rules) end def register(id, doublebattle, numPokemon, battletype, mode = 1) ensureType(id) - if battletype == BattleFactoryID + if battletype == BATTLE_FACTORY_ID @bc.setExtraData(BattleFactoryData.new(@bc)) numPokemon = 3 - battletype = BattleTowerID + battletype = BATTLE_TOWER_ID end @rules = modeToRules(doublebattle, numPokemon, battletype, mode) if !@rules end @@ -47,9 +47,9 @@ class BattleChallenge rules = PokemonChallengeRules.new # Set the battle type case battletype - when BattlePalaceID + when BATTLE_PALACE_ID rules.setBattleType(BattlePalace.new) - when BattleArenaID + when BATTLE_ARENA_ID rules.setBattleType(BattleArena.new) doublebattle = false else # Factory works the same as Tower @@ -82,8 +82,7 @@ class BattleChallenge @bc.pbStart(t, @numRounds) end - def pbStart(challenge) - end + def pbStart(challenge); end def pbEnd if @currentChallenge != -1 @@ -98,8 +97,8 @@ class BattleChallenge opponent = pbGenerateBattleTrainer(self.nextTrainer, self.rules) bttrainers = pbGetBTTrainers(@id) trainerdata = bttrainers[self.nextTrainer] - opponent.lose_text = pbGetMessageFromHash(MessageTypes::FrontierEndSpeechesLose, trainerdata[4]) - opponent.win_text = pbGetMessageFromHash(MessageTypes::FrontierEndSpeechesWin, trainerdata[3]) + opponent.lose_text = pbGetMessageFromHash(MessageTypes::FRONTIER_END_SPEECHES_LOSE, trainerdata[4]) + opponent.win_text = pbGetMessageFromHash(MessageTypes::FRONTIER_END_SPEECHES_WIN, trainerdata[3]) ret = pbOrganizedBattleEx(opponent, self.rules) return ret end @@ -166,6 +165,8 @@ class BattleChallenge return ensureType(challenge).maxSwaps end + #----------------------------------------------------------------------------- + private def ensureType(id) @@ -284,6 +285,8 @@ class BattleChallengeData return @trainers[@battleNumber - 1] end + #----------------------------------------------------------------------------- + private def reset @@ -373,23 +376,23 @@ class BattleFactoryData bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge) trainerdata = bttrainers[@trainerid] @opponent = NPCTrainer.new( - pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]), + pbGetMessageFromHash(MessageTypes::TRAINER_NAMES, trainerdata[1]), trainerdata[0] ) - @opponent.lose_text = pbGetMessageFromHash(MessageTypes::FrontierEndSpeechesLose, trainerdata[4]) - @opponent.win_text = pbGetMessageFromHash(MessageTypes::FrontierEndSpeechesWin, trainerdata[3]) + @opponent.lose_text = pbGetMessageFromHash(MessageTypes::FRONTIER_END_SPEECHES_LOSE, trainerdata[4]) + @opponent.win_text = pbGetMessageFromHash(MessageTypes::FRONTIER_END_SPEECHES_WIN, trainerdata[3]) opponentPkmn = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps, @rentals) @opponent.party = opponentPkmn.sample(3) end def pbChooseRentals - pbFadeOutIn { + pbFadeOutIn do scene = BattleSwapScene.new screen = BattleSwapScreen.new(scene) @rentals = screen.pbStartRent(@rentals) @bcdata.pbAddSwap @bcdata.setParty(@rentals) - } + end end def pbPrepareSwaps @@ -398,11 +401,11 @@ class BattleFactoryData bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge) trainerdata = bttrainers[trainerid] @opponent = NPCTrainer.new( - pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]), + pbGetMessageFromHash(MessageTypes::TRAINER_NAMES, trainerdata[1]), trainerdata[0] ) - @opponent.lose_text = pbGetMessageFromHash(MessageTypes::FrontierEndSpeechesLose, trainerdata[4]) - @opponent.win_text = pbGetMessageFromHash(MessageTypes::FrontierEndSpeechesWin, trainerdata[3]) + @opponent.lose_text = pbGetMessageFromHash(MessageTypes::FRONTIER_END_SPEECHES_LOSE, trainerdata[4]) + @opponent.win_text = pbGetMessageFromHash(MessageTypes::FRONTIER_END_SPEECHES_WIN, trainerdata[3]) opponentPkmn = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps, [].concat(@rentals).concat(@oldopponent)) @opponent.party = opponentPkmn.sample(3) @@ -410,19 +413,17 @@ class BattleFactoryData def pbChooseSwaps swapMade = true - pbFadeOutIn { + pbFadeOutIn do scene = BattleSwapScene.new screen = BattleSwapScreen.new(scene) swapMade = screen.pbStartSwap(@rentals, @oldopponent) @bcdata.pbAddSwap if swapMade @bcdata.setParty(@rentals) - } + end return swapMade end def pbBattle(challenge) - bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge) - trainerdata = bttrainers[@trainerid] return pbOrganizedBattleEx(@opponent, challenge.rules) end end diff --git a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/002_Challenge_Data.rb b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/002_Challenge_Data.rb index c4536f6dd..e75815f93 100644 --- a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/002_Challenge_Data.rb +++ b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/002_Challenge_Data.rb @@ -37,7 +37,7 @@ end #=============================================================================== def pbEntryScreen(*arg) retval = false - pbFadeOutIn { + pbFadeOutIn do scene = PokemonParty_Scene.new screen = PokemonPartyScreen.new(scene, $player.party) ret = screen.pbPokemonMultipleEntryScreenEx(pbBattleChallenge.rules.ruleset) @@ -45,7 +45,7 @@ def pbEntryScreen(*arg) pbBattleChallenge.setParty(ret) if ret # Continue (return true) if Pokémon were chosen retval = (ret && ret.length > 0) - } + end return retval end @@ -92,7 +92,7 @@ def pbBattleChallengeBeginSpeech return "..." if !pbBattleChallenge.pbInProgress? bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge) tr = bttrainers[pbBattleChallenge.nextTrainer] - return (tr) ? pbGetMessageFromHash(MessageTypes::FrontierIntroSpeeches, tr[2]) : "..." + return (tr) ? pbGetMessageFromHash(MessageTypes::FRONTIER_INTRO_SPEECHES, tr[2]) : "..." end #=============================================================================== @@ -184,16 +184,14 @@ class PBPokemon return "#{species},#{item},#{nature},#{move1},#{move2},#{move3},#{move4},#{ev}" end -=begin - def _dump(depth) - return [@species, @item, @nature, @move1, @move2, @move3, @move4, @ev].pack("vvCvvvvC") - end +# def _dump(depth) +# return [@species, @item, @nature, @move1, @move2, @move3, @move4, @ev].pack("vvCvvvvC") +# end - def self._load(str) - data = str.unpack("vvCvvvvC") - return self.new(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]) - end -=end +# def self._load(str) +# data = str.unpack("vvCvvvvC") +# return self.new(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]) +# end def convertMove(move) move = :FRUSTRATION if move == :RETURN && GameData::Move.exists?(:FRUSTRATION) diff --git a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/003_Challenge_ChooseFoes.rb b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/003_Challenge_ChooseFoes.rb index caf10494d..a502171d2 100644 --- a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/003_Challenge_ChooseFoes.rb +++ b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/003_Challenge_ChooseFoes.rb @@ -43,7 +43,7 @@ def pbGenerateBattleTrainer(idxTrainer, rules) # Create the trainer trainerdata = bttrainers[idxTrainer] opponent = NPCTrainer.new( - pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]), + pbGetMessageFromHash(MessageTypes::TRAINER_NAMES, trainerdata[1]), trainerdata[0] ) # Determine how many IVs the trainer's Pokémon will have diff --git a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/004_Challenge_Battles.rb b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/004_Challenge_Battles.rb index 49ffd9a87..7b2a9514f 100644 --- a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/004_Challenge_Battles.rb +++ b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/004_Challenge_Battles.rb @@ -62,11 +62,9 @@ def pbOrganizedBattleEx(opponent, challengedata) BattleCreationHelperMethods.prepare_battle(battle) # Perform the battle itself decision = 0 - pbBattleAnimation(pbGetTrainerBattleBGM(opponent)) { - pbSceneStandby { - decision = battle.pbStartBattle - } - } + pbBattleAnimation(pbGetTrainerBattleBGM(opponent)) do + pbSceneStandby { decision = battle.pbStartBattle } + end Input.update # Restore both parties to their original levels challengedata.unadjustLevels($player.party, opponent.party, oldlevels) @@ -116,19 +114,17 @@ def pbPlayBattle(battledata) scene.abortable = true lastbattle = Marshal.restore(battledata) case lastbattle[0] - when BattleChallenge::BattleTowerID + when BattleChallenge::BATTLE_TOWER_ID battleplayer = RecordedBattle::PlaybackBattle.new(scene, lastbattle) - when BattleChallenge::BattlePalaceID + when BattleChallenge::BATTLE_PALACE_ID battleplayer = RecordedBattle::BattlePalacePlaybackBattle.new(scene, lastbattle) - when BattleChallenge::BattleArenaID + when BattleChallenge::BATTLE_ARENA_ID battleplayer = RecordedBattle::BattleArenaPlaybackBattle.new(scene, lastbattle) end bgm = RecordedBattle::PlaybackHelper.pbGetBattleBGM(lastbattle) - pbBattleAnimation(bgm) { - pbSceneStandby { - battleplayer.pbStartBattle - } - } + pbBattleAnimation(bgm) do + pbSceneStandby { battleplayer.pbStartBattle } + end end #=============================================================================== @@ -140,9 +136,7 @@ def pbDebugPlayBattle params.setInitialValue(0) params.setCancelValue(-1) num = pbMessageChooseNumber(_INTL("Choose a battle."), params) - if num >= 0 - pbPlayBattleFromFile(sprintf("Battles/Battle%03d.dat", num)) - end + pbPlayBattleFromFile(sprintf("Battles/Battle%03d.dat", num)) if num >= 0 end def pbPlayBattleFromFile(filename) diff --git a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/005_UI_BattleSwap.rb b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/005_UI_BattleSwap.rb index de4b14977..41abbe4cf 100644 --- a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/005_UI_BattleSwap.rb +++ b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/005_UI_BattleSwap.rb @@ -91,7 +91,7 @@ class BattleSwapScene # Processes the scene def pbChoosePokemon(canCancel) - pbActivateWindow(@sprites, "list") { + pbActivateWindow(@sprites, "list") do loop do Graphics.update Input.update @@ -109,7 +109,7 @@ class BattleSwapScene end end end - } + end end def pbUpdateChoices(choices) diff --git a/Data/Scripts/018_Alternate battle modes/001_SafariZone.rb b/Data/Scripts/018_Alternate battle modes/001_SafariZone.rb index 89f8876ea..3ae186060 100644 --- a/Data/Scripts/018_Alternate battle modes/001_SafariZone.rb +++ b/Data/Scripts/018_Alternate battle modes/001_SafariZone.rb @@ -26,7 +26,7 @@ class SafariState def pbGoToStart if $scene.is_a?(Scene_Map) - pbFadeOutIn { + pbFadeOutIn do $game_temp.player_transferring = true $game_temp.transition_processing = true $game_temp.player_new_map_id = @start[0] @@ -35,7 +35,7 @@ class SafariState $game_temp.player_new_direction = 2 pbDismountBike $scene.transfer_player - } + end end end @@ -129,11 +129,9 @@ def pbSafariBattle(pkmn, level = 1) BattleCreationHelperMethods.prepare_battle(battle) # Perform the battle itself decision = 0 - pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) { - pbSceneStandby { - decision = battle.pbStartBattle - } - } + pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) do + pbSceneStandby { decision = battle.pbStartBattle } + end Input.update # Update Safari game data based on result of battle pbSafariState.ballcount = battle.ballCount diff --git a/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/001_Challenge_ChallengeRules.rb b/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/001_Challenge_ChallengeRules.rb index 8c99ec4db..12d761667 100644 --- a/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/001_Challenge_ChallengeRules.rb +++ b/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/001_Challenge_ChallengeRules.rb @@ -68,14 +68,14 @@ class PokemonChallengeRules end def adjustLevelsBilateral(party1, party2) - if @levelAdjustment && @levelAdjustment.type == LevelAdjustment::BothTeams + if @levelAdjustment && @levelAdjustment.type == LevelAdjustment::BOTH_TEAMS return @levelAdjustment.adjustLevels(party1, party2) end return nil end def unadjustLevelsBilateral(party1, party2, adjusts) - if @levelAdjustment && adjusts && @levelAdjustment.type == LevelAdjustment::BothTeams + if @levelAdjustment && adjusts && @levelAdjustment.type == LevelAdjustment::BOTH_TEAMS @levelAdjustment.unadjustLevels(party1, party2, adjusts) end end diff --git a/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/002_Challenge_Rulesets.rb b/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/002_Challenge_Rulesets.rb index 8681c46f6..b6fa87777 100644 --- a/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/002_Challenge_Rulesets.rb +++ b/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/002_Challenge_Rulesets.rb @@ -134,9 +134,9 @@ class PokemonRuleSet def hasRegistrableTeam?(list) return false if !list || list.length < self.minTeamLength - pbEachCombination(list, self.maxTeamLength) { |comb| + pbEachCombination(list, self.maxTeamLength) do |comb| return true if canRegisterTeam?(comb) - } + end return false end @@ -156,7 +156,7 @@ class PokemonRuleSet return false if !rule.isValid?(team) end if @subsetRules.length > 0 - pbEachCombination(team, teamNumber) { |comb| + pbEachCombination(team, teamNumber) do |comb| isValid = true @subsetRules.each do |rule| next if rule.isValid?(comb) @@ -164,7 +164,7 @@ class PokemonRuleSet break end return true if isValid - } + end return false end return true diff --git a/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/004_Challenge_LevelAdjustment.rb b/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/004_Challenge_LevelAdjustment.rb index b2955a30f..1e200b30c 100644 --- a/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/004_Challenge_LevelAdjustment.rb +++ b/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/004_Challenge_LevelAdjustment.rb @@ -2,10 +2,10 @@ # #=============================================================================== class LevelAdjustment - BothTeams = 0 - EnemyTeam = 1 - MyTeam = 2 - BothTeamsDifferent = 3 + BOTH_TEAMS = 0 + ENEMY_TEAM = 1 + MY_TEAM = 2 + BOTH_TEAMS_DIFFERENT = 3 def initialize(adjustment) @adjustment = adjustment @@ -48,14 +48,14 @@ class LevelAdjustment adj1 = nil adj2 = nil ret = [getOldExp(team1, team2), getOldExp(team2, team1)] - if @adjustment == BothTeams || @adjustment == MyTeam + if @adjustment == BOTH_TEAMS || @adjustment == MY_TEAM adj1 = getAdjustment(team1, team2) - elsif @adjustment == BothTeamsDifferent + elsif @adjustment == BOTH_TEAMS_DIFFERENT adj1 = getMyAdjustment(team1, team2) end - if @adjustment == BothTeams || @adjustment == EnemyTeam + if @adjustment == BOTH_TEAMS || @adjustment == ENEMY_TEAM adj2 = getAdjustment(team2, team1) - elsif @adjustment == BothTeamsDifferent + elsif @adjustment == BOTH_TEAMS_DIFFERENT adj2 = getTheirAdjustment(team2, team1) end if adj1 @@ -81,7 +81,7 @@ end #=============================================================================== class FixedLevelAdjustment < LevelAdjustment def initialize(level) - super(LevelAdjustment::BothTeams) + super(LevelAdjustment::BOTH_TEAMS) @level = level.clamp(1, GameData::GrowthRate.max_level) end @@ -97,7 +97,7 @@ end #=============================================================================== class TotalLevelAdjustment < LevelAdjustment def initialize(minLevel, maxLevel, totalLevel) - super(LevelAdjustment::EnemyTeam) + super(LevelAdjustment::ENEMY_TEAM) @minLevel = minLevel.clamp(1, GameData::GrowthRate.max_level) @maxLevel = maxLevel.clamp(1, GameData::GrowthRate.max_level) @totalLevel = totalLevel @@ -129,7 +129,7 @@ end #=============================================================================== class CombinedLevelAdjustment < LevelAdjustment def initialize(my, their) - super(LevelAdjustment::BothTeamsDifferent) + super(LevelAdjustment::BOTH_TEAMS_DIFFERENT) @my = my @their = their end @@ -159,7 +159,7 @@ end #=============================================================================== class CappedLevelAdjustment < LevelAdjustment def initialize(level) - super(LevelAdjustment::BothTeams) + super(LevelAdjustment::BOTH_TEAMS) @level = level.clamp(1, GameData::GrowthRate.max_level) end @@ -175,7 +175,7 @@ end #=============================================================================== class LevelBalanceAdjustment < LevelAdjustment def initialize(minLevel) - super(LevelAdjustment::BothTeams) + super(LevelAdjustment::BOTH_TEAMS) @minLevel = minLevel end @@ -193,7 +193,7 @@ end #=============================================================================== class EnemyLevelAdjustment < LevelAdjustment def initialize(level) - super(LevelAdjustment::EnemyTeam) + super(LevelAdjustment::ENEMY_TEAM) @level = level.clamp(1, GameData::GrowthRate.max_level) end @@ -209,7 +209,7 @@ end #=============================================================================== class OpenLevelAdjustment < LevelAdjustment def initialize(minLevel = 1) - super(LevelAdjustment::EnemyTeam) + super(LevelAdjustment::ENEMY_TEAM) @minLevel = minLevel end diff --git a/Data/Scripts/018_Alternate battle modes/002_BugContest.rb b/Data/Scripts/018_Alternate battle modes/002_BugContest.rb index 0dd6cbd22..a7573aea5 100644 --- a/Data/Scripts/018_Alternate battle modes/002_BugContest.rb +++ b/Data/Scripts/018_Alternate battle modes/002_BugContest.rb @@ -128,9 +128,7 @@ class BugContestState score = pbBugContestScore(pokemon) judgearray.push([cont, pokemon.species, score]) end - if judgearray.length < 3 - raise _INTL("Too few bug catching contestants") - end + raise _INTL("Too few bug catching contestants") if judgearray.length < 3 judgearray.sort! { |a, b| b[2] <=> a[2] } # sort by score in descending order @places.push(judgearray[0]) @places.push(judgearray[1]) @@ -156,7 +154,7 @@ class BugContestState @decision = 1 pbJudge if $scene.is_a?(Scene_Map) - pbFadeOutIn { + pbFadeOutIn do $game_temp.player_transferring = true $game_temp.player_new_map_id = @start[0] $game_temp.player_new_x = @start[1] @@ -165,7 +163,7 @@ class BugContestState pbDismountBike $scene.transfer_player $game_map.need_refresh = true # in case player moves to the same map - } + end end end @@ -386,7 +384,7 @@ def pbBugContestBattle(pkmn, level = 1) BattleCreationHelperMethods.prepare_battle(battle) # Perform the battle itself decision = 0 - pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) { + pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) do decision = battle.pbStartBattle BattleCreationHelperMethods.after_battle(decision, true) if [2, 5].include?(decision) # Lost or drew @@ -394,7 +392,7 @@ def pbBugContestBattle(pkmn, level = 1) $game_system.bgs_unpause pbBugContestStartOver end - } + end Input.update # Update Bug Contest game data based on result of battle pbBugContestState.ballcount = battle.ballCount diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb index b6da49dba..46a4bbcd9 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb @@ -40,20 +40,18 @@ end #=============================================================================== # #=============================================================================== -=begin -[3/10] -0-266 - 0-500 -[106] -267-372 - 380-500 -[95] -373-467 - 400-555 (nonlegendary) -468-563 - 400-555 (nonlegendary) -564-659 - 400-555 (nonlegendary) -660-755 - 400-555 (nonlegendary) -756-799 - 580-600 [legendary] (compat1==15 or compat2==15, genderbyte=255) -800-849 - 500- -850-881 - 580- -=end +# [3/10] +# 0-266 - 0-500 +# [106] +# 267-372 - 380-500 +# [95] +# 373-467 - 400-555 (nonlegendary) +# 468-563 - 400-555 (nonlegendary) +# 564-659 - 400-555 (nonlegendary) +# 660-755 - 400-555 (nonlegendary) +# 756-799 - 580-600 [legendary] (compat1==15 or compat2==15, genderbyte=255) +# 800-849 - 500- +# 850-881 - 580- def withRestr(_rule, minbs, maxbs, legendary) ret = PokemonChallengeRules.new.addPokemonRule(BaseStatRestriction.new(minbs, maxbs)) @@ -99,11 +97,11 @@ def pbArrangeByTier(pokemonlist, rule) # Now for each tier, sort the Pokemon in that tier by their BST (lowest first). ret = [] tiers.length.times do |i| - tierPokemon[i].sort! { |a, b| + tierPokemon[i].sort! do |a, b| bstA = baseStatTotal(a.species) bstB = baseStatTotal(b.species) (bstA == bstB) ? a.species <=> b.species : bstA <=> bstB - } + end ret.concat(tierPokemon[i]) end return ret @@ -323,7 +321,7 @@ def pbWriteCup(id, rules) return if !pbConfirmMessage(_INTL("This may take a long time. Are you sure?")) mw = pbCreateMessageWindow t = Time.now - pbGenerateChallenge(rules, id) { |message| + pbGenerateChallenge(rules, id) do |message| if Time.now - t >= 5 Graphics.update t = Time.now @@ -333,7 +331,7 @@ def pbWriteCup(id, rules) Graphics.update t = Time.now end - } + end pbDisposeMessageWindow(mw) pbMessage(_INTL("Team generation complete.")) end diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/002_ChallengeGenerator_Pokemon.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/002_ChallengeGenerator_Pokemon.rb index 07efc0b12..d94e62edb 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/002_ChallengeGenerator_Pokemon.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/002_ChallengeGenerator_Pokemon.rb @@ -115,9 +115,7 @@ def addMove(moves, move, base) [:REFLECT, :LIGHTSCREEN, :SAFEGUARD, :SUBSTITUTE, :FAKEOUT].include?(data.id) count = base + 2 end - if data.base_damage >= 80 && data.type == :NORMAL - count = base + 3 - end + count = base + 3 if data.base_damage >= 80 && data.type == :NORMAL if [:PROTECT, :DETECT, :TOXIC, :AERIALACE, :WILLOWISP, :SPORE, :THUNDERWAVE, :HYPNOSIS, :CONFUSERAY, :ENDURE, :SWORDSDANCE].include?(data.id) count = base + 3 @@ -345,9 +343,7 @@ def pbRandomPokemonFromRule(rules, trainer) types = GameData::Species.get(species).types item = :LEFTOVERS if !types.include?(:POISON) end - if item == :HEATROCK && moves.none? { |m| m == :SUNNYDAY } - item = :LEFTOVERS - end + item = :LEFTOVERS if item == :HEATROCK && moves.none? { |m| m == :SUNNYDAY } if item == :DAMPROCK && moves.none? { |m| m == :RAINDANCE } item = :LEFTOVERS end diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/003_ChallengeGenerator_Trainers.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/003_ChallengeGenerator_Trainers.rb index b131206c2..045a27017 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/003_ChallengeGenerator_Trainers.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/003_ChallengeGenerator_Trainers.rb @@ -40,11 +40,11 @@ def pbTrainerInfo(pokemonlist, trfile, rules) bttrainers.push(tr) end # Sort all the randomly chosen trainers by their base money (smallest first) - bttrainers.sort! { |a, b| + bttrainers.sort! do |a, b| money1 = GameData::TrainerType.get(a[0]).base_money money2 = GameData::TrainerType.get(b[0]).base_money next (money1 == money2) ? a[0].to_s <=> b[0].to_s : money1 <=> money2 - } + end end yield(nil) if block_given? # Set all Pokémon in pokemonlist to the appropriate level, and determine their @@ -119,14 +119,14 @@ def pbTrainerInfo(pokemonlist, trfile, rules) # anyway (more likely to add it if the trainer has access to more # Pokémon of the same type(s) as this Pokémon) t = pkmntypes[index] - t.each { |typ| + t.each do |typ| weight = [32, 12, 5, 2, 1, 0, 0, 0][[absDiff, 7].min] weight *= types[typ] if rand(40) < weight numbers.push(index) numbersPokemon.push(pokemonlist[index]) end - } + end end end numbers |= [] # Remove duplicates diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb index c1768e9ee..cbe5bc7fd 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb @@ -237,6 +237,8 @@ class PlayerRating setVolatility2(volatility) end + #----------------------------------------------------------------------------- + private attr_writer :volatility @@ -286,7 +288,7 @@ class PlayerRating squVariance = variance + variance squDevplusVar = squDeviation + variance x0 = a - 100.times { # Up to 100 iterations to avoid potentially infinite loops + 100.times do # Up to 100 iterations to avoid potentially infinite loops e = Math.exp(x0) d = squDevplusVar + e squD = d * d @@ -297,7 +299,7 @@ class PlayerRating x1 = x0 x0 -= h1 / h2 break if (x1 - x0).abs < 0.000001 - } + end return Math.exp(x0 / 2.0) end end diff --git a/Data/Scripts/019_Utilities/001_Utilities.rb b/Data/Scripts/019_Utilities/001_Utilities.rb index ee23519dc..4809ea972 100644 --- a/Data/Scripts/019_Utilities/001_Utilities.rb +++ b/Data/Scripts/019_Utilities/001_Utilities.rb @@ -285,66 +285,77 @@ end def getRandomNameEx(type, variable, upper, maxLength = 100) return "" if maxLength <= 0 name = "" - 50.times { + 50.times do name = "" formats = [] case type - when 0 then formats = %w[F5 BvE FE FE5 FEvE] # Names for males - when 1 then formats = %w[vE6 vEvE6 BvE6 B4 v3 vEv3 Bv3] # Names for females - when 2 then formats = %w[WE WEU WEvE BvE BvEU BvEvE] # Neutral gender names + when 0 then formats = ["F5", "BvE", "FE", "FE5", "FEvE"] # Names for males + when 1 then formats = ["vE6", "vEvE6", "BvE6", "B4", "v3", "vEv3", "Bv3"] # Names for females + when 2 then formats = ["WE", "WEU", "WEvE", "BvE", "BvEU", "BvEvE"] # Neutral gender names else return "" end - format = formats[rand(formats.length)] - format.scan(/./) { |c| + format = formats.sample + format.scan(/./) do |c| case c - when "c" # consonant - set = %w[b c d f g h j k l m n p r s t v w x z] - name += set[rand(set.length)] - when "v" # vowel - set = %w[a a a e e e i i i o o o u u u] - name += set[rand(set.length)] - when "W" # beginning vowel - set = %w[a a a e e e i i i o o o u u u au au ay ay ea ea ee ee oo oo ou ou] - name += set[rand(set.length)] - when "U" # ending vowel - set = %w[a a a a a e e e i i i o o o o o u u ay ay ie ie ee ue oo] - name += set[rand(set.length)] - when "B" # beginning consonant - set1 = %w[b c d f g h j k l l m n n p r r s s t t v w y z] - set2 = %w[bl br ch cl cr dr fr fl gl gr kh kl kr ph pl pr sc sk sl - sm sn sp st sw th tr tw vl zh] - name += (rand(3) > 0) ? set1[rand(set1.length)] : set2[rand(set2.length)] - when "E" # ending consonant - set1 = %w[b c d f g h j k k l l m n n p r r s s t t v z] - set2 = %w[bb bs ch cs ds fs ft gs gg ld ls nd ng nk rn kt ks - ms ns ph pt ps sk sh sp ss st rd rn rp rm rt rk ns th zh] - name += (rand(3) > 0) ? set1[rand(set1.length)] : set2[rand(set2.length)] - when "f" # consonant and vowel - set = %w[iz us or] - name += set[rand(set.length)] - when "F" # consonant and vowel - set = %w[bo ba be bu re ro si mi zho se nya gru gruu glee gra glo ra do zo ri - di ze go ga pree pro po pa ka ki ku de da ma mo le la li] - name += set[rand(set.length)] + when "c" # consonant + set = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r", + "s", "t", "v", "w", "x", "z"] + name += set.sample + when "v" # vowel + set = ["a", "a", "a", "e", "e", "e", "i", "i", "i", "o", "o", "o", "u", "u", "u"] + name += set.sample + when "W" # beginning vowel + set = ["a", "a", "a", "e", "e", "e", "i", "i", "i", "o", "o", "o", "u", + "u", "u", "au", "au", "ay", "ay", "ea", "ea", "ee", "ee", "oo", + "oo", "ou", "ou"] + name += set.sample + when "U" # ending vowel + set = ["a", "a", "a", "a", "a", "e", "e", "e", "i", "i", "i", "o", "o", + "o", "o", "o", "u", "u", "ay", "ay", "ie", "ie", "ee", "ue", "oo"] + name += set.sample + when "B" # beginning consonant + set1 = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "l", "m", "n", "n", + "p", "r", "r", "s", "s", "t", "t", "v", "w", "y", "z"] + set2 = ["bl", "br", "ch", "cl", "cr", "dr", "fr", "fl", "gl", "gr", "kh", + "kl", "kr", "ph", "pl", "pr", "sc", "sk", "sl", "sm", "sn", "sp", + "st", "sw", "th", "tr", "tw", "vl", "zh"] + name += (rand(3) > 0) ? set1.sample : set2.sample + when "E" # ending consonant + set1 = ["b", "c", "d", "f", "g", "h", "j", "k", "k", "l", "l", "m", "n", + "n", "p", "r", "r", "s", "s", "t", "t", "v", "z"] + set2 = ["bb", "bs", "ch", "cs", "ds", "fs", "ft", "gs", "gg", "ld", "ls", + "nd", "ng", "nk", "rn", "kt", "ks", "ms", "ns", "ph", "pt", "ps", + "sk", "sh", "sp", "ss", "st", "rd", "rn", "rp", "rm", "rt", "rk", + "ns", "th", "zh"] + name += (rand(3) > 0) ? set1.sample : set2.sample + when "f" # consonant and vowel + set = ["iz", "us", "or"] + name += set.sample + when "F" # consonant and vowel + set = ["bo", "ba", "be", "bu", "re", "ro", "si", "mi", "zho", "se", "nya", + "gru", "gruu", "glee", "gra", "glo", "ra", "do", "zo", "ri", "di", + "ze", "go", "ga", "pree", "pro", "po", "pa", "ka", "ki", "ku", + "de", "da", "ma", "mo", "le", "la", "li"] + name += set.sample when "2" - set = %w[c f g k l p r s t] - name += set[rand(set.length)] + set = ["c", "f", "g", "k", "l", "p", "r", "s", "t"] + name += set.sample when "3" - set = %w[nka nda la li ndra sta cha chie] - name += set[rand(set.length)] + set = ["nka", "nda", "la", "li", "ndra", "sta", "cha", "chie"] + name += set.sample when "4" - set = %w[una ona ina ita ila ala ana ia iana] - name += set[rand(set.length)] + set = ["una", "ona", "ina", "ita", "ila", "ala", "ana", "ia", "iana"] + name += set.sample when "5" - set = %w[e e o o ius io u u ito io ius us] - name += set[rand(set.length)] + set = ["e", "e", "o", "o", "ius", "io", "u", "u", "ito", "io", "ius", "us"] + name += set.sample when "6" - set = %w[a a a elle ine ika ina ita ila ala ana] - name += set[rand(set.length)] + set = ["a", "a", "a", "elle", "ine", "ika", "ina", "ita", "ila", "ala", "ana"] + name += set.sample end - } + end break if name.length <= maxLength - } + end name = name[0, maxLength] case upper when 0 then name = name.upcase @@ -444,7 +455,7 @@ def pbMoveTutorChoose(move, movelist = nil, bymachine = false, oneusemachine = f if movelist.is_a?(Array) movelist.map! { |m| GameData::Move.get(m).id } end - pbFadeOutIn { + pbFadeOutIn do movename = GameData::Move.get(move).name annot = pbMoveTutorAnnotations(move, movelist) scene = PokemonParty_Scene.new @@ -471,7 +482,7 @@ def pbMoveTutorChoose(move, movelist = nil, bymachine = false, oneusemachine = f end end screen.pbEndScene - } + end return ret # Returns whether the move was learned by a Pokemon end @@ -529,36 +540,36 @@ end def pbHideVisibleObjects visibleObjects = [] - ObjectSpace.each_object(Sprite) { |o| + ObjectSpace.each_object(Sprite) do |o| if !o.disposed? && o.visible visibleObjects.push(o) o.visible = false end - } - ObjectSpace.each_object(Viewport) { |o| + end + ObjectSpace.each_object(Viewport) do |o| if !pbDisposed?(o) && o.visible visibleObjects.push(o) o.visible = false end - } - ObjectSpace.each_object(Plane) { |o| + end + ObjectSpace.each_object(Plane) do |o| if !o.disposed? && o.visible visibleObjects.push(o) o.visible = false end - } - ObjectSpace.each_object(Tilemap) { |o| + end + ObjectSpace.each_object(Tilemap) do |o| if !o.disposed? && o.visible visibleObjects.push(o) o.visible = false end - } - ObjectSpace.each_object(Window) { |o| + end + ObjectSpace.each_object(Window) do |o| if !o.disposed? && o.visible visibleObjects.push(o) o.visible = false end - } + end return visibleObjects end diff --git a/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb b/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb index 9bbc595b8..edc3e22af 100644 --- a/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb +++ b/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb @@ -63,11 +63,11 @@ def pbAddPokemon(pkmn, level = 1, see_form = true) if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && see_form && !was_owned && $player.has_pokedex pbMessage(_INTL("{1}'s data was added to the Pokédex.", species_name)) $player.pokedex.register_last_seen(pkmn) - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokedexInfo_Scene.new screen = PokemonPokedexInfoScreen.new(scene) screen.pbDexEntry(pkmn.species) - } + end end # Nickname and add the Pokémon pbNicknameAndStore(pkmn) @@ -105,11 +105,11 @@ def pbAddToParty(pkmn, level = 1, see_form = true) if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && see_form && !was_owned && $player.has_pokedex pbMessage(_INTL("{1}'s data was added to the Pokédex.", species_name)) $player.pokedex.register_last_seen(pkmn) - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokedexInfo_Scene.new screen = PokemonPokedexInfoScreen.new(scene) screen.pbDexEntry(pkmn.species) - } + end end # Nickname and add the Pokémon pbNicknameAndStore(pkmn) @@ -145,11 +145,11 @@ def pbAddForeignPokemon(pkmn, level = 1, owner_name = nil, nickname = nil, owner if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && see_form && !was_owned && $player.has_pokedex pbMessage(_INTL("The Pokémon's data was added to the Pokédex.")) $player.pokedex.register_last_seen(pkmn) - pbFadeOutIn { + pbFadeOutIn do scene = PokemonPokedexInfo_Scene.new screen = PokemonPokedexInfoScreen.new(scene) screen.pbDexEntry(pkmn.species) - } + end end # Add the Pokémon pbStorePokemon(pkmn) diff --git a/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb b/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb index efbd7d8ca..9cf9eba5c 100644 --- a/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb +++ b/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb @@ -2,9 +2,7 @@ # Load various wild battle music #=============================================================================== def pbGetWildBattleBGM(_wildParty) # wildParty is an array of Pokémon objects - if $PokemonGlobal.nextBattleBGM - return $PokemonGlobal.nextBattleBGM.clone - end + return $PokemonGlobal.nextBattleBGM.clone if $PokemonGlobal.nextBattleBGM ret = nil if !ret # Check map metadata @@ -73,9 +71,7 @@ def pbPlayTrainerIntroBGM(trainer_type) end def pbGetTrainerBattleBGM(trainer) # can be a Player, NPCTrainer or an array of them - if $PokemonGlobal.nextBattleBGM - return $PokemonGlobal.nextBattleBGM.clone - end + return $PokemonGlobal.nextBattleBGM.clone if $PokemonGlobal.nextBattleBGM ret = nil music = nil trainerarray = (trainer.is_a?(Array)) ? trainer : [trainer] @@ -99,9 +95,7 @@ def pbGetTrainerBattleBGM(trainer) # can be a Player, NPCTrainer or an array o end def pbGetTrainerBattleBGMFromType(trainertype) - if $PokemonGlobal.nextBattleBGM - return $PokemonGlobal.nextBattleBGM.clone - end + return $PokemonGlobal.nextBattleBGM.clone if $PokemonGlobal.nextBattleBGM trainer_type_data = GameData::TrainerType.get(trainertype) ret = trainer_type_data.battle_BGM if trainer_type_data.battle_BGM if !ret diff --git a/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb b/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb index 4ecd0f956..44672a015 100644 --- a/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb +++ b/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb @@ -344,7 +344,7 @@ end #=============================================================================== def pbTrainerTypeEditor properties = GameData::TrainerType.editor_properties - pbListScreenBlock(_INTL("Trainer Types"), TrainerTypeLister.new(0, true)) { |button, tr_type| + pbListScreenBlock(_INTL("Trainer Types"), TrainerTypeLister.new(0, true)) do |button, tr_type| if tr_type case button when Input::ACTION @@ -386,7 +386,7 @@ def pbTrainerTypeEditor end end end - } + end end def pbTrainerTypeEditorNew(default_name) @@ -477,7 +477,7 @@ end #=============================================================================== def pbTrainerBattleEditor modified = false - pbListScreenBlock(_INTL("Trainer Battles"), TrainerBattleLister.new(0, true)) { |button, trainer_id| + pbListScreenBlock(_INTL("Trainer Battles"), TrainerBattleLister.new(0, true)) do |button, trainer_id| if trainer_id case button when Input::ACTION @@ -589,7 +589,7 @@ def pbTrainerBattleEditor end end end - } + end if modified && pbConfirmMessage(_INTL("Save changes?")) GameData::Trainer.save pbConvertTrainerData @@ -821,7 +821,7 @@ end #=============================================================================== def pbItemEditor properties = GameData::Item.editor_properties - pbListScreenBlock(_INTL("Items"), ItemLister.new(0, true)) { |button, item| + pbListScreenBlock(_INTL("Items"), ItemLister.new(0, true)) do |button, item| if item case button when Input::ACTION @@ -863,7 +863,7 @@ def pbItemEditor end end end - } + end end def pbItemEditorNew(default_name) @@ -925,7 +925,7 @@ end #=============================================================================== def pbPokemonEditor properties = GameData::Species.editor_properties - pbListScreenBlock(_INTL("Pokémon species"), SpeciesLister.new(0, false)) { |button, species| + pbListScreenBlock(_INTL("Pokémon species"), SpeciesLister.new(0, false)) do |button, species| if species case button when Input::ACTION @@ -983,7 +983,7 @@ def pbPokemonEditor end end end - } + end end #=============================================================================== diff --git a/Data/Scripts/020_Debug/001_Editor screens/002_EditorScreens_TerrainTags.rb b/Data/Scripts/020_Debug/001_Editor screens/002_EditorScreens_TerrainTags.rb index 3ec9276a4..be667799c 100644 --- a/Data/Scripts/020_Debug/001_Editor screens/002_EditorScreens_TerrainTags.rb +++ b/Data/Scripts/020_Debug/001_Editor screens/002_EditorScreens_TerrainTags.rb @@ -227,12 +227,12 @@ end # #=============================================================================== def pbTilesetScreen - pbFadeOutIn { + pbFadeOutIn do Graphics.resize_screen(Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT * 2) pbSetResizeFactor(1) scene = PokemonTilesetScene.new scene.pbStartScene Graphics.resize_screen(Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT) pbSetResizeFactor($PokemonSystem.screensize) - } + end end diff --git a/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb b/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb index ae47d55bd..4542c8a2f 100644 --- a/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb +++ b/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb @@ -271,9 +271,7 @@ class MapScreenScene while j < ret.length && !connectionsSymmetric?(ret[j], conn) j += 1 end - if j == ret.length - ret.push(conn) - end + ret.push(conn) if j == ret.length end end return ret @@ -567,7 +565,7 @@ end # #=============================================================================== def pbConnectionsEditor - pbCriticalCode { + pbCriticalCode do Graphics.resize_screen(Settings::SCREEN_WIDTH + 288, Settings::SCREEN_HEIGHT + 288) pbSetResizeFactor(1) mapscreen = MapScreenScene.new @@ -576,5 +574,5 @@ def pbConnectionsEditor mapscreen.close Graphics.resize_screen(Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT) pbSetResizeFactor($PokemonSystem.screensize) - } + end end diff --git a/Data/Scripts/020_Debug/001_Editor_Utilities.rb b/Data/Scripts/020_Debug/001_Editor_Utilities.rb index 6a1c44dab..3418211c1 100644 --- a/Data/Scripts/020_Debug/001_Editor_Utilities.rb +++ b/Data/Scripts/020_Debug/001_Editor_Utilities.rb @@ -77,11 +77,11 @@ def pbMapTree maplevels.push([i, level, info.parent_id, info.order]) end end - maplevels.sort! { |a, b| + maplevels.sort! do |a, b| next a[1] <=> b[1] if a[1] != b[1] # level next a[2] <=> b[2] if a[2] != b[2] # parent ID next a[3] <=> b[3] # order - } + end stack = [] stack.push(0, 0) while stack.length > 0 @@ -133,15 +133,15 @@ end # the ID of the species to initially select. Pressing Input::ACTION will toggle # the list sorting between numerical and alphabetical. def pbChooseSpeciesList(default = nil) - return pbChooseFromGameDataList(:Species, default) { |data| + return pbChooseFromGameDataList(:Species, default) do |data| next (data.form > 0) ? nil : data.real_name - } + end end def pbChooseSpeciesFormList(default = nil) - return pbChooseFromGameDataList(:Species, default) { |data| + return pbChooseFromGameDataList(:Species, default) do |data| next (data.form > 0) ? sprintf("%s_%d", data.real_name, data.form) : data.real_name - } + end end # Displays a list of all types, and returns the ID of the type selected (or nil @@ -149,9 +149,9 @@ end # to initially select. Pressing Input::ACTION will toggle the list sorting # between numerical and alphabetical. def pbChooseTypeList(default = nil) - return pbChooseFromGameDataList(:Type, default) { |data| + return pbChooseFromGameDataList(:Type, default) do |data| next (data.pseudo_type) ? nil : data.real_name - } + end end # Displays a list of all items, and returns the ID of the item selected (or nil diff --git a/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb b/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb index 10499653d..c11fa61a2 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb @@ -32,9 +32,7 @@ class Window_Menu < Window_CommandPokemon rc = Rect.new(0, 32 * (i - toprow), self.contents.width, 32) rc.x += self.x + self.leftEdge rc.y += self.y + self.topEdge - if rc.contains(mousepos[0], mousepos[1]) - return i - end + return i if rc.contains(mousepos[0], mousepos[1]) end return -1 end @@ -341,8 +339,7 @@ class InvalidatableSprite < Sprite # Redraws the sprite. This method should not check whether # the sprite is invalid, to allow it to be explicitly called. - def refresh - end + def refresh; end end #=============================================================================== @@ -820,11 +817,11 @@ class AnimationCanvas < Sprite currentFrame = getCurrentFrame if currentFrame && !@selecting && (Input.triggerex?(:TAB) || Input.repeatex?(:TAB)) - currentFrame.length.times { + currentFrame.length.times do @currentcel += 1 @currentcel = 0 if @currentcel >= currentFrame.length break if currentFrame[@currentcel] - } + end invalidate return end diff --git a/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb b/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb index 800edff09..7eecb1a76 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb @@ -72,21 +72,19 @@ class UIControl return @invalid end - def invalidate # Marks that the control must be redrawn to reflect current logic + def invalidate # Marks that the control must be redrawn to reflect current logic @invalid = true end - def update # Updates the logic on the control, invalidating it if necessary - end + def update; end # Updates the logic on the control, invalidating it if necessary - def refresh # Redraws the control - end + def refresh; end # Redraws the control - def validate # Makes the control no longer invalid + def validate # Makes the control no longer invalid @invalid = false end - def repaint # Redraws the control only if it is invalid + def repaint # Redraws the control only if it is invalid if self.invalid? self.refresh self.validate @@ -208,9 +206,7 @@ class Checkbox < Button else bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0)) end - if self.checked - shadowtext(bitmap, x, y, 32, 32, "X", @disabled, 1) - end + shadowtext(bitmap, x, y, 32, 32, "X", @disabled, 1) if self.checked size = bitmap.text_size(self.label).width shadowtext(bitmap, x + 36, y, size, height, self.label, @disabled) return ret @@ -241,9 +237,7 @@ class TextField < UIControl chars = self.text.scan(/./m) chars.insert(@cursor, ch) @text = "" - chars.each do |ch| - @text += ch - end + chars.each { |char| @text += char } @cursor += 1 @frame = 0 self.changed = true @@ -254,9 +248,7 @@ class TextField < UIControl chars = self.text.scan(/./m) chars.delete_at(@cursor - 1) @text = "" - chars.each do |ch| - @text += ch - end + chars.each { |char| @text += char } @cursor -= 1 @frame = 0 self.changed = true @@ -533,6 +525,8 @@ class OptionalSlider < Slider @checkbox.refresh end + #----------------------------------------------------------------------------- + private def updatedefs @@ -786,6 +780,8 @@ class OptionalTextSlider < TextSlider @checkbox.refresh end + #----------------------------------------------------------------------------- + private def updatedefs diff --git a/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb b/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb index 1d9fd40b9..0571f1adf 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb @@ -132,13 +132,9 @@ class PointPath end def smoothPointPath(frames, roundValues = false) - if frames < 0 - raise ArgumentError.new("frames out of range: #{frames}") - end + raise ArgumentError.new("frames out of range: #{frames}") if frames < 0 ret = PointPath.new - if @points.length == 0 - return ret - end + return ret if @points.length == 0 step = 1.0 / frames t = 0.0 (frames + 2).times do @@ -160,9 +156,7 @@ class PointPath end return nil if @points.length == 0 ret = @points[@points.length - 1].clone - if @points.length == 1 - return ret - end + return ret if @points.length == 1 curdist = 0 distForT = @totaldist * t i = 0 @@ -217,9 +211,7 @@ def getCurvePoint(src, t) end def curveToPointPath(curve, numpoints) - if numpoints < 2 - return nil - end + return nil if numpoints < 2 path = PointPath.new step = 1.0 / (numpoints - 1) t = 0.0 @@ -311,9 +303,7 @@ def pbDefinePath(canvas) end mousepos = Mouse.getMousePos(true) newtext = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)" - if window.text != newtext - window.text = newtext - end + window.text = newtext if window.text != newtext if curve[0].visible && curve[3].visible && !curve[0].dragging && !curve[3].dragging points.each do |point| @@ -332,10 +322,10 @@ def pbDefinePath(canvas) if showline step = 1.0 / (points.length - 1) t = 0.0 - points.length.times do |i| + points.length.times do |j| point = getCurvePoint(curve, t) - points[i].x = point[0] - points[i].y = point[1] + points[j].x = point[0] + points[j].y = point[1] t += step end end @@ -418,14 +408,14 @@ def pbDefinePath(canvas) end thiscel = canvas.currentCel celnumber = canvas.currentcel - (canvas.currentframe...neededsize).each do |i| - cel = canvas.animation[i][celnumber] - if !canvas.animation[i][celnumber] + (canvas.currentframe...neededsize).each do |j| + cel = canvas.animation[j][celnumber] + if !canvas.animation[j][celnumber] cel = pbCreateCel(0, 0, thiscel[AnimFrame::PATTERN], canvas.animation.position) - canvas.animation[i][celnumber] = cel + canvas.animation[j][celnumber] = cel end - cel[AnimFrame::X] = path[i - canvas.currentframe][0] - cel[AnimFrame::Y] = path[i - canvas.currentframe][1] + cel[AnimFrame::X] = path[j - canvas.currentframe][0] + cel[AnimFrame::Y] = path[j - canvas.currentframe][1] end break elsif sliderwin2.changed?(cancelbutton) || Input.trigger?(Input::BACK) diff --git a/Data/Scripts/020_Debug/002_Animation editor/004_AnimEditor_ExportImport.rb b/Data/Scripts/020_Debug/002_Animation editor/004_AnimEditor_ExportImport.rb index 2692d6dcd..fc56ec72e 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/004_AnimEditor_ExportImport.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/004_AnimEditor_ExportImport.rb @@ -26,9 +26,9 @@ def pbExportAnim(animations) if filename != "" begin filename += ".anm" - File.open(filename, "wb") { |f| + File.open(filename, "wb") do |f| f.write(dumpBase64Anim(animations[animations.selected])) - } + end failed = false rescue pbMessage(_INTL("Couldn't save the animation to {1}.", filename)) @@ -43,9 +43,7 @@ end def pbImportAnim(animations, canvas, animwin) animfiles = [] - pbRgssChdir(".") { - animfiles.concat(Dir.glob("*.anm")) - } + pbRgssChdir(".") { animfiles.concat(Dir.glob("*.anm")) } cmdwin = pbListWindow(animfiles, 320) cmdwin.opacity = 200 cmdwin.height = 480 diff --git a/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb b/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb index ffdfde73b..e5604a7d8 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb @@ -25,9 +25,7 @@ end #=============================================================================== def pbSelectAnim(canvas, animwin) animfiles = [] - pbRgssChdir(File.join("Graphics", "Animations")) { - animfiles.concat(Dir.glob("*.png")) - } + pbRgssChdir(File.join("Graphics", "Animations")) { animfiles.concat(Dir.glob("*.png")) } cmdwin = pbListWindow(animfiles, 320) cmdwin.opacity = 200 cmdwin.height = 512 @@ -507,12 +505,12 @@ def pbSelectSE(canvas, audio) displayname = (filename != "") ? filename : _INTL("") animfiles = [] ret = false - pbRgssChdir(File.join("Audio", "SE", "Anim")) { + pbRgssChdir(File.join("Audio", "SE", "Anim")) do animfiles.concat(Dir.glob("*.wav")) # animfiles.concat(Dir.glob("*.mp3")) animfiles.concat(Dir.glob("*.ogg")) animfiles.concat(Dir.glob("*.wma")) - } + end animfiles.uniq! animfiles.sort! { |a, b| a.downcase <=> b.downcase } animfiles = [_INTL("[Play user's cry]")] + animfiles @@ -535,13 +533,11 @@ def pbSelectSE(canvas, audio) Input.update cmdwin.update maxsizewindow.update - if maxsizewindow.changed?(3) && animfiles.length > 0 # Play Sound + if maxsizewindow.changed?(3) && animfiles.length > 0 # Play Sound fname = (cmdwin.index == 0) ? "Cries/001Cry" : "Anim/" + filename pbSEPlay(RPG::AudioFile.new(fname, maxsizewindow.value(1), maxsizewindow.value(2))) end - if maxsizewindow.changed?(4) && animfiles.length > 0 # Stop Sound - pbSEStop - end + pbSEStop if maxsizewindow.changed?(4) && animfiles.length > 0 # Stop Sound if maxsizewindow.changed?(5) # OK audio.name = File.basename(filename, ".*") audio.volume = maxsizewindow.value(1) @@ -549,9 +545,7 @@ def pbSelectSE(canvas, audio) ret = true break end - if maxsizewindow.changed?(6) # Cancel - break - end + break if maxsizewindow.changed?(6) # Cancel if Input.trigger?(Input::USE) && animfiles.length > 0 filename = (cmdwin.index == 0) ? "" : cmdwin.commands[cmdwin.index] displayname = (filename != "") ? filename : _INTL("") @@ -571,13 +565,13 @@ def pbSelectBG(canvas, timing) animfiles = [] animfiles[cmdErase = animfiles.length] = _INTL("[Erase background graphic]") ret = false - pbRgssChdir(File.join("Graphics", "Animations")) { + pbRgssChdir(File.join("Graphics", "Animations")) do animfiles.concat(Dir.glob("*.png")) animfiles.concat(Dir.glob("*.gif")) # animfiles.concat(Dir.glob("*.jpg")) # animfiles.concat(Dir.glob("*.jpeg")) # animfiles.concat(Dir.glob("*.bmp")) - } + end animfiles.map! { |f| File.basename(f, ".*") } animfiles.uniq! animfiles.sort! { |a, b| a.downcase <=> b.downcase } @@ -615,9 +609,7 @@ def pbSelectBG(canvas, timing) ret = true break end - if maxsizewindow.changed?(9) # Cancel - break - end + break if maxsizewindow.changed?(9) # Cancel if Input.trigger?(Input::USE) && animfiles.length > 0 filename = (cmdwin.index == cmdErase) ? "" : cmdwin.commands[cmdwin.index] maxsizewindow.controls[0].text = _INTL("File: \"{1}\"", filename) @@ -676,9 +668,7 @@ def pbEditBG(canvas, timing) end break end - if maxsizewindow.changed?(9) # Cancel - break - end + break if maxsizewindow.changed?(9) # Cancel if Input.trigger?(Input::BACK) break end @@ -1001,9 +991,7 @@ def animationEditorMain(animation) sidewin.update animwin.update bottomwindow.update - if animwin.changed? - canvas.pattern = animwin.selected - end + canvas.pattern = animwin.selected if animwin.changed? if Input.trigger?(Input::BACK) if pbConfirmMessage(_INTL("Save changes?")) save_data(animation, "Data/PkmnAnimations.rxdata") @@ -1031,9 +1019,7 @@ def animationEditorMain(animation) Clipboard.setData(canvas.animation[canvas.currentframe], "PBAnimFrame") end when 1 # Paste - if canvas.currentframe >= 0 - canvas.pasteFrame(canvas.currentframe) - end + canvas.pasteFrame(canvas.currentframe) if canvas.currentframe >= 0 when 2 # Clear Frame canvas.clearFrame(canvas.currentframe) when 3 # Insert Frame @@ -1076,9 +1062,7 @@ def animationEditorMain(animation) canvas.deleteCel(canvas.currentcel) end when 2 # Copy - if canvas.currentCel - Clipboard.setData(canvas.currentCel, "PBAnimCel") - end + Clipboard.setData(canvas.currentCel, "PBAnimCel") if canvas.currentCel when 3 # Paste canvas.pasteCel(mousepos[0], mousepos[1]) when 4 # Delete @@ -1087,9 +1071,7 @@ def animationEditorMain(animation) if canvas.currentcel && canvas.currentcel >= 2 cel1 = canvas.currentcel cel2 = pbChooseNum(cel1) - if cel2 >= 2 && cel1 != cel2 - canvas.swapCels(cel1, cel2) - end + canvas.swapCels(cel1, cel2) if cel2 >= 2 && cel1 != cel2 end when 6 # Extrapolate Path if canvas.currentCel @@ -1128,9 +1110,7 @@ def animationEditorMain(animation) indexes = [2, 1, 3, 4] # Keeping backwards compatibility positions.length.times do |i| selected = "[ ]" - if animation[animation.selected].position == indexes[i] - selected = "[x]" - end + selected = "[x]" if animation[animation.selected].position == indexes[i] positions[i] = sprintf("%s %s", selected, positions[i]) end pos = pbShowCommands(nil, positions, -1) diff --git a/Data/Scripts/020_Debug/002_Editor_DataTypes.rb b/Data/Scripts/020_Debug/002_Editor_DataTypes.rb index dac8ce166..96c5f5e7f 100644 --- a/Data/Scripts/020_Debug/002_Editor_DataTypes.rb +++ b/Data/Scripts/020_Debug/002_Editor_DataTypes.rb @@ -1558,8 +1558,8 @@ class EvolutionsProperty ret = "" value.length.times do |i| ret << "," if i > 0 - ret << value[i][0].to_s + "," - ret << value[i][1].to_s + "," + ret << (value[i][0].to_s + ",") + ret << (value[i][1].to_s + ",") ret << value[i][2].to_s if value[i][2] end return ret diff --git a/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb b/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb index 13f084dc6..b1ac11b81 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb @@ -436,9 +436,7 @@ MenuHandlers.add(:debug_menu, :encounter_version, { params.setInitialValue($PokemonGlobal.encounter_version) params.setCancelValue(-1) value = pbMessageChooseNumber(_INTL("Set encounters version to which value?"), params) - if value >= 0 - $PokemonGlobal.encounter_version = value - end + $PokemonGlobal.encounter_version = value if value >= 0 } }) @@ -457,7 +455,7 @@ MenuHandlers.add(:debug_menu, :add_item, { "parent" => :items_menu, "description" => _INTL("Choose an item and a quantity of it to add to the Bag."), "effect" => proc { - pbListScreenBlock(_INTL("ADD ITEM"), ItemLister.new) { |button, item| + pbListScreenBlock(_INTL("ADD ITEM"), ItemLister.new) do |button, item| if button == Input::USE && item params = ChooseNumberParams.new params.setRange(1, Settings::BAG_MAX_PER_SLOT) @@ -470,7 +468,7 @@ MenuHandlers.add(:debug_menu, :add_item, { pbMessage(_INTL("Gave {1}x {2}.", qty, GameData::Item.get(item).name)) end end - } + end } }) @@ -558,17 +556,15 @@ MenuHandlers.add(:debug_menu, :give_demo_party, { "effect" => proc { party = [] species = [:PIKACHU, :PIDGEOTTO, :KADABRA, :GYARADOS, :DIGLETT, :CHANSEY] - species.each do |id| - party.push(id) if GameData::Species.exists?(id) - end + species.each { |id| party.push(id) if GameData::Species.exists?(id) } $player.party.clear # Generate Pokémon of each species at level 20 - party.each do |species| - pkmn = Pokemon.new(species, 20) + party.each do |spec| + pkmn = Pokemon.new(spec, 20) $player.party.push(pkmn) $player.pokedex.register(pkmn) - $player.pokedex.set_owned(species) - case species + $player.pokedex.set_owned(spec) + case spec when :PIDGEOTTO pkmn.learn_move(:FLY) when :KADABRA @@ -617,7 +613,7 @@ MenuHandlers.add(:debug_menu, :quick_hatch_party_eggs, { MenuHandlers.add(:debug_menu, :fill_boxes, { "name" => _INTL("Fill Storage Boxes"), "parent" => :pokemon_menu, - "description" => _INTL("Add one Pokémon of each species (at Level 50) to storage."), + "description" => _INTL("Puts one Pokémon of each species (at Level 50) in storage."), "effect" => proc { added = 0 box_qty = $PokemonStorage.maxPokemon(0) @@ -680,11 +676,11 @@ MenuHandlers.add(:debug_menu, :open_storage, { "parent" => :pokemon_menu, "description" => _INTL("Opens the Pokémon storage boxes in Organize Boxes mode."), "effect" => proc { - pbFadeOutIn { + pbFadeOutIn do scene = PokemonStorageScene.new screen = PokemonStorageScreen.new(scene, $PokemonStorage) screen.pbStartScreen(0) - } + end } }) @@ -1010,11 +1006,11 @@ MenuHandlers.add(:debug_menu, :position_sprites, { "parent" => :editors_menu, "description" => _INTL("Reposition Pokémon sprites in battle."), "effect" => proc { - pbFadeOutIn { + pbFadeOutIn do sp = SpritePositioner.new sps = SpritePositionerScreen.new(sp) sps.pbStart - } + end } }) diff --git a/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb b/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb index 054fc0be2..1531c21d0 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb @@ -329,12 +329,12 @@ def pbDebugDayCare case pbMessage("\\ts[]" + msg, [_INTL("Summary"), _INTL("Withdraw"), _INTL("Cancel")], 3) when 0 # Summary - pbFadeOutIn { + pbFadeOutIn do scene = PokemonSummary_Scene.new screen = PokemonSummaryScreen.new(scene, false) screen.pbStartScreen([pkmn], 0) need_refresh = true - } + end when 1 # Withdraw if $player.party_full? pbMessage(_INTL("Party is full, can't withdraw Pokémon.")) @@ -557,9 +557,9 @@ def pbExportAllAnimations Graphics.update safename = anim.name.gsub(/\W/, "_") Dir.mkdir("Animations/#{safename}") rescue nil - File.open("Animations/#{safename}/#{safename}.anm", "wb") { |f| + File.open("Animations/#{safename}/#{safename}.anm", "wb") do |f| f.write(dumpBase64Anim(anim)) - } + end if anim.graphic && anim.graphic != "" graphicname = RTP.getImagePath("Graphics/Animations/" + anim.graphic) pbSafeCopyFile(graphicname, "Animations/#{safename}/" + File.basename(graphicname)) @@ -592,12 +592,10 @@ end def pbImportAllAnimations animationFolders = [] if safeIsDirectory?("Animations") - Dir.foreach("Animations") { |fb| + Dir.foreach("Animations") do |fb| f = "Animations/" + fb - if safeIsDirectory?(f) && fb != "." && fb != ".." - animationFolders.push(f) - end - } + animationFolders.push(f) if safeIsDirectory?(f) && fb != "." && fb != ".." + end end if animationFolders.length == 0 pbMessage(_INTL("There are no animations to import. Put each animation in a folder within the Animations folder.")) @@ -610,24 +608,24 @@ def pbImportAllAnimations Graphics.update audios = [] files = Dir.glob(folder + "/*.*") - ["wav", "ogg", "mid", "wma"].each { |ext| # mp3 + ["wav", "ogg", "mid", "wma"].each do |ext| # mp3 upext = ext.upcase audios.concat(files.find_all { |f| f[f.length - 3, 3] == ext }) audios.concat(files.find_all { |f| f[f.length - 3, 3] == upext }) - } + end audios.each do |audio| pbSafeCopyFile(audio, RTP.getAudioPath("Audio/SE/Anim/" + File.basename(audio)), "Audio/SE/Anim/" + File.basename(audio)) end images = [] - ["png", "gif"].each { |ext| # jpg jpeg bmp + ["png", "gif"].each do |ext| # jpg jpeg bmp upext = ext.upcase images.concat(files.find_all { |f| f[f.length - 3, 3] == ext }) images.concat(files.find_all { |f| f[f.length - 3, 3] == upext }) - } + end images.each do |image| pbSafeCopyFile(image, RTP.getImagePath("Graphics/Animations/" + File.basename(image)), "Graphics/Animations/" + File.basename(image)) end - Dir.glob(folder + "/*.anm") { |f| + Dir.glob(folder + "/*.anm") do |f| textdata = loadBase64Anim(IO.read(f)) rescue nil if textdata.is_a?(PBAnimation) index = pbAllocateAnimation(animations, textdata.name) @@ -650,7 +648,7 @@ def pbImportAllAnimations end animations[index] = textdata end - } + end end save_data(animations, "Data/PkmnAnimations.rxdata") $game_temp.battle_animations_data = nil @@ -788,7 +786,7 @@ class PokemonDebugPartyScreen @messageBox.text = text @messageBox.visible = true @helpWindow.visible = false - using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) { + using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) do cmdwindow.visible = false pbBottomRight(cmdwindow) cmdwindow.y -= @messageBox.height @@ -809,7 +807,7 @@ class PokemonDebugPartyScreen end end end - } + end @messageBox.visible = false @helpWindow.visible = true return ret @@ -818,7 +816,7 @@ class PokemonDebugPartyScreen def pbShowCommands(text, commands, index = 0) ret = -1 @helpWindow.visible = true - using(cmdwindow = Window_CommandPokemonColor.new(commands)) { + using(cmdwindow = Window_CommandPokemonColor.new(commands)) do cmdwindow.z = @viewport.z + 1 cmdwindow.index = index pbBottomRight(cmdwindow) @@ -840,7 +838,7 @@ class PokemonDebugPartyScreen break end end - } + end return ret end diff --git a/Data/Scripts/020_Debug/003_Debug menus/005_Debug_BattlePkmnCommands.rb b/Data/Scripts/020_Debug/003_Debug menus/005_Debug_BattlePkmnCommands.rb index 5f80ba295..bf00bff07 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/005_Debug_BattlePkmnCommands.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/005_Debug_BattlePkmnCommands.rb @@ -295,7 +295,6 @@ MenuHandlers.add(:battle_pokemon_debug_menu, :hidden_values, { "effect" => proc { |pkmn, battler, battle| cmd = 0 loop do - persid = sprintf("0x%08X", pkmn.personalID) cmd = pbMessage("\\ts[]" + _INTL("Choose hidden values to edit."), [_INTL("Set EVs"), _INTL("Set IVs")], -1, nil, cmd) break if cmd < 0 diff --git a/Data/Scripts/020_Debug/003_Debug menus/008_Debug_FilenameUpdater.rb b/Data/Scripts/020_Debug/003_Debug menus/008_Debug_FilenameUpdater.rb index 3b4d43de6..92ab574aa 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/008_Debug_FilenameUpdater.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/008_Debug_FilenameUpdater.rb @@ -6,11 +6,11 @@ module FilenameUpdater def readDirectoryFiles(directory, formats) files = [] - Dir.chdir(directory) { + Dir.chdir(directory) do formats.each do |format| Dir.glob(format) { |f| files.push(f) } end - } + end return files end diff --git a/Data/Scripts/020_Debug/003_Editor_Listers.rb b/Data/Scripts/020_Debug/003_Editor_Listers.rb index 938b92db6..4c86c61b8 100644 --- a/Data/Scripts/020_Debug/003_Editor_Listers.rb +++ b/Data/Scripts/020_Debug/003_Editor_Listers.rb @@ -93,18 +93,14 @@ def pbListScreenBlock(title, lister) if Input.trigger?(Input::ACTION) yield(Input::ACTION, lister.value(selectedmap)) list.commands = lister.commands - if list.index == list.commands.length - list.index = list.commands.length - end + list.index = list.commands.length if list.index == list.commands.length lister.refresh(list.index) elsif Input.trigger?(Input::BACK) break elsif Input.trigger?(Input::USE) yield(Input::USE, lister.value(selectedmap)) list.commands = lister.commands - if list.index == list.commands.length - list.index = list.commands.length - end + list.index = list.commands.length if list.index == list.commands.length lister.refresh(list.index) end end @@ -146,13 +142,13 @@ class GraphicsLister def commands @commands.clear - Dir.chdir(@folder) { + Dir.chdir(@folder) do Dir.glob("*.png") { |f| @commands.push(f) } Dir.glob("*.gif") { |f| @commands.push(f) } # Dir.glob("*.jpg") { |f| @commands.push(f) } # Dir.glob("*.jpeg") { |f| @commands.push(f) } # Dir.glob("*.bmp") { |f| @commands.push(f) } - } + end @commands.sort! @commands.length.times do |i| @index = i if @commands[i] == @selection @@ -199,8 +195,7 @@ class MusicFileLister pbPlayBGM(@oldbgm) end - def setViewport(viewport) - end + def setViewport(viewport); end def getPlayingBGM ($game_system) ? $game_system.getPlayingBGM : nil @@ -217,13 +212,13 @@ class MusicFileLister def commands folder = (@bgm) ? "Audio/BGM/" : "Audio/ME/" @commands.clear - Dir.chdir(folder) { + Dir.chdir(folder) do # Dir.glob("*.mp3") { |f| @commands.push(f) } Dir.glob("*.ogg") { |f| @commands.push(f) } Dir.glob("*.wav") { |f| @commands.push(f) } Dir.glob("*.mid") { |f| @commands.push(f) } Dir.glob("*.midi") { |f| @commands.push(f) } - } + end @commands.uniq! @commands.sort! { |a, b| a.downcase <=> b.downcase } @commands.length.times do |i| @@ -325,9 +320,7 @@ class MapLister def commands @commands.clear - if @addGlobalOffset == 1 - @commands.push(_INTL("[GLOBAL]")) - end + @commands.push(_INTL("[GLOBAL]")) if @addGlobalOffset == 1 @maps.length.times do |i| @commands.push(sprintf("%s%03d %s", (" " * @maps[i][2]), @maps[i][0], @maps[i][1])) end @@ -578,7 +571,7 @@ class TrainerBattleLister cmds.push([idx, trainer.trainer_type, trainer.real_name, trainer.version]) idx += 1 end - cmds.sort! { |a, b| + cmds.sort! do |a, b| if a[1] == b[1] if a[2] == b[2] (a[3] == b[3]) ? a[0] <=> b[0] : a[3] <=> b[3] @@ -588,7 +581,7 @@ class TrainerBattleLister else a[1].to_s.downcase <=> b[1].to_s.downcase end - } + end if @includeNew @commands.push(_INTL("[NEW TRAINER BATTLE]")) @ids.push(true) diff --git a/Data/Scripts/021_Compiler/001_Compiler.rb b/Data/Scripts/021_Compiler/001_Compiler.rb index fba3576b9..096dcb591 100644 --- a/Data/Scripts/021_Compiler/001_Compiler.rb +++ b/Data/Scripts/021_Compiler/001_Compiler.rb @@ -59,13 +59,13 @@ module Compiler def findIndex(a) index = -1 count = 0 - a.each { |i| + a.each do |i| if yield i index = count break end count += 1 - } + end return index end @@ -97,7 +97,7 @@ module Compiler havesection = false sectionname = nil lastsection = {} - f.each_line { |line| + f.each_line do |line| if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF line = line[3, line.length - 3] end @@ -130,7 +130,7 @@ module Compiler end lineno += 1 Graphics.update if lineno % 1000 == 0 - } + end yield lastsection, sectionname if havesection end @@ -139,16 +139,16 @@ module Compiler # ribbons.txt, trainer_types.txt, battle_facility_lists.txt, Battle Tower # trainers PBS files and dungeon_parameters.txt def pbEachFileSection(f, schema = nil) - pbEachFileSectionEx(f, schema) { |section, name| + pbEachFileSectionEx(f, schema) do |section, name| yield section, name if block_given? && name[/^.+$/] - } + end end # Used for metadata.txt and map_metadata.txt def pbEachFileSectionNumbered(f, schema = nil) - pbEachFileSectionEx(f, schema) { |section, name| + pbEachFileSectionEx(f, schema) do |section, name| yield section, name.to_i if block_given? && name[/^\d+$/] - } + end end # Used by translated text compiler @@ -157,7 +157,7 @@ module Compiler havesection = false sectionname = nil lastsection = [] - f.each_line { |line| + f.each_line do |line| if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF line = line[3, line.length - 3] end @@ -177,29 +177,29 @@ module Compiler end lineno += 1 Graphics.update if lineno % 500 == 0 - } + end yield lastsection, sectionname if havesection end # Unused def pbEachCommentedLine(f) lineno = 1 - f.each_line { |line| + f.each_line do |line| if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF line = line[3, line.length - 3] end line.force_encoding(Encoding::UTF_8) yield line, lineno if !line[/^\#/] && !line[/^\s*$/] lineno += 1 - } + end end # Used for town_map.txt and Battle Tower Pokémon PBS files def pbCompilerEachCommentedLine(filename) - File.open(filename, "rb") { |f| + File.open(filename, "rb") do |f| FileLineData.file = filename lineno = 1 - f.each_line { |line| + f.each_line do |line| if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF line = line[3, line.length - 3] end @@ -209,14 +209,14 @@ module Compiler yield line, lineno end lineno += 1 - } - } + end + end end # Unused def pbEachPreppedLine(f) lineno = 1 - f.each_line { |line| + f.each_line do |line| if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF line = line[3, line.length - 3] end @@ -224,16 +224,16 @@ module Compiler line = prepline(line) yield line, lineno if !line[/^\#/] && !line[/^\s*$/] lineno += 1 - } + end end # Used for map_connections.txt, phone.txt, regional_dexes.txt, encounters.txt, # trainers.txt and dungeon_tilesets.txt def pbCompilerEachPreppedLine(filename) - File.open(filename, "rb") { |f| + File.open(filename, "rb") do |f| FileLineData.file = filename lineno = 1 - f.each_line { |line| + f.each_line do |line| if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF line = line[3, line.length - 3] end @@ -244,8 +244,8 @@ module Compiler yield line, lineno end lineno += 1 - } - } + end + end end #============================================================================= @@ -408,10 +408,11 @@ module Compiler repeat = false schema_length = schema[1].length start = 0 - if schema[1][0, 1] == "*" + case schema[1][0, 1] + when "*" repeat = true start = 1 - elsif schema[1][0, 1] == "^" + when "^" start = 1 schema_length -= 1 end @@ -740,16 +741,16 @@ module Compiler def edit_and_rewrite_pbs_file_text(filename) return if !block_given? lines = [] - File.open(filename, "rb") { |f| + File.open(filename, "rb") do |f| f.each_line { |line| lines.push(line) } - } + end changed = false lines.each { |line| changed = true if yield line } if changed Console.markup_style("Changes made to file #{filename}.", text: :yellow) - File.open(filename, "wb") { |f| + File.open(filename, "wb") do |f| lines.each { |line| f.write(line) } - } + end end end @@ -882,9 +883,9 @@ module Compiler data_files.each do |filename| if safeExists?("Data/" + filename) begin - File.open("Data/#{filename}") { |file| + File.open("Data/#{filename}") do |file| latestDataTime = [latestDataTime, file.mtime.to_i].max - } + end rescue SystemCallError mustCompile = true end diff --git a/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb b/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb index 168082b28..8d4ff7200 100644 --- a/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb +++ b/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb @@ -10,13 +10,13 @@ module Compiler base_filename = game_data::PBS_BASE_FILENAME base_filename = base_filename[0] if base_filename.is_a?(Array) # For Species file_suffix = File.basename(path, ".txt")[base_filename.length + 1, path.length] || "" - File.open(path, "rb") { |f| + File.open(path, "rb") do |f| FileLineData.file = path # For error reporting # Read a whole section's lines at once, then run through this code. # contents is a hash containing all the XXX=YYY lines in that section, where # the keys are the XXX and the values are the YYY (as unprocessed strings). idx = 0 - pbEachFileSection(f, schema) { |contents, section_name| + pbEachFileSection(f, schema) do |contents, section_name| echo "." if idx % 50 == 0 Graphics.update if idx % 250 == 0 idx += 1 @@ -55,8 +55,8 @@ module Compiler end # Add section's data to records game_data.register(data_hash) - } - } + end + end process_pbs_file_message_end end yield true, nil if block_given? @@ -90,9 +90,9 @@ module Compiler end point_names.uniq! interest_names.uniq! - MessageTypes.setMessagesAsHash(MessageTypes::Regions, region_names) - MessageTypes.setMessagesAsHash(MessageTypes::RegionLocations, point_names) - MessageTypes.setMessagesAsHash(MessageTypes::RegionDescriptions, interest_names) + MessageTypes.setMessagesAsHash(MessageTypes::REGION_NAMES, region_names) + MessageTypes.setMessagesAsHash(MessageTypes::REGION_LOCATION_NAMES, point_names) + MessageTypes.setMessagesAsHash(MessageTypes::REGION_LOCATION_DESCRIPTIONS, interest_names) end #============================================================================= @@ -102,7 +102,7 @@ module Compiler records = [] paths.each do |path| compile_pbs_file_message_start(path) - pbCompilerEachPreppedLine(path) { |line, lineno| + pbCompilerEachPreppedLine(path) do |line, lineno| hashenum = { "N" => "N", "North" => "N", "E" => "E", "East" => "E", @@ -134,7 +134,7 @@ module Compiler raise _INTL("West side of first map must connect with east side of second map\r\n{1}", FileLineData.linereport) if record[4] != "E" end records.push(record) - } + end process_pbs_file_message_end end save_data(records, "Data/map_connections.dat") @@ -175,7 +175,7 @@ module Compiler # Get type names for translating type_names.push(type.real_name) end - MessageTypes.setMessagesAsHash(MessageTypes::Types, type_names) + MessageTypes.setMessagesAsHash(MessageTypes::TYPE_NAMES, type_names) end #============================================================================= @@ -198,8 +198,8 @@ module Compiler ability_names.push(ability.real_name) ability_descriptions.push(ability.real_description) end - MessageTypes.setMessagesAsHash(MessageTypes::Abilities, ability_names) - MessageTypes.setMessagesAsHash(MessageTypes::AbilityDescriptions, ability_descriptions) + MessageTypes.setMessagesAsHash(MessageTypes::ABILITY_NAMES, ability_names) + MessageTypes.setMessagesAsHash(MessageTypes::ABILITY_DESCRIPTIONS, ability_descriptions) end #============================================================================= @@ -230,8 +230,8 @@ module Compiler move_names.push(move.real_name) move_descriptions.push(move.real_description) end - MessageTypes.setMessagesAsHash(MessageTypes::Moves, move_names) - MessageTypes.setMessagesAsHash(MessageTypes::MoveDescriptions, move_descriptions) + MessageTypes.setMessagesAsHash(MessageTypes::MOVE_NAMES, move_names) + MessageTypes.setMessagesAsHash(MessageTypes::MOVE_DESCRIPTIONS, move_descriptions) end #============================================================================= @@ -260,11 +260,11 @@ module Compiler item_portion_names_plural.push(item.real_portion_name_plural) item_descriptions.push(item.real_description) end - MessageTypes.setMessagesAsHash(MessageTypes::Items, item_names) - MessageTypes.setMessagesAsHash(MessageTypes::ItemPlurals, item_names_plural) - MessageTypes.setMessagesAsHash(MessageTypes::ItemPortions, item_portion_names) - MessageTypes.setMessagesAsHash(MessageTypes::ItemPortionPlurals, item_portion_names_plural) - MessageTypes.setMessagesAsHash(MessageTypes::ItemDescriptions, item_descriptions) + MessageTypes.setMessagesAsHash(MessageTypes::ITEM_NAMES, item_names) + MessageTypes.setMessagesAsHash(MessageTypes::ITEM_NAME_PLURALS, item_names_plural) + MessageTypes.setMessagesAsHash(MessageTypes::ITEM_PORTION_NAMES, item_portion_names) + MessageTypes.setMessagesAsHash(MessageTypes::ITEM_PORTION_NAME_PLURALS, item_portion_names_plural) + MessageTypes.setMessagesAsHash(MessageTypes::ITEM_DESCRIPTIONS, item_descriptions) end #============================================================================= @@ -369,10 +369,10 @@ module Compiler species_categories.push(species.real_category) species_pokedex_entries.push(species.real_pokedex_entry) end - MessageTypes.setMessagesAsHash(MessageTypes::Species, species_names) - MessageTypes.setMessagesAsHash(MessageTypes::SpeciesForms, species_form_names) - MessageTypes.setMessagesAsHash(MessageTypes::SpeciesCategories, species_categories) - MessageTypes.setMessagesAsHash(MessageTypes::PokedexEntries, species_pokedex_entries) + MessageTypes.setMessagesAsHash(MessageTypes::SPECIES_NAMES, species_names) + MessageTypes.setMessagesAsHash(MessageTypes::SPECIES_FORM_NAMES, species_form_names) + MessageTypes.setMessagesAsHash(MessageTypes::SPECIES_CATEGORIES, species_categories) + MessageTypes.setMessagesAsHash(MessageTypes::POKEDEX_ENTRIES, species_pokedex_entries) end #============================================================================= @@ -386,13 +386,13 @@ module Compiler paths.each do |path| compile_pbs_file_message_start(path) file_suffix = File.basename(path, ".txt")[GameData::Species::PBS_BASE_FILENAME[1].length + 1, path.length] || "" - File.open(path, "rb") { |f| + File.open(path, "rb") do |f| FileLineData.file = path # For error reporting # Read a whole section's lines at once, then run through this code. # contents is a hash containing all the XXX=YYY lines in that section, where # the keys are the XXX and the values are the YYY (as unprocessed strings). idx = 0 - pbEachFileSection(f, schema) { |contents, section_name| + pbEachFileSection(f, schema) do |contents, section_name| echo "." if idx % 50 == 0 Graphics.update if idx % 250 == 0 idx += 1 @@ -431,8 +431,8 @@ module Compiler end # Add section's data to records GameData::Species.register(data_hash) - } - } + end + end process_pbs_file_message_end end validate_all_compiled_pokemon_forms @@ -508,9 +508,9 @@ module Compiler species_categories.push(species.real_category) species_pokedex_entries.push(species.real_pokedex_entry) end - MessageTypes.addMessagesAsHash(MessageTypes::SpeciesForms, species_form_names) - MessageTypes.addMessagesAsHash(MessageTypes::SpeciesCategories, species_categories) - MessageTypes.addMessagesAsHash(MessageTypes::PokedexEntries, species_pokedex_entries) + MessageTypes.addMessagesAsHash(MessageTypes::SPECIES_FORM_NAMES, species_form_names) + MessageTypes.addMessagesAsHash(MessageTypes::SPECIES_CATEGORIES, species_categories) + MessageTypes.addMessagesAsHash(MessageTypes::POKEDEX_ENTRIES, species_pokedex_entries) end #============================================================================= @@ -562,7 +562,7 @@ module Compiler paths.each do |path| compile_pbs_file_message_start(path) section = nil - pbCompilerEachPreppedLine(path) { |line, line_no| + pbCompilerEachPreppedLine(path) do |line, line_no| Graphics.update if line_no % 200 == 0 if line[/^\s*\[\s*(\d+)\s*\]\s*$/] section = $~[1].to_i @@ -579,7 +579,7 @@ module Compiler dex_lists[section].push(s) end end - } + end process_pbs_file_message_end end # Check for duplicate species in a Regional Dex @@ -615,8 +615,8 @@ module Compiler ribbon_names.push(ribbon.real_name) ribbon_descriptions.push(ribbon.real_description) end - MessageTypes.setMessagesAsHash(MessageTypes::RibbonNames, ribbon_names) - MessageTypes.setMessagesAsHash(MessageTypes::RibbonDescriptions, ribbon_descriptions) + MessageTypes.setMessagesAsHash(MessageTypes::RIBBON_NAMES, ribbon_names) + MessageTypes.setMessagesAsHash(MessageTypes::RIBBON_DESCRIPTIONS, ribbon_descriptions) end #============================================================================= @@ -632,7 +632,7 @@ module Compiler step_chances = nil current_type = nil idx = 0 - pbCompilerEachPreppedLine(path) { |line, line_no| + pbCompilerEachPreppedLine(path) do |line, line_no| echo "." if idx % 50 == 0 idx += 1 Graphics.update if idx % 250 == 0 @@ -707,7 +707,7 @@ module Compiler line, encounter_hash[:map], FileLineData.linereport) end end - } + end # Add last map's encounter data to records if encounter_hash encounter_hash[:types].each_value do |slots| @@ -750,7 +750,7 @@ module Compiler GameData::TrainerType.each do |tr_type| trainer_type_names.push(tr_type.real_name) end - MessageTypes.setMessagesAsHash(MessageTypes::TrainerTypes, trainer_type_names) + MessageTypes.setMessagesAsHash(MessageTypes::TRAINER_TYPE_NAMES, trainer_type_names) end #============================================================================= @@ -770,7 +770,7 @@ module Compiler section_name = nil section_line = nil # Read each line of trainers.txt at a time and compile it as a trainer property - pbCompilerEachPreppedLine(path) { |line, line_no| + pbCompilerEachPreppedLine(path) do |line, line_no| echo "." if idx % 50 == 0 idx += 1 Graphics.update if idx % 250 == 0 @@ -815,7 +815,7 @@ module Compiler current_pkmn[sub_schema[key][0]] = pbGetCsvRecord($~[2], line_no, sub_schema[key]) end end - } + end # Add last trainer's data to records if data_hash FileLineData.setSection(section_name, nil, section_line) @@ -908,8 +908,8 @@ module Compiler trainer_names.push(trainer.real_name) lose_texts.push(trainer.real_lose_text) end - MessageTypes.setMessagesAsHash(MessageTypes::TrainerNames, trainer_names) - MessageTypes.setMessagesAsHash(MessageTypes::TrainerLoseTexts, lose_texts) + MessageTypes.setMessagesAsHash(MessageTypes::TRAINER_NAMES, trainer_names) + MessageTypes.setMessagesAsHash(MessageTypes::TRAINER_SPEECHES_LOSE, lose_texts) end #============================================================================= @@ -923,23 +923,23 @@ module Compiler "Challenges" => [2, "*s"] } if !safeExists?(path) - File.open(path, "wb") { |f| + File.open(path, "wb") do |f| f.write(0xEF.chr) f.write(0xBB.chr) f.write(0xBF.chr) f.write("[DefaultTrainerList]\r\n") f.write("Trainers = battle_tower_trainers.txt\r\n") f.write("Pokemon = battle_tower_pokemon.txt\r\n") - } + end end sections = [] - MessageTypes.setMessagesAsHash(MessageTypes::FrontierIntroSpeeches, []) - MessageTypes.setMessagesAsHash(MessageTypes::FrontierEndSpeechesWin, []) - MessageTypes.setMessagesAsHash(MessageTypes::FrontierEndSpeechesLose, []) - File.open(path, "rb") { |f| + MessageTypes.setMessagesAsHash(MessageTypes::FRONTIER_INTRO_SPEECHES, []) + MessageTypes.setMessagesAsHash(MessageTypes::FRONTIER_END_SPEECHES_WIN, []) + MessageTypes.setMessagesAsHash(MessageTypes::FRONTIER_END_SPEECHES_LOSE, []) + File.open(path, "rb") do |f| FileLineData.file = path idx = 0 - pbEachFileSection(f) { |section, name| + pbEachFileSection(f) do |section, name| echo "." idx += 1 Graphics.update @@ -970,9 +970,9 @@ module Compiler if safeExists?("PBS/" + rsection[1]) filename = "PBS/" + rsection[1] rsection[1] = [] - pbCompilerEachCommentedLine(filename) { |line, _lineno| + pbCompilerEachCommentedLine(filename) do |line, _lineno| rsection[1].push(PBPokemon.fromInspected(line)) - } + end else rsection[1] = [] end @@ -982,8 +982,8 @@ module Compiler end rsection[2].compact! sections.push(rsection) - } - } + end + end save_data(sections, "Data/trainer_lists.dat") process_pbs_file_message_end end @@ -1003,9 +1003,9 @@ module Compiler endspeechwin = [] endspeechlose = [] if safeExists?(filename) - File.open(filename, "rb") { |f| + File.open(filename, "rb") do |f| FileLineData.file = filename - pbEachFileSection(f) { |section, name| + pbEachFileSection(f) do |section, name| rsection = [] section.each_key do |key| FileLineData.setSection(name, key, section[key]) @@ -1019,13 +1019,13 @@ module Compiler endspeechwin.push(rsection[3]) endspeechlose.push(rsection[4]) sections.push(rsection) - } - } + end + end end - MessageTypes.addMessagesAsHash(MessageTypes::TrainerNames, trainernames) - MessageTypes.addMessagesAsHash(MessageTypes::FrontierIntroSpeeches, beginspeech) - MessageTypes.addMessagesAsHash(MessageTypes::FrontierEndSpeechesWin, endspeechwin) - MessageTypes.addMessagesAsHash(MessageTypes::FrontierEndSpeechesLose, endspeechlose) + MessageTypes.addMessagesAsHash(MessageTypes::TRAINER_NAMES, trainernames) + MessageTypes.addMessagesAsHash(MessageTypes::FRONTIER_INTRO_SPEECHES, beginspeech) + MessageTypes.addMessagesAsHash(MessageTypes::FRONTIER_END_SPEECHES_WIN, endspeechwin) + MessageTypes.addMessagesAsHash(MessageTypes::FRONTIER_END_SPEECHES_LOSE, endspeechlose) return sections end @@ -1043,13 +1043,13 @@ module Compiler compile_pbs_file_message_start(path) file_suffix = File.basename(path, ".txt")[GameData::Metadata::PBS_BASE_FILENAME.length + 1, path.length] || "" # Read from PBS file - File.open(path, "rb") { |f| + File.open(path, "rb") do |f| FileLineData.file = path # For error reporting # Read a whole section's lines at once, then run through this code. # contents is a hash containing all the XXX=YYY lines in that section, where # the keys are the XXX and the values are the YYY (as unprocessed strings). idx = 0 - pbEachFileSection(f) { |contents, section_name| + pbEachFileSection(f) do |contents, section_name| echo "." if idx % 50 == 0 Graphics.update if idx % 250 == 0 idx += 1 @@ -1100,8 +1100,8 @@ module Compiler else GameData::PlayerMetadata.register(data_hash) end - } - } + end + end process_pbs_file_message_end end validate_all_compiled_metadata @@ -1131,7 +1131,7 @@ module Compiler end # Get storage creator's name for translating storage_creator = [GameData::Metadata.get.real_storage_creator] - MessageTypes.setMessagesAsHash(MessageTypes::StorageCreator, storage_creator) + MessageTypes.setMessagesAsHash(MessageTypes::STORAGE_CREATOR_NAME, storage_creator) end #============================================================================= @@ -1154,7 +1154,7 @@ module Compiler # Get map names for translating map_names = [] GameData::MapMetadata.each { |map| map_names[map.id] = map.real_name } - MessageTypes.setMessagesAsHash(MessageTypes::MapNames, map_names) + MessageTypes.setMessagesAsHash(MessageTypes::MAP_NAMES, map_names) end #============================================================================= @@ -1232,7 +1232,7 @@ module Compiler msgs.each { |msg| messages.push(msg) } end end - MessageTypes.setMessagesAsHash(MessageTypes::PhoneMessages, messages) + MessageTypes.setMessagesAsHash(MessageTypes::PHONE_MESSAGES, messages) end #============================================================================= @@ -1247,20 +1247,18 @@ module Compiler end changed = false move2anim = [{}, {}] -=begin - anims = load_data("Data/Animations.rxdata") - for anim in anims - next if !anim || anim.frames.length==1 - found = false - for i in 0...pbanims.length - if pbanims[i] && pbanims[i].id==anim.id - found = true if pbanims[i].array.length>1 - break - end - end - pbanims[anim.id] = pbConvertRPGAnimation(anim) if !found - end -=end +# anims = load_data("Data/Animations.rxdata") +# for anim in anims +# next if !anim || anim.frames.length == 1 +# found = false +# for i in 0...pbanims.length +# if pbanims[i] && pbanims[i].id == anim.id +# found = true if pbanims[i].array.length > 1 +# break +# end +# end +# pbanims[anim.id] = pbConvertRPGAnimation(anim) if !found +# end pbanims.length.times do |i| next if !pbanims[i] if pbanims[i].name[/^OppMove\:\s*(.*)$/] diff --git a/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb b/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb index 0dac52b56..e09bc34f3 100644 --- a/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb +++ b/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb @@ -26,7 +26,7 @@ module Compiler idx = 0 paths.each do |path| write_pbs_file_message_start(path[0]) - File.open(path[0], "wb") { |f| + File.open(path[0], "wb") do |f| add_PBS_header_to_file(f) # Write each element in turn game_data.each do |element| @@ -59,7 +59,7 @@ module Compiler end end end - } + end process_pbs_file_message_end end end @@ -107,7 +107,7 @@ module Compiler return if !conndata write_pbs_file_message_start(path) mapinfos = pbLoadMapInfos - File.open(path, "wb") { |f| + File.open(path, "wb") do |f| add_PBS_header_to_file(f) f.write("\#-------------------------------\r\n") conndata.each do |conn| @@ -127,7 +127,7 @@ module Compiler end f.write("\r\n") end - } + end process_pbs_file_message_end end @@ -184,7 +184,7 @@ module Compiler idx = 0 paths.each do |path| write_pbs_file_message_start(path[0]) - File.open(path[0], "wb") { |f| + File.open(path[0], "wb") do |f| add_PBS_header_to_file(f) # Write each element in turn GameData::Species.each_species do |element| @@ -217,7 +217,7 @@ module Compiler end end end - } + end process_pbs_file_message_end end end @@ -243,7 +243,7 @@ module Compiler idx = 0 paths.each do |path| write_pbs_file_message_start(path[0]) - File.open(path[0], "wb") { |f| + File.open(path[0], "wb") do |f| add_PBS_header_to_file(f) # Write each element in turn GameData::Species.each do |element| @@ -277,7 +277,7 @@ module Compiler end end end - } + end process_pbs_file_message_end end end @@ -304,7 +304,7 @@ module Compiler idx = 0 paths.each do |path| write_pbs_file_message_start(path[0]) - File.open(path[0], "wb") { |f| + File.open(path[0], "wb") do |f| add_PBS_header_to_file(f) # Write each element in turn GameData::SpeciesMetrics.each do |element| @@ -345,7 +345,7 @@ module Compiler end end end - } + end process_pbs_file_message_end end end @@ -364,7 +364,7 @@ module Compiler def write_regional_dexes(path = "PBS/regional_dexes.txt") write_pbs_file_message_start(path) dex_lists = pbLoadRegionalDexes - File.open(path, "wb") { |f| + File.open(path, "wb") do |f| add_PBS_header_to_file(f) # Write each Dex list in turn dex_lists.each_with_index do |list, index| @@ -386,7 +386,7 @@ module Compiler end f.write("\r\n") end - } + end process_pbs_file_message_end end @@ -406,7 +406,7 @@ module Compiler idx = 0 paths.each do |path| write_pbs_file_message_start(path[0]) - File.open(path[0], "wb") { |f| + File.open(path[0], "wb") do |f| add_PBS_header_to_file(f) GameData::Encounter.each do |element| next if element.pbs_file_suffix != path[1] @@ -436,7 +436,7 @@ module Compiler end end end - } + end process_pbs_file_message_end end end @@ -458,7 +458,7 @@ module Compiler idx = 0 paths.each do |path| write_pbs_file_message_start(path[0]) - File.open(path[0], "wb") { |f| + File.open(path[0], "wb") do |f| add_PBS_header_to_file(f) # Write each element in turn GameData::Trainer.each do |element| @@ -500,7 +500,7 @@ module Compiler end end end - } + end process_pbs_file_message_end end end @@ -512,7 +512,7 @@ module Compiler trainerlists = load_data("Data/trainer_lists.dat") rescue nil return if !trainerlists write_pbs_file_message_start(path) - File.open(path, "wb") { |f| + File.open(path, "wb") do |f| add_PBS_header_to_file(f) trainerlists.each do |tr| echo "." @@ -524,7 +524,7 @@ module Compiler write_battle_tower_trainers(tr[0], "PBS/" + tr[3]) write_battle_tower_pokemon(tr[1], "PBS/" + tr[4]) end - } + end process_pbs_file_message_end end @@ -541,7 +541,7 @@ module Compiler "EndSpeechLose" => [4, "s"], "PokemonNos" => [5, "*u"] } - File.open(filename, "wb") { |f| + File.open(filename, "wb") do |f| add_PBS_header_to_file(f) bttrainers.length.times do |i| next if !bttrainers[i] @@ -563,7 +563,7 @@ module Compiler f.write(sprintf("\r\n")) end end - } + end Graphics.update end @@ -584,7 +584,7 @@ module Compiler :SPECIAL_DEFENSE => "SD", :SPEED => "SPD" } - File.open(filename, "wb") { |f| + File.open(filename, "wb") do |f| add_PBS_header_to_file(f) f.write("\#-------------------------------\r\n") btpokemon.length.times do |i| @@ -597,15 +597,15 @@ module Compiler end c3 = (natures[pkmn.nature]) ? natures[pkmn.nature] : (natures[pkmn.nature] = GameData::Nature.get(pkmn.nature).id.to_s) evlist = "" - pkmn.ev.each_with_index do |stat, i| - evlist += "," if i > 0 + pkmn.ev.each_with_index do |stat, j| + evlist += "," if j > 0 evlist += evs[stat] end c4 = c5 = c6 = c7 = "" - [pkmn.move1, pkmn.move2, pkmn.move3, pkmn.move4].each_with_index do |move, i| + [pkmn.move1, pkmn.move2, pkmn.move3, pkmn.move4].each_with_index do |move, j| next if !move text = (moves[move]) ? moves[move] : (moves[move] = GameData::Move.get(move).id.to_s) - case i + case j when 0 then c4 = text when 1 then c5 = text when 2 then c6 = text @@ -614,7 +614,7 @@ module Compiler end f.write("#{c1};#{c2};#{c3};#{evlist};#{c4},#{c5},#{c6},#{c7}\r\n") end - } + end Graphics.update end @@ -641,7 +641,7 @@ module Compiler player_schema = GameData::PlayerMetadata.schema paths.each do |path| write_pbs_file_message_start(path[0]) - File.open(path[0], "wb") { |f| + File.open(path[0], "wb") do |f| add_PBS_header_to_file(f) # Write each element in turn [GameData::Metadata, GameData::PlayerMetadata].each do |game_data| @@ -675,7 +675,7 @@ module Compiler end end end - } + end process_pbs_file_message_end end end @@ -692,7 +692,7 @@ module Compiler idx = 0 paths.each do |path| write_pbs_file_message_start(path[0]) - File.open(path[0], "wb") { |f| + File.open(path[0], "wb") do |f| add_PBS_header_to_file(f) GameData::MapMetadata.each do |element| next if element.pbs_file_suffix != path[1] @@ -721,7 +721,7 @@ module Compiler end end end - } + end process_pbs_file_message_end end end @@ -737,7 +737,7 @@ module Compiler tilesets = load_data("Data/Tilesets.rxdata") paths.each do |path| write_pbs_file_message_start(path[0]) - File.open(path[0], "wb") { |f| + File.open(path[0], "wb") do |f| add_PBS_header_to_file(f) # Write each element in turn GameData::DungeonTileset.each do |element| @@ -769,7 +769,7 @@ module Compiler end end end - } + end process_pbs_file_message_end end end diff --git a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb index ecf2107be..ca55008df 100644 --- a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb +++ b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb @@ -46,12 +46,12 @@ module Compiler return false if !$DEBUG mapfiles = {} # Get IDs of all maps in the Data folder - Dir.chdir("Data") { + Dir.chdir("Data") do mapData = sprintf("Map*.rxdata") Dir.glob(mapData).each do |map| mapfiles[$1.to_i(10)] = true if map[/map(\d+)\.rxdata/i] end - } + end mapinfos = pbLoadMapInfos maxOrder = 0 # Exclude maps found in mapinfos @@ -93,19 +93,19 @@ module Compiler i = 0 while i < commands.length case commands[i] - when PBMoveRoute::Wait, PBMoveRoute::SwitchOn, PBMoveRoute::SwitchOff, - PBMoveRoute::ChangeSpeed, PBMoveRoute::ChangeFreq, PBMoveRoute::Opacity, - PBMoveRoute::Blending, PBMoveRoute::PlaySE, PBMoveRoute::Script + when PBMoveRoute::WAIT, PBMoveRoute::SWITCH_ON, PBMoveRoute::SWITCH_OFF, + PBMoveRoute::CHANGE_SPEED, PBMoveRoute::CHANGE_FREQUENCY, PBMoveRoute::OPACITY, + PBMoveRoute::BLENDING, PBMoveRoute::PLAY_SE, PBMoveRoute::SCRIPT route.list.push(RPG::MoveCommand.new(commands[i], [commands[i + 1]])) i += 1 - when PBMoveRoute::ScriptAsync - route.list.push(RPG::MoveCommand.new(PBMoveRoute::Script, [commands[i + 1]])) - route.list.push(RPG::MoveCommand.new(PBMoveRoute::Wait, [0])) + when PBMoveRoute::SCRIPT_ASYNC + route.list.push(RPG::MoveCommand.new(PBMoveRoute::SCRIPT, [commands[i + 1]])) + route.list.push(RPG::MoveCommand.new(PBMoveRoute::WAIT, [0])) i += 1 - when PBMoveRoute::Jump + when PBMoveRoute::JUMP route.list.push(RPG::MoveCommand.new(commands[i], [commands[i + 1], commands[i + 2]])) i += 2 - when PBMoveRoute::Graphic + when PBMoveRoute::GRAPHIC route.list.push(RPG::MoveCommand.new(commands[i], [commands[i + 1], commands[i + 2], commands[i + 3], commands[i + 4]])) i += 4 else @@ -241,7 +241,7 @@ module Compiler push_event(list, 208, [0], 1) # Change Transparent Flag push_wait(list, 6, 1) # Wait push_event(list, 208, [1], 1) # Change Transparent Flag - push_move_route_and_wait(list, -1, [PBMoveRoute::Down], 1) + push_move_route_and_wait(list, -1, [PBMoveRoute::DOWN], 1) push_branch_end(list, 1) push_script(list, "setTempSwitchOn(\"A\")") push_end(list) @@ -647,9 +647,10 @@ module Compiler (1...battles.length).each do |i| # Run trainer check now, except in editor trainerChecker.pbTrainerBattleCheck(trtype, trname, battleid + i) - if i == 1 + case i + when 1 push_branch(rematchpage.list, sprintf("Phone.variant(%s) <= %d", safetrcombo, i)) - elsif i == battles.length - 1 + when battles.length - 1 push_branch(rematchpage.list, sprintf("Phone.variant(%s) >= %d", safetrcombo, i)) else push_branch(rematchpage.list, sprintf("Phone.variant(%s) == %d", safetrcombo, i)) @@ -837,24 +838,24 @@ module Compiler list.clear push_move_route_and_wait( # Move Route for door opening list, 0, - [PBMoveRoute::PlaySE, RPG::AudioFile.new("Door enter"), PBMoveRoute::Wait, 2, - PBMoveRoute::TurnLeft, PBMoveRoute::Wait, 2, - PBMoveRoute::TurnRight, PBMoveRoute::Wait, 2, - PBMoveRoute::TurnUp, PBMoveRoute::Wait, 2] + [PBMoveRoute::PLAY_SE, RPG::AudioFile.new("Door enter"), PBMoveRoute::WAIT, 2, + PBMoveRoute::TURN_LEFT, PBMoveRoute::WAIT, 2, + PBMoveRoute::TURN_RIGHT, PBMoveRoute::WAIT, 2, + PBMoveRoute::TURN_UP, PBMoveRoute::WAIT, 2] ) push_move_route_and_wait( # Move Route for player entering door list, -1, - [PBMoveRoute::ThroughOn, PBMoveRoute::Up, PBMoveRoute::ThroughOff] + [PBMoveRoute::THROUGH_ON, PBMoveRoute::UP, PBMoveRoute::THROUGH_OFF] ) push_event(list, 208, [0]) # Change Transparent Flag (invisible) push_script(list, "Followers.follow_into_door") push_event(list, 210, []) # Wait for Move's Completion push_move_route_and_wait( # Move Route for door closing list, 0, - [PBMoveRoute::Wait, 2, - PBMoveRoute::TurnRight, PBMoveRoute::Wait, 2, - PBMoveRoute::TurnLeft, PBMoveRoute::Wait, 2, - PBMoveRoute::TurnDown, PBMoveRoute::Wait, 2] + [PBMoveRoute::WAIT, 2, + PBMoveRoute::TURN_RIGHT, PBMoveRoute::WAIT, 2, + PBMoveRoute::TURN_LEFT, PBMoveRoute::WAIT, 2, + PBMoveRoute::TURN_DOWN, PBMoveRoute::WAIT, 2] ) push_event(list, 223, [Tone.new(-255, -255, -255), 6]) # Change Screen Color Tone push_wait(list, 8) # Wait @@ -870,17 +871,17 @@ module Compiler push_script(list, "Followers.hide_followers", 1) push_move_route_and_wait( # Move Route for setting door to open list, 0, - [PBMoveRoute::TurnLeft, PBMoveRoute::Wait, 6], + [PBMoveRoute::TURN_LEFT, PBMoveRoute::WAIT, 6], 1 ) push_event(list, 208, [1], 1) # Change Transparent Flag (visible) - push_move_route_and_wait(list, -1, [PBMoveRoute::Down], 1) # Move Route for player exiting door + push_move_route_and_wait(list, -1, [PBMoveRoute::DOWN], 1) # Move Route for player exiting door push_script(list, "Followers.put_followers_on_player", 1) push_move_route_and_wait( # Move Route for door closing list, 0, - [PBMoveRoute::TurnUp, PBMoveRoute::Wait, 2, - PBMoveRoute::TurnRight, PBMoveRoute::Wait, 2, - PBMoveRoute::TurnDown, PBMoveRoute::Wait, 2], + [PBMoveRoute::TURN_UP, PBMoveRoute::WAIT, 2, + PBMoveRoute::TURN_RIGHT, PBMoveRoute::WAIT, 2, + PBMoveRoute::TURN_DOWN, PBMoveRoute::WAIT, 2], 1 ) push_branch_end(list, 1) @@ -1163,17 +1164,13 @@ module Compiler # Using old method of recovering case script when "foriin$player.partyi.healend" - (i..lastScript).each do |j| - list.delete_at(i) - end + (lastScript - i).times { list.delete_at(i) } list.insert(i, RPG::EventCommand.new(314, list[i].indent, [0])) # Recover All changed = true when "pbFadeOutIn(99999){foriin$player.partyi.healend}" oldIndent = list[i].indent - (i..lastScript).each do |j| - list.delete_at(i) - end + (lastScript - i).times { list.delete_at(i) } list.insert( i, RPG::EventCommand.new(223, oldIndent, [Tone.new(-255, -255, -255), 6]), # Fade to black