From 681a8331abbf68c59840277bd41a15e1315a3d2f Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sun, 6 Sep 2020 17:31:12 +0100 Subject: [PATCH] Resolved many Rubocop warnings --- .../001_Technical/002_RGSS2Compatibility.rb | 90 ++++------- Data/Scripts/001_Technical/003_RPG__Sprite.rb | 6 +- Data/Scripts/001_Technical/004_Win32API.rb | 12 +- .../Scripts/001_Technical/006_DebugConsole.rb | 4 +- .../001_Technical/007_Sprite_Resizer.rb | 20 +-- .../003_Game classes/005_Game_Character.rb | 4 +- .../003_Game classes/007_Game_Player.rb | 3 - Data/Scripts/003_Game classes/009_Game_Map.rb | 4 +- .../004_Sprites/007_Spriteset_Global.rb | 14 +- .../Scripts/004_Sprites/010_ParticleEngine.rb | 3 +- .../005_Map renderer/001_Tilemap_XP.rb | 57 +++---- .../002_Tilemap_Perspective.rb | 12 +- .../005_Map renderer/003_Tilemap_Original.rb | 1 - .../005_Map renderer/005_TileDrawingHelper.rb | 56 +++---- .../006_Game processing/001_Interpreter.rb | 16 +- .../007_Events and files/001_FileTests.rb | 16 +- .../007_Events and files/002_File_Mixins.rb | 101 +++++------- .../007_Events and files/003_Intl_Messages.rb | 11 +- Data/Scripts/008_Audio/001_Audio.rb | 4 +- Data/Scripts/008_Audio/002_Audio_Play.rb | 2 +- Data/Scripts/008_Audio/003_Audio_Utilities.rb | 73 ++++----- .../001_BitmapCache.rb | 14 +- .../003_SpriteWindow.rb | 4 +- .../004_SpriteWindow_text.rb | 39 ++--- .../005_SpriteWindow_sprites.rb | 14 +- .../009_Objects and windows/006_DrawText.rb | 41 ++--- .../009_Objects and windows/007_Messages.rb | 27 ++-- .../009_Objects and windows/008_TextEntry.rb | 151 +++++++----------- Data/Scripts/010_Scenes/001_Transitions.rb | 1 - Data/Scripts/010_Scenes/002_EventScene.rb | 1 - Data/Scripts/010_Scenes/003_Scene_Intro.rb | 10 +- Data/Scripts/010_Scenes/004_Scene_Controls.rb | 36 ++--- Data/Scripts/010_Scenes/005_Scene_Credits.rb | 1 - Data/Scripts/010_Scenes/006_Scene_Movie.rb | 4 +- Data/Scripts/011_Data/002_PBMove.rb | 4 +- Data/Scripts/011_Data/003_PBStatuses.rb | 15 +- Data/Scripts/011_Data/007_PBExperience.rb | 10 +- Data/Scripts/011_Data/010_PBEggGroups.rb | 30 ++-- Data/Scripts/011_Data/011_PBColors.rb | 20 +-- Data/Scripts/011_Data/012_PBHabitats.rb | 20 +-- .../001_Battler/001_PokeBattle_Battler.rb | 1 - .../001_Battler/003_Battler_ChangeSelf.rb | 1 - .../001_Battler/004_Battler_Statuses.rb | 2 +- .../001_Battler/006_Battler_AbilityAndItem.rb | 2 +- .../001_Battler/007_Battler_UseMove.rb | 7 +- .../008_Battler_UseMove_Targeting.rb | 6 +- .../009_Battler_UseMove_SuccessChecks.rb | 2 +- .../002_Move/001_PokeBattle_Move.rb | 6 +- .../012_Battle/002_Move/002_Move_Usage.rb | 6 +- .../002_Move/006_Move_Effects_080-0FF.rb | 14 +- .../002_Move/007_Move_Effects_100-17F.rb | 2 +- .../003_Battle/002_PokeBattle_Battle.rb | 14 +- .../003_Battle/003_Battle_StartAndEnd.rb | 8 +- .../004_Battle_ExpAndMoveLearning.rb | 1 - .../003_Battle/006_Battle_Action_Switching.rb | 4 +- .../003_Battle/010_Battle_Phase_Command.rb | 2 +- .../003_Battle/012_Battle_Phase_EndOfRound.rb | 4 +- .../012_Battle/004_AI/003_AI_Switch.rb | 2 +- Data/Scripts/012_Battle/004_AI/004_AI_Move.rb | 5 +- .../004_AI/006_AI_Move_Utilities.rb | 10 +- .../002_PokeBattle_SceneAnimations.rb | 12 +- .../005_Battle scene/006_PokeBattle_Scene.rb | 2 +- .../005_Battle scene/008_Scene_Commands.rb | 7 +- .../005_Battle scene/009_Scene_Animations.rb | 4 +- .../001_PokeBattle_AnimationPlayer.rb | 12 +- .../002_PokeBattle_SafariZone.rb | 7 +- .../003_PokeBattle_BugContest.rb | 6 +- .../004_PokeBattle_BattlePalace.rb | 4 +- .../005_PokeBattle_BattleArena.rb | 3 +- .../006_PokeBattle_BattleRecord.rb | 4 +- .../007_PokeBattle_DebugScene.rb | 4 +- .../007_BattleHandlers_Abilities.rb | 2 +- .../Scripts/013_Overworld/002_PField_Field.rb | 39 ++--- .../013_Overworld/003_PField_Visuals.rb | 3 +- .../013_Overworld/004_PField_Weather.rb | 4 +- .../013_Overworld/005_PField_Metadata.rb | 2 +- .../013_Overworld/006_PField_Battles.rb | 4 +- .../013_Overworld/007_PField_Encounters.rb | 3 +- .../008_PField_EncounterModifiers.rb | 18 +-- .../009_PField_RoamingPokemon.rb | 9 +- .../010_PField_RandomDungeons.rb | 31 ++-- .../013_Overworld/011_PField_FieldMoves.rb | 21 +-- .../013_Overworld/012_PField_BerryPlants.rb | 4 +- .../013_Overworld/013_PField_DayCare.rb | 6 +- .../014_PField_DependentEvents.rb | 15 +- Data/Scripts/013_Overworld/015_PField_Time.rb | 4 +- .../014_Trainers/001_PokeBattle_Trainer.rb | 38 +++-- .../014_Trainers/002_PTrainer_NPCTrainers.rb | 7 +- Data/Scripts/015_Items/001_PItem_Items.rb | 7 +- Data/Scripts/015_Items/004_PItem_Phone.rb | 5 +- Data/Scripts/015_Items/005_PItem_PokeRadar.rb | 10 +- Data/Scripts/015_Items/006_PItem_Mail.rb | 7 +- Data/Scripts/015_Items/008_PItem_Bag.rb | 10 -- .../016_Pokemon/001_PokeBattle_Pokemon.rb | 37 +++-- Data/Scripts/016_Pokemon/002_Pokemon_Forms.rb | 3 +- .../016_Pokemon/004_Pokemon_ShadowPokemon.rb | 13 +- .../016_Pokemon/006_Pokemon_Chatter.rb | 2 +- .../016_Pokemon/008_Pokemon_Storage.rb | 2 +- .../Scripts/017_UI/003_PScreen_PokedexMain.rb | 11 +- Data/Scripts/017_UI/005_PScreen_Party.rb | 8 +- Data/Scripts/017_UI/006_PScreen_Summary.rb | 9 +- Data/Scripts/017_UI/007_PScreen_Bag.rb | 6 +- Data/Scripts/017_UI/010_PScreen_Phone.rb | 2 +- Data/Scripts/017_UI/013_PScreen_Load.rb | 8 +- Data/Scripts/017_UI/014_PScreen_Save.rb | 1 - Data/Scripts/017_UI/015_PScreen_Options.rb | 19 ++- .../017_UI/017_PScreen_PokemonStorage.rb | 32 ++-- .../Scripts/017_UI/018_PScreen_ItemStorage.rb | 2 +- Data/Scripts/017_UI/019_PScreen_PC.rb | 6 +- .../Scripts/017_UI/020_PScreen_EggHatching.rb | 5 +- Data/Scripts/017_UI/021_PScreen_Evolution.rb | 9 +- .../017_UI/023_PScreen_MoveRelearner.rb | 3 +- .../017_UI/024_PScreen_PurifyChamber.rb | 148 +++++++++-------- Data/Scripts/017_UI/025_PScreen_Mart.rb | 22 +-- .../Scripts/017_UI/026_PScreen_MysteryGift.rb | 22 ++- Data/Scripts/017_UI/027_PScreen_HallOfFame.rb | 10 +- .../019_Other battles/001_PBattle_Safari.rb | 6 +- .../002_PBattle_BugContest.rb | 12 +- .../003_PBattle_OrgBattle.rb | 24 +-- .../004_PBattle_OrgBattleRules.rb | 16 +- .../005_PBattle_OrgBattleGenerator.rb | 79 +++++---- .../006_PBattle_BattleSwap.rb | 2 +- .../003_PSystem_FileUtilities.rb | 2 +- .../004_PSystem_PokemonUtilities.rb | 2 +- .../005_PSystem_Utilities.rb | 8 +- Data/Scripts/021_Debug/001_Debug_Menu.rb | 1 - Data/Scripts/021_Debug/002_Debug_Actions.rb | 10 +- Data/Scripts/021_Debug/004_Editor_Screens.rb | 7 +- .../Scripts/021_Debug/006_Editor_DataTypes.rb | 45 +++--- .../Scripts/021_Debug/008_Editor_Utilities.rb | 7 +- .../021_Debug/009_Editor_TilesetEditor.rb | 10 +- .../010_Editor_MapConnectionEditor.rb | 3 +- .../021_Debug/011_Editor_SpritePosEditor.rb | 1 - .../012_Editor_BattleAnimationEditor.rb | 28 +--- Data/Scripts/022_Compiler/001_Compiler.rb | 32 ++-- Data/Scripts/022_Compiler/002_Compiler_PBS.rb | 30 ++-- .../003_Compiler_MapsAndEvents.rb | 52 +++--- 137 files changed, 921 insertions(+), 1200 deletions(-) diff --git a/Data/Scripts/001_Technical/002_RGSS2Compatibility.rb b/Data/Scripts/001_Technical/002_RGSS2Compatibility.rb index 59068dc49..17ffc64c8 100644 --- a/Data/Scripts/001_Technical/002_RGSS2Compatibility.rb +++ b/Data/Scripts/001_Technical/002_RGSS2Compatibility.rb @@ -4,8 +4,9 @@ $scene = nil Font.default_shadow = false if Font.respond_to?(:default_shadow) Graphics.frame_rate = 40 - - +#=============================================================================== +# +#=============================================================================== =begin class Win32API class << self @@ -14,9 +15,9 @@ class Win32API end def new(*args) - File.open("winapi.txt","ab") { |f| f.write("new(#{args[0]},#{args[1]})\r\n") } - b=debug_new(*args) - b.setDllName(args[0],args[1]) + File.open("winapi.txt", "ab") { |f| f.write("new(#{args[0]},#{args[1]})\r\n") } + b = debug_new(*args) + b.setDllName(args[0], args[1]) return b end end @@ -26,13 +27,13 @@ class Win32API end def setDllName(a,b) - @w32dll=a - @w32name=b + @w32dll = a + @w32name = b end def call(*args) - if @w32name!="GetAsyncKeyState" - File.open("winapi.txt","ab") { |f| + if @w32name != "GetAsyncKeyState" + File.open("winapi.txt", "ab") { |f| f.write("call(#{@w32dll},#{@w32name},#{args.inspect})\r\n") } end @@ -47,8 +48,8 @@ class Bitmap end def new(*args) - if args.length==1 - File.open("winapib.txt","ab") { |f| f.write("new(#{args[0]})\r\n") } + if args.length == 1 + File.open("winapib.txt", "ab") { |f| f.write("new(#{args[0]})\r\n") } end debug_new(*args) end @@ -58,31 +59,28 @@ end alias debug_load_data load_data def load_data(*args) - File.open("winapif.txt","ab") { |f| f.write("load(#{args[0]})\r\n") } + File.open("winapif.txt", "ab") { |f| f.write("load(#{args[0]})\r\n") } debug_load_data(*args) end =end - - class Hangup < Exception; end - - if false - p (Tilemap.instance_methods-Kernel.instance_methods-Object.instance_methods).sort -# no changes - p (Plane.instance_methods-Kernel.instance_methods-Object.instance_methods).sort -# no changes - p (Viewport.instance_methods-Kernel.instance_methods-Object.instance_methods).sort - p (Bitmap.instance_methods-Kernel.instance_methods-Object.instance_methods).sort -# openness(=) - p (Window.instance_methods-Kernel.instance_methods-Object.instance_methods).sort - p (Sprite.instance_methods-Kernel.instance_methods-Object.instance_methods).sort + p (Tilemap.instance_methods - Kernel.instance_methods - Object.instance_methods).sort + # no changes + p (Plane.instance_methods - Kernel.instance_methods - Object.instance_methods).sort + # no changes + p (Viewport.instance_methods - Kernel.instance_methods - Object.instance_methods).sort + p (Bitmap.instance_methods - Kernel.instance_methods - Object.instance_methods).sort + # openness(=) + p (Window.instance_methods - Kernel.instance_methods - Object.instance_methods).sort + p (Sprite.instance_methods - Kernel.instance_methods - Object.instance_methods).sort end - - +#=============================================================================== +# +#=============================================================================== module RPG class Animation attr_accessor :id @@ -107,8 +105,6 @@ module RPG end end - - module RPG class Animation class Frame @@ -123,8 +119,6 @@ module RPG end end - - module RPG class Animation class Timing @@ -139,7 +133,7 @@ module RPG @frame = 0 @se = RPG::AudioFile.new("", 80) @flash_scope = 0 - @flash_color = Color.new(255,255,255,255) + @flash_color = Color.new(255, 255, 255, 255) @flash_duration = 5 @condition = 0 end @@ -147,8 +141,6 @@ module RPG end end - - module RPG class System attr_accessor :magic_number @@ -227,8 +219,6 @@ module RPG end end - - module RPG class Tileset attr_accessor :id @@ -253,7 +243,7 @@ module RPG @id = 0 @name = "" @tileset_name = "" - @autotile_names = [""]*7 + @autotile_names = [""] * 7 @panorama_name = "" @panorama_hue = 0 @fog_name = "" @@ -272,8 +262,6 @@ module RPG end end - - module RPG class CommonEvent attr_accessor :id @@ -292,8 +280,6 @@ module RPG end end - - module RPG class Map attr_accessor :tileset_id @@ -324,8 +310,6 @@ module RPG end end - - module RPG class MapInfo attr_accessor :name @@ -346,8 +330,6 @@ module RPG end end - - module RPG class Event attr_accessor :id @@ -366,8 +348,6 @@ module RPG end end - - module RPG class Event class Page @@ -404,8 +384,6 @@ module RPG end end - - module RPG class Event class Page @@ -436,8 +414,6 @@ module RPG end end - - module RPG class Event class Page @@ -464,8 +440,6 @@ module RPG end end - - module RPG class EventCommand attr_accessor :code @@ -480,8 +454,6 @@ module RPG end end - - module RPG class MoveRoute attr_accessor :repeat @@ -496,8 +468,6 @@ module RPG end end - - module RPG class MoveCommand attr_accessor :code @@ -510,8 +480,6 @@ module RPG end end - - module RPG class System class Words @@ -562,8 +530,6 @@ module RPG end end - - module RPG class System class TestBattler @@ -588,8 +554,6 @@ module RPG end end - - module RPG class AudioFile attr_accessor :name diff --git a/Data/Scripts/001_Technical/003_RPG__Sprite.rb b/Data/Scripts/001_Technical/003_RPG__Sprite.rb index f40b815dd..e719bb11a 100644 --- a/Data/Scripts/001_Technical/003_RPG__Sprite.rb +++ b/Data/Scripts/001_Technical/003_RPG__Sprite.rb @@ -8,7 +8,7 @@ class SpriteAnimation %w[ x y ox oy viewport flash src_rect opacity tone - ].each_with_index do |s, i| + ].each_with_index do |s, _i| eval <<-__END__ def #{s}(*arg) @@ -49,7 +49,7 @@ class SpriteAnimation end @_animation_sprites = [] if @_animation.position != 3 or not @@_animations.include?(animation) - for i in 0..15 + 16.times do sprite = ::Sprite.new(self.viewport) sprite.bitmap = bitmap sprite.visible = false @@ -82,7 +82,7 @@ class SpriteAnimation @@_reference_count[bitmap] = 1 end @_loop_animation_sprites = [] - for i in 0..15 + 16.times do sprite = ::Sprite.new(self.viewport) sprite.bitmap = bitmap sprite.visible = false diff --git a/Data/Scripts/001_Technical/004_Win32API.rb b/Data/Scripts/001_Technical/004_Win32API.rb index 8bfbeec65..706ec6e54 100644 --- a/Data/Scripts/001_Technical/004_Win32API.rb +++ b/Data/Scripts/001_Technical/004_Win32API.rb @@ -1,8 +1,8 @@ class Win32API @@RGSSWINDOW = nil - @@GetCurrentThreadId = Win32API.new('kernel32','GetCurrentThreadId', '%w()','l') - @@GetWindowThreadProcessId = Win32API.new('user32','GetWindowThreadProcessId', '%w(l p)','l') - @@FindWindowEx = Win32API.new('user32','FindWindowEx', '%w(l l p p)','l') + @@GetCurrentThreadId = Win32API.new('kernel32', 'GetCurrentThreadId', '%w()', 'l') + @@GetWindowThreadProcessId = Win32API.new('user32', 'GetWindowThreadProcessId', '%w(l p)', 'l') + @@FindWindowEx = Win32API.new('user32', 'FindWindowEx', '%w(l l p p)', 'l') def Win32API.SetWindowText(text) hWnd = pbFindRgssWindow @@ -16,7 +16,7 @@ class Win32API processid = [0].pack('l') threadid = @@GetCurrentThreadId.call nextwindow = 0 - begin + loop do nextwindow = @@FindWindowEx.call(0,nextwindow,"RGSS Player",0) if nextwindow!=0 wndthreadid = @@GetWindowThreadProcessId.call(nextwindow,processid) @@ -25,9 +25,9 @@ class Win32API return @@RGSSWINDOW end end - end until nextwindow==0 + break if nextwindow==0 + end raise "Can't find RGSS player window" - return 0 end def Win32API.SetWindowPos(w, h) diff --git a/Data/Scripts/001_Technical/006_DebugConsole.rb b/Data/Scripts/001_Technical/006_DebugConsole.rb index df28b3449..0c20df963 100644 --- a/Data/Scripts/001_Technical/006_DebugConsole.rb +++ b/Data/Scripts/001_Technical/006_DebugConsole.rb @@ -48,7 +48,6 @@ module Console @apiSetConsoleTitle = Win32API.new("kernel32","SetConsoleTitle","p","s") access = (GENERIC_READ | GENERIC_WRITE) sharemode = (FILE_SHARE_READ | FILE_SHARE_WRITE) - returnCode = AllocConsole() @bufferHandle = CreateConsoleScreenBuffer(access,sharemode,CONSOLE_TEXTMODE_BUFFER) f = File.open("Game.ini") lines = f.readlines() @@ -94,7 +93,7 @@ module Console offset=0 events=eventsread.unpack("V") echo("got input [eventsread #{events}") - for i in 0...events[0] + events[0].length.times do keyevent=buffer[offset,20] keyevent=keyevent.unpack("vCvvvvV") if keyevent[0]==1 && keyevent[1]>0 @@ -121,7 +120,6 @@ module Console echo(sprintf("failed (%d)\r\n",getlast.call())) break end - offset=0 events=eventsread.unpack("V") if events[0]>0 echo("got input [eventsread #{events}][buffer #{buffer}]\r\n") diff --git a/Data/Scripts/001_Technical/007_Sprite_Resizer.rb b/Data/Scripts/001_Technical/007_Sprite_Resizer.rb index 093432493..75faefa04 100644 --- a/Data/Scripts/001_Technical/007_Sprite_Resizer.rb +++ b/Data/Scripts/001_Technical/007_Sprite_Resizer.rb @@ -157,7 +157,7 @@ module Graphics def self.wait(frames) return if frames<=0 - frames.times do |i| + frames.times do self.update end end @@ -675,16 +675,16 @@ class Bitmap end def swap32(x) - return ((x>>24)&0x000000FF)| - ((x>>8)&0x0000FF00)| - ((x<<8)&0x00FF0000)| - ((x<<24)&0xFF000000) + return ((x >> 24) & 0x000000FF) | + ((x >> 8) & 0x0000FF00) | + ((x << 8) & 0x00FF0000) | + ((x << 24) & 0xFF000000) end def asOpaque data=getData j=3 - for i in 0...width*height + (width*height).times do data[j]=0xFF j+=4 end @@ -705,7 +705,6 @@ class Bitmap row=(self.height-1)*bytesPerScan data=self.getData data2=data.clone - width=self.width x="" len=bytesPerScan*self.height ttt=Time.now @@ -713,13 +712,14 @@ class Bitmap SwapRgb.call(data2,data2.length) else # the following is considerably slower - b=0;c=2;while b!=len + b=0; c=2 + while b!=len data2[b]=data[c] data2[c]=data[b] - b+=4;c+=4; + b+=4; c+=4; end end - #$times.push(Time.now-ttt) +# $times.push(Time.now-ttt) filter="\0" while row>=0 thisRow=data2[row,bytesPerScan] diff --git a/Data/Scripts/003_Game classes/005_Game_Character.rb b/Data/Scripts/003_Game classes/005_Game_Character.rb index 617fa2d8a..8b895a858 100644 --- a/Data/Scripts/003_Game classes/005_Game_Character.rb +++ b/Data/Scripts/003_Game classes/005_Game_Character.rb @@ -22,7 +22,7 @@ class Game_Character attr_accessor :transparent attr_reader :move_speed attr_accessor :walk_anime - attr_accessor :bob_height + attr_writer :bob_height def initialize(map=nil) @map = map @@ -415,7 +415,7 @@ class Game_Character when 42; @opacity = command.parameters[0] when 43; @blend_type = command.parameters[0] when 44; pbSEPlay(command.parameters[0]) - when 45; result = eval(command.parameters[0]) + when 45; eval(command.parameters[0]) end @move_route_index += 1 end diff --git a/Data/Scripts/003_Game classes/007_Game_Player.rb b/Data/Scripts/003_Game classes/007_Game_Player.rb index dd61b6762..c1e50de57 100644 --- a/Data/Scripts/003_Game classes/007_Game_Player.rb +++ b/Data/Scripts/003_Game classes/007_Game_Player.rb @@ -225,8 +225,6 @@ class Game_Player < Game_Character def center(x, y) center_x = (Graphics.width/2 - Game_Map::TILE_WIDTH/2) * Game_Map::X_SUBPIXELS center_y = (Graphics.height/2 - Game_Map::TILE_HEIGHT/2) * Game_Map::Y_SUBPIXELS - max_x = (self.map.width - Graphics.width*1.0/Game_Map::TILE_WIDTH) * Game_Map::REAL_RES_X - max_y = (self.map.height - Graphics.height*1.0/Game_Map::TILE_HEIGHT) * Game_Map::REAL_RES_Y dispx = x * Game_Map::REAL_RES_X - center_x dispy = y * Game_Map::REAL_RES_Y - center_y self.map.display_x = dispx @@ -464,7 +462,6 @@ end def pbUpdateVehicle meta = pbGetMetadata(0,MetadataPlayerA+$PokemonGlobal.playerID) if meta - newCharName = nil charset = 1 # Regular graphic if $PokemonGlobal.diving; charset = 5 # Diving graphic elsif $PokemonGlobal.surfing; charset = 3 # Surfing graphic diff --git a/Data/Scripts/003_Game classes/009_Game_Map.rb b/Data/Scripts/003_Game classes/009_Game_Map.rb index cb9c8c490..6f19797e1 100644 --- a/Data/Scripts/003_Game classes/009_Game_Map.rb +++ b/Data/Scripts/003_Game classes/009_Game_Map.rb @@ -25,8 +25,8 @@ class Game_Map attr_reader :fog_oy # fog y-coordinate starting point attr_reader :fog_tone # fog color tone attr_accessor :battleback_name # battleback file name - attr_accessor :display_x # display x-coordinate * 128 - attr_accessor :display_y # display y-coordinate * 128 + attr_reader :display_x # display x-coordinate * 128 + attr_reader :display_y # display y-coordinate * 128 attr_accessor :need_refresh # refresh request flag TILE_WIDTH = 32 diff --git a/Data/Scripts/004_Sprites/007_Spriteset_Global.rb b/Data/Scripts/004_Sprites/007_Spriteset_Global.rb index 22b9fe9f7..cfd228787 100644 --- a/Data/Scripts/004_Sprites/007_Spriteset_Global.rb +++ b/Data/Scripts/004_Sprites/007_Spriteset_Global.rb @@ -1,13 +1,13 @@ class Spriteset_Global attr_reader :playersprite - @@viewport2 = Viewport.new(0,0,Graphics.width,Graphics.height) + @@viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height) @@viewport2.z = 200 def initialize - @playersprite = Sprite_Character.new(Spriteset_Map.viewport,$game_player) + @playersprite = Sprite_Character.new(Spriteset_Map.viewport, $game_player) @picture_sprites = [] for i in 1..100 - @picture_sprites.push(Sprite_Picture.new(@@viewport2,$game_screen.pictures[i])) + @picture_sprites.push(Sprite_Picture.new(@@viewport2, $game_screen.pictures[i])) end @timer_sprite = Sprite_Timer.new update @@ -15,9 +15,7 @@ class Spriteset_Global def dispose @playersprite.dispose - for sprite in @picture_sprites - sprite.dispose - end + @picture_sprites.each { |sprite| sprite.dispose } @timer_sprite.dispose @playersprite = nil @picture_sprites.clear @@ -26,9 +24,7 @@ class Spriteset_Global def update @playersprite.update - for sprite in @picture_sprites - sprite.update - end + @picture_sprites.each { |sprite| sprite.update } @timer_sprite.update end end diff --git a/Data/Scripts/004_Sprites/010_ParticleEngine.rb b/Data/Scripts/004_Sprites/010_ParticleEngine.rb index ce5b78c05..fca95b724 100644 --- a/Data/Scripts/004_Sprites/010_ParticleEngine.rb +++ b/Data/Scripts/004_Sprites/010_ParticleEngine.rb @@ -117,7 +117,8 @@ end class ParticleSprite - attr_accessor :x, :y, :z, :ox, :oy, :opacity, :bitmap, :blend_type + attr_accessor :x, :y, :z, :ox, :oy, :opacity, :blend_type + attr_reader :bitmap def initialize(viewport) @viewport = viewport diff --git a/Data/Scripts/005_Map renderer/001_Tilemap_XP.rb b/Data/Scripts/005_Map renderer/001_Tilemap_XP.rb index c56916963..477b064e0 100644 --- a/Data/Scripts/005_Map renderer/001_Tilemap_XP.rb +++ b/Data/Scripts/005_Map renderer/001_Tilemap_XP.rb @@ -41,24 +41,24 @@ class CustomTilemap attr_reader :viewport attr_reader :graphicsWidth attr_reader :graphicsHeight - attr_accessor :ox - attr_accessor :oy + attr_reader :ox + attr_reader :oy attr_accessor :tone attr_accessor :color Autotiles = [ - [ [27, 28, 33, 34], [ 5, 28, 33, 34], [27, 6, 33, 34], [ 5, 6, 33, 34], - [27, 28, 33, 12], [ 5, 28, 33, 12], [27, 6, 33, 12], [ 5, 6, 33, 12] ], - [ [27, 28, 11, 34], [ 5, 28, 11, 34], [27, 6, 11, 34], [ 5, 6, 11, 34], - [27, 28, 11, 12], [ 5, 28, 11, 12], [27, 6, 11, 12], [ 5, 6, 11, 12] ], - [ [25, 26, 31, 32], [25, 6, 31, 32], [25, 26, 31, 12], [25, 6, 31, 12], - [15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ], - [ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36], - [39, 40, 45, 46], [ 5, 40, 45, 46], [39, 6, 45, 46], [ 5, 6, 45, 46] ], - [ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12], - [17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ], - [ [37, 38, 43, 44], [37, 6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44], - [37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1, 2, 7, 8] ] + [ [27, 28, 33, 34], [ 5, 28, 33, 34], [27, 6, 33, 34], [ 5, 6, 33, 34], + [27, 28, 33, 12], [ 5, 28, 33, 12], [27, 6, 33, 12], [ 5, 6, 33, 12] ], + [ [27, 28, 11, 34], [ 5, 28, 11, 34], [27, 6, 11, 34], [ 5, 6, 11, 34], + [27, 28, 11, 12], [ 5, 28, 11, 12], [27, 6, 11, 12], [ 5, 6, 11, 12] ], + [ [25, 26, 31, 32], [25, 6, 31, 32], [25, 26, 31, 12], [25, 6, 31, 12], + [15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ], + [ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36], + [39, 40, 45, 46], [ 5, 40, 45, 46], [39, 6, 45, 46], [ 5, 6, 45, 46] ], + [ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12], + [17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ], + [ [37, 38, 43, 44], [37, 6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44], + [37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1, 2, 7, 8] ] ] Animated_Autotiles_Frames = 5*Graphics.frame_rate/20 # Frequency of updating animated autotiles FlashOpacity = [100,90,80,70,80,90] @@ -132,26 +132,30 @@ class CustomTilemap return if disposed? @help.dispose if @help @help = nil - i = 0; len = @autotileInfo.length; while i>2) @oyFlash = @oy-(height>>2) @@ -488,7 +491,8 @@ class CustomTilemap end def refresh_tileset - i = 0; len = @regularTileInfo.length; while i25 - j = count; len = @tiles.length; while j0 flashindex=@sprites.length-1 for j in 0...@numsprites @@ -249,8 +248,6 @@ class Draw_Tilemap # This class controls a set of sprites, with @doredraw=false elsif @oldOx==@ox && @oldOy==@oy return - elsif @oldOy==@oy - oyunchanged=true end @oldOx=@ox @oldOy=@oy @@ -274,7 +271,6 @@ class Draw_Tilemap # This class controls a set of sprites, with end vpy=@viewport.rect.y vpr=@viewport.rect.x+@viewport.rect.width - vpb=@viewport.rect.y+@viewport.rect.height numsprites=0 for i in @sprites numsprites+=i.compact.length diff --git a/Data/Scripts/005_Map renderer/003_Tilemap_Original.rb b/Data/Scripts/005_Map renderer/003_Tilemap_Original.rb index 3dddc6b58..1ee2bf736 100644 --- a/Data/Scripts/005_Map renderer/003_Tilemap_Original.rb +++ b/Data/Scripts/005_Map renderer/003_Tilemap_Original.rb @@ -57,7 +57,6 @@ class SynchronizedTilemapAutotilesInternal end def sync - frameused = [] for i in 0...7 frames = [1,@atframes[i].length].max frame = (Graphics.frame_count/15)%frames diff --git a/Data/Scripts/005_Map renderer/005_TileDrawingHelper.rb b/Data/Scripts/005_Map renderer/005_TileDrawingHelper.rb index c5c700482..b881a1fe5 100644 --- a/Data/Scripts/005_Map renderer/005_TileDrawingHelper.rb +++ b/Data/Scripts/005_Map renderer/005_TileDrawingHelper.rb @@ -3,38 +3,38 @@ class TileDrawingHelper attr_accessor :autotiles Autotiles = [ - [ [27, 28, 33, 34], [ 5, 28, 33, 34], [27, 6, 33, 34], [ 5, 6, 33, 34], - [27, 28, 33, 12], [ 5, 28, 33, 12], [27, 6, 33, 12], [ 5, 6, 33, 12] ], - [ [27, 28, 11, 34], [ 5, 28, 11, 34], [27, 6, 11, 34], [ 5, 6, 11, 34], - [27, 28, 11, 12], [ 5, 28, 11, 12], [27, 6, 11, 12], [ 5, 6, 11, 12] ], - [ [25, 26, 31, 32], [25, 6, 31, 32], [25, 26, 31, 12], [25, 6, 31, 12], - [15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ], - [ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36], - [39, 40, 45, 46], [ 5, 40, 45, 46], [39, 6, 45, 46], [ 5, 6, 45, 46] ], - [ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12], - [17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ], - [ [37, 38, 43, 44], [37, 6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44], - [37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1, 2, 7, 8] ] + [ [27, 28, 33, 34], [ 5, 28, 33, 34], [27, 6, 33, 34], [ 5, 6, 33, 34], + [27, 28, 33, 12], [ 5, 28, 33, 12], [27, 6, 33, 12], [ 5, 6, 33, 12] ], + [ [27, 28, 11, 34], [ 5, 28, 11, 34], [27, 6, 11, 34], [ 5, 6, 11, 34], + [27, 28, 11, 12], [ 5, 28, 11, 12], [27, 6, 11, 12], [ 5, 6, 11, 12] ], + [ [25, 26, 31, 32], [25, 6, 31, 32], [25, 26, 31, 12], [25, 6, 31, 12], + [15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ], + [ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36], + [39, 40, 45, 46], [ 5, 40, 45, 46], [39, 6, 45, 46], [ 5, 6, 45, 46] ], + [ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12], + [17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ], + [ [37, 38, 43, 44], [37, 6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44], + [37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1, 2, 7, 8] ] ] # converts neighbors returned from tableNeighbors to tile indexes NeighborsToTiles = [ - 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, - 42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16, - 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, - 42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16, - 45, 39, 45, 39, 33, 31, 33, 29, 45, 39, 45, 39, 33, 31, 33, 29, - 37, 27, 37, 27, 23, 15, 23, 13, 37, 27, 37, 27, 22, 11, 22, 9, - 45, 39, 45, 39, 33, 31, 33, 29, 45, 39, 45, 39, 33, 31, 33, 29, - 36, 26, 36, 26, 21, 7, 21, 5, 36, 26, 36, 26, 20, 3, 20, 1, - 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, - 42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16, - 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, - 42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16, - 45, 38, 45, 38, 33, 30, 33, 28, 45, 38, 45, 38, 33, 30, 33, 28, - 37, 25, 37, 25, 23, 14, 23, 12, 37, 25, 37, 25, 22, 10, 22, 8, - 45, 38, 45, 38, 33, 30, 33, 28, 45, 38, 45, 38, 33, 30, 33, 28, - 36, 24, 36, 24, 21, 6, 21, 4, 36, 24, 36, 24, 20, 2, 20, 0 + 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, + 42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16, + 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, + 42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16, + 45, 39, 45, 39, 33, 31, 33, 29, 45, 39, 45, 39, 33, 31, 33, 29, + 37, 27, 37, 27, 23, 15, 23, 13, 37, 27, 37, 27, 22, 11, 22, 9, + 45, 39, 45, 39, 33, 31, 33, 29, 45, 39, 45, 39, 33, 31, 33, 29, + 36, 26, 36, 26, 21, 7, 21, 5, 36, 26, 36, 26, 20, 3, 20, 1, + 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, + 42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16, + 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, + 42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16, + 45, 38, 45, 38, 33, 30, 33, 28, 45, 38, 45, 38, 33, 30, 33, 28, + 37, 25, 37, 25, 23, 14, 23, 12, 37, 25, 37, 25, 22, 10, 22, 8, + 45, 38, 45, 38, 33, 30, 33, 28, 45, 38, 45, 38, 33, 30, 33, 28, + 36, 24, 36, 24, 21, 6, 21, 4, 36, 24, 36, 24, 20, 2, 20, 0 ] def self.tableNeighbors(data,x,y) diff --git a/Data/Scripts/006_Game processing/001_Interpreter.rb b/Data/Scripts/006_Game processing/001_Interpreter.rb index a9bbc1fc4..52cc81c69 100644 --- a/Data/Scripts/006_Game processing/001_Interpreter.rb +++ b/Data/Scripts/006_Game processing/001_Interpreter.rb @@ -192,10 +192,6 @@ class Interpreter $game_temp.choice_proc = Proc.new { |n| @branch[current_indent] = n } end - def command_dummy - return true - end - def pbExecuteScript(script) begin result = eval(script) @@ -234,7 +230,6 @@ class Interpreter if e.is_a?(Hangup) $EVENTHANGUPMSG = err; raise end - raise err elsif $game_map mapname = ($game_map.name rescue nil) || "???" err = "Script error within map #{$game_map.map_id} " @@ -242,15 +237,13 @@ class Interpreter if e.is_a?(Hangup) $EVENTHANGUPMSG = err; raise end - raise err else err = "Script error in interpreter:\r\n#{message}\r\n#{s}" if e.is_a?(Hangup) $EVENTHANGUPMSG = err; raise end - raise err end - return false + raise err end end #----------------------------------------------------------------------------- @@ -844,7 +837,7 @@ class Interpreter value = $game_variables[@parameters[4]] when 2 # random number value = @parameters[4] + rand(@parameters[5] - @parameters[4] + 1) - when 3, 4, 5 # item, actor, enemy +# when 3, 4, 5 # item, actor, enemy when 6 # character character = get_character(@parameters[4]) if character != nil @@ -860,14 +853,13 @@ class Interpreter when 7 # other case @parameters[4] when 0; value = $game_map.map_id # map ID - when 1, 3 # number of party members, steps +# when 1, 3 # number of party members, steps when 2; value = $Trainer.money # gold when 4; value = Graphics.frame_count / Graphics.frame_rate # play time when 5; value = $game_system.timer / Graphics.frame_rate # timer when 6; value = $game_system.save_count # save count end end - shouldRefresh = false # Loop for group control for i in @parameters[0] .. @parameters[1] # Branch with control @@ -1463,7 +1455,7 @@ class Interpreter end @index += 1 end - result = pbExecuteScript(script) + pbExecuteScript(script) return true end end diff --git a/Data/Scripts/007_Events and files/001_FileTests.rb b/Data/Scripts/007_Events and files/001_FileTests.rb index 5d0c15cee..ea24e3789 100644 --- a/Data/Scripts/007_Events and files/001_FileTests.rb +++ b/Data/Scripts/007_Events and files/001_FileTests.rb @@ -133,7 +133,7 @@ def getKnownFolder(guid) coTaskMemFree = Win32API.new("ole32.dll","CoTaskMemFree","i","") rescue nil return "" if !(shGetKnownFolderPath && coTaskMemFree) path = "\0"*4 - ret = shGetKnownFolderPath.call(packedGuid,0,0,path) + path = shGetKnownFolderPath.call(packedGuid,0,0,path) path = path.unpack("V")[0] ret = getUnicodeString(path) coTaskMemFree.call(path) @@ -245,7 +245,7 @@ module RTP return false if !dir || dir=="" loop do name = dir.gsub(/[\/\\]$/,"")+"/writetest" - for i in 0...12 + 12.times do name += sprintf("%02X",rand(256)) end name += ".tmp" @@ -471,12 +471,12 @@ module MiniRegistry type = type.unpack("V")[0] data = data[0,size.unpack("V")[0]] case type - when 1; return data.chop # REG_SZ - when 2; return data.gsub(/%([^%]+)%/) { ENV[$1] || $& } # REG_EXPAND_SZ - when 3; return data # REG_BINARY - when 4; return data.unpack("V")[0] # REG_DWORD - when 5; return data.unpack("V")[0] # REG_DWORD_BIG_ENDIAN - when 11; qw = data.unpack("VV"); return (data[1]<<32|data[0]) # REG_QWORD + when 1; return data.chop # REG_SZ + when 2; return data.gsub(/%([^%]+)%/) { ENV[$1] || $& } # REG_EXPAND_SZ + when 3; return data # REG_BINARY + when 4; return data.unpack("V")[0] # REG_DWORD + when 5; return data.unpack("V")[0] # REG_DWORD_BIG_ENDIAN + when 11; data.unpack("VV"); return (data[1]<<32|data[0]) # REG_QWORD else; raise "Type #{type} not supported." end end diff --git a/Data/Scripts/007_Events and files/002_File_Mixins.rb b/Data/Scripts/007_Events and files/002_File_Mixins.rb index db41d4e36..187049ec6 100644 --- a/Data/Scripts/007_Events and files/002_File_Mixins.rb +++ b/Data/Scripts/007_Events and files/002_File_Mixins.rb @@ -1,121 +1,113 @@ module FileInputMixin def fgetb - x=0 - ret=0 + ret = 0 each_byte do |i| - ret=i || 0 + ret = i || 0 break end return ret end def fgetw - x=0 - ret=0 + x = 0 + ret = 0 each_byte do |i| break if !i - ret|=(i<>3 - return 0 if index>=offset - self.pos=index*8 + self.pos = 0 + offset = fgetdw >> 3 + return 0 if index >= offset + self.pos = index * 8 return fgetdw end def getLength(index) self.binmode - self.pos=0 - offset=fgetdw>>3 - return 0 if index>=offset - self.pos=index*8+4 + self.pos = 0 + offset = fgetdw >> 3 + return 0 if index >= offset + self.pos = index * 8 + 4 return fgetdw end def readName(index) self.binmode - self.pos=0 - offset=fgetdw>>3 - return "" if index>=offset - self.pos=index<<3 - offset=fgetdw - length=fgetdw - return "" if length==0 - self.pos=offset + self.pos = 0 + offset = fgetdw >> 3 + return "" if index >= offset + self.pos = index << 3 + offset = fgetdw + length = fgetdw + return "" if length == 0 + self.pos = offset return read(length) end end - - module FileOutputMixin def fputb(b) - b=b&0xFF + b &= 0xFF write(b.chr) end def fputw(w) 2.times do - b=w&0xFF + b = w & 0xFF write(b.chr) - w>>=8 + w >>= 8 end end def fputdw(w) 4.times do - b=w&0xFF + b = w & 0xFF write(b.chr) - w>>=8 + w >>= 8 end end end - - class File < IO =begin unless defined?(debugopen) @@ -124,12 +116,12 @@ class File < IO end end - def open(f,m="r") - debugopen("debug.txt","ab") { |file| file.write([f,m,Time.now.to_f].inspect+"\r\n") } + 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 } + debugopen(f, m) { |file| yield file } else - return debugopen(f,m) + return debugopen(f, m) end end =end @@ -137,8 +129,6 @@ class File < IO include FileOutputMixin end - - class StringInput include FileInputMixin @@ -152,12 +142,9 @@ class StringInput end end - def binmode - end + def binmode; end end - - class StringOutput include FileOutputMixin end diff --git a/Data/Scripts/007_Events and files/003_Intl_Messages.rb b/Data/Scripts/007_Events and files/003_Intl_Messages.rb index 3c34f1691..cc33c0f39 100644 --- a/Data/Scripts/007_Events and files/003_Intl_Messages.rb +++ b/Data/Scripts/007_Events and files/003_Intl_Messages.rb @@ -228,7 +228,6 @@ def pbGetText(infile) begin pbEachIntlSection(file) { |section,name| next if section.length==0 - index=name if !name[/^([Mm][Aa][Pp])?(\d+)$/] raise _INTL("Invalid section name {1}",name) end @@ -335,7 +334,7 @@ class OrderedHash < Hash return ret end - def _dump(depth=100) + def _dump(_depth=100) values=[] for key in @keys values.push(self[key]) @@ -476,7 +475,7 @@ class Messages @messages[type]=arr end - def self.createHash(type,array) + def self.createHash(_type,array) arr=OrderedHash.new for i in 0...array.length if array[i] @@ -487,10 +486,8 @@ class Messages return arr end - def self.addToHash(type,array,hash) - if !hash - hash=OrderedHash.new - end + def self.addToHash(_type,array,hash) + hash=OrderedHash.new if !hash for i in 0...array.length if array[i] key=Messages.stringToKey(array[i]) diff --git a/Data/Scripts/008_Audio/001_Audio.rb b/Data/Scripts/008_Audio/001_Audio.rb index d84304b45..45d297356 100644 --- a/Data/Scripts/008_Audio/001_Audio.rb +++ b/Data/Scripts/008_Audio/001_Audio.rb @@ -1,11 +1,11 @@ class Thread def Thread.exclusive - _old = Thread.critical + old_critical = Thread.critical begin Thread.critical = true return yield ensure - Thread.critical = _old + Thread.critical = old_critical end end end diff --git a/Data/Scripts/008_Audio/002_Audio_Play.rb b/Data/Scripts/008_Audio/002_Audio_Play.rb index 38ae27cfd..d18fca354 100644 --- a/Data/Scripts/008_Audio/002_Audio_Play.rb +++ b/Data/Scripts/008_Audio/002_Audio_Play.rb @@ -220,7 +220,7 @@ end def pbSEFade(x=0.0); pbSEStop(x);end # Stops SE playback. -def pbSEStop(timeInSeconds=0.0) +def pbSEStop(_timeInSeconds=0.0) if $game_system $game_system.se_stop elsif (RPG.const_defined?(:SE) rescue false) diff --git a/Data/Scripts/008_Audio/003_Audio_Utilities.rb b/Data/Scripts/008_Audio/003_Audio_Utilities.rb index a01f7a872..ee36afbe9 100644 --- a/Data/Scripts/008_Audio/003_Audio_Utilities.rb +++ b/Data/Scripts/008_Audio/003_Audio_Utilities.rb @@ -99,7 +99,7 @@ def pbPlaySoundData(samples,volume,async=false,sampleFreq=11025) saveToTemp = proc { |samples,freq| chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ret = nil - for i in 1...1000 + 999.times do name="" 8.times { name += chars[rand(chars.length),1] } name = ENV["TEMP"]+"\\"+name+"_tmp.wav" @@ -110,14 +110,14 @@ def pbPlaySoundData(samples,volume,async=false,sampleFreq=11025) end return ret } - playThenDelete = proc { |path,volume,length,async| + playThenDelete = proc { |path,volume,length,_async| next if !path || !safeExists?(path) thread=Thread.new{ Thread.stop - _path=Thread.current[:path] - _length=Thread.current[:length] - sleep(_length) - File.delete(_path) rescue nil + cur_path=Thread.current[:path] + cur_length=Thread.current[:length] + sleep(cur_length) + File.delete(cur_path) rescue nil } thread[:path]=path thread[:length]=length @@ -132,14 +132,14 @@ def pbPlaySoundData(samples,volume,async=false,sampleFreq=11025) waveOutHandle=" "*4 code=waveOutOpen.call(waveOutHandle,-1,waveFormat,0,0,0) if code!=0 - timeLength=samples.length.to_f/sampleFreq + timeLength=duration.to_f/sampleFreq path=saveToTemp.call(samples,sampleFreq) playThenDelete.call(path,volume,timeLength,async) return end waveOutHandle=waveOutHandle.unpack("L")[0] volume=(volume*65535/100) - volume=(volume<<16)|volume + volume=(volume << 16)|volume waveOutSetVolume.call(waveOutHandle,volume) code=waveOutPrepareHeader.call(waveOutHandle,waveHdr,waveHdr.length) if code!=0 @@ -150,7 +150,6 @@ def pbPlaySoundData(samples,volume,async=false,sampleFreq=11025) Thread.stop waveOut=Thread.current[:waveOut] waveHdr=Thread.current[:waveHeader] - waveData=Thread.current[:waveData] waveOutUnprepareHeader=Win32API.new("winmm.dll","waveOutUnprepareHeader","lpl","l") waveOutClose=Win32API.new("winmm.dll","waveOutClose","l","l") loop do @@ -272,7 +271,7 @@ class WaveData return ret end - def _dump(depth=100) + def _dump(_depth=100) return Marshal.dump([@freq,Zlib::Deflate.deflate(@samples)]) end @@ -594,11 +593,17 @@ class WaveForm# :nodoc: def lcm(x,y) return y if x==0; return x if y==0 return x if x==y - if x>y; incr=x - while x%y!=0; x+=incr; end + if x>y + incr=x + while x%y!=0 + x+=incr + end return x - else; incr=y - while y%x!=0; y+=incr; end + else + incr=y + while y%x!=0 + y+=incr + end return y end end @@ -626,7 +631,6 @@ class WaveForm# :nodoc: vol=@volumeIterator.getValue(fframe) end if @proc - updateBuffer=false if @freqEnvelope.length>0 # Update frequency freq=@freqIterator.getValue(fframe) if freq!=@freq # update sample buffer @@ -843,8 +847,6 @@ module Audio t2=852 if "7pqrs8tuv9wxyzC".include?(tone) t2=941 if "*0#D".include?(tone) return if t1==0 || t2==0 - f1=Math::PI*2.0*t1/WaveForm::SAMPLEFREQ - f2=Math::PI*2.0*t2/WaveForm::SAMPLEFREQ doubleSine(durationInMs,t1,t2,volume,volume,0.5,0.5,async) end @@ -908,7 +910,7 @@ def callheld(duration,volume=95) volume,volume) end -def loudFastBusy(duration,volume=95) +def loudFastBusy(duration,_volume=95) Audio.doubleSine(duration, SoundEnvelope.blink(480,250,250,duration), SoundEnvelope.blink(620,250,250,duration) @@ -1009,7 +1011,6 @@ end # internal function def getOggPage(file) - pos=file.pos fgetdw=proc { |file| (file.eof? ? 0 : (file.read(4).unpack("V")[0] || 0)) } @@ -1035,13 +1036,15 @@ def oggfiletime(file) } pages=[] page=nil - begin + loop do page=getOggPage(file) if page pages.push(page) file.pos=page[3] + else + break end - end while page + end if pages.length==0 return -1 end @@ -1054,30 +1057,23 @@ def oggfiletime(file) serial=header[10,4].unpack("V") frame=header[2,8].unpack("C*") frameno=frame[7] - frameno=(frameno<<8)|frame[6] - frameno=(frameno<<8)|frame[5] - frameno=(frameno<<8)|frame[4] - frameno=(frameno<<8)|frame[3] - frameno=(frameno<<8)|frame[2] - frameno=(frameno<<8)|frame[1] - frameno=(frameno<<8)|frame[0] + frameno=(frameno << 8)|frame[6] + frameno=(frameno << 8)|frame[5] + frameno=(frameno << 8)|frame[4] + frameno=(frameno << 8)|frame[3] + frameno=(frameno << 8)|frame[2] + frameno=(frameno << 8)|frame[1] + frameno=(frameno << 8)|frame[0] if serial!=curserial curserial=serial file.pos=page[1] packtype=(file.read(1)[0] rescue 0) string=file.read(6) - if string!="vorbis" - return -1 - end - if packtype!=1 - return -1 - end + return -1 if string!="vorbis" + return -1 if packtype!=1 i+=1 version=fgetdw.call(file) - if version!=0 - return -1 - end - channels=(file.read(1)[0] rescue 0) + return -1 if version!=0 rates[i]=fgetdw.call(file) end pcmlengths[i]=frameno @@ -1180,7 +1176,6 @@ end # Creates wave data from the given WAV file path def getWaveData(filename) - time=-1 fgetdw=proc { |file| (file.eof? ? 0 : (file.read(4).unpack("V")[0] || 0)) } diff --git a/Data/Scripts/009_Objects and windows/001_BitmapCache.rb b/Data/Scripts/009_Objects and windows/001_BitmapCache.rb index abdc3a2c5..516236d12 100644 --- a/Data/Scripts/009_Objects and windows/001_BitmapCache.rb +++ b/Data/Scripts/009_Objects and windows/001_BitmapCache.rb @@ -44,7 +44,7 @@ class WeakRef @@id_map = {} @@id_rev_map = {} @@final = lambda { |id| - __old_status = Thread.critical + old_thread_status = Thread.critical Thread.critical = true begin rids = @@id_map[id] @@ -61,7 +61,7 @@ class WeakRef @@id_map.delete(rid) if @@id_map[rid].empty? end ensure - Thread.critical = __old_status + Thread.critical = old_thread_status end } @@ -83,7 +83,7 @@ class WeakRef def __setobj__(obj) @__id = obj.__id__ - __old_status = Thread.critical + old_thread_status = Thread.critical begin Thread.critical = true unless @@id_rev_map.key?(self) @@ -92,7 +92,7 @@ class WeakRef end @@id_map[@__id] = [] unless @@id_map[@__id] ensure - Thread.critical = __old_status + Thread.critical = old_thread_status end @@id_map[@__id].push self.__id__ @@id_rev_map[self.__id__] = @__id @@ -111,7 +111,7 @@ class WeakHashtable include Enumerable def initialize - @hash={} + @hash = {} end def clear @@ -277,12 +277,12 @@ end # bitmap is freed when the reference count reaches 0. class Thread def Thread.exclusive - _old = Thread.critical + old_thread_status = Thread.critical begin Thread.critical = true return yield ensure - Thread.critical = _old + Thread.critical = old_thread_status end end end diff --git a/Data/Scripts/009_Objects and windows/003_SpriteWindow.rb b/Data/Scripts/009_Objects and windows/003_SpriteWindow.rb index f9d9c36fe..18e7924bb 100644 --- a/Data/Scripts/009_Objects and windows/003_SpriteWindow.rb +++ b/Data/Scripts/009_Objects and windows/003_SpriteWindow.rb @@ -519,10 +519,10 @@ end # Fades and window activations for sprite hashes #=============================================================================== class Game_Temp - attr_accessor :fadestate + attr_writer :fadestate def fadestate - return (@fadestate) ? @fadestate : 0 + return @fadestate || 0 end end diff --git a/Data/Scripts/009_Objects and windows/004_SpriteWindow_text.rb b/Data/Scripts/009_Objects and windows/004_SpriteWindow_text.rb index 5636cb157..099067682 100644 --- a/Data/Scripts/009_Objects and windows/004_SpriteWindow_text.rb +++ b/Data/Scripts/009_Objects and windows/004_SpriteWindow_text.rb @@ -390,7 +390,7 @@ class SpriteWindow < Window attr_reader :skinformat attr_reader :skinrect - def loadSkinFile(file) + def loadSkinFile(_file) if (self.windowskin.width==80 || self.windowskin.width==96) && self.windowskin.height==48 # Body = X, Y, width, height of body rectangle within windowskin @@ -519,9 +519,9 @@ class SpriteWindow < Window dstbitmap.blt(x+left,y+top,srcbitmap,srcrect) x+=srcrect.width end - y+=srcrect.height - end - end + y+=srcrect.height + end + end def privRefreshCursor contopac=self.contents_opacity @@ -666,8 +666,6 @@ class SpriteWindow < Window startX=@skinrect.x # width of top end of window startY=@skinrect.y - backWidth=@skinrect.width - backHeight=@skinrect.height cx=@skinrect.x+@skinrect.width # right side of BODY rect cy=@skinrect.y+@skinrect.height # bottom side of BODY rect # width of right end of window @@ -707,8 +705,6 @@ class SpriteWindow < Window end end if @_windowskin && !@_windowskin.disposed? - backTrimX=startX+endX - backTrimY=startX+endX borderX=startX+endX borderY=startY+endY @sprites["corner0"].x=@x @@ -857,8 +853,6 @@ class SpriteWindow < Window sprite.zoom_x=1.0 sprite.oy=0 sprite.y=(@y+(@height/2.0)+(@height*ratio*opn)-(@height/2*opn)).floor - oldbitmap=sprite.bitmap - oldsrcrect=sprite.src_rect.clone end else for k in @spritekeys @@ -1117,7 +1111,6 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base attr_reader :baseColor attr_reader :shadowColor attr_accessor :letterbyletter - attr_reader :lineHeight attr_reader :waitcount def initialize(text="") @@ -1291,7 +1284,6 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base @curchar = 0 @drawncurchar = -1 @lastDrawnChar = -1 - oldtext = @text @text = value @textlength = unformattedTextLength(value) @scrollstate = 0 @@ -1466,7 +1458,6 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base self.oy = @scrollY numchars = @numtextchars numchars = [@curchar,@numtextchars].min if self.letterbyletter - startchar = 0 return if busy? && @drawncurchar==@curchar && @scrollstate==0 if !self.letterbyletter || !oldcontents.equal?(self.contents) @drawncurchar = -1 @@ -1614,7 +1605,6 @@ end # #=============================================================================== class Window_InputNumberPokemon < SpriteWindow_Base - attr_reader :number attr_reader :sign def initialize(digits_max) @@ -1643,13 +1633,6 @@ class Window_InputNumberPokemon < SpriteWindow_Base @number*(@sign && @negative ? -1 : 1) end - def sign=(value) - @sign=value - self.width=@digits_max*24+8+self.borderX+(@sign ? 24 : 0) - @index=(@digits_max-1)+(@sign ? 1 : 0) - refresh - end - def number=(value) value=0 if !value.is_a?(Numeric) if @sign @@ -1661,13 +1644,19 @@ class Window_InputNumberPokemon < SpriteWindow_Base refresh end + def sign=(value) + @sign=value + self.width=@digits_max*24+8+self.borderX+(@sign ? 24 : 0) + @index=(@digits_max-1)+(@sign ? 1 : 0) + refresh + end + def refresh self.contents=pbDoEnsureBitmap(self.contents, self.width-self.borderX,self.height-self.borderY) pbSetSystemFont(self.contents) self.contents.clear s=sprintf("%0*d",@digits_max,@number.abs) - x=0 if @sign textHelper(0,0,@negative ? "-" : "+",0) end @@ -2080,7 +2069,7 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx end def textWidth(bitmap,text) - return tmpbitmap.text_size(i).width + return bitmap.text_size(text).width end def getAutoDims(commands,dims,width=nil) @@ -2230,7 +2219,7 @@ class Window_CommandPokemon < Window_DrawableCommand return @commands ? @commands.length : 0 end - def drawItem(index,count,rect) + def drawItem(index,_count,rect) pbSetSystemFont(self.contents) if @starting rect=drawCursor(index,rect) pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height, @@ -2344,7 +2333,7 @@ class Window_AdvancedCommandPokemon < Window_DrawableCommand return @commands ? @commands.length : 0 end - def drawItem(index,count,rect) + def drawItem(index,_count,rect) pbSetSystemFont(self.contents) rect=drawCursor(index,rect) if toUnformattedText(@commands[index]).gsub(/\n/,"")==@commands[index] diff --git a/Data/Scripts/009_Objects and windows/005_SpriteWindow_sprites.rb b/Data/Scripts/009_Objects and windows/005_SpriteWindow_sprites.rb index 5261ccb5e..2a93d17b4 100644 --- a/Data/Scripts/009_Objects and windows/005_SpriteWindow_sprites.rb +++ b/Data/Scripts/009_Objects and windows/005_SpriteWindow_sprites.rb @@ -111,7 +111,7 @@ class PngAnimatedBitmap @currentFrame end - def frameDelay(index) + def frameDelay(_index) return @frameDelay end @@ -259,10 +259,6 @@ class GifBitmap return @gifbitmaps[index] end - def width; self.bitmap.width; end - - def height; self.bitmap.height; end - def deanimate for i in 1...@gifbitmaps.length @gifbitmaps[i].dispose @@ -349,7 +345,7 @@ end def pbGetTileBitmap(filename, tile_id, hue) return BitmapCache.tileEx(filename, tile_id, hue) { |f| - AnimatedBitmap.new("Graphics/Tilesets/"+filename).deanimate; + AnimatedBitmap.new("Graphics/Tilesets/"+filename).deanimate } end @@ -1000,8 +996,10 @@ class LargePlane < Plane top = (dstrect.y-@__oy/@__sprite.zoom_y).to_i while left>0; left -= srcbitmap.width; end while top>0; top -= srcbitmap.height; end - y = top; while y",ret) end @@ -168,13 +168,9 @@ end def getFormattedTextFast(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight, newlineBreaks=true,explicitBreaksOnly=false) - numchars=0 x=y=0 characters=[] - charactersInternal=[] textchunks=[] - controls=[] - charsonline=0 textchunks.push(text) text=textchunks.join("") textchars=text.scan(/./m) @@ -192,19 +188,18 @@ def getFormattedTextFast(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight, end defaultfontname=defaultfontname.clone havenl=false - position=0;while position0) ? 2+(width/2) : 2 @@ -909,7 +899,6 @@ def getLineBrokenChunks(bitmap,value,width,dims,plain=false) reNoMatch=/]+>/ return ret if !bitmap || bitmap.disposed? || width<=0 textmsg=value.clone - lines=0 color=Font.default_color while (c = textmsg.slice!(/\n|[^ \r\t\f\n\-]*\-+|(\S*([ \r\t\f]?))/)) != nil break if c=="" @@ -1111,7 +1100,7 @@ def coloredToFormattedText(text,baseColor=nil,shadowColor=nil) end # Deprecated -- not to be used in new code -def drawColoredTextEx(bitmap,x,y,width,text,baseColor=nil,shadowColor=nil) +def drawColoredTextEx(bitmap,x,y,width,text,_baseColor=nil,_shadowColor=nil) chars=getFormattedText(bitmap,x,y,width,-1,coloredToFormattedText(text),32) drawFormattedChars(bitmap,chars) end diff --git a/Data/Scripts/009_Objects and windows/007_Messages.rb b/Data/Scripts/009_Objects and windows/007_Messages.rb index 4d3ca1111..4b7d34c97 100644 --- a/Data/Scripts/009_Objects and windows/007_Messages.rb +++ b/Data/Scripts/009_Objects and windows/007_Messages.rb @@ -315,12 +315,13 @@ module InterpreterMixin if common_event != nil interp = Interpreter.new interp.setup(common_event.list,0) - begin + loop do Graphics.update Input.update interp.update pbUpdateSceneMap - end while interp.running? + break if !interp.running? + end end else $game_system.battle_interpreter.setup(common_event.list, 0) @@ -705,7 +706,7 @@ class ChooseNumberParams ret=0 if @maxDigits>0 ret=-((10**@maxDigits)-1) - elsif + else ret=@minNumber end ret=0 if !@negativeAllowed && ret<0 @@ -716,7 +717,7 @@ class ChooseNumberParams ret=0 if @maxDigits>0 ret=((10**@maxDigits)-1) - elsif + else ret=@maxNumber end ret=0 if !@negativeAllowed && ret<0 @@ -767,9 +768,7 @@ def pbChooseNumber(msgwindow,params) cmdwindow.setSkin(params.skin) if params.skin cmdwindow.sign=params.negativesAllowed # must be set before number cmdwindow.number=defaultNumber - curnumber=defaultNumber pbPositionNearMsgWindow(cmdwindow,msgwindow,:right) - command=0 loop do Graphics.update Input.update @@ -1007,7 +1006,6 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil) oldletterbyletter=msgwindow.letterbyletter msgwindow.letterbyletter=(letterbyletter) ? true : false ret=nil - count=0 commands=nil facewindow=nil goldwindow=nil @@ -1048,17 +1046,19 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil) m = $1.to_i next getSkinColor(msgwindow.windowskin,m,isDarkSkin) } - begin + loop do last_text = text.clone text.gsub!(/\\v\[([0-9]+)\]/i) { $game_variables[$1.to_i] } - end until text == last_text - begin + break if text == last_text + end + loop do last_text = text.clone text.gsub!(/\\l\[([0-9]+)\]/i) { linecount = [1,$1.to_i].max next "" } - end until text == last_text + break if text == last_text + end colortag = "" if ($game_message && $game_message.background>0) || ($game_system && $game_system.respond_to?("message_frame") && @@ -1156,7 +1156,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil) ########## Show text ############################# msgwindow.text = text Graphics.frame_reset if Graphics.frame_rate>40 - begin + loop do if signWaitCount>0 signWaitCount -= 1 if atTop @@ -1256,7 +1256,8 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil) pbUpdateSceneMap msgwindow.update yield if block_given? - end until (!letterbyletter || commandProc || commands) && !msgwindow.busy? + break if (!letterbyletter || commandProc || commands) && !msgwindow.busy? + end Input.update # Must call Input.update again to avoid extra triggers msgwindow.letterbyletter=oldletterbyletter if commands diff --git a/Data/Scripts/009_Objects and windows/008_TextEntry.rb b/Data/Scripts/009_Objects and windows/008_TextEntry.rb index 228b859dc..c1b646a59 100644 --- a/Data/Scripts/009_Objects and windows/008_TextEntry.rb +++ b/Data/Scripts/009_Objects and windows/008_TextEntry.rb @@ -46,7 +46,7 @@ class Window_CharacterEntry < Window_DrawableCommand return @charset.length+3 end - def drawItem(index,count,rect) + def drawItem(index,_count,rect) rect=drawCursor(index,rect) if index==@charset.length # -1 pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,"[ ]", @@ -70,9 +70,9 @@ end # #=============================================================================== class CharacterEntryHelper - attr_reader :text - attr_reader :maxlength - attr_reader :passwordChar + attr_reader :text + attr_accessor :maxlength + attr_reader :passwordChar attr_accessor :cursor def initialize(text) @@ -80,12 +80,10 @@ class CharacterEntryHelper @text=text @passwordChar="" @cursor=text.scan(/./m).length - ensure end def text=(value) @text=value - ensure end def textChars @@ -100,11 +98,6 @@ class CharacterEntryHelper @passwordChar=value ? value : "" end - def maxlength=(value) - @maxlength=value - ensure - end - def length return self.text.scan(/./m).length end @@ -264,7 +257,6 @@ class Window_TextEntry < SpriteWindow_Base end x+=4 width=self.width-self.borderX - height=self.height-self.borderY cursorcolor=Color.new(16,24,32) textscan=self.text.scan(/./m) scanlength=textscan.length @@ -316,8 +308,6 @@ def getLineBrokenText(bitmap,value,width,dims) column=0 return ret if !bitmap || bitmap.disposed? || width<=0 textmsg=value.clone - lines=0 - color=Font.default_color ret.push(["",0,0,0,bitmap.text_size("X").height,0,0,0,0]) while ((c = textmsg.slice!(/\n|(\S*([ \r\t\f]?))/)) != nil) break if c=="" @@ -334,7 +324,6 @@ def getLineBrokenText(bitmap,value,width,dims) ret.push(["",x,y,0,textheight,line,position,column,0]) next end - textcols=[] words=[ccheck] for i in 0...words.length word=words[i] @@ -355,7 +344,6 @@ def getLineBrokenText(bitmap,value,width,dims) x+=textwidth dims[0]=x if dims && dims[0]=totallines - maximumY=0 - for i in 0...textchars.length - thisline=textchars[i][5] - y=textchars[i][2] - return y if thisline==line - maximumY=y if maximumY=totallines + maximumY=0 + for i in 0...textchars.length + thisline=textchars[i][5] + y=textchars[i][2] + return y if thisline==line + maximumY=y if maximumY=totallines - endpos=0 - for i in 0...textchars.length - thisline=textchars[i][5] - thispos=textchars[i][6] - thislength=textchars[i][8] - if thisline==line - endpos+=thislength - end - end - return endpos + return 0 if textchars.length==0 + totallines=getTotalLines() + line=0 if line<0 + line=totallines-1 if line>=totallines + endpos=0 + for i in 0...textchars.length + thisline=textchars[i][5] + thislength=textchars[i][8] + endpos+=thislength if thisline==line end + return endpos end def getPosFromLineAndColumn(line,column) textchars=getTextChars - if textchars.length==0 - return 0 - else - totallines=getTotalLines() - line=0 if line<0 - line=totallines-1 if line>=totallines - endpos=0 - for i in 0...textchars.length - thisline=textchars[i][5] - thispos=textchars[i][6] - thiscolumn=textchars[i][7] - thislength=textchars[i][8] - if thisline==line - endpos=thispos+thislength -# echoln [endpos,thispos+(column-thiscolumn),textchars[i]] - if column>=thiscolumn && column<=thiscolumn+thislength && thislength>0 - return thispos+(column-thiscolumn) - end + return 0 if textchars.length==0 + totallines=getTotalLines() + line=0 if line<0 + line=totallines-1 if line>=totallines + endpos=0 + for i in 0...textchars.length + thisline=textchars[i][5] + thispos=textchars[i][6] + thiscolumn=textchars[i][7] + thislength=textchars[i][8] + if thisline==line + endpos=thispos+thislength +# echoln [endpos,thispos+(column-thiscolumn),textchars[i]] + if column>=thiscolumn && column<=thiscolumn+thislength && thislength>0 + return thispos+(column-thiscolumn) end end - if endpos==0 -# echoln [totallines,line,column] -# echoln textchars - end -# echoln "endpos=#{endpos}" - return endpos end +# if endpos==0 +# echoln [totallines,line,column] +# echoln textchars +# end +# echoln "endpos=#{endpos}" + return endpos end def getLastVisibleLine - textchars=getTextChars() + getTextChars() textheight=[1,self.contents.text_size("X").height].max lastVisible=@firstline+((self.height-self.borderY)/textheight)-1 return lastVisible @@ -544,13 +517,9 @@ class Window_MultilineTextEntry < SpriteWindow_Base @frame=0 self.refresh end - if @cursorLine<@firstline - @firstline=@cursorLine - end + @firstline=@cursorLine if @cursorLine<@firstline lastVisible=getLastVisibleLine() - if @cursorLine>lastVisible - @firstline+=(@cursorLine-lastVisible) - end + @firstline+=(@cursorLine-lastVisible) if @cursorLine>lastVisible end def moveCursor(lineOffset, columnOffset) @@ -570,7 +539,6 @@ class Window_MultilineTextEntry < SpriteWindow_Base # Will happen if cursor is moved right from the end of a line @cursorLine+=1 @cursorColumn=0 - updateColumns=true end # Ensure column bounds totalColumns=getColumnsInLine(@cursorLine) @@ -688,20 +656,13 @@ class Window_MultilineTextEntry < SpriteWindow_Base self.contents=newContents bitmap=self.contents bitmap.clear - x=0 - y=0 getTextChars - x+=4 - width=self.width-self.borderX height=self.height-self.borderY cursorcolor=Color.new(0,0,0) textchars=getTextChars() - scanlength=@helper.length startY=getLineY(@firstline) - lastheight=32 for i in 0...textchars.length thisline=textchars[i][5] - thispos=textchars[i][6] thiscolumn=textchars[i][7] thislength=textchars[i][8] textY=textchars[i][2]-startY @@ -712,11 +673,10 @@ class Window_MultilineTextEntry < SpriteWindow_Base c=textchars[i][0] # Don't draw spaces next if c==" " - textwidth=textchars[i][3]+4 # add 4 to prevent draw_text from stretching text + textwidth=textchars[i][3]+4 # add 4 to prevent draw_text from stretching text textheight=textchars[i][4] - lastheight=textheight # Draw text - pbDrawShadowText(bitmap,textchars[i][1],textY, textwidth, textheight, c,@baseColor,@shadowColor) + pbDrawShadowText(bitmap, textchars[i][1], textY, textwidth, textheight, c, @baseColor, @shadowColor) end # Draw cursor if ((@frame/10)&1) == 0 @@ -725,7 +685,6 @@ class Window_MultilineTextEntry < SpriteWindow_Base cursorX=0 for i in 0...textchars.length thisline=textchars[i][5] - thispos=textchars[i][6] thiscolumn=textchars[i][7] thislength=textchars[i][8] if thisline==@cursorLine && @cursorColumn>=thiscolumn && @@ -1560,7 +1519,6 @@ class Interpreter if $game_actors && $data_actors && $data_actors[@parameters[0]] != nil # Set battle abort flag $game_temp.battle_abort = true - ret="" pbFadeOutIn { sscene=PokemonEntryScene.new sscreen=PokemonEntry.new(sscene) @@ -1583,7 +1541,6 @@ class Game_Interpreter end if $game_actors && $data_actors && $data_actors[@params[0]] != nil # Set battle abort flag - ret="" pbFadeOutIn { sscene=PokemonEntryScene.new sscreen=PokemonEntry.new(sscene) diff --git a/Data/Scripts/010_Scenes/001_Transitions.rb b/Data/Scripts/010_Scenes/001_Transitions.rb index bbe30738f..62fb4fd7a 100644 --- a/Data/Scripts/010_Scenes/001_Transitions.rb +++ b/Data/Scripts/010_Scenes/001_Transitions.rb @@ -385,7 +385,6 @@ class RandomStripeTransition rect = Rect.new(0,0,(dir==0) ? size : Graphics.width,(dir==0) ? Graphics.height : size) buffer = @buffer sprite = @sprite - phase = @numframes-@duration count = (bands-bands*@duration/@numframes)-@rand_stripe_deleted_count while count > 0 @rand_stripe_deleted[@rand_stripe_index_array.pop] = true diff --git a/Data/Scripts/010_Scenes/002_EventScene.rb b/Data/Scripts/010_Scenes/002_EventScene.rb index 1f2132176..80007aee3 100644 --- a/Data/Scripts/010_Scenes/002_EventScene.rb +++ b/Data/Scripts/010_Scenes/002_EventScene.rb @@ -53,7 +53,6 @@ end def pbTextBitmap(text, maxwidth=Graphics.width) - dims = [] tmp = Bitmap.new(maxwidth,Graphics.height) pbSetSystemFont(tmp) drawFormattedTextEx(tmp,0,0,maxwidth,text,Color.new(248,248,248),Color.new(168,184,184)) diff --git a/Data/Scripts/010_Scenes/003_Scene_Intro.rb b/Data/Scripts/010_Scenes/003_Scene_Intro.rb index 7cafe34ef..1cc032c8c 100644 --- a/Data/Scripts/010_Scenes/003_Scene_Intro.rb +++ b/Data/Scripts/010_Scenes/003_Scene_Intro.rb @@ -3,7 +3,7 @@ class IntroEventScene < EventScene TICKS_PER_ENTER_FLASH = 40 FADE_TICKS = 8 - def initialize(pics,splash,viewport=nil) + def initialize(pics,splash,_viewport=nil) super(nil) @pics = pics @splash = splash @@ -17,7 +17,7 @@ class IntroEventScene < EventScene openPic(self,nil) end - def openPic(scene,args) + def openPic(_scene,_args) onCTrigger.clear @pic.name = "Graphics/Titles/"+@pics[@index] # fade to opacity 255 in FADE_TICKS ticks after waiting 0 frames @@ -49,7 +49,7 @@ class IntroEventScene < EventScene end end - def openSplash(scene,args) + def openSplash(_scene,_args) onUpdate.clear onCTrigger.clear @pic.name = "Graphics/Titles/"+@splash @@ -63,7 +63,7 @@ class IntroEventScene < EventScene onCTrigger.set(method(:closeSplash)) # call closeSplash when C key is pressed end - def closeSplash(scene,args) + def closeSplash(scene,_args) onUpdate.clear onCTrigger.clear # Play random cry @@ -83,7 +83,7 @@ class IntroEventScene < EventScene sscreen.pbStartLoadScreen end - def closeSplashDelete(scene,args) + def closeSplashDelete(scene,_args) onUpdate.clear onCTrigger.clear # Play random cry diff --git a/Data/Scripts/010_Scenes/004_Scene_Controls.rb b/Data/Scripts/010_Scenes/004_Scene_Controls.rb index bf1a2de74..319218029 100644 --- a/Data/Scripts/010_Scenes/004_Scene_Controls.rb +++ b/Data/Scripts/010_Scenes/004_Scene_Controls.rb @@ -6,30 +6,30 @@ # pbEventScreen(ButtonEventScene) #============================================================================== class ButtonEventScene < EventScene - def initialize(viewport=nil) + def initialize(viewport = nil) super Graphics.freeze - addImage(0,0,"Graphics/Pictures/helpbg") - @labels=[ - addLabel(52*2,13*2,Graphics.width*3/4,_INTL("Moves the main character. Also used to scroll through list entries.")), - addLabel(52*2,53*2,Graphics.width*3/4,_INTL("Used to confirm a choice, check things, and talk to people.")), - addLabel(52*2,93*2,Graphics.width*3/4,_INTL("Used to exit, cancel a choice or mode, and open the pause menu.")), - addLabel(52*2,133*2,Graphics.width*3/4,_INTL("Hold down while walking to run.")), - addLabel(52*2,157*2,Graphics.width*3/4,_INTL("Press to use a registered Key Item.")) + addImage(0, 0, "Graphics/Pictures/helpbg") + @labels = [ + addLabel(52 * 2, 13 * 2, Graphics.width * 3 / 4, _INTL("Moves the main character. Also used to scroll through list entries.")), + addLabel(52 * 2, 53 * 2, Graphics.width * 3 / 4, _INTL("Used to confirm a choice, check things, and talk to people.")), + addLabel(52 * 2, 93 * 2, Graphics.width * 3 / 4, _INTL("Used to exit, cancel a choice or mode, and open the pause menu.")), + addLabel(52 * 2, 133 * 2, Graphics.width * 3 / 4, _INTL("Hold down while walking to run.")), + addLabel(52 * 2, 157 * 2, Graphics.width * 3 / 4, _INTL("Press to use a registered Key Item.")) ] - @keys=[ - addImage(26*2,18*2,"Graphics/Pictures/helpArrowKeys"), - addImage(26*2,59*2,"Graphics/Pictures/helpCkey"), - addImage(26*2,99*2,"Graphics/Pictures/helpXkey"), - addImage(26*2,130*2,"Graphics/Pictures/helpZkey"), - addImage(26*2,154*2,"Graphics/Pictures/helpFkey") + @keys = [ + addImage(26 * 2, 18 * 2, "Graphics/Pictures/helpArrowKeys"), + addImage(26 * 2, 59 * 2, "Graphics/Pictures/helpCkey"), + addImage(26 * 2, 99 * 2, "Graphics/Pictures/helpXkey"), + addImage(26 * 2, 130 * 2, "Graphics/Pictures/helpZkey"), + addImage(26 * 2, 154 * 2, "Graphics/Pictures/helpFkey") ] for key in @keys - key.origin=PictureOrigin::Top + key.origin = PictureOrigin::Top end for i in 0...5 # Make everything show (almost) immediately - @keys[i].setOrigin(0,PictureOrigin::Top) - @keys[i].setOpacity(0,255) + @keys[i].setOrigin(0, PictureOrigin::Top) + @keys[i].setOpacity(0, 255) end pictureWait # Update event scene with the changes Graphics.transition(20) @@ -37,7 +37,7 @@ class ButtonEventScene < EventScene onCTrigger.set(method(:pbOnScreen1)) end - def pbOnScreen1(scene,args) + def pbOnScreen1(scene,_args) # End scene Graphics.freeze scene.dispose diff --git a/Data/Scripts/010_Scenes/005_Scene_Credits.rb b/Data/Scripts/010_Scenes/005_Scene_Credits.rb index 1eff237e8..5b10e7bf4 100644 --- a/Data/Scripts/010_Scenes/005_Scene_Credits.rb +++ b/Data/Scripts/010_Scenes/005_Scene_Credits.rb @@ -135,7 +135,6 @@ _END_ line = line.split("") # LINE ADDED: If you use in your own game, you should remove this line pbSetSystemFont(credit_bitmap) # <--- This line was added - x = 0 xpos = 0 align = 1 # Centre align linewidth = Graphics.width diff --git a/Data/Scripts/010_Scenes/006_Scene_Movie.rb b/Data/Scripts/010_Scenes/006_Scene_Movie.rb index 9b3446a6c..b2e95d4be 100644 --- a/Data/Scripts/010_Scenes/006_Scene_Movie.rb +++ b/Data/Scripts/010_Scenes/006_Scene_Movie.rb @@ -15,7 +15,7 @@ class Scene_Movie def main @temp = Win32API.pbFindRgssWindow.to_s movie = Win32API.new('winmm','mciSendString','%w(p,p,l,l)','V') - x=movie.call("open \""+@movie_name+ + movie.call("open \""+@movie_name+ "\" alias FILE style 1073741824 parent " + @temp.to_s,0,0,0) @message = Win32API.new('user32','SendMessage','%w(l,l,l,l)','V') @detector = Win32API.new('user32','GetSystemMetrics','%w(l)','L') @@ -31,7 +31,7 @@ class Scene_Movie #fullscreen end status = " " * 255 - x=movie.call("play FILE",0,0,0) + movie.call("play FILE",0,0,0) loop do sleep(0.1) @message.call(@temp.to_i,11,0,0) diff --git a/Data/Scripts/011_Data/002_PBMove.rb b/Data/Scripts/011_Data/002_PBMove.rb index cde7e69a1..14ae13f05 100644 --- a/Data/Scripts/011_Data/002_PBMove.rb +++ b/Data/Scripts/011_Data/002_PBMove.rb @@ -54,8 +54,8 @@ class PBMoveData attr_reader :function,:basedamage,:type,:accuracy,:category attr_reader :totalpp,:addlEffect,:target,:priority,:flags - def initialize(moveid) - moveData = pbGetMoveData(moveID) + def initialize(move_id) + moveData = pbGetMoveData(move_id) @function = moveData[MOVE_FUNCTION_CODE] @basedamage = moveData[MOVE_BASE_DAMAGE] @type = moveData[MOVE_TYPE] diff --git a/Data/Scripts/011_Data/003_PBStatuses.rb b/Data/Scripts/011_Data/003_PBStatuses.rb index 3b3bfa636..4a48a0e30 100644 --- a/Data/Scripts/011_Data/003_PBStatuses.rb +++ b/Data/Scripts/011_Data/003_PBStatuses.rb @@ -11,15 +11,16 @@ begin def self.getName(id) id = getID(PBStatuses,id) names = [ - _INTL("healthy"), - _INTL("asleep"), - _INTL("poisoned"), - _INTL("burned"), - _INTL("paralyzed"), - _INTL("frozen") + _INTL("healthy"), + _INTL("asleep"), + _INTL("poisoned"), + _INTL("burned"), + _INTL("paralyzed"), + _INTL("frozen") ] return names[id] - end end + end + end rescue Exception if $!.is_a?(SystemExit) || "#{$!.class}"=="Reset" diff --git a/Data/Scripts/011_Data/007_PBExperience.rb b/Data/Scripts/011_Data/007_PBExperience.rb index 1ca4fb55d..e694700be 100644 --- a/Data/Scripts/011_Data/007_PBExperience.rb +++ b/Data/Scripts/011_Data/007_PBExperience.rb @@ -185,12 +185,10 @@ module PBExperience mLevel = maxLevel maxexp = pbGetExpInternal(mLevel,growth) exp = maxexp if exp>maxexp - i = 0 - for j in 0..mLevel - currentExp = pbGetExpInternal(i,growth) - return i if exp==currentExp - return i-1 if exp0 # Usually undefined @@ -127,8 +127,8 @@ class PokeBattle_Move def danceMove?; return @flags[/o/]; end # Causes perfect accuracy (param=1) and double damage (param=2). - def tramplesMinimize?(param=1); return false; end - def nonLethal?(user,target); return false; end # For False Swipe + def tramplesMinimize?(_param=1); return false; end + def nonLethal?(_user,_target); return false; end # For False Swipe def ignoresSubstitute?(user) # user is the Pokémon using this move if NEWEST_BATTLE_MECHANICS diff --git a/Data/Scripts/012_Battle/002_Move/002_Move_Usage.rb b/Data/Scripts/012_Battle/002_Move/002_Move_Usage.rb index e75b6cbb3..06a7d738b 100644 --- a/Data/Scripts/012_Battle/002_Move/002_Move_Usage.rb +++ b/Data/Scripts/012_Battle/002_Move/002_Move_Usage.rb @@ -30,8 +30,8 @@ class PokeBattle_Move # attack in the same turn. # user.effects[PBEffects::TwoTurnAttack] is set to the move's ID during the # charging turn, and is 0 during the attack turn. - def pbIsChargingTurn?(user); return false; end - def pbDamagingMove?; return damagingMove?; end + def pbIsChargingTurn?(user); return false; end + def pbDamagingMove?; return damagingMove?; end def pbContactMove?(user) return false if user.hasActiveAbility?(:LONGREACH) @@ -92,7 +92,7 @@ class PokeBattle_Move # Move failure checks #============================================================================= # Check whether the move fails completely due to move-specific requirements. - def pbMoveFailed?(user,targets); return false; end + def pbMoveFailed?(user,targets); return false; end # Checks whether the move will be ineffective against the target. def pbFailsAgainstTarget?(user,target); return false; end diff --git a/Data/Scripts/012_Battle/002_Move/006_Move_Effects_080-0FF.rb b/Data/Scripts/012_Battle/002_Move/006_Move_Effects_080-0FF.rb index f603f62f4..b49ee2468 100644 --- a/Data/Scripts/012_Battle/002_Move/006_Move_Effects_080-0FF.rb +++ b/Data/Scripts/012_Battle/002_Move/006_Move_Effects_080-0FF.rb @@ -543,8 +543,7 @@ class PokeBattle_Move_097 < PokeBattle_Move def pbBaseDamage(baseDmg,user,target) dmgs = [200,80,60,50,40] ppLeft = [@pp,dmgs.length-1].min # PP is reduced before the move is used - baseDmg = dmgs[ppLeft] - return baseDmg + return dmgs[ppLeft] end end @@ -897,7 +896,7 @@ class PokeBattle_Move_0A4 < PokeBattle_Move PBEnvironment::Forest, PBEnvironment::ForestGrass @secretPower = 2 # (Same as Grassy Terrain) when PBEnvironment::MovingWater, PBEnvironment::StillWater, - PBEnvironment::Puddle, PBEnvironment::Underwater + PBEnvironment::Underwater @secretPower = 5 # Water Pulse, lower Attack by 1 when PBEnvironment::Puddle @secretPower = 6 # Mud Shot, lower Speed by 1 @@ -1052,7 +1051,7 @@ class PokeBattle_Move_0A9 < PokeBattle_Move end def pbGetDefenseStats(user,target) - ret1, ret2 = super + ret1, _ret2 = super return ret1, 6 # Def/SpDef stat stage end end @@ -1321,7 +1320,6 @@ class PokeBattle_Move_0B3 < PokeBattle_Move # turn into, but what self-respecting game wouldn't at least have Tri # Attack in it? @npMove = getID(PBMoves,:TRIATTACK) - m = nil case @battle.field.terrain when PBBattleTerrains::Electric @npMove = getConst(PBMoves,:THUNDERBOLT) || @npMove @@ -2409,7 +2407,7 @@ class PokeBattle_Move_0D3 < PokeBattle_Move def pbBaseDamage(baseDmg,user,target) shift = (4-user.effects[PBEffects::Rollout]) # 0-4, where 0 is most powerful shift += 1 if user.effects[PBEffects::DefenseCurl] - baseDmg = baseDmg<ret end return ret @@ -433,13 +433,13 @@ class PokeBattle_Battle def pbSideBattlerCount(idxBattler=0) ret = 0 - eachSameSideBattler(idxBattler) { |b| ret += 1 } + eachSameSideBattler(idxBattler) { |_b| ret += 1 } return ret end def pbOpposingBattlerCount(idxBattler=0) ret = 0 - eachOtherSideBattler(idxBattler) { |b| ret += 1 } + eachOtherSideBattler(idxBattler) { |_b| ret += 1 } return ret end @@ -558,7 +558,7 @@ class PokeBattle_Battle idxPartyEnd = (idxTrainer=idxPartyEnd # Only check the team next if partyOrders[i]0 # No moves that can be chosen (will Struggle instead) usable = false - battler.eachMoveWithIndex do |m,i| + battler.eachMoveWithIndex do |_m,i| next if !pbCanChooseMove?(idxBattler,i,false) usable = true break diff --git a/Data/Scripts/012_Battle/003_Battle/012_Battle_Phase_EndOfRound.rb b/Data/Scripts/012_Battle/003_Battle/012_Battle_Phase_EndOfRound.rb index 2effb1fe3..56e889708 100644 --- a/Data/Scripts/012_Battle/003_Battle/012_Battle_Phase_EndOfRound.rb +++ b/Data/Scripts/012_Battle/003_Battle/012_Battle_Phase_EndOfRound.rb @@ -297,7 +297,7 @@ class PokeBattle_Battle next if !b.canHeal? hpGain = b.totalhp/16 hpGain = (hpGain*1.3).floor if b.hasActiveItem?(:BIGROOT) - hpGain = b.pbRecoverHP(hpGain) + b.pbRecoverHP(hpGain) pbDisplay(_INTL("Aqua Ring restored {1}'s HP!",b.pbThis(true))) end # Ingrain @@ -306,7 +306,7 @@ class PokeBattle_Battle next if !b.canHeal? hpGain = b.totalhp/16 hpGain = (hpGain*1.3).floor if b.hasActiveItem?(:BIGROOT) - hpGain = b.pbRecoverHP(hpGain) + b.pbRecoverHP(hpGain) pbDisplay(_INTL("{1} absorbed nutrients with its roots!",b.pbThis)) end # Leech Seed diff --git a/Data/Scripts/012_Battle/004_AI/003_AI_Switch.rb b/Data/Scripts/012_Battle/004_AI/003_AI_Switch.rb index ccd00898f..197a27201 100644 --- a/Data/Scripts/012_Battle/004_AI/003_AI_Switch.rb +++ b/Data/Scripts/012_Battle/004_AI/003_AI_Switch.rb @@ -147,7 +147,7 @@ class PokeBattle_AI #============================================================================= def pbDefaultChooseNewEnemy(idxBattler,party) enemies = [] - party.each_with_index do |p,i| + party.each_with_index do |_p,i| enemies.push(i) if @battle.pbCanSwitchLax?(idxBattler,i) end return -1 if enemies.length==0 diff --git a/Data/Scripts/012_Battle/004_AI/004_AI_Move.rb b/Data/Scripts/012_Battle/004_AI/004_AI_Move.rb index d3b01d83e..c1a2de5d7 100644 --- a/Data/Scripts/012_Battle/004_AI/004_AI_Move.rb +++ b/Data/Scripts/012_Battle/004_AI/004_AI_Move.rb @@ -14,7 +14,7 @@ class PokeBattle_AI # NOTE: A move is only added to the choices array if it has a non-zero # score. choices = [] - user.eachMoveWithIndex do |m,i| + user.eachMoveWithIndex do |_m,i| next if !@battle.pbCanChooseMove?(idxBattler,i,false) if wildBattler pbRegisterMoveWild(user,i,choices) @@ -106,7 +106,7 @@ class PokeBattle_AI # Get scores for the given move against each possible target #============================================================================= # Wild Pokémon choose their moves randomly. - def pbRegisterMoveWild(user,idxMove,choices) + def pbRegisterMoveWild(_user,idxMove,choices) choices.push([idxMove,100,-1]) # Move index, score, target end @@ -195,7 +195,6 @@ class PokeBattle_AI end # If user is asleep, prefer moves that are usable while asleep if user.status==PBStatuses::SLEEP && !move.usableWhenAsleep? - hasSleepMove = false user.eachMove do |m| next unless m.usableWhenAsleep? score -= 60 diff --git a/Data/Scripts/012_Battle/004_AI/006_AI_Move_Utilities.rb b/Data/Scripts/012_Battle/004_AI/006_AI_Move_Utilities.rb index 81ec1c8e3..da0ddc614 100644 --- a/Data/Scripts/012_Battle/004_AI/006_AI_Move_Utilities.rb +++ b/Data/Scripts/012_Battle/004_AI/006_AI_Move_Utilities.rb @@ -12,13 +12,13 @@ class PokeBattle_AI @battle.eachBattler { |b| numTargets += 1 if b.near?(user) } return numTargets>1 when PBTargets::UserAndAllies - @battle.eachSameSideBattler(user) { |b| numTargets += 1 } + @battle.eachSameSideBattler(user) { |_b| numTargets += 1 } return numTargets>1 when PBTargets::AllFoes - @battle.eachOtherSideBattler(user) { |b| numTargets += 1 } + @battle.eachOtherSideBattler(user) { |_b| numTargets += 1 } return numTargets>1 when PBTargets::AllBattlers - @battle.eachBattler { |b| numTargets += 1 } + @battle.eachBattler { |_b| numTargets += 1 } return numTargets>1 end return false @@ -75,7 +75,7 @@ class PokeBattle_AI # For switching. Determines the effectiveness of a potential switch-in against # an opposing battler. - def pbCalcTypeModPokemon(battlerThis,battlerOther) + def pbCalcTypeModPokemon(battlerThis,_battlerOther) mod1 = PBTypes.getCombinedEffectiveness(battlerThis.type1,target.type1,target.type2) mod2 = PBTypeEffectiveness::NORMAL_EFFECTIVE if battlerThis.type1!=battlerThis.type2 @@ -214,7 +214,7 @@ class PokeBattle_AI end when "0C1" # Beat Up mult = 0 - @battle.eachInTeamFromBattlerIndex(user.index) do |pkmn,i| + @battle.eachInTeamFromBattlerIndex(user.index) do |pkmn,_i| mult += 1 if pkmn && pkmn.able? && pkmn.status==PBStatuses::NONE end baseDmg *= mult diff --git a/Data/Scripts/012_Battle/005_Battle scene/002_PokeBattle_SceneAnimations.rb b/Data/Scripts/012_Battle/005_Battle scene/002_PokeBattle_SceneAnimations.rb index 80c05fa87..9f6ee0094 100644 --- a/Data/Scripts/012_Battle/005_Battle scene/002_PokeBattle_SceneAnimations.rb +++ b/Data/Scripts/012_Battle/005_Battle scene/002_PokeBattle_SceneAnimations.rb @@ -18,16 +18,16 @@ class BattleIntroAnimation < PokeBattle_Animation makeSlideSprite("base_0",1,appearTime,PictureOrigin::Bottom) makeSlideSprite("base_1",-1,appearTime,PictureOrigin::Center) # Player sprite, partner trainer sprite - @battle.player.each_with_index do |p,i| + @battle.player.each_with_index do |_p,i| makeSlideSprite("player_#{i+1}",1,appearTime,PictureOrigin::Bottom) end # Opposing trainer sprite(s) or wild Pokémon sprite(s) if @battle.trainerBattle? - @battle.opponent.each_with_index do |p,i| + @battle.opponent.each_with_index do |_p,i| makeSlideSprite("trainer_#{i+1}",-1,appearTime,PictureOrigin::Bottom) end else # Wild battle - @battle.pbParty(1).each_with_index do |pkmn,i| + @battle.pbParty(1).each_with_index do |_pkmn,i| idxBattler = 2*i+1 makeSlideSprite("pokemon_#{idxBattler}",-1,appearTime,PictureOrigin::Bottom) end @@ -574,9 +574,7 @@ class BattlerRecallAnimation < PokeBattle_Animation # Calculate the color to turn the battler sprite col = getBattlerColorFromBallType(ballType) col.alpha = 0 - # Calculate start and end coordinates for battler sprite movement - battlerStartX = batSprite.x - battlerStartY = batSprite.y + # Calculate end coordinates for battler sprite movement ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@idxBattler,batSprite.sideSize) battlerEndX = ballPos[0] battlerEndY = ballPos[1] @@ -867,8 +865,6 @@ class PokeballThrowDeflectAnimation < PokeBattle_Animation # Set up Poké Ball sprite ball = addBallSprite(ballStartX,ballStartY,@ballType) ball.setZ(0,90) - # Set up battler sprite - battler = addSprite(batSprite,PictureOrigin::Bottom) # Poké Ball arc animation ball.setSE(0,"Battle throw") createBallTrajectory(ball,0,16, diff --git a/Data/Scripts/012_Battle/005_Battle scene/006_PokeBattle_Scene.rb b/Data/Scripts/012_Battle/005_Battle scene/006_PokeBattle_Scene.rb index efe1b762d..178d68d52 100644 --- a/Data/Scripts/012_Battle/005_Battle scene/006_PokeBattle_Scene.rb +++ b/Data/Scripts/012_Battle/005_Battle scene/006_PokeBattle_Scene.rb @@ -293,7 +293,7 @@ class PokeBattle_Scene def pbBeginEndOfRoundPhase end - def pbEndBattle(result) + def pbEndBattle(_result) @abortable = false pbShowWindow(BLANK) # Fade out all sprites diff --git a/Data/Scripts/012_Battle/005_Battle scene/008_Scene_Commands.rb b/Data/Scripts/012_Battle/005_Battle scene/008_Scene_Commands.rb index 1c64f9e50..e438dac1c 100644 --- a/Data/Scripts/012_Battle/005_Battle scene/008_Scene_Commands.rb +++ b/Data/Scripts/012_Battle/005_Battle scene/008_Scene_Commands.rb @@ -144,9 +144,8 @@ class PokeBattle_Scene # Fade out and hide all sprites visibleSprites = pbFadeOutAndHide(@sprites) # Get player's party - party = @battle.pbParty(idxBattler) partyPos = @battle.pbPartyOrder(idxBattler) - partyStart, partyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler) + partyStart, _partyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler) modParty = @battle.pbPlayerDisplayParty(idxBattler) # Start party screen scene = PokemonParty_Scene.new @@ -190,7 +189,7 @@ class PokeBattle_Scene #============================================================================= # Opens the Bag screen and chooses an item to use #============================================================================= - def pbItemMenu(idxBattler,firstAction) + def pbItemMenu(idxBattler,_firstAction) # Fade out and hide all sprites visibleSprites = pbFadeOutAndHide(@sprites) # Set Bag starting positions @@ -250,7 +249,7 @@ class PokeBattle_Scene # Get player's party party = @battle.pbParty(idxBattler) partyPos = @battle.pbPartyOrder(idxBattler) - partyStart, partyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler) + partyStart, _partyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler) modParty = @battle.pbPlayerDisplayParty(idxBattler) # Start party screen pkmnScene = PokemonParty_Scene.new diff --git a/Data/Scripts/012_Battle/005_Battle scene/009_Scene_Animations.rb b/Data/Scripts/012_Battle/005_Battle scene/009_Scene_Animations.rb index 91b58f01e..35309f73b 100644 --- a/Data/Scripts/012_Battle/005_Battle scene/009_Scene_Animations.rb +++ b/Data/Scripts/012_Battle/005_Battle scene/009_Scene_Animations.rb @@ -272,7 +272,7 @@ class PokeBattle_Scene #============================================================================= # Shows stats windows upon a Pokémon levelling up #============================================================================= - def pbLevelUp(pkmn,battler,oldTotalHP,oldAttack,oldDefense,oldSpAtk,oldSpDef,oldSpeed) + def pbLevelUp(pkmn,_battler,oldTotalHP,oldAttack,oldDefense,oldSpAtk,oldSpDef,oldSpeed) pbTopRightWindow( _INTL("Max. HP+{1}\r\nAttack+{2}\r\nDefense+{3}\r\nSp. Atk+{4}\r\nSp. Def+{5}\r\nSpeed+{6}", pkmn.totalhp-oldTotalHP,pkmn.attack-oldAttack,pkmn.defense-oldDefense, @@ -482,7 +482,7 @@ class PokeBattle_Scene end # Plays a common animation. - def pbCommonAnimation(animName,user=nil,target=nil,hitNum=0) + def pbCommonAnimation(animName,user=nil,target=nil) return if !animName || animName=="" target = target[0] if target && target.is_a?(Array) animations = pbLoadBattleAnimations diff --git a/Data/Scripts/012_Battle/006_Other battle types/001_PokeBattle_AnimationPlayer.rb b/Data/Scripts/012_Battle/006_Other battle types/001_PokeBattle_AnimationPlayer.rb index 1e8d59fcd..d5378d2ab 100644 --- a/Data/Scripts/012_Battle/006_Other battle types/001_PokeBattle_AnimationPlayer.rb +++ b/Data/Scripts/012_Battle/006_Other battle types/001_PokeBattle_AnimationPlayer.rb @@ -119,7 +119,7 @@ def pbConvertRPGAnimation(animation) pbAnim.graphic = animation.animation_name pbAnim.hue = animation.animation_hue pbAnim.array.clear - yoffset = 0 + yOffset = 0 pbAnim.position = animation.position yOffset = -64 if animation.position==0 yOffset = 64 if animation.position==2 @@ -240,7 +240,7 @@ end #=============================================================================== class PBAnimTiming attr_accessor :frame - attr_accessor :timingType # 0=play SE, 1=set bg, 2=bg mod + attr_writer :timingType # 0=play SE, 1=set bg, 2=bg mod attr_accessor :name # Name of SE file or BG file attr_accessor :volume attr_accessor :pitch @@ -251,7 +251,7 @@ class PBAnimTiming attr_accessor :colorGreen # Color of bg (or to change bg to) attr_accessor :colorBlue # Color of bg (or to change bg to) attr_accessor :colorAlpha # Color of bg (or to change bg to) - attr_accessor :duration # How long to spend changing to the new bg coords/color + attr_writer :duration # How long to spend changing to the new bg coords/color attr_accessor :flashScope attr_accessor :flashColor attr_accessor :flashDuration @@ -276,13 +276,11 @@ class PBAnimTiming end def timingType - @timingType = 0 if !@timingType - return @timingType + return @timingType || 0 end def duration - @duration = 5 if !@duration - return @duration + return @duration || 5 end def to_s diff --git a/Data/Scripts/012_Battle/006_Other battle types/002_PokeBattle_SafariZone.rb b/Data/Scripts/012_Battle/006_Other battle types/002_PokeBattle_SafariZone.rb index 4410fc529..dfb942701 100644 --- a/Data/Scripts/012_Battle/006_Other battle types/002_PokeBattle_SafariZone.rb +++ b/Data/Scripts/012_Battle/006_Other battle types/002_PokeBattle_SafariZone.rb @@ -110,7 +110,6 @@ class ThrowBaitAnimation < PokeBattle_Animation def createProcesses # Calculate start and end coordinates for battler sprite movement batSprite = @sprites["pokemon_#{@battler.index}"] - shaSprite = @sprites["shadow_#{@battler.index}"] traSprite = @sprites["player_1"] ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@battler.index,batSprite.sideSize) ballStartX = traSprite.x @@ -177,7 +176,6 @@ class ThrowRockAnimation < PokeBattle_Animation def createProcesses # Calculate start and end coordinates for battler sprite movement batSprite = @sprites["pokemon_#{@battler.index}"] - shaSprite = @sprites["shadow_#{@battler.index}"] traSprite = @sprites["player_1"] ballStartX = traSprite.x ballStartY = traSprite.y-traSprite.bitmap.height/2 @@ -431,7 +429,7 @@ class PokeBattle_SafariZone catchFactor = [[catchFactor,3].max,20].min escapeFactor = (pbEscapeRate(rareness)*100)/1275 escapeFactor = [[escapeFactor,2].max,20].min - begin + loop do cmd = @scene.pbSafariCommandMenu(0) case cmd when 0 # Ball @@ -483,7 +481,8 @@ class PokeBattle_SafariZone # Weather continues @scene.pbCommonAnimation(PBWeather.animationName(@weather)) end - end while @decision==0 + break if @decision > 0 + end @scene.pbEndBattle(@decision) rescue BattleAbortedException @decision = 0 diff --git a/Data/Scripts/012_Battle/006_Other battle types/003_PokeBattle_BugContest.rb b/Data/Scripts/012_Battle/006_Other battle types/003_PokeBattle_BugContest.rb index ab16d82fb..bc0f0036a 100644 --- a/Data/Scripts/012_Battle/006_Other battle types/003_PokeBattle_BugContest.rb +++ b/Data/Scripts/012_Battle/006_Other battle types/003_PokeBattle_BugContest.rb @@ -40,11 +40,11 @@ class PokeBattle_BugContestBattle < PokeBattle_Battle super(*arg) end - def pbItemMenu(idxBattler,firstAction) + def pbItemMenu(idxBattler,_firstAction) return pbRegisterItem(idxBattler,@ballConst,1) end - def pbCommandMenu(idxBattler,firstAction) + def pbCommandMenu(idxBattler,_firstAction) return @scene.pbCommandMenuEx(idxBattler,[ _INTL("Sport Balls: {1}",@ballCount), _INTL("Fight"), @@ -54,7 +54,7 @@ class PokeBattle_BugContestBattle < PokeBattle_Battle ],4) end - def pbConsumeItemInBag(item,idxBattler) + def pbConsumeItemInBag(_item,_idxBattler) @ballCount -= 1 if @ballCount>0 end diff --git a/Data/Scripts/012_Battle/006_Other battle types/004_PokeBattle_BattlePalace.rb b/Data/Scripts/012_Battle/006_Other battle types/004_PokeBattle_BattlePalace.rb index 9ec52f8fc..5110d6d90 100644 --- a/Data/Scripts/012_Battle/006_Other battle types/004_PokeBattle_BattlePalace.rb +++ b/Data/Scripts/012_Battle/006_Other battle types/004_PokeBattle_BattlePalace.rb @@ -134,7 +134,7 @@ class PokeBattle_BattlePalace < PokeBattle_Battle end end - def pbRegisterMove(idxBattler,idxMove,showMessages=true) + def pbRegisterMove(idxBattler,idxMove,_showMessages=true) thispkmn = @battlers[idxBattler] if idxMove==-2 @choices[idxPokemon][0] = :UseMove # Move @@ -264,7 +264,7 @@ class PokeBattle_AI end @justswitched[idxBattler] = shouldswitch if shouldswitch - @battle.pbParty(idxBattler).each_with_index do |pkmn,i| + @battle.pbParty(idxBattler).each_with_index do |_pkmn,i| next if !@battle.pbCanSwitch?(idxBattler,i) @battle.pbRegisterSwitch(idxBattler,i) return true diff --git a/Data/Scripts/012_Battle/006_Other battle types/005_PokeBattle_BattleArena.rb b/Data/Scripts/012_Battle/006_Other battle types/005_PokeBattle_BattleArena.rb index 0a450e5f9..77ac61c52 100644 --- a/Data/Scripts/012_Battle/006_Other battle types/005_PokeBattle_BattleArena.rb +++ b/Data/Scripts/012_Battle/006_Other battle types/005_PokeBattle_BattleArena.rb @@ -13,7 +13,7 @@ class PokeBattle_BattleArena < PokeBattle_Battle @battleAI.battleArena = true end - def pbCanSwitchLax?(idxBattler,idxParty,partyScene=nil) + def pbCanSwitchLax?(idxBattler,_idxParty,partyScene=nil) if partyScene partyScene.pbDisplay(_INTL("{1} can't be switched out!",@battlers[idxBattler].pbThis)) end @@ -101,7 +101,6 @@ class PokeBattle_BattleArena < PokeBattle_Battle end # PBDebug.log("[Mind: #{@mind.inspect}, Skill: #{@skill.inspect}]") if @count==3 - points = [0,0] @battlers[0].pbCancelMoves @battlers[1].pbCancelMoves ratings1 = [0,0,0] diff --git a/Data/Scripts/012_Battle/006_Other battle types/006_PokeBattle_BattleRecord.rb b/Data/Scripts/012_Battle/006_Other battle types/006_PokeBattle_BattleRecord.rb index 1416a8a22..78c7c66c0 100644 --- a/Data/Scripts/012_Battle/006_Other battle types/006_PokeBattle_BattleRecord.rb +++ b/Data/Scripts/012_Battle/006_Other battle types/006_PokeBattle_BattleRecord.rb @@ -209,13 +209,13 @@ module PokeBattle_BattlePlayerModule super end - def pbSwitchInBetween(idxBattler,checkLaxOnly=false,canCancel=false) + def pbSwitchInBetween(_idxBattler,_checkLaxOnly=false,_canCancel=false) ret = @switches[@switchindex] @switchindex += 1 return ret end - def pbRandom(num) + def pbRandom(_num) ret = @randomnums[@randomindex] @randomindex += 1 return ret diff --git a/Data/Scripts/012_Battle/006_Other battle types/007_PokeBattle_DebugScene.rb b/Data/Scripts/012_Battle/006_Other battle types/007_PokeBattle_DebugScene.rb index 8ee26131a..b5ce44078 100644 --- a/Data/Scripts/012_Battle/006_Other battle types/007_PokeBattle_DebugScene.rb +++ b/Data/Scripts/012_Battle/006_Other battle types/007_PokeBattle_DebugScene.rb @@ -24,7 +24,7 @@ class PokeBattle_DebugSceneNoLogging def pbBeginAttackPhase; end def pbShowOpponent(idxTrainer); end def pbDamageAnimation(battler,effectiveness=0); end - def pbCommonAnimation(animName,user=nil,target=nil,hitNum=0); end + def pbCommonAnimation(animName,user=nil,target=nil); end def pbAnimation(moveID,user,targets,hitNum=0); end def pbEndBattle(result); end def pbWildBattleSuccess; end @@ -74,7 +74,7 @@ class PokeBattle_DebugSceneNoLogging def pbPartyScreen(idxBattler,canCancel=false) replacements = [] - @battle.eachInTeamFromBattlerIndex(idxBattler) do |b,idxParty| + @battle.eachInTeamFromBattlerIndex(idxBattler) do |_b,idxParty| replacements.push(idxParty) if !@battle.pbFindBattler(idxParty,idxBattler) end return if replacements.length==0 diff --git a/Data/Scripts/012_Battle/007_BattleHandlers_Abilities.rb b/Data/Scripts/012_Battle/007_BattleHandlers_Abilities.rb index 53504a98e..40ec4a70b 100644 --- a/Data/Scripts/012_Battle/007_BattleHandlers_Abilities.rb +++ b/Data/Scripts/012_Battle/007_BattleHandlers_Abilities.rb @@ -2129,7 +2129,7 @@ BattleHandlers::AbilityOnSwitchIn.add(:ANTICIPATION, if NEWEST_BATTLE_MECHANICS && isConst?(m.id,PBMoves,:HIDDENPOWER) moveType = pbHiddenPower(b.pokemon)[0] end - eff = PBTypes.getCombinedEffectiveness(moveData[MOVE_TYPE],type1,type2,type3) + eff = PBTypes.getCombinedEffectiveness(moveType,type1,type2,type3) next if PBTypes.ineffective?(eff) next if !PBTypes.superEffective?(eff) && moveData[MOVE_FUNCTION_CODE]!="070" # OHKO else diff --git a/Data/Scripts/013_Overworld/002_PField_Field.rb b/Data/Scripts/013_Overworld/002_PField_Field.rb index 3007e329a..344f38f16 100644 --- a/Data/Scripts/013_Overworld/002_PField_Field.rb +++ b/Data/Scripts/013_Overworld/002_PField_Field.rb @@ -173,7 +173,7 @@ end # Constant checks #=============================================================================== # Pokérus check -Events.onMapUpdate += proc { |sender,e| +Events.onMapUpdate += proc { |_sender,_e| next if !$Trainer last = $PokemonGlobal.pokerusTime now = pbGetTimeNow @@ -226,7 +226,7 @@ def pbBatteryLow? return false end -Events.onMapUpdate += proc { |sender,e| +Events.onMapUpdate += proc { |_sender,_e| if !$PokemonTemp.batterywarning && pbBatteryLow? if !$game_temp.in_menu && !$game_temp.in_battle && !$game_player.move_route_forcing && !$game_temp.message_window_showing && @@ -266,7 +266,7 @@ Events.onStepTaken += proc{ } # Poison party Pokémon -Events.onStepTakenTransferPossible += proc { |sender,e| +Events.onStepTakenTransferPossible += proc { |_sender,e| handled = e[0] next if handled[0] if $PokemonGlobal.stepcount%4==0 && POISON_IN_FIELD @@ -307,7 +307,7 @@ def pbCheckAllFainted end # Gather soot from soot grass -Events.onStepTakenFieldMovement += proc { |sender,e| +Events.onStepTakenFieldMovement += proc { |_sender,e| event = e[0] # Get the event affected by field movement thistile = $MapFactory.getRealTilePos(event.map.map_id,event.x,event.y) map = $MapFactory.getMap(thistile[0]) @@ -331,7 +331,7 @@ Events.onStepTakenFieldMovement += proc { |sender,e| } # Show grass rustle animation, and auto-move the player over waterfalls and ice -Events.onStepTakenFieldMovement += proc { |sender,e| +Events.onStepTakenFieldMovement += proc { |_sender,e| event = e[0] # Get the event affected by field movement if $scene.is_a?(Scene_Map) currentTag = pbGetTerrainTag(event) @@ -395,9 +395,8 @@ end #=============================================================================== # Clears the weather of the old map, if the old and new maps have different # names or defined weather -Events.onMapChanging += proc { |sender,e| +Events.onMapChanging += proc { |_sender,e| newMapID = e[0] - newMap = e[1] if newMapID>0 mapinfos = ($RPGVX) ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata") oldWeather = pbGetMetadata($game_map.map_id,MetadataWeather) @@ -411,7 +410,7 @@ Events.onMapChanging += proc { |sender,e| } # Set up various data related to the new map -Events.onMapChange += proc { |sender,e| +Events.onMapChange += proc { |_sender,e| oldid = e[0] # previous map ID, 0 if no map ID healing = pbGetMetadata($game_map.map_id,MetadataHealingSpot) $PokemonGlobal.healingSpot = healing if healing @@ -430,18 +429,12 @@ Events.onMapChange += proc { |sender,e| end } -Events.onMapSceneChange += proc { |sender,e| +Events.onMapSceneChange += proc { |_sender,e| scene = e[0] mapChanged = e[1] next if !scene || !scene.spriteset # Update map trail if $game_map - lastmapdetails = $PokemonGlobal.mapTrail[0] ? - pbGetMetadata($PokemonGlobal.mapTrail[0],MetadataMapPosition) : [-1,0,0] - lastmapdetails = [-1,0,0] if !lastmapdetails - newmapdetails = $game_map.map_id ? - pbGetMetadata($game_map.map_id,MetadataMapPosition) : [-1,0,0] - newmapdetails = [-1,0,0] if !newmapdetails $PokemonGlobal.mapTrail = [] if !$PokemonGlobal.mapTrail if $PokemonGlobal.mapTrail[0]!=$game_map.map_id $PokemonGlobal.mapTrail[3] = $PokemonGlobal.mapTrail[2] if $PokemonGlobal.mapTrail[2] @@ -556,7 +549,8 @@ def pbMoveRoute(event,commands,waitComplete=false) route.skippable = true route.list.clear route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOn)) - i=0; while imLevel - pokemon.level = newlevel + if $game_map.map_id == 51 + max_level = PBExperience.maxLevel + new_level = pbBalancedLevel($Trainer.party) - 4 + rand(5) # For variety + new_level = 1 if new_level < 1 + new_level = max_level if new_level > max_level + pokemon.level = new_level pokemon.calcStats pokemon.resetMoves end @@ -35,7 +35,7 @@ Events.onWildPokemonCreate += proc { |sender,e| # Note that you can only modify a partner trainer's Pokémon, and not the trainer # themselves nor their items this way, as those are generated from scratch # before each battle. -#Events.onTrainerPartyLoad += proc { |sender,e| +#Events.onTrainerPartyLoad += proc { |_sender, e| # if e[0] # Trainer data should exist to be loaded, but may not exist somehow # trainer = e[0][0] # A PokeBattle_Trainer object of the loaded trainer # items = e[0][1] # An array of the trainer's items they can use diff --git a/Data/Scripts/013_Overworld/009_PField_RoamingPokemon.rb b/Data/Scripts/013_Overworld/009_PField_RoamingPokemon.rb index 8d253c1a2..8750f930d 100644 --- a/Data/Scripts/013_Overworld/009_PField_RoamingPokemon.rb +++ b/Data/Scripts/013_Overworld/009_PField_RoamingPokemon.rb @@ -3,11 +3,10 @@ class PokemonGlobalMetadata attr_accessor :roamedAlready # Whether a roamer has been encountered on current map attr_accessor :roamEncounter attr_accessor :roamPokemon - attr_accessor :roamPokemonCaught + attr_writer :roamPokemonCaught def roamPokemonCaught - @roamPokemonCaught = [] if !@roamPokemonCaught - return @roamPokemonCaught + return @roamPokemonCaught || [] end end @@ -97,7 +96,7 @@ end # When the player moves to a new map (with a different name), make all roaming # Pokémon roam. -Events.onMapChange += proc { |sender,e| +Events.onMapChange += proc { |_sender,e| oldMapID = e[0] # Get and compare map names mapInfos = $RPGVX ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata") @@ -206,7 +205,7 @@ EncounterModifier.register(proc { |encounter| next [chosenRoamer[1],chosenRoamer[2]] # Species, level }) -Events.onWildBattleOverride += proc { |sender,e| +Events.onWildBattleOverride += proc { |_sender,e| species = e[0] level = e[1] handled = e[2] diff --git a/Data/Scripts/013_Overworld/010_PField_RandomDungeons.rb b/Data/Scripts/013_Overworld/010_PField_RandomDungeons.rb index 2d09564fb..5b479132e 100644 --- a/Data/Scripts/013_Overworld/010_PField_RandomDungeons.rb +++ b/Data/Scripts/013_Overworld/010_PField_RandomDungeons.rb @@ -19,20 +19,17 @@ class AntiRandom # Get old value value=rand(@old.length) return @old[value] - else - if @new.length>0 - # Get new value - value=rand(@new.length) - ret=@new.delete_at(value) - @old.push(ret) - return ret - else - # Get old value - value=rand(@old.length) - return @old[value] - end end - return 0 + if @new.length>0 + # Get new value + value=rand(@new.length) + ret=@new.delete_at(value) + @old.push(ret) + return ret + end + # Get old value + value=rand(@old.length) + return @old[value] end end @@ -310,7 +307,7 @@ class Maze def buildMazeWall(x,y,dir,len) wx=x;wy=y return if isBlockedNode?(x,y) - for c in 0...len + len.times do ox=wx;oy=wy wy-=1 if dir==EdgeMasks::North wx-=1 if dir==EdgeMasks::West @@ -341,7 +338,6 @@ class Maze def recurseDepthFirst(x,y,depth) setVisited(x,y) dirs=@@dirs.shuffle! - success=0 for c in 0...4 d=dirs[c] cx=0;cy=0 @@ -543,7 +539,7 @@ end def pbRandomRoomTile(dungeon,tiles) ar1=AntiRandom.new(dungeon.width) ar2=AntiRandom.new(dungeon.height) - for i in 0...(tiles.length+1)*1000 + ((tiles.length+1)*1000).times do x=ar1.get() y=ar2.get() if dungeon.isRoom?(x,y) && @@ -556,10 +552,9 @@ def pbRandomRoomTile(dungeon,tiles) return nil end -Events.onMapCreate += proc { |sender, e| +Events.onMapCreate += proc { |_sender, e| mapID=e[0] map=e[1] - tileset=e[2] if pbGetMetadata(mapID,MetadataDungeon) # this map is a randomly generated dungeon dungeon=Dungeon.new(map.width,map.height) diff --git a/Data/Scripts/013_Overworld/011_PField_FieldMoves.rb b/Data/Scripts/013_Overworld/011_PField_FieldMoves.rb index f1658311b..c7fd4150b 100644 --- a/Data/Scripts/013_Overworld/011_PField_FieldMoves.rb +++ b/Data/Scripts/013_Overworld/011_PField_FieldMoves.rb @@ -104,7 +104,7 @@ def pbHiddenMoveAnimation(pokemon) phase=1 frames=0 strobeSpeed = 64*20/Graphics.frame_rate - begin + loop do Graphics.update Input.update sprite.update @@ -176,7 +176,8 @@ def pbHiddenMoveAnimation(pokemon) end end pbUpdateSceneMap - end while phase!=6 + break if phase==6 + end sprite.dispose for strobe in strobes strobe.dispose @@ -380,7 +381,7 @@ def pbTransferUnderwater(mapid,x,y,direction=$game_player.direction) } end -Events.onAction += proc { |sender,e| +Events.onAction += proc { |_sender,_e| if $PokemonGlobal.diving if DIVING_SURFACE_ANYWHERE pbSurfacing @@ -673,7 +674,7 @@ def pbStrength return false end -Events.onAction += proc { |sender,e| +Events.onAction += proc { |_sender,_e| facingEvent = $game_player.pbFacingEvent pbStrength if facingEvent && facingEvent.name.downcase=="boulder" } @@ -733,7 +734,7 @@ def pbStartSurfing $game_player.check_event_trigger_here([1,2]) end -def pbEndSurf(xOffset,yOffset) +def pbEndSurf(_xOffset,_yOffset) return false if !$PokemonGlobal.surfing x = $game_player.x y = $game_player.y @@ -765,7 +766,7 @@ def pbTransferSurfing(mapid,xcoord,ycoord,direction=$game_player.direction) } end -Events.onAction += proc { |sender,e| +Events.onAction += proc { |_sender,_e| next if $PokemonGlobal.surfing next if pbGetMetadata($game_map.map_id,MetadataBicycleAlways) next if !PBTerrain.isSurfable?(pbFacingTerrainTag) @@ -825,7 +826,7 @@ def pbSweetScent viewport.color.blue = 0 viewport.color.alpha -= 10 alphaDiff = 12 * 20 / Graphics.frame_rate - begin + loop do if count==0 && viewport.color.alpha<128 viewport.color.alpha += alphaDiff elsif count>Graphics.frame_rate/4 @@ -836,9 +837,9 @@ def pbSweetScent Graphics.update Input.update pbUpdateSceneMap - end until viewport.color.alpha<=0 + break if viewport.color.alpha<=0 + end viewport.dispose - encounter = nil enctype = $PokemonEncounters.pbEncounterType if enctype<0 || !$PokemonEncounters.isEncounterPossibleHere? || !pbEncounter(enctype) @@ -969,7 +970,7 @@ def pbWaterfall return false end -Events.onAction += proc { |sender,e| +Events.onAction += proc { |_sender,_e| terrain = pbFacingTerrainTag if terrain==PBTerrain::Waterfall pbWaterfall diff --git a/Data/Scripts/013_Overworld/012_PField_BerryPlants.rb b/Data/Scripts/013_Overworld/012_PField_BerryPlants.rb index b61e38138..c9cae4239 100644 --- a/Data/Scripts/013_Overworld/012_PField_BerryPlants.rb +++ b/Data/Scripts/013_Overworld/012_PField_BerryPlants.rb @@ -28,7 +28,7 @@ def pbClearData __berryPlant__pbClearData end -Events.onSpritesetCreate += proc { |sender,e| +Events.onSpritesetCreate += proc { |_sender,e| spriteset = e[0] viewport = e[1] map = spriteset.map @@ -105,7 +105,7 @@ end class BerryPlantSprite REPLANTS = 9 - def initialize(event,map,viewport) + def initialize(event,map,_viewport) @event=event @map=map @oldstage=0 diff --git a/Data/Scripts/013_Overworld/013_PField_DayCare.rb b/Data/Scripts/013_Overworld/013_PField_DayCare.rb index 80c0c3922..fb204b603 100644 --- a/Data/Scripts/013_Overworld/013_PField_DayCare.rb +++ b/Data/Scripts/013_Overworld/013_PField_DayCare.rb @@ -321,7 +321,7 @@ def pbDayCareGenerateEgg ivinherit[i] = PBStats::SPEED if isConst?(parent.item,PBItems,:POWERANKLET) end num = 0; r = rand(2) - for i in 0...2 + 2.times do if ivinherit[r]!=nil parent = [mother,father][r] ivs[ivinherit[r]] = parent.iv[ivinherit[r]] @@ -355,7 +355,7 @@ def pbDayCareGenerateEgg shinyretries += 5 if father.language!=mother.language shinyretries += 2 if hasConst?(PBItems,:SHINYCHARM) && $PokemonBag.pbHasItem?(:SHINYCHARM) if shinyretries>0 - for i in 0...shinyretries + shinyretries.times do break if egg.shiny? egg.personalID = rand(65536)|(rand(65536)<<16) end @@ -410,7 +410,7 @@ end #=============================================================================== # Code that happens every step the player takes. #=============================================================================== -Events.onStepTaken += proc { |sender,e| +Events.onStepTaken += proc { |_sender,_e| # Make an egg available at the Day Care deposited = pbDayCareDeposited if deposited==2 && $PokemonGlobal.daycareEgg==0 diff --git a/Data/Scripts/013_Overworld/014_PField_DependentEvents.rb b/Data/Scripts/013_Overworld/014_PField_DependentEvents.rb index 7e399df31..44ee53b1b 100644 --- a/Data/Scripts/013_Overworld/014_PField_DependentEvents.rb +++ b/Data/Scripts/013_Overworld/014_PField_DependentEvents.rb @@ -1,5 +1,5 @@ class PokemonTemp - attr_accessor :dependentEvents + attr_writer :dependentEvents def dependentEvents @dependentEvents=DependentEvents.new if !@dependentEvents @@ -38,11 +38,10 @@ end class PokemonGlobalMetadata - attr_accessor :dependentEvents + attr_writer :dependentEvents def dependentEvents - @dependentEvents=[] if !@dependentEvents - return @dependentEvents + return @dependentEvents || [] end end @@ -56,7 +55,7 @@ end -def pbTestPass(follower,x,y,direction=nil) +def pbTestPass(follower,x,y,_direction=nil) return $MapFactory.isPassableStrict?(follower.map.map_id,x,y,follower) end @@ -176,7 +175,6 @@ class DependentEvents def pbEnsureEvent(event, newMapID) events=$PokemonGlobal.dependentEvents - found=-1 for i in 0...events.length # Check original map ID and original event ID if events[i][0]==event.map_id && events[i][1]==event.id @@ -552,15 +550,14 @@ end -Events.onSpritesetCreate += proc { |sender,e| +Events.onSpritesetCreate += proc { |_sender,e| spriteset = e[0] # Spriteset being created viewport = e[1] # Viewport used for tilemap and characters map = spriteset.map # Map associated with the spriteset (not necessarily the current map) spriteset.addUserSprite(DependentEventSprites.new(viewport,map)) } -Events.onMapSceneChange += proc { |sender,e| - scene = e[0] +Events.onMapSceneChange += proc { |_sender,e| mapChanged = e[1] if mapChanged $PokemonTemp.dependentEvents.pbMapChangeMoveDependentEvents diff --git a/Data/Scripts/013_Overworld/015_PField_Time.rb b/Data/Scripts/013_Overworld/015_PField_Time.rb index 82a0897ca..e8d2548f8 100644 --- a/Data/Scripts/013_Overworld/015_PField_Time.rb +++ b/Data/Scripts/013_Overworld/015_PField_Time.rb @@ -72,7 +72,7 @@ module PBDayNight def self.getShade time = pbGetDayNightMinutes time = (24*60)-time if time>(12*60) - shade=255*time/(12*60) + return 255*time/(12*60) end # Gets a Tone object representing a suggested shading @@ -97,7 +97,7 @@ module PBDayNight # Internal function - def self.getToneInternal + def getToneInternal # Calculates the tone for the current frame, used for day/night effects realMinutes = pbGetDayNightMinutes hour = realMinutes/60 diff --git a/Data/Scripts/014_Trainers/001_PokeBattle_Trainer.rb b/Data/Scripts/014_Trainers/001_PokeBattle_Trainer.rb index 6c187b441..77ffef5a5 100644 --- a/Data/Scripts/014_Trainers/001_PokeBattle_Trainer.rb +++ b/Data/Scripts/014_Trainers/001_PokeBattle_Trainer.rb @@ -1,20 +1,20 @@ class PokeBattle_Trainer - attr_accessor(:name) - attr_accessor(:id) - attr_accessor(:metaID) - attr_accessor(:trainertype) - attr_accessor(:outfit) - attr_accessor(:badges) - attr_accessor(:money) - attr_accessor(:seen) - attr_accessor(:owned) - attr_accessor(:formseen) - attr_accessor(:formlastseen) - attr_accessor(:shadowcaught) - attr_accessor(:party) - attr_accessor(:pokedex) # Whether the Pokédex was obtained - attr_accessor(:pokegear) # Whether the Pokégear was obtained - attr_accessor(:language) + attr_accessor :name + attr_accessor :id + attr_writer :metaID + attr_accessor :trainertype + attr_writer :outfit + attr_accessor :badges + attr_reader :money + attr_accessor :seen + attr_accessor :owned + attr_accessor :formseen + attr_accessor :formlastseen + attr_accessor :shadowcaught + attr_accessor :party + attr_accessor :pokedex # Whether the Pokédex was obtained + attr_accessor :pokegear # Whether the Pokégear was obtained + attr_writer :language def trainerTypeName # Name of this trainer type (localized) return PBTrainers.getName(@trainertype) rescue _INTL("PkMn Trainer") @@ -55,13 +55,11 @@ class PokeBattle_Trainer end def outfit - @outfit=0 if !@outfit - return @outfit + return @outfit || 0 end def language - @language=pbGetLanguage() if !@language - return @language + return @language || pbGetLanguage end def money=(value) diff --git a/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb b/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb index 343092784..52362698b 100644 --- a/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb +++ b/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb @@ -126,7 +126,6 @@ def pbNewTrainer(trainerid,trainername,trainerparty,savechanges=true) params.setDefaultValue(10) level = pbMessageChooseNumber(_INTL("Set the level for {1} (max. #{PBExperience.maxLevel}).", PBSpecies.getName(species)),params) - tempPoke = pbNewPkmn(species,level) pokemon.push([species,level]) break end @@ -136,7 +135,7 @@ def pbNewTrainer(trainerid,trainername,trainerparty,savechanges=true) if savechanges data = pbLoadTrainersData data.push(trainer) - data = save_data(data,"Data/trainers.dat") + save_data(data,"Data/trainers.dat") $PokemonTemp.trainersData = nil pbConvertTrainerData pbMessage(_INTL("The Trainer's data was added to the list of battles and in PBS/trainers.txt.")) @@ -168,7 +167,6 @@ def pbGetFreeTrainerParty(trainerid,trainername) end trainerid = getID(PBTrainers,trainerid) end - ret = -1 trainers = pbLoadTrainersData usedparties = [] for trainer in trainers @@ -213,8 +211,7 @@ def pbMissingTrainer(trainerid, trainername, trainerparty) end trainerid = getID(PBTrainers,trainerid) end - traineridstring = "#{trainerid}" - traineridstring = getConstantName(PBTrainers,trainerid) rescue "-" + traineridstring = getConstantName(PBTrainers,trainerid) rescue "#{trainerid}" if !$DEBUG raise _INTL("Can't find trainer ({1}, {2}, ID {3})",traineridstring,trainername,trainerparty) end diff --git a/Data/Scripts/015_Items/001_PItem_Items.rb b/Data/Scripts/015_Items/001_PItem_Items.rb index e16d7f5b9..b2986d56b 100644 --- a/Data/Scripts/015_Items/001_PItem_Items.rb +++ b/Data/Scripts/015_Items/001_PItem_Items.rb @@ -209,7 +209,6 @@ def pbIsUnlosableItem?(item,species,ability) :KYOGRE => [:BLUEORB], :GROUDON => [:REDORB] } - ret = false combos.each do |comboSpecies, items| next if !isConst?(species,PBSpecies,comboSpecies) items.each { |i| return true if isConst?(item,PBItems,i) } @@ -363,7 +362,6 @@ def pbChangeLevel(pkmn,newlevel,scene) spatkdiff = pkmn.spatk spdefdiff = pkmn.spdef totalhpdiff = pkmn.totalhp - oldlevel = pkmn.level pkmn.level = newlevel pkmn.changeHappiness("vitamin") pkmn.calcStats @@ -677,7 +675,6 @@ end # Use an item from the Bag and/or on a Pokémon #=============================================================================== def pbUseItem(bag,item,bagscene=nil) - found = false useType = pbGetItemData(item,ITEM_FIELD_USE) if pbIsMachine?(item) # TM or HM if $Trainer.pokemonCount==0 @@ -808,7 +805,7 @@ def pbUseItemMessage(item) end end -def pbCheckUseOnPokemon(item,pkmn,screen) +def pbCheckUseOnPokemon(_item,pkmn,_screen) return pkmn && !pkmn.egg? end @@ -905,7 +902,7 @@ end #=============================================================================== # Choose an item from the Bag #=============================================================================== -def pbChooseItem(var=0,*args) +def pbChooseItem(var=0,_args) ret = 0 pbFadeOutIn { scene = PokemonBag_Scene.new diff --git a/Data/Scripts/015_Items/004_PItem_Phone.rb b/Data/Scripts/015_Items/004_PItem_Phone.rb index c5c6f839b..89013a6f0 100644 --- a/Data/Scripts/015_Items/004_PItem_Phone.rb +++ b/Data/Scripts/015_Items/004_PItem_Phone.rb @@ -90,7 +90,7 @@ def pbFindPhoneTrainer(trtype,trname) # Ignores whether visible or not end def pbHasPhoneTrainer?(trtype,trname) - return pbFindPhoneTrainer!=nil + return pbFindPhoneTrainer(trtype,trname)!=nil end def pbPhoneBattleCount(trtype,trname) @@ -133,7 +133,7 @@ end #=============================================================================== # Phone-related counters #=============================================================================== -Events.onMapUpdate += proc { |sender,e| +Events.onMapUpdate += proc { |_sender,_e| next if !$Trainer || !$Trainer.pokegear # Reset time to next phone call if necessary if !$PokemonGlobal.phoneTime || $PokemonGlobal.phoneTime<=0 @@ -207,7 +207,6 @@ end # Generate phone message #=============================================================================== def pbPhoneGenerateCall(phonenum) - call = "" phoneData = pbLoadPhoneData # Choose random greeting depending on time of day call = pbRandomPhoneItem(phoneData.greetings) diff --git a/Data/Scripts/015_Items/005_PItem_PokeRadar.rb b/Data/Scripts/015_Items/005_PItem_PokeRadar.rb index f9a20789e..ccc5c3654 100644 --- a/Data/Scripts/015_Items/005_PItem_PokeRadar.rb +++ b/Data/Scripts/015_Items/005_PItem_PokeRadar.rb @@ -190,7 +190,7 @@ EncounterModifier.register(proc { |encounter| next encounter }) -Events.onWildPokemonCreate += proc { |sender,e| +Events.onWildPokemonCreate += proc { |_sender,e| pokemon = e[0] next if !$PokemonTemp.pokeradar grasses = $PokemonTemp.pokeradar[3] @@ -202,7 +202,7 @@ Events.onWildPokemonCreate += proc { |sender,e| end } -Events.onWildBattleEnd += proc { |sender,e| +Events.onWildBattleEnd += proc { |_sender,e| species = e[0] level = e[1] decision = e[2] @@ -221,7 +221,7 @@ Events.onWildBattleEnd += proc { |sender,e| end } -Events.onStepTaken += proc { |sender,e| +Events.onStepTaken += proc { |_sender,_e| if $PokemonGlobal.pokeradarBattery && $PokemonGlobal.pokeradarBattery>0 && !$PokemonTemp.pokeradar $PokemonGlobal.pokeradarBattery -= 1 @@ -232,11 +232,11 @@ Events.onStepTaken += proc { |sender,e| end } -Events.onMapUpdate += proc { |sender,e| +Events.onMapUpdate += proc { |_sender,_e| pbPokeRadarCancel if $PokemonGlobal.bicycle } -Events.onMapChange += proc { |sender,e| +Events.onMapChange += proc { |_sender,_e| pbPokeRadarCancel } diff --git a/Data/Scripts/015_Items/006_PItem_Mail.rb b/Data/Scripts/015_Items/006_PItem_Mail.rb index 8ed08cbe3..8d8ad1414 100644 --- a/Data/Scripts/015_Items/006_PItem_Mail.rb +++ b/Data/Scripts/015_Items/006_PItem_Mail.rb @@ -28,7 +28,7 @@ def pbStoreMail(pkmn,item,message,poke1=nil,poke2=nil,poke3=nil) pkmn.mail = PokemonMail.new(item,message,$Trainer.name,poke1,poke2,poke3) end -def pbDisplayMail(mail,bearer=nil) +def pbDisplayMail(mail,_bearer=nil) sprites = {} viewport = Viewport.new(0,0,Graphics.width,Graphics.height) viewport.z = 99999 @@ -95,7 +95,7 @@ def pbWriteMail(item,pkmn,pkmnid,scene) "",false,256,Graphics.width) { scene.pbUpdate } if message!="" # Store mail if a message was written - poke1 = poke2 = poke3 = nil + poke1 = poke2 = nil if $Trainer.party[pkmnid+2] p = $Trainer.party[pkmnid+2] poke1 = [p.species,p.gender,p.shiny?,(p.form rescue 0),p.shadowPokemon?] @@ -110,8 +110,7 @@ def pbWriteMail(item,pkmn,pkmnid,scene) poke3.push(true) if pkmn.egg? pbStoreMail(pkmn,item,message,poke1,poke2,poke3) return true - else - return false if scene.pbConfirm(_INTL("Stop giving the Pokémon Mail?")) end + return false if scene.pbConfirm(_INTL("Stop giving the Pokémon Mail?")) end end diff --git a/Data/Scripts/015_Items/008_PItem_Bag.rb b/Data/Scripts/015_Items/008_PItem_Bag.rb index eed4d3e08..2b82a62ec 100644 --- a/Data/Scripts/015_Items/008_PItem_Bag.rb +++ b/Data/Scripts/015_Items/008_PItem_Bag.rb @@ -3,7 +3,6 @@ #=============================================================================== class PokemonBag attr_accessor :lastpocket - attr_reader :pockets def self.pocketNames return pbPocketNames @@ -92,7 +91,6 @@ class PokemonBag item = getID(PBItems,item) if !item || item<1 raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) - return 0 end pocket = pbGetPocket(item) maxsize = maxPocketSize(pocket) @@ -108,7 +106,6 @@ class PokemonBag item = getID(PBItems,item) if !item || item<1 raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) - return false end pocket = pbGetPocket(item) maxsize = maxPocketSize(pocket) @@ -121,7 +118,6 @@ class PokemonBag item = getID(PBItems,item) if !item || item<1 raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) - return false end pocket = pbGetPocket(item) maxsize = maxPocketSize(pocket) @@ -134,7 +130,6 @@ class PokemonBag item = getID(PBItems,item) if !item || item<1 raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) - return false end pocket = pbGetPocket(item) maxsize = maxPocketSize(pocket) @@ -148,10 +143,8 @@ class PokemonBag newitem = getID(PBItems,newitem) if !olditem || olditem<1 raise ArgumentError.new(_INTL("Item number {1} is invalid.",olditem)) - return false elsif !newitem || newitem<1 raise ArgumentError.new(_INTL("Item number {1} is invalid.",newitem)) - return false end pocket = pbGetPocket(olditem) maxsize = maxPocketSize(pocket) @@ -179,7 +172,6 @@ class PokemonBag item = getID(PBItems,item) if !item || item<1 raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) - return false end pocket = pbGetPocket(item) maxsize = maxPocketSize(pocket) @@ -209,7 +201,6 @@ class PokemonBag item = getID(PBItems,item) if !item || item<1 raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) - return end registeredlist = self.registeredItems registeredlist.push(item) if !registeredlist.include?(item) @@ -220,7 +211,6 @@ class PokemonBag item = getID(PBItems,item) if !item || item<1 raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) - return end registeredlist = self.registeredItems if registeredlist.include?(item) diff --git a/Data/Scripts/016_Pokemon/001_PokeBattle_Pokemon.rb b/Data/Scripts/016_Pokemon/001_PokeBattle_Pokemon.rb index f32354d0a..9cb66333f 100644 --- a/Data/Scripts/016_Pokemon/001_PokeBattle_Pokemon.rb +++ b/Data/Scripts/016_Pokemon/001_PokeBattle_Pokemon.rb @@ -21,16 +21,16 @@ class PokeBattle_Pokemon attr_accessor :moves # Moves (PBMove) attr_accessor :firstmoves # The moves known when this Pokémon was obtained attr_accessor :item # Held item - attr_accessor :mail # Mail + attr_writer :mail # Mail attr_accessor :fused # The Pokémon fused into this one attr_accessor :iv # Array of 6 Individual Values for HP, Atk, Def, # Speed, Sp Atk, and Sp Def - attr_accessor :ivMaxed # Array of booleans that max each IV value + attr_writer :ivMaxed # Array of booleans that max each IV value attr_accessor :ev # Effort Values attr_accessor :happiness # Current happiness attr_accessor :ballused # Ball used attr_accessor :eggsteps # Steps to hatch egg, 0 if Pokémon is not an egg - attr_accessor :markings # Markings + attr_writer :markings # Markings attr_accessor :ribbons # Array of ribbons attr_accessor :pokerus # Pokérus strain and infection time attr_accessor :personalID # Personal ID @@ -41,15 +41,15 @@ class PokeBattle_Pokemon # 4 - fateful encounter attr_accessor :obtainMap # Map where obtained attr_accessor :obtainText # Replaces the obtain map's name if not nil - attr_accessor :obtainLevel # Level obtained + attr_writer :obtainLevel # Level obtained attr_accessor :hatchedMap # Map where an egg was hatched - attr_accessor :language # Language + attr_writer :language # Language attr_accessor :ot # Original Trainer's name - attr_accessor :otgender # Original Trainer's gender: + attr_writer :otgender # Original Trainer's gender: # 0 - male, 1 - female, 2 - mixed, 3 - unknown # For information only, not used to verify # ownership of the Pokémon - attr_accessor :cool,:beauty,:cute,:smart,:tough,:sheen # Contest stats + attr_writer :cool,:beauty,:cute,:smart,:tough,:sheen # Contest stats IV_STAT_LIMIT = 31 # Max total IVs EV_LIMIT = 510 # Max total EVs @@ -348,7 +348,7 @@ class PokeBattle_Pokemon strain = 1+rand(15) if strain<=0 || strain>=16 time = 1+(strain%4) @pokerus = time - @pokerus |= strain<<4 + @pokerus |= strain << 4 end # Resets the infection time for this Pokémon's Pokérus (even if cured). @@ -357,7 +357,7 @@ class PokeBattle_Pokemon strain = @pokerus%16 time = 1+(strain%4) @pokerus = time - @pokerus |= strain<<4 + @pokerus |= strain << 4 end # Reduces the time remaining for this Pokémon's Pokérus (if infected). @@ -447,7 +447,8 @@ class PokeBattle_Pokemon return if move<=0 for i in 0...4 # Already knows move, relocate it to the end of the list next if @moves[i].id!=move - j = i+1; while j<4 + j = i+1 + while j<4 break if @moves[j].id==0 tmp = @moves[j] @moves[j] = @moves[j-1] @@ -524,12 +525,12 @@ class PokeBattle_Pokemon #============================================================================= # Contest attributes, ribbons #============================================================================= - def cool; return @cool ? @cool : 0; end - def beauty; return @beauty ? @beauty : 0; end - def cute; return @cute ? @cute : 0; end - def smart; return @smart ? @smart : 0; end - def tough; return @tough ? @tough : 0; end - def sheen; return @sheen ? @sheen : 0; end + def cool; return @cool || 0; end + def beauty; return @beauty || 0; end + def cute; return @cute || 0; end + def smart; return @smart || 0; end + def tough; return @tough || 0; end + def sheen; return @sheen || 0; end # Returns the number of ribbons this Pokémon has. def ribbonCount @@ -672,8 +673,7 @@ class PokeBattle_Pokemon # Returns an array of booleans indicating whether a stat is made to have # maximum IVs (for Hyper Training). Set like @ivMaxed[PBStats::ATTACK] = true def ivMaxed - @ivMaxed = [] if !@ivMaxed - return @ivMaxed + return @ivMaxed || [] end # Returns this Pokémon's effective IVs, taking into account Hyper Training. @@ -870,7 +870,6 @@ class PokeBattle_Pokemon realSpecies = pbGetSpeciesFromFSpecies(species)[0] if species && species>0 if !species || species<=0 || realSpecies>PBSpecies.maxValue || !cname raise ArgumentError.new(_INTL("The species given ({1}) is invalid.",ospecies)) - return nil end @species = realSpecies @name = PBSpecies.getName(@species) diff --git a/Data/Scripts/016_Pokemon/002_Pokemon_Forms.rb b/Data/Scripts/016_Pokemon/002_Pokemon_Forms.rb index 508aac8a9..ab390f25c 100644 --- a/Data/Scripts/016_Pokemon/002_Pokemon_Forms.rb +++ b/Data/Scripts/016_Pokemon/002_Pokemon_Forms.rb @@ -63,7 +63,7 @@ end class PokeBattle_RealBattlePeer - def pbOnEnteringBattle(battle,pkmn,wild=false) + def pbOnEnteringBattle(_battle,pkmn,wild=false) f = MultipleForms.call("getFormOnEnteringBattle",pkmn,wild) pkmn.form = f if f end @@ -248,7 +248,6 @@ MultipleForms.register(:BURMY,{ }, "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| next if !endBattle || !usedInBattle - env = battle.environment case battle.environment when PBEnvironment::Rock, PBEnvironment::Sand, PBEnvironment::Cave next 1 # Sandy Cloak diff --git a/Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb b/Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb index 1865f72c2..3afe34b6f 100644 --- a/Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb +++ b/Data/Scripts/016_Pokemon/004_Pokemon_ShadowPokemon.rb @@ -231,9 +231,9 @@ end # Pokémon class. #=============================================================================== class PokeBattle_Pokemon - attr_accessor :heartgauge + attr_writer :heartgauge attr_accessor :shadow - attr_accessor :hypermode + attr_writer :hypermode attr_accessor :savedev attr_accessor :savedexp attr_accessor :shadowmoves @@ -260,8 +260,7 @@ class PokeBattle_Pokemon end def heartgauge - @heartgauge = 0 if !@heartgauge - return @heartgauge + return @heartgauge || 0 end def heartStage @@ -668,7 +667,7 @@ end -Events.onStartBattle += proc { |sender| +Events.onStartBattle += proc { |_sender| # Record current heart gauges of Pokémon in party, to see if they drop to zero # during battle and need to say they're ready to be purified afterwards $PokemonTemp.heartgauges = [] @@ -677,9 +676,7 @@ Events.onStartBattle += proc { |sender| end } -Events.onEndBattle += proc { |sender,e| - decision = e[0] - canLose = e[1] +Events.onEndBattle += proc { |_sender,_e| for i in 0...$PokemonTemp.heartgauges.length pokemon = $Trainer.party[i] if pokemon && $PokemonTemp.heartgauges[i] && diff --git a/Data/Scripts/016_Pokemon/006_Pokemon_Chatter.rb b/Data/Scripts/016_Pokemon/006_Pokemon_Chatter.rb index f971de152..d50e8671f 100644 --- a/Data/Scripts/016_Pokemon/006_Pokemon_Chatter.rb +++ b/Data/Scripts/016_Pokemon/006_Pokemon_Chatter.rb @@ -39,7 +39,7 @@ HiddenMoveHandlers::UseMove.add(:CHATTER,proc { |move,pokemon| class PokeBattle_Scene - def pbChatter(user,target) + def pbChatter(user,_target) pbPlayCry(user.pokemon,90,100) if user.pokemon Graphics.frame_rate.times do Graphics.update diff --git a/Data/Scripts/016_Pokemon/008_Pokemon_Storage.rb b/Data/Scripts/016_Pokemon/008_Pokemon_Storage.rb index 2d6f286f1..1672f1c4d 100644 --- a/Data/Scripts/016_Pokemon/008_Pokemon_Storage.rb +++ b/Data/Scripts/016_Pokemon/008_Pokemon_Storage.rb @@ -111,7 +111,7 @@ class PokemonStorage $Trainer.party end - def party=(value) + def party=(_value) raise ArgumentError.new("Not supported") end diff --git a/Data/Scripts/017_UI/003_PScreen_PokedexMain.rb b/Data/Scripts/017_UI/003_PScreen_PokedexMain.rb index 765c503b9..8af41d95c 100644 --- a/Data/Scripts/017_UI/003_PScreen_PokedexMain.rb +++ b/Data/Scripts/017_UI/003_PScreen_PokedexMain.rb @@ -29,7 +29,7 @@ class Window_Pokedex < Window_DrawableCommand return @commands.length end - def drawItem(index,count,rect) + def drawItem(index,_count,rect) return if index>=self.top_row+self.page_item_max rect = Rect.new(rect.x+16,rect.y,rect.width-16,rect.height) species = @commands[index][0] @@ -431,7 +431,8 @@ class PokemonPokedex_Scene y = 78 y += ((sliderheight-boxheight)*itemlist.top_row/(itemlist.row_max-itemlist.page_row_max)).floor overlay.blt(468,y,@sliderbitmap.bitmap,Rect.new(40,0,40,8)) - i = 0; while i*163 @@ -718,10 +715,8 @@ class PokemonSummary_Scene # Get data for selected move moveData = pbGetMoveData(moveid) basedamage = moveData[MOVE_BASE_DAMAGE] - type = moveData[MOVE_TYPE] category = moveData[MOVE_CATEGORY] accuracy = moveData[MOVE_ACCURACY] - move = moveid textpos = [] # Write power and accuracy values for selected move if basedamage==0 # Status move @@ -818,8 +813,6 @@ class PokemonSummary_Scene def drawPageFive overlay = @sprites["overlay"].bitmap - base = Color.new(248,248,248) - shadow = Color.new(104,104,104) @sprites["uparrow"].visible = false @sprites["downarrow"].visible = false # Write various bits of text @@ -1178,7 +1171,7 @@ class PokemonSummary_Scene pbFadeOutIn { scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene,$PokemonBag) - item = screen.pbChooseItemScreen(Proc.new { |item| pbCanHoldItem?(item) }) + item = screen.pbChooseItemScreen(Proc.new { |itm| pbCanHoldItem?(itm) }) } if item>0 dorefresh = pbGiveItemToPokemon(item,@pokemon,self,@partyindex) diff --git a/Data/Scripts/017_UI/007_PScreen_Bag.rb b/Data/Scripts/017_UI/007_PScreen_Bag.rb index f054aee68..dfd13a03e 100644 --- a/Data/Scripts/017_UI/007_PScreen_Bag.rb +++ b/Data/Scripts/017_UI/007_PScreen_Bag.rb @@ -58,7 +58,7 @@ class Window_PokemonBag < Window_DrawableCommand end end - def drawItem(index,count,rect) + def drawItem(index,_count,rect) textpos = [] rect = Rect.new(rect.x+16,rect.y+16,rect.width-16,rect.height) ypos = rect.y+4 @@ -307,7 +307,8 @@ class PokemonBag_Scene y = 54 y += ((sliderheight-boxheight)*itemlist.top_row/(itemlist.row_max-itemlist.page_row_max)).floor overlay.blt(470,y,@sliderbitmap.bitmap,Rect.new(36,0,36,4)) - i = 0; while i*16=self.top_row+self.page_item_max super - overlapCursor = drawCursor(index-1,itemRect(index-1)) + drawCursor(index-1,itemRect(index-1)) end end diff --git a/Data/Scripts/017_UI/013_PScreen_Load.rb b/Data/Scripts/017_UI/013_PScreen_Load.rb index 8b838c743..9db9aaf7d 100644 --- a/Data/Scripts/017_UI/013_PScreen_Load.rb +++ b/Data/Scripts/017_UI/013_PScreen_Load.rb @@ -551,15 +551,9 @@ module FontInstaller success = [] # Check if all fonts already exist filesExist = true - fontsExist = true dest = self.getFontFolder for i in 0...Names.size - if !safeExists?(dest + Filenames[i]) - filesExist = false - end - if !Font.exist?(Names[i]) - fontsExist = false - end + filesExist = false if !safeExists?(dest + Filenames[i]) end return if filesExist # Check if all source fonts exist diff --git a/Data/Scripts/017_UI/014_PScreen_Save.rb b/Data/Scripts/017_UI/014_PScreen_Save.rb index d5bec2926..bc5997f52 100644 --- a/Data/Scripts/017_UI/014_PScreen_Save.rb +++ b/Data/Scripts/017_UI/014_PScreen_Save.rb @@ -117,7 +117,6 @@ class PokemonSaveScreen @scene.pbStartScreen if pbConfirmMessage(_INTL("Would you like to save the game?")) if safeExists?(RTP.getSaveFileName("Game.rxdata")) - confirm="" if $PokemonTemp.begunNewGame pbMessage(_INTL("WARNING!")) pbMessage(_INTL("There is a different game file that is already saved.")) diff --git a/Data/Scripts/017_UI/015_PScreen_Options.rb b/Data/Scripts/017_UI/015_PScreen_Options.rb index 514db5c33..f32e6983b 100644 --- a/Data/Scripts/017_UI/015_PScreen_Options.rb +++ b/Data/Scripts/017_UI/015_PScreen_Options.rb @@ -3,15 +3,15 @@ class PokemonSystem attr_accessor :battlescene attr_accessor :battlestyle attr_accessor :frame - attr_accessor :textskin + attr_writer :textskin attr_accessor :font attr_accessor :screensize - attr_accessor :border - attr_accessor :language - attr_accessor :runstyle - attr_accessor :bgmvolume - attr_accessor :sevolume - attr_accessor :textinput + attr_writer :border + attr_writer :language + attr_writer :runstyle + attr_writer :bgmvolume + attr_writer :sevolume + attr_writer :textinput def initialize @textspeed = 1 # Text speed (0=slow, 1=normal, 2=fast) @@ -327,7 +327,7 @@ class Window_PokemonOption < Window_DrawableCommand return @options.length+1 end - def drawItem(index,count,rect) + def drawItem(index,_count,rect) rect = drawCursor(index,rect) optionname = (index==@options.length) ? _INTL("Cancel") : @options[index].name optionwidth = rect.width*9/20 @@ -389,7 +389,6 @@ class Window_PokemonOption < Window_DrawableCommand end def update - dorefresh = false oldindex = self.index @mustUpdateOptions = false super @@ -419,7 +418,7 @@ class PokemonOption_Scene pbUpdateSpriteHash(@sprites) end - def pbStartScene(inloadscreen=false) + def pbStartScene(inloadscreen=false) @sprites = {} @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) @viewport.z = 99999 diff --git a/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb b/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb index 387fc23f5..74170ab0a 100644 --- a/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb +++ b/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb @@ -805,7 +805,7 @@ class PokemonStorageScene return selection end - def pbSelectBoxInternal(party) + def pbSelectBoxInternal(_party) selection = @selection pbSetArrow(@sprites["arrow"],selection) pbUpdateOverlay(selection) @@ -995,13 +995,14 @@ class PokemonStorageScene newbox.x = 520 Graphics.frame_reset distancePerFrame = 64*20/Graphics.frame_rate - begin + loop do Graphics.update Input.update @sprites["box"].x -= distancePerFrame newbox.x -= distancePerFrame self.update - end until newbox.x<=184 + break if newbox.x<=184 + end diff = newbox.x-184 newbox.x = 184 @sprites["box"].x -= diff @@ -1014,13 +1015,14 @@ class PokemonStorageScene newbox.x = -152 Graphics.frame_reset distancePerFrame = 64*20/Graphics.frame_rate - begin + loop do Graphics.update Input.update @sprites["box"].x += distancePerFrame newbox.x += distancePerFrame self.update - end until newbox.x>=184 + break if newbox.x>=184 + end diff = newbox.x-184 newbox.x = 184 @sprites["box"].x -= diff @@ -1057,24 +1059,26 @@ class PokemonStorageScene def pbShowPartyTab pbSEPlay("GUI storage show party panel") distancePerFrame = 48*20/Graphics.frame_rate - begin + loop do Graphics.update Input.update @sprites["boxparty"].y -= distancePerFrame self.update - end until @sprites["boxparty"].y<=Graphics.height-352 + break if @sprites["boxparty"].y<=Graphics.height-352 + end @sprites["boxparty"].y = Graphics.height-352 end def pbHidePartyTab pbSEPlay("GUI storage hide party panel") distancePerFrame = 48*20/Graphics.frame_rate - begin + loop do Graphics.update Input.update @sprites["boxparty"].y += distancePerFrame self.update - end until @sprites["boxparty"].y>=Graphics.height + break if @sprites["boxparty"].y>=Graphics.height + end @sprites["boxparty"].y = Graphics.height end @@ -1092,7 +1096,7 @@ class PokemonStorageScene end end - def pbSwap(selected,heldpoke) + def pbSwap(selected,_heldpoke) pbSEPlay("GUI storage pick up") heldpokesprite = @sprites["arrow"].heldPokemon boxpokesprite = nil @@ -1112,7 +1116,7 @@ class PokemonStorageScene @selectionForMosaic = selected[1] end - def pbPlace(selected,heldpoke) + def pbPlace(selected,_heldpoke) pbSEPlay("GUI storage put down") heldpokesprite = @sprites["arrow"].heldPokemon @sprites["arrow"].place @@ -1270,7 +1274,6 @@ class PokemonStorageScene end def pbMark(selected,heldpoke) - ret = 0 @sprites["markingbg"].visible = true @sprites["markingoverlay"].visible = true msg = _INTL("Mark your Pokémon.") @@ -1366,7 +1369,7 @@ class PokemonStorageScene @sprites["boxparty"].y = oldPartyY end - def drawMarkings(bitmap,x,y,width,height,markings) + def drawMarkings(bitmap,x,y,_width,_height,markings) markrect = Rect.new(0,0,16,16) for i in 0...8 markrect.x = i*16 @@ -1704,7 +1707,6 @@ class PokemonStorageScreen loop do destbox = @scene.pbChooseBox(_INTL("Deposit in which Box?")) if destbox>=0 - success = false firstfree = @storage.pbFirstFreePos(destbox) if firstfree<0 pbDisplay(_INTL("The Box is full.")) @@ -1921,7 +1923,7 @@ class PokemonStorageScreen end end - def pbChoosePokemon(party=nil) + def pbChoosePokemon(_party=nil) @heldpkmn = nil @scene.pbStartBox(self,1) retval = nil diff --git a/Data/Scripts/017_UI/018_PScreen_ItemStorage.rb b/Data/Scripts/017_UI/018_PScreen_ItemStorage.rb index 483f3da36..5eb95a1a0 100644 --- a/Data/Scripts/017_UI/018_PScreen_ItemStorage.rb +++ b/Data/Scripts/017_UI/018_PScreen_ItemStorage.rb @@ -25,7 +25,7 @@ class Window_PokemonItemStorage < Window_DrawableCommand return @bag.length+1 end - def drawItem(index,count,rect) + def drawItem(index,_count,rect) rect = drawCursor(index,rect) ypos = rect.y textpos = [] diff --git a/Data/Scripts/017_UI/019_PScreen_PC.rb b/Data/Scripts/017_UI/019_PScreen_PC.rb index 703fa120e..a5f666d4e 100644 --- a/Data/Scripts/017_UI/019_PScreen_PC.rb +++ b/Data/Scripts/017_UI/019_PScreen_PC.rb @@ -25,14 +25,14 @@ def pbPCItemStorage pbFadeOutIn { scene = WithdrawItemScene.new screen = PokemonBagScreen.new(scene,$PokemonBag) - ret = screen.pbWithdrawItemScreen + screen.pbWithdrawItemScreen } end when 1 # Deposit Item pbFadeOutIn { scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene,$PokemonBag) - ret = screen.pbDepositItemScreen + screen.pbDepositItemScreen } when 2 # Toss Item if !$PokemonGlobal.pcItemStorage @@ -44,7 +44,7 @@ def pbPCItemStorage pbFadeOutIn { scene = TossItemScene.new screen = PokemonBagScreen.new(scene,$PokemonBag) - ret = screen.pbTossItemScreen + screen.pbTossItemScreen } end else diff --git a/Data/Scripts/017_UI/020_PScreen_EggHatching.rb b/Data/Scripts/017_UI/020_PScreen_EggHatching.rb index 0d85e1619..b3714b32c 100644 --- a/Data/Scripts/017_UI/020_PScreen_EggHatching.rb +++ b/Data/Scripts/017_UI/020_PScreen_EggHatching.rb @@ -190,7 +190,7 @@ def pbHatchAnimation(pokemon) end def pbHatch(pokemon) - speciesname = PBSpecies.getName(pokemon.species) + speciesname = pokemon.speciesName pokemon.name = speciesname pokemon.trainerID = $Trainer.id pokemon.ot = $Trainer.name @@ -208,7 +208,6 @@ def pbHatch(pokemon) pbMessage(_INTL("... .... .....\1")) pbMessage(_INTL("{1} hatched from the Egg!",speciesname)) if pbConfirmMessage(_INTL("Would you like to nickname the newly hatched {1}?",speciesname)) - species = PBSpecies.getName(pokemon.species) nickname = pbEnterPokemonName(_INTL("{1}'s nickname?",speciesname), 0,PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE,"",pokemon) pokemon.name = nickname if nickname!="" @@ -216,7 +215,7 @@ def pbHatch(pokemon) end end -Events.onStepTaken += proc { |sender,e| +Events.onStepTaken += proc { |_sender,_e| for egg in $Trainer.party next if egg.eggsteps<=0 egg.eggsteps -= 1 diff --git a/Data/Scripts/017_UI/021_PScreen_Evolution.rb b/Data/Scripts/017_UI/021_PScreen_Evolution.rb index bff2e78d5..7f52d431e 100644 --- a/Data/Scripts/017_UI/021_PScreen_Evolution.rb +++ b/Data/Scripts/017_UI/021_PScreen_Evolution.rb @@ -48,8 +48,7 @@ class SpriteMetafile return false end - def dispose - end + def dispose; end def flash(color,duration) if duration>0 @@ -95,8 +94,8 @@ class SpriteMetafile def src_rect=(value) @values[SRC_RECT]=value - @metafile.push([SRC_RECT,value]) - end + @metafile.push([SRC_RECT,value]) + end def visible return @values[VISIBLE] @@ -610,7 +609,7 @@ class PokemonEvolutionScene def pbRemoveItemAfterEvolution removeItem = false - createSpecies = pbCheckEvolutionEx(@pokemon) { |pokemon,evonib,level,pkmn| + createSpecies = pbCheckEvolutionEx(@pokemon) { |_pokemon,evonib,_level,pkmn| case evonib when PBEvolution::Shedinja next pkmn if $PokemonBag.pbHasItem?(getConst(PBItems,:POKEBALL)) diff --git a/Data/Scripts/017_UI/023_PScreen_MoveRelearner.rb b/Data/Scripts/017_UI/023_PScreen_MoveRelearner.rb index 90a6d0973..051b1eb5e 100644 --- a/Data/Scripts/017_UI/023_PScreen_MoveRelearner.rb +++ b/Data/Scripts/017_UI/023_PScreen_MoveRelearner.rb @@ -84,8 +84,6 @@ class MoveRelearner_Scene movesData = pbLoadMovesData overlay=@sprites["overlay"].bitmap overlay.clear - textpos=[] - imagepos=[] type1rect=Rect.new(0,@pokemon.type1*28,64,28) type2rect=Rect.new(0,@pokemon.type2*28,64,28) if @pokemon.type1==@pokemon.type2 @@ -97,6 +95,7 @@ class MoveRelearner_Scene textpos=[ [_INTL("Teach which move?"),16,8,0,Color.new(88,88,80),Color.new(168,184,184)] ] + imagepos=[] yPos=82 for i in 0...VISIBLEMOVES moveobject=@moves[@sprites["commands"].top_item+i] diff --git a/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb b/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb index bf6ee56af..fc1df25be 100644 --- a/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb +++ b/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb @@ -1,13 +1,13 @@ class PurifyChamberSet - attr_accessor :facing - attr_accessor :shadow + attr_reader :facing + attr_reader :shadow def partialSum(x) return (x*x+x)/2 # pattern: 1, 3, 6, 10, 15, 21, 28, ... end def length - return @list.length + return @list.length end def initialize @@ -16,15 +16,15 @@ class PurifyChamberSet end def facing=(value) - if value>=0 && value<@list.length - @facing=value - end + if value>=0 && value<@list.length + @facing=value + end end def shadow=(value) - if value==nil || value.shadowPokemon? - @shadow=value - end + if value==nil || value.shadowPokemon? + @shadow=value + end end =begin @@ -33,15 +33,15 @@ Boosted if center has advantage over facing Pokemon Boosted based on number of best circles =end def flow - ret=0 - return 0 if !@shadow - for i in 0...@list.length - ret+=(PurifyChamberSet.isSuperEffective(@list[i],@list[(i+1)%@list.length])) ? 1 : 0 - end - if @list[@facing] - ret+=PurifyChamberSet.isSuperEffective(@shadow,@list[@facing]) ? 1 : 0 - end - return [ret+(@list.length/2),4].min + ret=0 + return 0 if !@shadow + for i in 0...@list.length + ret+=(PurifyChamberSet.isSuperEffective(@list[i],@list[(i+1)%@list.length])) ? 1 : 0 + end + if @list[@facing] + ret+=PurifyChamberSet.isSuperEffective(@shadow,@list[@facing]) ? 1 : 0 + end + return [ret+(@list.length/2),4].min end def shadowAffinity @@ -57,19 +57,19 @@ Boosted based on number of best circles # Tempo refers to the type advantages of each Pokemon in a certain set in a # clockwise direction. Tempo also depends on the number of Pokemon in the set def tempo - ret=0 - for i in 0...@list.length - ret+=(PurifyChamberSet.isSuperEffective(@list[i],@list[(i+1)%@list.length])) ? 1 : 0 - end - return partialSum(@list.length)+ret + ret=0 + for i in 0...@list.length + ret+=(PurifyChamberSet.isSuperEffective(@list[i],@list[(i+1)%@list.length])) ? 1 : 0 + end + return partialSum(@list.length)+ret end def list - return @list.clone + return @list.clone end def [](index) - return @list[index] + return @list[index] end def insertAfter(index,value) @@ -108,7 +108,7 @@ end class PurifyChamber # German: der Kryptorbis NUMSETS=9 SETSIZE=4 - attr_accessor :currentSet # German: das Forum + attr_reader :currentSet # German: das Forum def self.maximumTempo() # Calculates the maximum possible tempo x=SETSIZE+1 @@ -198,7 +198,6 @@ class PurifyChamber # German: der Kryptorbis def update # called each step for set in 0...NUMSETS # If a shadow Pokemon and a regular Pokemon are on the same set - count=setCount(set) if @sets[set].shadow if @sets[set].shadow.heartgauge>0 flow=self.chamberFlow(set) @@ -225,12 +224,11 @@ class PurifyChamber # German: der Kryptorbis end def debugAdd(set,shadow,type1,type2=nil) - species=getID(PBSpecies,species) pkmn=PseudoPokemon.new(shadow,type1,type2||type1) if pkmn.shadowPokemon? - self.setShadow(set,pkmn) + self.setShadow(set,pkmn) else - self.insertAfter(set,setCount(set),pkmn) + self.insertAfter(set,setCount(set),pkmn) end end end @@ -238,14 +236,12 @@ end class PokemonGlobalMetadata - attr_accessor :purifyChamber + attr_writer :purifyChamber attr_accessor :seenPurifyChamber def purifyChamber - if !@purifyChamber - @purifyChamber=PurifyChamber.new() - end - return @purifyChamber + @purifyChamber = PurifyChamber.new() if !@purifyChamber + return @purifyChamber end end @@ -330,13 +326,13 @@ module PurifyChamberHelper def self.adjustOnInsert(position) if position>0 - position-=1 - oldpos=position/2 - if position%2==0 + position-=1 + oldpos=position/2 + if position%2==0 return position+1 - else - return ((oldpos+1)*2)+1 - end + else + return ((oldpos+1)*2)+1 + end end return position end @@ -384,8 +380,8 @@ class PurifyChamberScreen @scene.pbShift(position,pkmn) else @scene.pbPlace(position,pkmn) - end - PurifyChamberHelper.pbSetPokemon(@chamber,position,pkmn) + end + PurifyChamberHelper.pbSetPokemon(@chamber,position,pkmn) @scene.pbRefresh else @scene.pbDisplay(_INTL("Only a Shadow Pokémon can go there.")) @@ -401,8 +397,8 @@ class PurifyChamberScreen @scene.pbShift(position,pkmn) else @scene.pbPlace(position,pkmn) - end - PurifyChamberHelper.pbSetPokemon(@chamber,position,pkmn) + end + PurifyChamberHelper.pbSetPokemon(@chamber,position,pkmn) @scene.pbRefresh end end @@ -431,7 +427,6 @@ class PurifyChamberScreen def pbOpenSetDetail chamber=@chamber @scene.pbOpenSetDetail(chamber.currentSet) - selected=nil heldpkmn=nil loop do # Commands @@ -459,7 +454,7 @@ class PurifyChamberScreen if !heldpkmn && curpkmn commands[cmdReplace=commands.length]=_INTL("REPLACE") end - commands.push(_INTL("CANCEL")) + commands.push(_INTL("CANCEL")) choice=@scene.pbShowCommands( _INTL("What shall I do with this {1}?", heldpkmn ? heldpkmn.name : curpkmn.name),commands) @@ -468,7 +463,7 @@ class PurifyChamberScreen if pbPlace(heldpkmn,cmd[1]) # calls place or shift as appropriate if !curpkmn pbOnPlace(heldpkmn) - @scene.pbPositionHint(PurifyChamberHelper.adjustOnInsert(cmd[1])) + @scene.pbPositionHint(PurifyChamberHelper.adjustOnInsert(cmd[1])) heldpkmn=nil # Pokemon was placed else heldpkmn=curpkmn # Pokemon was shifted @@ -490,7 +485,7 @@ class PurifyChamberScreen $PokemonStorage.pbStoreCaught(heldpkmn) heldpkmn=nil @scene.pbRefresh - else + else # Store and delete Pokemon. @scene.pbWithdraw(cmd[1],heldpkmn) $PokemonStorage.pbStoreCaught(curpkmn) @@ -516,7 +511,7 @@ class PurifyChamberScreen @scene.pbReplace(cmd,pos) PurifyChamberHelper.pbSetPokemon(@chamber,cmd[1],newpkmn) $PokemonStorage[pos[0],pos[1]]=curpkmn - @scene.pbRefresh + @scene.pbRefresh pbOnPlace(curpkmn) end end @@ -527,7 +522,7 @@ class PurifyChamberScreen if pbPlacePokemon(pos,cmd[1]) curpkmn=PurifyChamberHelper.pbGetPokemon(@chamber,cmd[1]) pbOnPlace(curpkmn) - @scene.pbPositionHint(PurifyChamberHelper.adjustOnInsert(cmd[1])) + @scene.pbPositionHint(PurifyChamberHelper.adjustOnInsert(cmd[1])) end end elsif cmd[0]==1 # Change the active set @@ -614,7 +609,6 @@ class PurifyChamberScreen @scene.pbEnd() return end - alreadyopen=false @scene.pbOpenSet(chamber.currentSet) loop do set=@scene.pbChooseSet @@ -650,7 +644,7 @@ end class Window_PurifyChamberSets < Window_DrawableCommand - attr_accessor :switching + attr_reader :switching def initialize(chamber,x,y,width,height,viewport=nil) @chamber=chamber @@ -663,10 +657,11 @@ class Window_PurifyChamberSets < Window_DrawableCommand end def switching=(value) - @switching=value; refresh + @switching = value + refresh end - def drawItem(index,count,rect) + def drawItem(index,_count,rect) textpos=[] rect=drawCursor(index,rect) if index==@switching @@ -736,7 +731,8 @@ class DirectFlowDiagram point.visible=false end j=0 - i=0; while i<@distance + i=0 + while i<@distance o=(i+@offset)%@distance if o>=0 && o<@distance ensurePoint(j) @@ -818,7 +814,8 @@ class FlowDiagram point.visible=false end j=0 - i=0; while i<360 + i=0 + while i<360 angle=(i+@offset)%360 if withinRange(angle,@startAngle,@endAngle) ensurePoint(j) @@ -956,30 +953,30 @@ class PurifyChamberSetView < SpriteWrapper pbSetSmallFont(@info.bitmap) textpos=[] if pkmn - if pkmn.type1==pkmn.type2 + if pkmn.type1==pkmn.type2 textpos.push([_INTL("{1} Lv.{2} {3}",pkmn.name,pkmn.level,PBTypes.getName(pkmn.type1)),2,0,0, - Color.new(248,248,248),Color.new(128,128,128)]) + Color.new(248,248,248),Color.new(128,128,128)]) else textpos.push([_INTL("{1} Lv.{2} {3}/{4}",pkmn.name,pkmn.level,PBTypes.getName(pkmn.type1), - PBTypes.getName(pkmn.type2)),2,0,0, - Color.new(248,248,248),Color.new(128,128,128)]) + PBTypes.getName(pkmn.type2)),2,0,0, + Color.new(248,248,248),Color.new(128,128,128)]) end textpos.push([_INTL("FLOW"),2+@info.bitmap.width/2,24,0, - Color.new(248,248,248),Color.new(128,128,128)]) - # draw heart gauge - pbDrawGauge(@info.bitmap,Rect.new(@info.bitmap.width*3/4,8,@info.bitmap.width*1/4,8), - Color.new(192,0,256),pkmn.heartgauge, + Color.new(248,248,248),Color.new(128,128,128)]) + # draw heart gauge + pbDrawGauge(@info.bitmap,Rect.new(@info.bitmap.width*3/4,8,@info.bitmap.width*1/4,8), + Color.new(192,0,256),pkmn.heartgauge, PokeBattle_Pokemon::HEARTGAUGESIZE) - # draw flow gauge + # draw flow gauge pbDrawGauge(@info.bitmap,Rect.new(@info.bitmap.width*3/4,24+8,@info.bitmap.width*1/4,8), - Color.new(0,0,248),@chamber.chamberFlow(@set),6) + Color.new(0,0,248),@chamber.chamberFlow(@set),6) end if @chamber.setCount(@set)>0 textpos.push([_INTL("TEMPO"),2,24,0, - Color.new(248,248,248),Color.new(128,128,128)]) + Color.new(248,248,248),Color.new(128,128,128)]) # draw tempo gauge pbDrawGauge(@info.bitmap,Rect.new(@info.bitmap.width*1/4,24+8,@info.bitmap.width*1/4,8), - Color.new(0,0,248),@chamber[@set].tempo, + Color.new(0,0,248),@chamber[@set].tempo, PurifyChamber.maximumTempo()) end pbDrawTextPositions(@info.bitmap,textpos) @@ -1161,30 +1158,29 @@ class PurifyChamberScene pbRefresh end - def pbMove(pos) + def pbMove(_pos) @sprites["setview"].heldpkmn=@sprites["setview"].getCurrent() pbRefresh end - def pbShift(pos,heldpoke) + def pbShift(_pos,_heldpoke) @sprites["setview"].heldpkmn=@sprites["setview"].getCurrent() pbRefresh end - def pbPlace(pos,heldpoke) + def pbPlace(_pos,_heldpoke) @sprites["setview"].heldpkmn=nil pbRefresh end - def pbReplace(pos,storagePos) + def pbReplace(_pos,_storagePos) @sprites["setview"].heldpkmn=nil pbRefresh end - def pbRotate(facing) - end + def pbRotate(facing); end - def pbWithdraw(pos,heldpoke) + def pbWithdraw(_pos,_heldpoke) @sprites["setview"].heldpkmn=nil pbRefresh end diff --git a/Data/Scripts/017_UI/025_PScreen_Mart.rb b/Data/Scripts/017_UI/025_PScreen_Mart.rb index a20c85cef..ea79f4259 100644 --- a/Data/Scripts/017_UI/025_PScreen_Mart.rb +++ b/Data/Scripts/017_UI/025_PScreen_Mart.rb @@ -40,7 +40,7 @@ class PokemonMartAdapter return pbItemIconFile(item) end - def getItemIconRect(item) + def getItemIconRect(_item) return Rect.new(0,0,48,48) end @@ -101,7 +101,7 @@ class RpgxpMartAdapter $game_party.gain_gold(value) end - def getPrice(item,selling=false) + def getPrice(item,_selling=false) return item.price end @@ -129,19 +129,13 @@ class RpgxpMartAdapter def getInventory() data = [] for i in 1...$data_items.size - if getQuantity($data_items[i]) > 0 - data.push($data_items[i]) - end + data.push($data_items[i]) if getQuantity($data_items[i]) > 0 end for i in 1...$data_weapons.size - if getQuantity($data_weapons[i]) > 0 - data.push($data_weapons[i]) - end + data.push($data_weapons[i]) if getQuantity($data_weapons[i]) > 0 end for i in 1...$data_armors.size - if getQuantity($data_armors[i]) > 0 - data.push($data_armors[i]) - end + data.push($data_armors[i]) if getQuantity($data_armors[i]) > 0 end return data end @@ -158,7 +152,7 @@ class RpgxpMartAdapter return item ? item.name : "" end - def getDisplayPrice(item,selling=false) + def getDisplayPrice(item,_selling=false) price=item.price return price.to_s end @@ -201,7 +195,7 @@ class RpgxpMartAdapter return ret end - def showQuantity?(item) + def showQuantity?(_item) return true end @@ -788,7 +782,7 @@ class PokemonMartScreen price*=qty if pbConfirm(_INTL("I can pay ${1}. Would that be OK?",price.to_s_formatted)) @adapter.setMoney(@adapter.getMoney+price) - for i in 0...qty + qty.times do @adapter.removeItem(item) end pbDisplayPaused(_INTL("Turned over the {1} and received ${2}.",itemname,price.to_s_formatted)) { pbSEPlay("Mart buy item") } diff --git a/Data/Scripts/017_UI/026_PScreen_MysteryGift.rb b/Data/Scripts/017_UI/026_PScreen_MysteryGift.rb index 7869ccf42..43ed60a76 100644 --- a/Data/Scripts/017_UI/026_PScreen_MysteryGift.rb +++ b/Data/Scripts/017_UI/026_PScreen_MysteryGift.rb @@ -12,17 +12,15 @@ MYSTERY_GIFT_URL = "http://images1.wikia.nocookie.net/pokemonessentials/images/e class PokeBattle_Trainer - attr_accessor(:mysterygiftaccess) # Whether MG can be used from load screen - attr_accessor(:mysterygift) # Variable that stores downloaded MG data + attr_writer :mysterygiftaccess # Whether MG can be used from load screen + attr_writer :mysterygift # Variable that stores downloaded MG data def mysterygiftaccess - @mysterygiftaccess = false if !@mysterygiftaccess - return @mysterygiftaccess + return @mysterygiftaccess || false end def mysterygift - @mysterygift = [] if !@mysterygift - return @mysterygift + return @mysterygift || [] end end @@ -288,7 +286,6 @@ def pbDownloadMysteryGift(trainer) else gift=pending[command] sprites["msgwindow"].visible=false - isitem=false if gift[1]==0 sprite=PokemonSprite.new(viewport) sprite.setOffset(PictureOrigin::Center) @@ -299,15 +296,15 @@ def pbDownloadMysteryGift(trainer) sprite=ItemIconSprite.new(0,0,gift[2],viewport) sprite.x=Graphics.width/2 sprite.y=-sprite.height/2 - isitem=true end distanceDiff = 8*20/Graphics.frame_rate - begin + loop do Graphics.update Input.update sprite.update sprite.y+=distanceDiff - end while sprite.y=Graphics.height/2 + end pbMEPlay("Battle capture success") (Graphics.frame_rate*3).times do Graphics.update @@ -321,12 +318,13 @@ def pbDownloadMysteryGift(trainer) trainer.mysterygift.push(gift) pending[command]=nil; pending.compact! opacityDiff = 16*20/Graphics.frame_rate - begin + loop do Graphics.update Input.update sprite.update sprite.opacity-=opacityDiff - end while sprite.opacity>0 + break if sprite.opacity<=0 + end sprite.dispose end if pending.length==0 diff --git a/Data/Scripts/017_UI/027_PScreen_HallOfFame.rb b/Data/Scripts/017_UI/027_PScreen_HallOfFame.rb index 1d07bd7f4..de153a00f 100644 --- a/Data/Scripts/017_UI/027_PScreen_HallOfFame.rb +++ b/Data/Scripts/017_UI/027_PScreen_HallOfFame.rb @@ -481,18 +481,16 @@ PokemonPCList.registerPC(HallOfFamePC.new) class PokemonGlobalMetadata - attr_accessor :hallOfFame + attr_writer :hallOfFame # Number necessary if hallOfFame array reach in its size limit - attr_accessor :hallOfFameLastNumber + attr_writer :hallOfFameLastNumber def hallOfFame - @hallOfFame=[] if !@hallOfFame - return @hallOfFame + return @hallOfFame || [] end def hallOfFameLastNumber - @hallOfFameLastNumber=0 if !@hallOfFameLastNumber - return @hallOfFameLastNumber + return @hallOfFameLastNumber || 0 end end diff --git a/Data/Scripts/019_Other battles/001_PBattle_Safari.rb b/Data/Scripts/019_Other battles/001_PBattle_Safari.rb index 78a359e39..a1b146b7d 100644 --- a/Data/Scripts/019_Other battles/001_PBattle_Safari.rb +++ b/Data/Scripts/019_Other battles/001_PBattle_Safari.rb @@ -52,7 +52,7 @@ end -Events.onMapChange += proc { |sender,args| +Events.onMapChange += proc { |_sender,_args| pbSafariState.pbEnd if !pbInSafari? } @@ -72,7 +72,7 @@ def pbSafariState return $PokemonGlobal.safariState end -Events.onStepTakenTransferPossible += proc { |sender,e| +Events.onStepTakenTransferPossible += proc { |_sender,e| handled = e[0] next if handled[0] if pbInSafari? && pbSafariState.decision==0 && SAFARI_STEPS>0 @@ -87,7 +87,7 @@ Events.onStepTakenTransferPossible += proc { |sender,e| end } -Events.onWildBattleOverride += proc { |sender,e| +Events.onWildBattleOverride += proc { |_sender,e| species = e[0] level = e[1] handled = e[2] diff --git a/Data/Scripts/019_Other battles/002_PBattle_BugContest.rb b/Data/Scripts/019_Other battles/002_PBattle_BugContest.rb index a872f92c5..a91efd05e 100644 --- a/Data/Scripts/019_Other battles/002_PBattle_BugContest.rb +++ b/Data/Scripts/019_Other battles/002_PBattle_BugContest.rb @@ -299,13 +299,12 @@ def pbBugContestDecided? return pbBugContestState.decided? end -Events.onMapChange += proc { |sender,e| +Events.onMapChange += proc { |_sender,_e| pbBugContestState.pbClearIfEnded } -Events.onMapSceneChange += proc { |sender,e| +Events.onMapSceneChange += proc { |_sender,e| scene=e[0] - mapChanged=e[1] if pbInBugContest? && pbBugContestState.decision==0 && BugContestState::TimerSeconds>0 scene.spriteset.addUserSprite(TimerDisplay.new( pbBugContestState.timer, @@ -313,7 +312,7 @@ Events.onMapSceneChange += proc { |sender,e| end } -Events.onMapUpdate += proc { |sender,e| +Events.onMapUpdate += proc { |_sender,_e| if !$game_player.move_route_forcing && !pbMapInterpreterRunning? && !$game_temp.message_window_showing if pbBugContestState.expired? @@ -324,9 +323,8 @@ Events.onMapUpdate += proc { |sender,e| end } -Events.onMapChanging += proc { |sender,e| +Events.onMapChanging += proc { |_sender,e| newmapID=e[0] - newmap=e[1] if pbInBugContest? if pbBugContestState.pbOffLimits?(newmapID) # Clear bug contest if player flies/warps/teleports out of the contest @@ -344,7 +342,7 @@ def pbBugContestStartOver pbBugContestState.pbStartJudging end -Events.onWildBattleOverride += proc { |sender,e| +Events.onWildBattleOverride += proc { |_sender,e| species = e[0] level = e[1] handled = e[2] diff --git a/Data/Scripts/019_Other battles/003_PBattle_OrgBattle.rb b/Data/Scripts/019_Other battles/003_PBattle_OrgBattle.rb index e7e11bfdb..b6fc4b54f 100644 --- a/Data/Scripts/019_Other battles/003_PBattle_OrgBattle.rb +++ b/Data/Scripts/019_Other battles/003_PBattle_OrgBattle.rb @@ -1,7 +1,7 @@ #=============================================================================== # Pokémon Organized Battle #=============================================================================== -def pbHasEligible?(*arg) +def pbHasEligible?(_arg) return pbBattleChallenge.rules.ruleset.hasValidTeam?($Trainer.party) end @@ -483,14 +483,14 @@ class BattleChallenge pbWriteCup(id,rules) end - def start(*args) - t=ensureType(@id) + def start(_args) + ensureType(@id) @currentChallenge=@id # must appear before pbStart @bc.pbStart(t,@numRounds) end def register(id,doublebattle,numrounds,numPokemon,battletype,mode=1) - t=ensureType(id) + ensureType(id) if battletype==BattleFactoryID @bc.setExtraData(BattleFactoryData.new(@bc)) numPokemon=3 @@ -622,7 +622,7 @@ def pbPlayBattle(battledata) bgm = BattlePlayerHelper.pbGetBattleBGM(lastbattle) pbBattleAnimation(bgm) { pbSceneStandby { - decision = battleplayer.pbStartBattle + battleplayer.pbStartBattle } } end @@ -716,7 +716,7 @@ def pbBattleChallengeBeginSpeech end end -def pbEntryScreen(*arg) +def pbEntryScreen(_arg) retval = false pbFadeOutIn { scene = PokemonParty_Scene.new @@ -802,7 +802,7 @@ end -def pbBattleFactoryPokemon(rule,numwins,numswaps,rentals) +def pbBattleFactoryPokemon(rule,numwins,numswaps,_rentals) table=nil btpokemon=pbGetBTPokemon(pbBattleChallenge.currentChallenge) ivtable=[ @@ -873,7 +873,7 @@ def pbBattleFactoryPokemon(rule,numwins,numswaps,rentals) end end party=[] - begin + loop do party.clear while party.length<6 rnd=pokemonNumbers[0]+rand(pokemonNumbers[1]-pokemonNumbers[0]+1) @@ -881,7 +881,8 @@ def pbBattleFactoryPokemon(rule,numwins,numswaps,rentals) indvalue=(party.length(maxHeightInMeters*10).round end -def pbTooHeavy?(pokemon,maxWeightInKg) +def pbTooHeavy?(pkmn,maxWeightInKg) species = (pkmn.is_a?(PokeBattle_Pokemon)) ? pkmn.species : pkmn form = (pkmn.is_a?(PokeBattle_Pokemon)) ? pkmn.form : 0 weight = pbGetSpeciesData(species,form,SpeciesWeight) @@ -39,7 +39,7 @@ class LevelAdjustment @adjustment=adjustment end - def self.getNullAdjustment(thisTeam,otherTeam) + def self.getNullAdjustment(thisTeam,_otherTeam) ret=[] for i in 0...thisTeam.length ret[i]=thisTeam[i].level @@ -51,7 +51,7 @@ class LevelAdjustment return self.getNullAdjustment(thisTeam,otherTeam) end - def getOldExp(team1,team2) + def getOldExp(team1,_team2) ret=[] for i in 0...team1.length ret.push(team1[i].exp) @@ -118,7 +118,7 @@ class LevelBalanceAdjustment < LevelAdjustment @minLevel=minLevel end - def getAdjustment(thisTeam,otherTeam) + def getAdjustment(thisTeam,_otherTeam) ret=[] for i in 0...thisTeam.length ret[i]=pbBalancedLevelFromBST(thisTeam[i].species) @@ -135,7 +135,7 @@ class EnemyLevelAdjustment < LevelAdjustment @level=[[1,level].max,PBExperience.maxLevel].min end - def getAdjustment(thisTeam,otherTeam) + def getAdjustment(thisTeam,_otherTeam) ret=[] for i in 0...thisTeam.length ret[i]=@level @@ -180,7 +180,7 @@ class CappedLevelAdjustment < LevelAdjustment @level=[[1,level].max,PBExperience.maxLevel].min end - def getAdjustment(thisTeam,otherTeam) + def getAdjustment(thisTeam,_otherTeam) ret=[] for i in 0...thisTeam.length ret[i]=[thisTeam[i].level,@level].min @@ -197,7 +197,7 @@ class FixedLevelAdjustment < LevelAdjustment @level=[[1,level].max,PBExperience.maxLevel].min end - def getAdjustment(thisTeam,otherTeam) + def getAdjustment(thisTeam,_otherTeam) ret=[] for i in 0...thisTeam.length ret[i]=@level @@ -217,7 +217,7 @@ class TotalLevelAdjustment < LevelAdjustment @totalLevel=totalLevel end - def getAdjustment(thisTeam,otherTeam) + def getAdjustment(thisTeam,_otherTeam) ret=[] total=0 for i in 0...thisTeam.length diff --git a/Data/Scripts/019_Other battles/005_PBattle_OrgBattleGenerator.rb b/Data/Scripts/019_Other battles/005_PBattle_OrgBattleGenerator.rb index 0c55f8a23..b416a8e38 100644 --- a/Data/Scripts/019_Other battles/005_PBattle_OrgBattleGenerator.rb +++ b/Data/Scripts/019_Other battles/005_PBattle_OrgBattleGenerator.rb @@ -1,11 +1,7 @@ def pbRandomMove loop do - if false - move=rand(0xA6)+1 - else - move=rand(PBMoves.maxValue)+1 - next if move>384 || isConst?(move,PBMoves,:SKETCH) || isConst?(move,PBMoves,:STRUGGLE) - end + move=rand(PBMoves.maxValue)+1 + next if move>384 || isConst?(move,PBMoves,:SKETCH) || isConst?(move,PBMoves,:STRUGGLE) return move if PBMoves.getName(move)!="" end end @@ -97,31 +93,31 @@ def pbGetLegalMoves2(species,maxlevel) end # Delete less powerful moves deleteAll=proc { |a,item| - while a.include?(item) - a.delete(item) - end + while a.include?(item) + a.delete(item) + end } for move in moves md=moveData(move) for move2 in movedatas if md.function=="0A5" && move2[1].function=="000" && md.type==move2[1].type && md.basedamage>=move2[1].basedamage - deleteAll.call(moves,move2[0]) + deleteAll.call(moves,move2[0]) elsif md.function==move2[1].function && md.basedamage==0 && md.accuracy>move2[1].accuracy # Supersonic vs. Confuse Ray, etc. deleteAll.call(moves,move2[0]) elsif md.function=="006" && move2[1].function=="005" - deleteAll.call(moves,move2[0]) + deleteAll.call(moves,move2[0]) elsif md.function==move2[1].function && md.basedamage!=0 && - md.type==move2[1].type && - (md.totalpp==15 || md.totalpp==10 || md.totalpp==move2[1].totalpp) && - (md.basedamage>move2[1].basedamage || - (md.basedamage==move2[1].basedamage && md.accuracy>move2[1].accuracy)) - # Surf, Flamethrower, Thunderbolt, etc. - deleteAll.call(moves,move2[0]) - end - end + md.type==move2[1].type && + (md.totalpp==15 || md.totalpp==10 || md.totalpp==move2[1].totalpp) && + (md.basedamage>move2[1].basedamage || + (md.basedamage==move2[1].basedamage && md.accuracy>move2[1].accuracy)) + # Surf, Flamethrower, Thunderbolt, etc. + deleteAll.call(moves,move2[0]) + end + end end return moves end @@ -215,7 +211,7 @@ end -def withRestr(rule,minbs,maxbs,legendary) +def withRestr(_rule,minbs,maxbs,legendary) ret=PokemonChallengeRules.new.addPokemonRule(BaseStatRestriction.new(minbs,maxbs)) if legendary==0 ret.addPokemonRule(NonlegendaryRestriction.new) @@ -239,7 +235,7 @@ def pbArrangeByTier(pokemonlist,rule) withRestr(rule,580,680,2) ] tierPokemon=[] - for i in 0...tiers.length + tiers.length.times do tierPokemon.push([]) end for i in 0...pokemonlist.length @@ -290,7 +286,7 @@ def pbRandomPokemonFromRule(rule,trainer) pkmn=nil i=0 iteration=-1 - begin + loop do iteration+=1 species=0 level=rule.ruleset.suggestedLevel @@ -524,7 +520,8 @@ def pbRandomPokemonFromRule(rule,trainer) pk=PBPokemon.new(species,item,nature,moves[0],moves[1],moves[2],moves[3],ev) pkmn=pk.createPokemon(level,31,trainer) i+=1 - end while !rule.ruleset.isPokemonValid?(pkmn) + break if rule.ruleset.isPokemonValid?(pkmn) + end return pkmn end @@ -603,7 +600,7 @@ class PlayerRatingElo return end stake=0 - for i in 0...matches.length + matches.length.times do score=(match.score==-1) ? 0.5 : match.score e=(1+10.0**((@rating-match.opponentRating)/400.0)) stake+=match.kValue*(score-e) @@ -884,16 +881,16 @@ def pbDecideWinnerScore(party0,party1,rating) end def pbDecideWinner(party0,party1,rating0,rating1) - rating0=(rating0*15.0/100).round - rating1=(rating1*15.0/100).round - score0=pbDecideWinnerScore(party0,party1,rating0) - score1=pbDecideWinnerScore(party1,party0,rating1) - if score0==score1 - return 5 if rating0==rating1 - return (rating0>rating1) ? 1 : 2 - else - return (score0>score1) ? 1 : 2 - end + rating0=(rating0*15.0/100).round + rating1=(rating1*15.0/100).round + score0=pbDecideWinnerScore(party0,party1,rating0) + score1=pbDecideWinnerScore(party1,party0,rating1) + if score0==score1 + return 5 if rating0==rating1 + return (rating0>rating1) ? 1 : 2 + else + return (score0>score1) ? 1 : 2 + end end def pbRuledBattle(team1,team2,rule) @@ -985,7 +982,7 @@ def pbTrainerInfo(pokemonlist,trfile,rules) gender=(!trainertypes[trainerid] || !trainertypes[trainerid][7]) ? 2 : trainertypes[trainerid][7] randomName=getRandomNameEx(gender,nil,0,12) - tr=[trainerid,randomName,_INTL("Here I come!"), + tr=[trainerid,randomName,_INTL("Here I come!"), _INTL("Yes, I won!"),_INTL("Man, I lost!"),[]] bttrainers.push(tr) end @@ -1002,7 +999,6 @@ def pbTrainerInfo(pokemonlist,trfile,rules) rulesetTeam=rules.ruleset.copy.clearPokemonRules pkmntypes=[] validities=[] - t=Time.new for pkmn in pokemonlist pkmn.level=suggestedLevel if pkmn.level!=suggestedLevel pkmntypes.push(getTypes(pkmn.species)) @@ -1046,7 +1042,6 @@ def pbTrainerInfo(pokemonlist,trfile,rules) pkmn=pokemonlist[index] next if !validities[index] absDiff=((index*8/pokemonlist.length)-(btt*8/bttrainers.length)).abs - sameDiff=(absDiff==0) if species.include?(pkmn.species) weight=[32,12,5,2,1,0,0,0][[absDiff,7].min] if rand(40)=6 && rules.ruleset.hasValidTeam?(numbersPokemon) end - if numbers.length<6 || !rules.ruleset.hasValidTeam?(numbersPokemon) + if numbers.length<6 || !rules.ruleset.hasValidTeam?(numbersPokemon) while numbers.length=80 @@ -1334,7 +1330,6 @@ end def pbWriteCup(id,rules) return if !$DEBUG - bttrainers=[] trlists=(load_data("Data/trainer_lists.dat") rescue []) list=[] for i in 0...trlists.length diff --git a/Data/Scripts/019_Other battles/006_PBattle_BattleSwap.rb b/Data/Scripts/019_Other battles/006_PBattle_BattleSwap.rb index 6c7b2b30b..a5bd45cd0 100644 --- a/Data/Scripts/019_Other battles/006_PBattle_BattleSwap.rb +++ b/Data/Scripts/019_Other battles/006_PBattle_BattleSwap.rb @@ -126,7 +126,7 @@ class BattleSwapScene @sprites["list"].commands=commands end - def pbSwapChosen(pkmnindex) + def pbSwapChosen(_pkmnindex) commands=pbGetCommands(@newPokemon,[]) commands.push(_INTL("PKMN FOR SWAP")) commands.push(_INTL("CANCEL")) diff --git a/Data/Scripts/020_System and utilities/003_PSystem_FileUtilities.rb b/Data/Scripts/020_System and utilities/003_PSystem_FileUtilities.rb index b28ef0d07..95f8f968c 100644 --- a/Data/Scripts/020_System and utilities/003_PSystem_FileUtilities.rb +++ b/Data/Scripts/020_System and utilities/003_PSystem_FileUtilities.rb @@ -525,7 +525,7 @@ end #=============================================================================== # Load various wild battle music #=============================================================================== -def pbGetWildBattleBGM(wildParty) # wildParty is an array of Pokémon objects +def pbGetWildBattleBGM(_wildParty) # wildParty is an array of Pokémon objects if $PokemonGlobal.nextBattleBGM return $PokemonGlobal.nextBattleBGM.clone end diff --git a/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb b/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb index ecda3646c..725f808e0 100644 --- a/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb +++ b/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb @@ -428,7 +428,7 @@ def pbBalancedLevel(party) weights.push(weight) end weightSum = 0 - weights.each { |weight| weightSum += weight } + weights.each { |w| weightSum += w } # Calculate the weighted mean, assigning each weight to each level's # contribution to the sum for i in 0...party.length diff --git a/Data/Scripts/020_System and utilities/005_PSystem_Utilities.rb b/Data/Scripts/020_System and utilities/005_PSystem_Utilities.rb index ed3dd8d8c..496980a3a 100644 --- a/Data/Scripts/020_System and utilities/005_PSystem_Utilities.rb +++ b/Data/Scripts/020_System and utilities/005_PSystem_Utilities.rb @@ -248,7 +248,7 @@ class LinearCongRandom def self.dsSeed t = Time.now - seed = (((t.mon*t.mday+t.min+t.sec)&0xFF)<<24) | (t.hour<<16) | (t.year-2000) + seed = (((t.mon*t.mday+t.min+t.sec)&0xFF)<<24) | (t.hour << 16) | (t.year-2000) seed = (seed+0xFFFFFFFF)+1 if seed<0 return seed end @@ -416,9 +416,8 @@ class MiniXmlReader raise ArgumentError.new("Illegal character") if codepoint<9 || codepoint==11 || codepoint==12 || (codepoint>=14 && codepoint<32) || codepoint==0xFFFE || codepoint==0xFFFF || (codepoint>=0xD800 && codepoint<0xE000) - if codepoint<=0x7F - return codepoint.chr - elsif codepoint<=0x7FF + return codepoint.chr if codepoint<=0x7F + if codepoint<=0x7FF str = (0xC0|((codepoint>>6)&0x1F)).chr str += (0x80|(codepoint &0x3F)).chr return str @@ -436,7 +435,6 @@ class MiniXmlReader else raise ArgumentError.new("Illegal character") end - return str end def unescape(attr) #:nodoc: diff --git a/Data/Scripts/021_Debug/001_Debug_Menu.rb b/Data/Scripts/021_Debug/001_Debug_Menu.rb index 52aebdfd6..ba7f3b3a4 100644 --- a/Data/Scripts/021_Debug/001_Debug_Menu.rb +++ b/Data/Scripts/021_Debug/001_Debug_Menu.rb @@ -738,7 +738,6 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil) pbFadeOutIn { pbTilesetScreen } when "setencounters" encdata = pbLoadEncountersData - oldencdata = Marshal.dump(encdata) map = pbDefaultMap loop do map = pbListScreen(_INTL("SET ENCOUNTERS"),MapLister.new(map)) diff --git a/Data/Scripts/021_Debug/002_Debug_Actions.rb b/Data/Scripts/021_Debug/002_Debug_Actions.rb index ff6a5085d..49598df12 100644 --- a/Data/Scripts/021_Debug/002_Debug_Actions.rb +++ b/Data/Scripts/021_Debug/002_Debug_Actions.rb @@ -75,7 +75,7 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand pbDrawShadowText(self.contents,x,y,[width,w].max,h,t,base,Color.new(26*8,26*8,25*8)) end - def drawItem(index,count,rect) + def drawItem(index,_count,rect) pbSetNarrowFont(self.contents) colors = 0; codeswitch = false if @mode==0 @@ -83,8 +83,8 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand codeswitch = (name[/^s\:/]) val = (codeswitch) ? (eval($~.post_match) rescue nil) : $game_switches[index+1] if val==nil; status = "[-]"; colors = 0; codeswitch = true - elsif val; status = "[ON]"; colors = 2 - else; status = "[OFF]"; colors = 1 + elsif val; status = "[ON]"; colors = 2 + else; status = "[OFF]"; colors = 1 end else name = $data_system.variables[index+1] @@ -93,7 +93,6 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand end name = '' if name==nil id_text = sprintf("%04d:",index+1) - width = self.contents.text_size(id_text).width rect = drawCursor(index,rect) totalWidth = rect.width idWidth = totalWidth*15/100 @@ -275,7 +274,6 @@ def pbDebugDayCare if Input.trigger?(Input::B) break elsif Input.trigger?(Input::C) - ret = cmdwindow.index case cmdwindow.index when 0 # Withdraw Pokémon 1 if !$PokemonGlobal.daycare[0][0] @@ -382,7 +380,7 @@ class SpriteWindow_DebugRoamers < Window_DrawableCommand pbDrawShadowText(self.contents,x,y,[width,w].max,h,t,base,Color.new(26*8,26*8,25*8)) end - def drawItem(index,count,rect) + def drawItem(index,_count,rect) pbSetNarrowFont(self.contents) rect = drawCursor(index,rect) nameWidth = rect.width*50/100 diff --git a/Data/Scripts/021_Debug/004_Editor_Screens.rb b/Data/Scripts/021_Debug/004_Editor_Screens.rb index ca9ea161f..414771cc0 100644 --- a/Data/Scripts/021_Debug/004_Editor_Screens.rb +++ b/Data/Scripts/021_Debug/004_Editor_Screens.rb @@ -36,7 +36,6 @@ def pbEncounterEditorTypes(enc,enccmd) enccmd.active = true enccmd.index = 0 enccmd.visible = true - ret = 0 command = 0 loop do Graphics.update @@ -94,7 +93,7 @@ def pbNewEncounterType(enc) if ret>=0 chances = EncounterTypes::EnctypeChances[ret] enc[1][ret] = [] - for i in 0...chances.length + chances.length.times do enc[1][ret].push([1,5,5]) end end @@ -129,8 +128,6 @@ def pbEditEncounterType(enc,etype) species = pbChooseSpeciesList(enctype[ret][0]) next if species<=0 enctype[ret][0] = species if species>0 - minlevel = 0 - maxlevel = 0 mLevel = PBExperience.maxLevel params = ChooseNumberParams.new params.setRange(1,mLevel) @@ -185,7 +182,6 @@ def pbEncounterEditorMap(encdata,map) enchelp.z = 99999 mapinfos = load_data("Data/MapInfos.rxdata") mapname = mapinfos[map].name - lastchoice = 0 loop do enc = encdata[map] enchelp.text = mapname @@ -421,7 +417,6 @@ def pbTrainerBattleEditor if selection<0 # New trainer trainertype = -1 - trainername = "" ret = pbMessage(_INTL("First, define the type of trainer."),[ _INTL("Use existing type"), _INTL("Use new type"), diff --git a/Data/Scripts/021_Debug/006_Editor_DataTypes.rb b/Data/Scripts/021_Debug/006_Editor_DataTypes.rb index 04e371c98..4903711a9 100644 --- a/Data/Scripts/021_Debug/006_Editor_DataTypes.rb +++ b/Data/Scripts/021_Debug/006_Editor_DataTypes.rb @@ -2,7 +2,7 @@ # Data type properties #=============================================================================== module UndefinedProperty - def self.set(settingname,oldsetting) + def self.set(_settingname,oldsetting) pbMessage(_INTL("This property can't be edited here at this time.")) return oldsetting end @@ -15,7 +15,7 @@ end module ReadOnlyProperty - def self.set(settingname,oldsetting) + def self.set(_settingname,oldsetting) pbMessage(_INTL("This property cannot be edited.")) return oldsetting end @@ -125,7 +125,7 @@ end module BooleanProperty - def self.set(settingname,oldsetting) + def self.set(settingname,_oldsetting) return pbConfirmMessage(_INTL("Enable the setting {1}?",settingname)) ? true : false end @@ -137,7 +137,7 @@ end module BooleanProperty2 - def self.set(settingname,oldsetting) + def self.set(_settingname,_oldsetting) ret = pbShowCommands(nil,[_INTL("True"),_INTL("False")],-1) return (ret>=0) ? (ret==0) : nil end @@ -262,7 +262,7 @@ end module SpeciesProperty - def self.set(settingname,oldsetting) + def self.set(_settingname,oldsetting) ret = pbChooseSpeciesList((oldsetting) ? oldsetting : 1) return (ret<=0) ? (oldsetting) ? oldsetting : 0 : ret end @@ -279,7 +279,7 @@ end module TypeProperty - def self.set(settingname,oldsetting) + def self.set(_settingname,oldsetting) ret = pbChooseTypeList((oldsetting) ? oldsetting : 0) return (ret<0) ? (oldsetting) ? oldsetting : 0 : ret end @@ -296,7 +296,7 @@ end module MoveProperty - def self.set(settingname,oldsetting) + def self.set(_settingname,oldsetting) ret = pbChooseMoveList((oldsetting) ? oldsetting : 1) return (ret<=0) ? (oldsetting) ? oldsetting : 0 : ret end @@ -317,7 +317,7 @@ class MoveProperty2 @pokemondata = pokemondata end - def set(settingname,oldsetting) + def set(_settingname,oldsetting) ret = pbChooseMoveListForSpecies(@pokemondata[0],(oldsetting) ? oldsetting : 1) return (ret>0) ? ret : (oldsetting) ? oldsetting : nil end @@ -334,7 +334,7 @@ end class GenderProperty - def set(settingname,oldsetting) + def set(_settingname,_oldsetting) ret = pbShowCommands(nil,[_INTL("Male"),_INTL("Female")],-1) return (ret>=0) ? ret : nil end @@ -352,7 +352,7 @@ end module ItemProperty - def self.set(settingname,oldsetting) + def self.set(_settingname,oldsetting) ret = pbChooseItemList((oldsetting) ? oldsetting : 1) return (ret>0) ? ret : (oldsetting) ? oldsetting : nil end @@ -369,7 +369,7 @@ end module NatureProperty - def self.set(settingname,oldsetting) + def self.set(_settingname,_oldsetting) commands = [] (PBNatures.getCount).times do |i| commands.push(PBNatures.getName(i)) @@ -512,7 +512,7 @@ class BallProperty @pokemondata = pokemondata end - def set(settingname,oldsetting) + def set(_settingname,oldsetting) ret = pbChooseBallList((oldsetting) ? oldsetting : -1) return (ret>=0) ? ret : (oldsetting) ? oldsetting : nil end @@ -627,7 +627,7 @@ end module RegionMapCoordsProperty - def self.set(settingname,oldsetting) + def self.set(_settingname,oldsetting) regions = getMapNameList selregion = -1 if regions.length==0 @@ -659,7 +659,7 @@ end module WeatherEffectProperty - def self.set(settingname,oldsetting) + def self.set(_settingname,oldsetting) options = [] for i in 0..PBFieldWeather.maxValue options.push(getConstantName(PBFieldWeather,i) || "ERROR") @@ -684,7 +684,7 @@ end module EnvironmentProperty - def self.set(settingname,oldsetting) + def self.set(_settingname,_oldsetting) options = [] for i in 0..PBEnvironment.maxValue options.push(getConstantName(PBEnvironment,i) || "ERROR") @@ -741,7 +741,7 @@ module PocketProperty _INTL("Battle Items"),_INTL("Key Items")] end - def self.set(settingname,oldsetting) + def self.set(_settingname,oldsetting) cmd = pbMessage(_INTL("Choose a pocket for this item."),pocketnames(),-1) return (cmd>=0) ? cmd+1 : oldsetting end @@ -817,7 +817,7 @@ end module AbilityProperty - def self.set(settingname,oldsetting) + def self.set(_settingname,oldsetting) ret = pbChooseAbilityList((oldsetting) ? oldsetting : 1) return (ret<=0) ? (oldsetting) ? oldsetting : 0 : ret end @@ -834,7 +834,7 @@ end module MovePoolProperty - def self.set(settingname,oldsetting) + def self.set(_settingname,oldsetting) ret = oldsetting cmdwin = pbListWindow([],200) commands = [] @@ -981,7 +981,7 @@ end module EggMovesProperty - def self.set(settingname,oldsetting) + def self.set(_settingname,oldsetting) ret = oldsetting cmdwin = pbListWindow([],200) commands = [] @@ -1083,7 +1083,7 @@ end module FormNamesProperty - def self.set(settingname,oldsetting) + def self.set(_settingname,oldsetting) ret = oldsetting cmdwin = pbListWindow([],200) commands = [] @@ -1099,7 +1099,7 @@ module FormNamesProperty realcmds.sort! { |a,b| a[1]<=>b[1] } commands = [] for i in 0...realcmds.length - text = (realcmds[i][1]>=0) ? sprintf("#{realcmds[i][1].to_s} - #{realcmds[i][0]}") : realcmds[i][0] + text = (realcmds[i][1]>=0) ? sprintf("#{realcmds[i][1]} - #{realcmds[i][0]}") : realcmds[i][0] commands.push(text) cmd[1] = i if oldsel>=0 && realcmds[i][1]==oldsel end @@ -1187,7 +1187,7 @@ class EvolutionsProperty @evoparams = PBEvolution::EVOPARAM end - def set(settingname,oldsetting) + def set(_settingname,oldsetting) ret = oldsetting cmdwin = pbListWindow([]) commands = [] @@ -1449,7 +1449,6 @@ def pbPropertyList(title,data,properties,saveprompt=false) desc.viewport = viewport desc.z = 2 selectedmap = -1 - index = 0 retval = nil commands = [] for i in 0...properties.length diff --git a/Data/Scripts/021_Debug/008_Editor_Utilities.rb b/Data/Scripts/021_Debug/008_Editor_Utilities.rb index 248534401..a02121c42 100644 --- a/Data/Scripts/021_Debug/008_Editor_Utilities.rb +++ b/Data/Scripts/021_Debug/008_Editor_Utilities.rb @@ -292,7 +292,7 @@ def pbChooseMoveListForSpecies(species,defaultMoveID=0) end commands.sort! { |a,b| a[1]<=>b[1] } if defaultMoveID>0 - commands.each_with_index do |item,i| + commands.each_with_index do |_item,i| moveDefault = i if moveDefault==0 && i[0]==defaultMoveID end end @@ -304,7 +304,7 @@ def pbChooseMoveListForSpecies(species,defaultMoveID=0) end commands2.sort! { |a,b| a[1]<=>b[1] } if defaultMoveID>0 - commands2.each_with_index do |item,i| + commands2.each_with_index do |_item,i| moveDefault = i if moveDefault==0 && i[0]==defaultMoveID end end @@ -398,7 +398,6 @@ def pbCommands2(cmdwindow,commands,cmdIfCancel,defaultindex=-1,noresize=false) cmdwindow.z = 99999 cmdwindow.visible = true cmdwindow.active = true - ret = 0 command = 0 loop do Graphics.update @@ -436,7 +435,6 @@ def pbCommands3(cmdwindow,commands,cmdIfCancel,defaultindex=-1,noresize=false) cmdwindow.z = 99999 cmdwindow.visible = true cmdwindow.active = true - ret = [] command = 0 loop do Graphics.update @@ -526,7 +524,6 @@ def pbCommandsSortable(cmdwindow,commands,cmdIfCancel,defaultindex=-1,sortable=f cmdwindow.height = Graphics.height cmdwindow.z = 99999 cmdwindow.active = true - ret = nil command = 0 loop do Graphics.update diff --git a/Data/Scripts/021_Debug/009_Editor_TilesetEditor.rb b/Data/Scripts/021_Debug/009_Editor_TilesetEditor.rb index 788b2638c..694cd9541 100644 --- a/Data/Scripts/021_Debug/009_Editor_TilesetEditor.rb +++ b/Data/Scripts/021_Debug/009_Editor_TilesetEditor.rb @@ -112,7 +112,7 @@ class PokemonTilesetScene pbUpdateTileset elsif Input.repeat?(Input::DOWN) @y += 32 - @y = @sprites["tileset"].bitmap.height-32 if @y>=@sprites["tileset"].bitmap.height-32 + @y = height-32 if @y>=height-32 @topy = @y-(Graphics.height-64)+32 if @y-@topy>=Graphics.height-64 pbUpdateTileset elsif Input.repeat?(Input::LEFT) @@ -133,10 +133,10 @@ class PokemonTilesetScene elsif Input.repeat?(Input::R) @y += ((Graphics.height-64)/32)*32 @topy += ((Graphics.height-64)/32)*32 - @y = @sprites["tileset"].bitmap.height-32 if @y>=@sprites["tileset"].bitmap.height-32 + @y = height-32 if @y>=height-32 @topy = @y-(Graphics.height-64)+32 if @y-@topy>=Graphics.height-64 - if @topy>=@sprites["tileset"].bitmap.height-(Graphics.height-64) - @topy = @sprites["tileset"].bitmap.height-(Graphics.height-64) + if @topy>=height-(Graphics.height-64) + @topy = height-(Graphics.height-64) end pbUpdateTileset elsif Input.trigger?(Input::A) @@ -149,7 +149,7 @@ class PokemonTilesetScene ret = pbShowCommands(nil,commands,-1) case ret when 0 - @y = @sprites["tileset"].bitmap.height-32 + @y = height-32 @topy = @y-(Graphics.height-64)+32 if @y-@topy>=Graphics.height-64 pbUpdateTileset when 1 diff --git a/Data/Scripts/021_Debug/010_Editor_MapConnectionEditor.rb b/Data/Scripts/021_Debug/010_Editor_MapConnectionEditor.rb index e16bb9c7d..45fdc35f6 100644 --- a/Data/Scripts/021_Debug/010_Editor_MapConnectionEditor.rb +++ b/Data/Scripts/021_Debug/010_Editor_MapConnectionEditor.rb @@ -450,7 +450,8 @@ class MapScreenScene c1=(refsprite.x-othersprite.x)/4 c2=(refsprite.y-othersprite.y)/4 conn=[refmap,0,0,i,c1,c2] - j=0;while j> "), self.disabled || self.curvalue==self.maxvalue) @rightarrow=Rect.new(x,y,rightarrows.width,height) - x+=rightarrows.width end end @@ -614,10 +612,6 @@ class OptionalSlider < Slider private def updatedefs - x=self.x - y=self.y - width=self.width - height=self.height checkboxwidth=32 @slider.bitmap=self.bitmap @slider.parent=self.parent @@ -770,7 +764,6 @@ class TextSlider < UIControl width=self.width height=self.height color=Color.new(120,120,120) - colordisabled=Color.new(120,120,120,80) bitmap.fill_rect(x,y,width,height,Color.new(0,0,0,0)) size=bitmap.text_size(self.label).width leftarrows=bitmap.text_size(_INTL(" << ")) @@ -790,7 +783,6 @@ class TextSlider < UIControl shadowtext(bitmap,x,y,rightarrows.width,height,_INTL(" >> "), self.disabled || self.curvalue==self.maxvalue) @rightarrow=Rect.new(x,y,rightarrows.width,height) - x+=rightarrows.width end end @@ -867,10 +859,6 @@ class OptionalTextSlider < TextSlider private def updatedefs - x=self.x - y=self.y - width=self.width - height=self.height checkboxwidth=32 @slider.bitmap=self.bitmap @slider.parent=self.parent @@ -1529,10 +1517,6 @@ class AnimationCanvas < Sprite oldtargety=targetsprite ? targetsprite.y : 0 @player=PBAnimationPlayerX.new(@animation, @battle.battlers[oppmove ? 1 : 0],@battle.battlers[oppmove ? 0 : 1],self,oppmove,true) - userwidth=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.width - userheight=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.height - targetwidth=(!targetsprite.bitmap || targetsprite.bitmap.disposed?) ? 128 : targetsprite.bitmap.width - targetheight=(!targetsprite.bitmap || targetsprite.bitmap.disposed?) ? 128 : targetsprite.bitmap.height @player.setLineTransform( PokeBattle_SceneConstants::FOCUSUSER_X,PokeBattle_SceneConstants::FOCUSUSER_Y, PokeBattle_SceneConstants::FOCUSTARGET_X,PokeBattle_SceneConstants::FOCUSTARGET_Y, @@ -1544,7 +1528,6 @@ class AnimationCanvas < Sprite @sprites["pokemon_0"].y+=BORDERSIZE @sprites["pokemon_1"].x+=BORDERSIZE @sprites["pokemon_1"].y+=BORDERSIZE - prevoldstate=[] oldstate=[] for i in 0...PBAnimation::MAX_SPRITES oldstate.push([@celsprites[i].visible,@framesprites[i].visible,@lastframesprites[i].visible]) @@ -1552,10 +1535,11 @@ class AnimationCanvas < Sprite @framesprites[i].visible=false @lastframesprites[i].visible=false end - begin + loop do Graphics.update self.update - end while @playing + break if !@playing + end for i in 0...PBAnimation::MAX_SPRITES @celsprites[i].visible=oldstate[i][0] @framesprites[i].visible=oldstate[i][1] @@ -2447,7 +2431,7 @@ def pbEditBG(canvas,timing) if maxsizewindow.changed?(9) # Cancel break end - if Input.trigger?(Input::B) + if Input.trigger?(Input::B) break end end @@ -3193,7 +3177,7 @@ def curveToPointPath(curve,numpoints) path=PointPath.new step=1.0/(numpoints-1) t=0.0 - for i in 0...numpoints + numpoints.times do point=getCurvePoint(curve,t) path.addPoint(point[0],point[1]) t+=step @@ -3264,7 +3248,6 @@ def pbDefinePath(canvas) loop do Graphics.update Input.update - redrawline=false if Input.trigger?(Input::B) break end @@ -3401,7 +3384,6 @@ def pbDefinePath(canvas) cel[AnimFrame::X]=path[i-canvas.currentframe][0] cel[AnimFrame::Y]=path[i-canvas.currentframe][1] end - startframe=sliderwin2.value(0) break elsif sliderwin2.changed?(cancelbutton) || Input.trigger?(Input::B) break diff --git a/Data/Scripts/022_Compiler/001_Compiler.rb b/Data/Scripts/022_Compiler/001_Compiler.rb index a6ea9dd89..4a15c203c 100644 --- a/Data/Scripts/022_Compiler/001_Compiler.rb +++ b/Data/Scripts/022_Compiler/001_Compiler.rb @@ -6,7 +6,7 @@ end -def pbGetExceptionMessage(e,script="") +def pbGetExceptionMessage(e,_script="") emessage = e.message if e.is_a?(Hangup) emessage = "The script is taking too long. The game will restart." @@ -37,7 +37,7 @@ def pbGetExceptionMessage(e,script="") end def pbPrintException(e) - premessage = "\r\n=================\r\n\r\n[#{Time.now.to_s}]\r\n" + premessage = "\r\n=================\r\n\r\n[#{Time.now}]\r\n" emessage = "" if $EVENTHANGUPMSG && $EVENTHANGUPMSG!="" emessage = $EVENTHANGUPMSG # Message with map/event ID generated elsewhere @@ -365,19 +365,17 @@ def csvfield!(str) return ret end -def csvBoolean!(str,line=-1) +def csvBoolean!(str,_line=-1) field = csvfield!(str) if field[/^1|[Tt][Rr][Uu][Ee]|[Yy][Ee][Ss]|[Yy]$/] return true elsif field[/^0|[Ff][Aa][Ll][Ss][Ee]|[Nn][Oo]|[Nn]$/] return false - else - raise _INTL("Field {1} is not a Boolean value (true, false, 1, 0)\r\n{2}",field,FileLineData.linereport) - return false end + raise _INTL("Field {1} is not a Boolean value (true, false, 1, 0)\r\n{2}",field,FileLineData.linereport) end -def csvInt!(str,line=-1) +def csvInt!(str,_line=-1) ret = csvfield!(str) if !ret[/^\-?\d+$/] raise _INTL("Field {1} is not an integer\r\n{2}",ret,FileLineData.linereport) @@ -385,7 +383,7 @@ def csvInt!(str,line=-1) return ret.to_i end -def csvPosInt!(str,line=-1) +def csvPosInt!(str,_line=-1) ret = csvfield!(str) if !ret[/^\d+$/] raise _INTL("Field {1} is not a positive integer\r\n{2}",ret,FileLineData.linereport) @@ -393,17 +391,17 @@ def csvPosInt!(str,line=-1) return ret.to_i end -def csvFloat!(str,line=-1) +def csvFloat!(str,_line=-1) ret = csvfield!(str) return Float(ret) rescue raise _INTL("Field {1} is not a number\r\n{2}",ret,FileLineData.linereport) end -def csvEnumField!(value,enumer,key,section) +def csvEnumField!(value,enumer,_key,_section) ret = csvfield!(value) return checkEnumField(ret,enumer) end -def csvEnumFieldOrInt!(value,enumer,key,section) +def csvEnumFieldOrInt!(value,enumer,_key,_section) ret = csvfield!(value) return ret.to_i if ret[/\-?\d+/] return checkEnumField(ret,enumer) @@ -885,8 +883,8 @@ def pbAddScript(script,sectionname) rescue scripts = [] end - s = pbFindScript(scripts,sectionname) - if false#s + if false # s + s = pbFindScript(scripts,sectionname) s[2]+=Zlib::Deflate.deflate("#{script}\r\n") else scripts.push([rand(100000000),sectionname,Zlib::Deflate.deflate("#{script}\r\n")]) @@ -967,7 +965,7 @@ def readSerialRecords(filename) pbRgssOpen(filename,"rb") { |file| numrec = file.fgetdw>>3 curpos = 0 - for i in 0...numrec + numrec.times do file.pos = curpos offset = file.fgetdw length = file.fgetdw @@ -1026,7 +1024,7 @@ class ByteArray return self.new(str) end - def _dump(depth=100) + def _dump(_depth=100) return @a.pack("C*") end end @@ -1060,7 +1058,7 @@ class WordArray return self.new(str) end - def _dump(depth=100) + def _dump(_depth=100) return @a.pack("v*") end end @@ -1101,7 +1099,7 @@ class SignedWordArray return self.new(str) end - def _dump(depth=100) + def _dump(_depth=100) return @a.pack("v*") end end diff --git a/Data/Scripts/022_Compiler/002_Compiler_PBS.rb b/Data/Scripts/022_Compiler/002_Compiler_PBS.rb index c5ab09b33..db0432233 100644 --- a/Data/Scripts/022_Compiler/002_Compiler_PBS.rb +++ b/Data/Scripts/022_Compiler/002_Compiler_PBS.rb @@ -98,8 +98,6 @@ end #=============================================================================== def pbCompileConnections records = [] - constants = "" - itemnames = [] pbCompilerEachPreppedLine("PBS/connections.txt") { |line,lineno| hashenum = { "N" => "N","North" => "N", @@ -141,7 +139,7 @@ end def pbCompileBerryPlants sections = [] if File.exists?("PBS/berryplants.txt") - pbCompilerEachCommentedLine("PBS/berryplants.txt") { |line,lineno| + pbCompilerEachCommentedLine("PBS/berryplants.txt") { |line,_lineno| if line[ /^\s*(\w+)\s*=\s*(.*)$/ ] key = $1 value = $2 @@ -335,10 +333,8 @@ end def pbCompileTypes pbWriteDefaultTypes - sections = [] typechart = [] types = [] - nameToType = {} requiredtypes = { "Name" => [1, "s"], "InternalName" => [2, "s"], @@ -428,7 +424,8 @@ def pbCompileTypes count = maxValue+1 for i in 0...count type = typehash[i] - j = 0; k = i; while j>3 curpos = 0 - for i in 0...numrec + numrec.times do file.pos = curpos offset = file.fgetdw length = file.fgetdw @@ -601,7 +598,6 @@ def pbCompileMoves maxValue = 0 count = 0 pbCompilerEachPreppedLine("PBS/moves.txt") { |line,lineno| - thisline = line.clone record = [] lineRecord = pbGetCsvRecord(line,lineno,[0,"vnssueeuuuyiss", nil,nil,nil,nil,nil,PBTypes,["Physical","Special","Status"], @@ -939,11 +935,9 @@ def pbCompilePokemonForms # Ensure this is a valid form and not a duplicate. if form==0 raise _INTL("Form {1} is invalid (PBS/pokemonforms.txt). Form 0 data should be defined in \"PBS/pokemon.txt\".",sectionName) - next end if formToSpecies[baseSpeciesID] && formToSpecies[baseSpeciesID][form] raise _INTL("Form {1} is defined at least twice (PBS/pokemonforms.txt). It should only be defined once.",sectionName) - next end # Record new species number in formToSpecies. speciesID = baseSpeciesID @@ -1160,7 +1154,7 @@ def pbTMRS # Backup Gen 3 TM list :CUT,:FLY,:SURF,:STRENGTH,:FLASH,:ROCKSMASH,:WATERFALL,:DIVE ] ret = [] - for i in 0...rstm.length + rstm.length.times do ret.push((parseMove(rstm.to_s) rescue 0)) end return ret @@ -1231,7 +1225,7 @@ end def pbCompileShadowMoves sections = [] if File.exists?("PBS/shadowmoves.txt") - pbCompilerEachCommentedLine("PBS/shadowmoves.txt") { |line,lineno| + pbCompilerEachCommentedLine("PBS/shadowmoves.txt") { |line,_lineno| if line[ /^\s*(\w+)\s*=\s*(.*)$/ ] key = $1 value = $2 @@ -1272,11 +1266,10 @@ def pbCompileEncounters } encounters = {} thisenc = nil - lastenc = -1 - lastenclen = 0 needdensity = false lastmapid = -1 - i = 0; while i